Hyperledger Fabric private data collections and purging

Private data collections keep sensitive payloads among the organizations that need them while the channel records hashes as evidence. Purging decides how long that data lives on each peer and how fully it can be removed.

On this page

When Hyperledger Fabric private data collections fit a shared channel

Use a private data collection when a consortium channel has members who must not all see the same commercial or personal data. A collection keeps the payload with a subset of organizations, while the shared ledger holds only hashes of that data, so every channel member can verify that a value was written and agreed without reading it. The Fabric private data documentation describes a collection as a named set of private data that is shared only among the organizations defined in its configuration. Membership is set by a collection configuration that lists the member organizations and the policy that governs who may endorse writes to it. Peers only store the private payload if their organization is a member, which is why membership decisions belong to the governance group before any chaincode writes data.

The choice between a collection and a separate channel comes down to how much of the channel's workflow and ledger history must be shared. A collection still runs on one channel, so all members keep the same channel configuration, the same chaincode definition and the same block history, including the hashes. A separate channel isolates the ledger completely, but it means a second set of channel configuration, endorsement policies, peers and operational work. Teams that need the same business process across the whole group, with only a few fields hidden from some members, usually fit a collection. Teams that need different participants in different transaction flows, or where even the existence of a relationship is sensitive, should evaluate a separate channel.

Before building, confirm three things with your governance group: the exact list of member organizations for each collection, who can change that list later, and whether non-member organizations need to be able to prove a value without seeing it. Each change to membership is a channel configuration and chaincode definition change, so the process for approving it should be written down in advance. Also confirm the retention expectations for the private payloads themselves, because the purging behavior covered later in this page changes what peers that catch up or restore from backup can still return.

The parts of a private data collection and what each one stores

A private data collection splits one business record across two places: the sensitive payload stays with a defined group of peers, while the channel ledger carries only evidence. Each part below has a different holder, lifetime and failure mode, so review them together before you define a collection.

Collection definition and members

The collection definition names the organizations allowed to hold the private payload, along with its endorsement policy and purge settings. Only organizations listed as members can store the payload on their peers. Check that every member is correct before chaincode is approved, because changing membership later means a definition update on the live channel. Confirm with your channel administrators who can change the definition and how that change is approved.

Private data docs

Private payload on authorized peers

The actual sensitive data is stored only on peers that belong to member organizations, and it is delivered to them through transient data during endorsement. Non-member peers never receive the payload, even though they process the block. Ask who operates each member peer, where its state database lives and how its disk is protected, because the payload is only as protected as the least careful member.

Hash on the shared ledger

Every channel member receives a hash of the private data in the block, which proves that a given value was written without revealing the value itself. This hash is the evidence that auditors and counterparties can check against the payload later. Plan how you will compare a candidate payload against the on-chain hash, and who is allowed to perform that comparison.

Endorsement and collection-level policy

A collection-level endorsement policy can require a different set of organizations to endorse transactions that write private data than the chaincode-level policy requires. This lets a subset of members approve their own confidential updates. Document which organizations must endorse, because an overly narrow policy can block writes when a member peer is offline and an overly broad one exposes more parties to each write.

Automatic purge after blocks

A collection can be configured to purge private data automatically when it has not been modified for a set number of blocks. Once purged, the data is no longer available to chaincode queries, block events or peers requesting it. Set the block count against your retention obligations, not convenience, and confirm that the business process can still work after the payload has gone.

Explicit purge with PurgePrivateData

Deleting a key with DelPrivateData does not remove the value from block events or from peers that are still catching up, so it is not a complete removal. The PurgePrivateData API is the documented way to remove private data from all authorized peers. Plan a documented purge procedure, including who can invoke it and how you will record that it ran, before any data must be removed on request.

Private data docs

How automatic purging and explicit purges remove private data

A collection can be configured to purge private data automatically when that data has not been modified for a configurable number of blocks. Once purged, the data is no longer available to chaincode queries, to block events, or to other peers that request it. This is the mechanism to plan for data that has a natural shelf life, such as negotiation details or short-lived quotes, because the network handles removal without a transaction for each record. The block-count setting lives in the collection definition, so it is set when the collection is created or updated and should be reviewed alongside the retention rules your data protection policy requires. Confirm the exact configuration keys, their defaults, and how a modification resets the countdown against the private data documentation for your Fabric version, since these details change between releases.

Explicit removal is a different tool with a different guarantee. Deleting a key with DelPrivateData removes it from the peer's current state, but the deletion does not erase the earlier value from block events or from peers that are still catching up and fetch historical blocks. For data that must be gone from every authorized peer, the chaincode needs to call the PurgePrivateData API instead. Teams should decide, per collection and per data class, which removals are business deletions and which are purges that must reach all members, and then encode that choice in chaincode reviews. Before relying on either path, run a test on a non-production channel: write a value, remove it with each method, then query from a peer, pull a block event, and join a fresh peer to confirm what is actually returned.

Choosing between automatic purge, explicit purge and no purge

Some private data has a useful life that is known in advance, such as a quote that is only valid for a set period or a personal detail that a policy says must not be kept indefinitely. For this situation, an automatic purge tied to a collection setting fits best, because the peers remove the data without anyone having to remember to do it. The trade-off is that the removal runs on the schedule the collection defines, so data that is still needed after that point is gone from every peer that held it.

  • Availability: once the threshold passes, chaincode queries, block events and catch-up requests no longer return the data, so applications must not depend on it after expiry.
  • Evidence: the hash remains on the shared ledger, so the organizations can still show that a record existed and matched a given value, even though the content is gone.
  • Recovery: a peer that was offline past the threshold will not receive the purged value, so restores from older backups can bring back data the policy requires to be gone.
  • Configuration: the threshold is set on the collection definition, so changing it later is a channel administration change that the members must approve.
  • Review: confirm with your privacy and records teams that the schedule matches the written retention rule, not just the technical default.

Before you rely on automatic purge, confirm the exact behavior for modified and unmodified data in the version you run.

Collection settings and the effect of each on peers and backups

This table compares the collection settings that decide who holds private data, what the shared ledger keeps, and when data leaves peers. Read each row for when the setting fits and what it changes for peers catching up, block events and backups. The main takeaway is that deleting data and purging it are different operations, and only an explicit purge removes data from every authorized peer.

SettingWhen it fitsEffect on peers catching upEffect on block events and backups
Collection membershipOnly the organizations that must see the data are listed as members of the collectionOnly member peers receive the private data. Non-member peers catching up receive hashes onlyMember peers hold the plaintext in their backups. Non-member backups contain hashes and no private values
Endorsement policy for the collectionSet when a subset of members must approve writes to the collection, separate from the chaincode-level policyPeers catching up need the collection definition to validate writes, so the definition must be in place before they joinBlock events carry the transaction and its hashes, and the policy does not change what the backup stores beyond the data itself
Automatic purge thresholdSet for data that has a limited business life, such as quotes or temporary case records, measured in blocksA peer catching up past the threshold does not receive purged data, so it reaches the same state as peers that purged itBackups taken before a purge still hold the data. Restores from older backups can bring back data that was purged on the live network
Explicit purge with PurgePrivateDataUsed when a specific record must be removed from all authorized peers, for example after a legal requestPurged data is not returned to peers requesting it, so catch-up does not restore itPurged data is no longer returned in block events. Backups taken earlier still contain it, so backup retention needs a plan
Deletion with DelPrivateDataUsed only when removing data from the current state is enough and full removal is not requiredPeers catching up can still receive the deleted data, so it does not leave the network's historyDeleted data can still be returned in block events, so this option does not meet a full removal requirement
Hash-only evidence on the shared ledgerUsed when all channel members must prove that a private record existed and matched, without seeing the contentNon-member peers receive hashes while catching up, which lets them verify later disclosuresHashes remain in the shared ledger and backups even after private values are purged, so confirm with your legal team that hashes are acceptable

How to set up a private data collection with purge rules

This sequence takes a private data collection from a governance agreement with each member to a tested channel where non-members hold only hashes and purged keys stop returning. Each step ends with a check you can record before moving on.

  1. Agree membership and retention rules with each member

    Before any configuration, the channel's member organizations agree in writing which organizations may hold the sensitive data, which fields are sensitive, who may read and write them, and how long each value should stay on peers before it is purged. Legal, compliance and data owners from each organization should sign off, because the purge window is a business and records decision, not only a technical setting. The output is a short collection register listing the members, the data categories and the retention rule. You know this step is done when every member organization has signed the register and no open question about membership remains.

  2. Define the collection configuration

    Translate the register into a collection configuration file that names the collection, the member organizations' MSP IDs, the endorsement policy for the collection, and the purge settings. Set the block-to-live value so that data is purged automatically after the agreed number of blocks without modification, and confirm the unit you agreed on matches the blocks Fabric counts. Keep the file in version control so later changes are reviewed like code. Check the file against the register line by line, and run a schema or peer-side validation if your tooling offers it, since a mismatch here is hard to correct once data is written.

  3. Approve the chaincode definition with the collection

    Pass the collection configuration when the chaincode definition is approved by each organization on the channel, then commit the definition once enough organizations have approved it under the lifecycle policy. Every member must approve the same collection file, because peers compare the definition and a differing copy blocks the commit. Query the committed definition on a peer from each member organization and confirm the collection names, member lists and purge settings match the register. This check catches the most common setup error, which is an approval that used an older copy of the file.

  4. Implement private writes and purges in chaincode

    Update the chaincode so that sensitive values are written with the private data write call, scoped to the named collection, while the shared ledger receives only the hash that the chaincode also writes to public state as evidence. Add explicit purge logic that calls the PurgePrivateData API for records that must be removed from every authorized peer, because deleting with DelPrivateData still leaves the data returnable in block events and to peers catching up. Keep the transient data handling for inputs out of the ledger and review the code path for accidental logging of the sensitive values. Your check is a unit test run against a mock stub that confirms the public state holds a hash and the purge path calls the purge function, not the delete function.

  5. Test membership and hash visibility on a non-production channel

    Deploy the chaincode and collection to a non-production channel that mirrors the production membership. From a peer of a non-member organization, query the public state and the collection, and confirm the sensitive value is unavailable while the hash is present. From a member peer, write a test value, confirm it can be read, then wait for the configured number of blocks without modification and confirm the value is purged automatically. Record the block height of each check so the results can be compared with the register. Do not reuse production key material or real customer records in this environment.

  6. Confirm explicit purges and block event behavior

    Write a test record, run the explicit purge through the chaincode, and then verify three things: a chaincode query returns no value, block events emitted after the purge do not carry the value, and a peer that was offline during the write and catches up later does not receive the purged value. Use a second peer that was stopped during the write to test the catch-up path. Document any gap you find, because the Fabric private data documentation states that deletion alone does not remove data from block events or catching-up peers. The check is complete when all three results match the expected output and are saved with the test record.

  7. Document backup and catch-up behavior before production

    Before the collection goes live, confirm with your operations team how backups and peer recovery treat purged data. Purged values are not returned to queries, block events or other peers, but backups taken before a purge may still contain the earlier state, so the backup retention policy should match the register. Add the purge behavior and the backup rule to the runbook, and ask the Fabric administrators to confirm what happens to joining peers that rely on snapshots in your version. The sign-off is a runbook entry approved by the data owners and the operations lead.

How private payloads, hashes and purges move between peers

The diagram starts with a client proposing a transaction that touches a private data collection. The member peer endorses and holds the payload, while the shared channel ledger receives only a hash, which is what non-member peers store. A purge removes the payload from the member peers and from anything returned to peers that catch up, but a plain delete leaves it returnable, so confirm which API your chaincode calls and which peers are inside the boundary.

Payloads stay with member peers, while the shared ledger keeps hashes and purges reach catching-up peers.

What purging means for peers catching up and for backups

A peer that joins a channel or falls behind can only receive private data it is still entitled to and that the network still retains. Purged data does not come back through catch-up. Once a collection has purged a key, either automatically after its configured block count or through an explicit PurgePrivateData call, a peer that replays blocks from before the purge will not obtain the value from other peers. Member organizations should therefore decide, before go-live, whether a late-joining peer in a collection is expected to hold historical private values at all. If the answer is no, the purge settings are doing their job. If the answer is yes, the retention window must be long enough to cover the catch-up time you expect in practice, and you should test that a peer joining from a snapshot or from genesis ends up with the state you intend.

Backups add a second copy that purging does not reach. A backup taken before a purge can still contain the private value, so a restore can put back data the network believed it had removed. Backup retention for peer ledgers and any private data stores must therefore be set against the purge policy, not only against general disaster recovery needs. Restore runbooks should state whether restored private data is re-purged on the next relevant block, how a restored peer is reconciled with the channel, and who approves restoring a peer from an older backup into a collection where data was purged. Treat old backups that hold purged personal or confidential data as records that need their own disposal rule.

Confirm every one of these behaviors against the Fabric version you run, because catch-up, snapshot and private data handling have changed across releases. Check the current Fabric private data documentation, then test the sequence in a non-production network: purge a key, take a backup, restore it to a fresh peer, and observe what the peer returns. Confirm with your backup tooling vendor how snapshots, volume backups and ledger exports handle private data, and record the result as a documented control for your auditors.

Security and operational risks to plan for

Private data collections keep payloads off most members' peers, but they add failure modes that a plain channel does not have. The risks below connect membership, hashes, purge timing, backups, chaincode design and operator access, so each mitigation should be decided before the first sensitive write.

Mistaken collection membership

A collection definition lists the organizations whose peers may hold the private payload. If a member org is added by mistake, or an endorsement policy is set too broadly, that organization receives data it was never meant to see, and the leak cannot be undone by a later configuration change. Mitigation: require two-person review of every collection definition change, and confirm which organizations are listed on each peer's effective configuration before data is written. Restrict who can run channel configuration updates using the channel policies mapped to your admins.

Private data docs

Hashes reveal payload structure

The shared ledger holds a hash of each private value so that all channel members can verify transactions. Those hashes are visible to every channel member, so repeated values, predictable keys or small value spaces can let a non-member infer what a record contains by guessing and comparing. Mitigation: design private keys and values so they are not guessable, add a random salt or nonce to low-entropy fields in the payload, and review key naming with the privacy team before go-live.

Purge settings applied too late

Automatic purging removes private data after a configured number of blocks without modification, but a collection that is changed to purge sooner only affects data written after the change is active on each peer. Data written under the earlier retention rule stays on peers until it is purged or removed explicitly. Mitigation: set the retention count in the collection definition at design time, and test the purge behavior on a non-production channel before the first production write.

Backups holding purged data

A backup of a peer's ledger or state database taken before a purge still contains the removed private data. Restoring that backup, or a snapshot used to join a new peer, can bring purged records back onto a peer. Mitigation: set a backup retention period that matches your purge policy, record purge events and backup dates in your change log, and confirm with the operations team how restored peers are checked for data that should no longer exist.

Chaincode writing sensitive data publicly

Chaincode can write a value to public world state by mistake, for example by copying a private input into a normal key or into an event payload that every channel member can read. Once written to public state, the value is shared with all channel members and is not removed by any purge setting. Mitigation: review chaincode so that sensitive inputs only go through the private data APIs, and add tests that check public state and events for known sensitive fields before each chaincode release.

Operator access to peer storage

Administrators with shell or file access to a peer can read the ledger files and the state database directly, which bypasses collection membership and access control in the chaincode. Operator access on the operations service also matters, since its endpoints are secured with mutual TLS client certificates. Mitigation: limit host and database access to named operators, rotate and revoke their client certificates through your Fabric CA process, and log administrative access to the operations service endpoints.

Operations service docs

Questions teams ask before private data collections go live

How much effort does a private data collection design take?

Effort depends mostly on how many collections you need, how many organizations sit in each one, and how many distinct data classes must be separated. A single collection between two members with one data type is a small design exercise. Several overlapping collections with different retention rules, endorsement policies and access groups take much longer, because each collection needs its membership, memberOnlyRead and memberOnlyWrite settings, and purge behavior agreed and written down. Ask any partner to break the design into collection inventory, policy decisions, chaincode changes and test cases so you can see where the time goes.

Can our own team design and run private data collections without a partner?

Yes, if you already run Fabric chaincode and have engineers who understand endorsement policies, channel configuration and peer operations. The harder parts are usually not the Fabric configuration itself but the governance: agreeing which organizations may hold which data, handling disputes when a member leaves, and testing purge behavior before production. A partner is most useful when your team lacks recent Fabric experience or needs an outside review of the collection design before members sign. Be clear with yourself about which of those gaps you actually have.

What do we need to provide from legal, data owners and operations?

Private data design fails most often on decisions that are not technical. Your side needs to provide:

  • Legal or compliance sign-off on which personal or commercially sensitive fields may leave a member's control, and for how long
  • Data owners who can name each data class, its source system and its retention requirement
  • Operations staff who will run peer backups, snapshot restores and peer rebuilds, and who can confirm how purged data is handled in those backups
  • Named members who accept the collection membership and the purge schedule in writing

Without these inputs, the collection definitions will be guesses that need rework later.

How long does a private data collection pilot take?

The duration of a pilot depends on the number of member organizations, how many collections you test, and how complex your retention rules are. More members mean more peers to configure, more endorsement combinations to test and more coordination on the collection definition file. Automatic purging based on a block count requires you to test that data disappears on schedule, which depends on how quickly your channel produces blocks. Ask for the pilot plan to list the members, collections, retention rules and test scenarios it covers, and treat any duration without that list as unsupported.

Should sensitive data go on a separate channel instead of a private data collection?

Choose a separate channel when the group of organizations that must see the data is stable, the business process is distinct, and you want separate ledgers, endorsement rules and channel administration. Use a private data collection when most members share the ledger but only a subset should hold particular values, and the public hashes on the shared ledger are acceptable evidence. Channels add operational overhead: each has its own configuration, its own admin changes and its own peer joining process. Collections add complexity inside chaincode and collection definitions. Compare both options against your membership changes over the next few years.

What should we ask a partner to include in a quote?

Ask for a written scope that lists the collections in and out of scope, the chaincode changes, the endorsement and membership policies, the purge rules, and the test plan. The quote should separate one-time work (design, build, pilot, documentation) from recurring work (peer upgrades, collection changes when members join or leave, backup testing). Ask who writes and owns the collection definition file, who performs the purge tests, and what evidence you receive at the end. Confirm which items depend on your environment, such as peer hosting and backup tooling, and whether any of them need your staff's time.

Do private data collections change how we handle backups and new peers?

Yes. Purged data is no longer available to chaincode queries, block events or other peers requesting it, but backups and snapshots taken before a purge may still contain the values. Your backup procedure therefore needs a documented position on how long backups are kept and who can restore them. New peers that catch up from blocks can only receive private data that is still held by authorized peers, so a peer joining later may not recover data that was purged. Confirm these behaviors with your backup owner and test a restore before members rely on the design.

Where to read the Fabric private data documentation

The primary read for collection configuration, purge behavior and API details is the Fabric private data documentation. Start there before writing any collections_config.json file, choosing a blockToLive value or deciding how your team will call the purge APIs. The page covers how collection membership is defined, how hashes of private data appear on the shared ledger as evidence, and how automatic purging is configured, so it should be the reference your design review works from. Keep a copy of the page for the exact Fabric release your network runs, because the settings and behaviors described there are tied to the version in use.

Check the version-specific docs before you rely on any setting. Fabric publishes separate documentation for each release line, and the 2.5 LTS line and the 3.x line are maintained in parallel, so a configuration key or API behavior you read on the latest page may not match the binary your peers run. Confirm the version of every peer and orderer in the network, then read the private data page for that version. Where a behavior matters to your compliance or recovery plan, such as how purged data is treated by block events or peers catching up, verify it on a test channel running your exact versions before you commit the design. Record the version and the date you checked in your design document so auditors and future operators can see what the team relied on.

How DeployOpen scopes and delivers private data collection work

DeployOpen plans, implements, documents and supports Hyperledger Fabric networks inside the client's own infrastructure, including collection design, purge rules and the peer and backup procedures that follow from them. Engagements are fixed-scope, with the collection model, purge policy and handover agreed in writing before build work starts.

How we scope

  • Map which organizations must hold each private data collection and which hashes stay on the shared channel ledger
  • Record the purge policy for each collection, including whether automatic purging by block count applies and who approves it
  • Agree in writing how explicit PurgePrivateData requests are triggered, logged and verified across authorized peers
  • Confirm how snapshots, peer catch-up and backups will treat purged data before any collection goes live

How we build

  • Write the collection definition files, endorsement settings and chaincode logic that read and write private data
  • Test membership limits, hash visibility and purge behavior on a non-production channel before release
  • Verify that purged data no longer appears in chaincode queries, block events or peer catch-up on each authorized peer
  • Document backup and restore steps so purged records are not reintroduced from older archives

How we hand over

  • Deliver collection design records, purge runbooks and the approved change history for each channel
  • Train your operators on collection changes, explicit purges and the checks to run after each purge
  • Provide test evidence showing purge results per peer, so your compliance and security reviewers can examine it
  • Hand over administration access and documented ownership so your team can operate the network after delivery

How we support

  • Support collection changes, new member organizations and purge requests through a retainer agreed in writing
  • Review purge behavior again when Fabric upgrades change peer, lifecycle or capability settings in your network
  • Retest private data handling after significant chaincode or channel changes, with findings and fixes reported in writing
  • Ask any support provider to confirm response scope, reporting and access arrangements before signing

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.