> From *AT Protocol Spaces: A Field Guide* on atproto.how, revised 2026-11-23.
> Web page: https://atproto.how/atproto-spaces-field-guide/7-sync
> Index for agents: https://atproto.how/llms.txt · Text CC BY-SA 4.0, code samples MIT.

# Chapter 7 · Sync

The data perimeter of a space is dynamic and may extend past a single PDS to many. Each writer’s records sit in a space repo on that writer’s own PDS, so the perimeter reaches a new PDS whenever an account hosted there writes for the first time. The space host keeps a list of who has written, without the records themselves \[spec\]. The space comes together in one place, the copy a syncer builds, and every view your users see is drawn from that copy. Public atproto has relays that gather everyone’s records into one firehose. Spaces have no relay \[spec\], so each app that reads a space does the gathering itself. A syncer uses everything the earlier chapters set up: the credential that lets it in ([Chapter 6](https://atproto.how/atproto-spaces-field-guide/6-access-control.md)), the MAC that tells it who answered ([Chapter 5](https://atproto.how/atproto-spaces-field-guide/5-cryptography.md)), and the commit digest that tells it its copy is complete ([Chapter 4](https://atproto.how/atproto-spaces-field-guide/4-space-repos.md)).

A syncer learns *who* has written to the space from the space host and fetches *what* they wrote from each writer’s own repo host. A syncer’s copy is correct when its set hash matches the one in the repo host’s commit. Notifications only tell the syncer when to check. Missing one delays an update, but the next check still catches up.

> **If you’re building an app**
>
> Building an app on atproto spaces means understanding a space’s data perimeter and copying some or all of the data inside it, so your app can index and store it. Your app asks the space host who has written, pulls each writer’s repo from that writer’s own PDS, and then stays current through notifications and the op log. It confirms every change with the repo host before trusting it, and deletes data only on the space host’s own word. An app that can live with some delay can poll on a schedule instead of registering for notifications.

<a id="getting-a-copy-of-a-space"></a>

## 7.1 Getting a copy of a space

Your app can’t show anything from a space until it holds its own copy of the records. There’s no relay to subscribe to, so the syncer builds that copy one writer at a time. It asks the space host who has written, then goes to each writer’s PDS for their records. The copy is ready to trust once it matches the commit each repo host hands back, and the sections below cover how a syncer gets there and how it checks.

<a id="first-contact-the-writer-set"></a>

### 7.1.1 First contact: the writer set

> *In the family space.* The family app starts with a clean slate. It may know a few things about the space Marcus set up, but doesn’t have any records or blobs yet. Before it can read any, it has to learn which accounts have written to the space and where their space repos are.

The **writer set** is the list of accounts that have written at least one record into the space under the policy \[spec\]. An account the policy allows to write joins it only after its first write. A syncer starting calls `listWriters` on the space host, with a credential whose audience is the authority:

**Reference: `listWriters`** \[spec\]

The family app’s call to Marcus’s space host at 15:35, after Ruth’s change and Jake’s removal, so the response shows what a syncer starting at that moment would see.

<a id="try-list-writers"></a>

**Try it 7.1** · List the writer set. This example is interactive on the web: https://atproto.how/atproto-spaces-field-guide/7-sync#try-list-writers

Request:

```http
GET /xrpc/com.atproto.space.listWriters
  ?space=at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family
  &limit=100
Host: pds-a.example.com
Authorization: Atproto-Space-Credential <credential>
Atproto-Space-Audience: did:plc:ejjl2znzqp3ci25dqaslpkk2
Signature-Input: sig=("authorization" "atproto-space-audience");tag="atproto-space-credential"
Signature: sig=:<signature by the credential key>:
```

Headers:

- `Authorization`: The space credential the authority signed, naming the space and the key it is bound to. [Appendix C, Token types](https://atproto.how/atproto-spaces-field-guide/c-token-types.md)
- `Atproto-Space-Audience`: The host the request is for: the repo’s DID for repo methods, and otherwise the space’s authority. [Appendix B, Headers](https://atproto.how/atproto-spaces-field-guide/b-headers.md)
- `Signature-Input`: The two headers the binding signature covers. [Appendix B, Headers](https://atproto.how/atproto-spaces-field-guide/b-headers.md)
- `Signature`: The credential key’s signature over those headers, which shows the caller holds the key the credential is bound to. [Appendix B, Headers](https://atproto.how/atproto-spaces-field-guide/b-headers.md)

Sample response:

```json
{
  "repos": [
    {
      "$type": "com.atproto.space.defs#repoWrite",
      "repo": "did:plc:53ni6w7okqrxvjxezmopejoo",
      "repoRev": "3n2gsittdk32e",
      "data": {
        "$bytes": "LQ8ty3iUor9cbpB7YIHwOzjr7V9P+yOiOatCVXE2rdY"
      },
      "spaceRev": "3n2gsittdk42e"
    },
    {
      "$type": "com.atproto.space.defs#repoWrite",
      "repo": "did:plc:ashwgt3d5ntfxmlcfyizpu2g",
      "repoRev": "3n2gtdo55s32p",
      "data": {
        "$bytes": "INjMYdWaUBlDhmPVrmtaDralYgQLu+GffB4QmvGD2SE"
      },
      "spaceRev": "3n2gtdo55s22e"
    },
    {
      "$type": "com.atproto.space.defs#repoWrite",
      "repo": "did:plc:p4256dosynj6j6tkypz2q2l3",
      "repoRev": "3n2gtxdkr232p",
      "data": {
        "$bytes": "eVD7vKgDQrLKfOvN3VZJHYX0HGz158ocKa5oRd3kaYw"
      },
      "spaceRev": "3n2gtxdkr222e"
    },
    {
      "$type": "com.atproto.space.defs#repoRemoved",
      "repo": "did:plc:brthxhhoomvrib2avauses35",
      "spaceRev": "3n2gtz4rss22e"
    },
    {
      "$type": "com.atproto.space.defs#repoWrite",
      "repo": "did:plc:ejjl2znzqp3ci25dqaslpkk2",
      "repoRev": "3n2gu2vyuk32e",
      "data": {
        "$bytes": "x2sUmOzCG8t26JimHB15JxsbE9nBw3TZODEvXO+czuQ"
      },
      "spaceRev": "3n2gu2vyuk42e"
    }
  ],
  "cursor": "3n2gu2vyuk42e"
}
```

The response lists the latest update to each repo, ordered by `spaceRev` ascending. Each entry in `repos` is a union member carrying a `$type`, one of two shared definitions in [`com.atproto.space.defs`](https://lexicon.garden/nsid/com.atproto.space.defs) \[spec\].

Clients should branch on `$type` for every entry. The response leaves `prevSpaceRev` unset. A `#repoRemoved` entry means the authority took that repo out of the writer set (see Removing a writer, below), so stop treating it as part of the space. Pass `cursor` to resume, and the host returns repos updated after that space revision. `limit` runs from 1 to 1000 and defaults to 100. The declared errors are `SpaceNotFound`, `RepoTakendown`, and `RepoDeactivated`. The last two mean the authority’s account is taken down or deactivated \[spec\].

Treat the list as the authority’s claim, current as far as its notifications have kept it. Inclusion is necessary but not sufficient: an app may still exclude a listed repo on its own grounds. Each repo’s host is the source of truth for its contents \[spec\]. For each listed writer, the syncer resolves the DID document, finds `#atproto_pds` and `#atproto_kem`, and pulls the repo.

<a id="incremental-sync-with-listrepoops"></a>

### 7.1.2 Incremental sync with listRepoOps

> *In the family space.* Ruth changes her RSVP from interested to going. The family app already holds her space repo as it stood after her first reply. It needs the change, and proof that its copy now matches hers.

**Reference: `listRepoOps`** \[spec\]

The family app asks Ruth’s PDS what changed since her first RSVP.

<a id="try-list-repo-ops"></a>

**Try it 7.2** · Pull Ruth’s ops. This example is interactive on the web: https://atproto.how/atproto-spaces-field-guide/7-sync#try-list-repo-ops

Request:

```http
GET /xrpc/com.atproto.space.listRepoOps
  ?space=at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family
  &repo=did:plc:p4256dosynj6j6tkypz2q2l3
  &since=3n2gtkszes32p
Host: pds-b.example.com
Authorization: Atproto-Space-Credential <credential>
Atproto-Space-Audience: did:plc:p4256dosynj6j6tkypz2q2l3
Signature-Input: sig=("authorization" "atproto-space-audience");tag="atproto-space-credential"
Signature: sig=:<signature by the credential key>:
Accept-Signature: mac=("atproto-space-commit";sf);keyid="<ephemeral KEM key>";tag="atproto-space-commit"
```

Headers:

- `Authorization`: The space credential the authority signed, naming the space and the key it is bound to. [Appendix C, Token types](https://atproto.how/atproto-spaces-field-guide/c-token-types.md)
- `Atproto-Space-Audience`: The host the request is for: the repo’s DID for repo methods, and otherwise the space’s authority. [Appendix B, Headers](https://atproto.how/atproto-spaces-field-guide/b-headers.md)
- `Signature-Input`: The two headers the binding signature covers. [Appendix B, Headers](https://atproto.how/atproto-spaces-field-guide/b-headers.md)
- `Signature`: The credential key’s signature over those headers, which shows the caller holds the key the credential is bound to. [Appendix B, Headers](https://atproto.how/atproto-spaces-field-guide/b-headers.md)
- `Accept-Signature`: Asks the host to sign its answer with a MAC, using a key agreed with this ephemeral key. [Appendix B, Headers](https://atproto.how/atproto-spaces-field-guide/b-headers.md)

Sample response:

```json
{
  "ops": [
    {
      "rev": "3n2gtxdkr232p",
      "collection": "community.lexicon.calendar.rsvp",
      "rkey": "3n2gtxdkr222p",
      "cid": "bafyreiblr6f6oy3zi426nksahddwp4tgsfgedtqk27fyxqtav66kjvwkgu",
      "prev": null,
      "value": {
        "$type": "community.lexicon.calendar.rsvp",
        "subject": {
          "uri": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family/did:plc:ejjl2znzqp3ci25dqaslpkk2/community.lexicon.calendar.event/3n2gsywstc22e",
          "cid": "bafyreigjlo4wnf5e6inmlkp7ib7pcym5o34vblhnbrf6tij6olzq4hyliu"
        },
        "status": "community.lexicon.calendar.rsvp#going"
      }
    },
    {
      "rev": "3n2gtxdkr232p",
      "collection": "community.lexicon.calendar.rsvp",
      "rkey": "3n2gtkszes22p",
      "cid": null,
      "prev": "bafyreiautip3hgihuw4ypueftfdiv3iyliieamu5mdv4d4duqhhyetxs7a"
    }
  ],
  "commit": {
    "ver": 1,
    "repo": "did:plc:p4256dosynj6j6tkypz2q2l3",
    "space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family",
    "rev": "3n2gtxdkr232p",
    "data": {
      "$bytes": "eVD7vKgDQrLKfOvN3VZJHYX0HGz158ocKa5oRd3kaYw"
    }
  }
}
```

Each entry is a [`com.atproto.space.listRepoOps`](https://lexicon.garden/nsid/com.atproto.space.listRepoOps)`#opEntry` \[spec\].

- `prev: null` is a create.
- `cid: null` is a delete.
- With both set, it’s an update.
- Entries that share a `rev` came from one atomic batch.
- `value` holds the record. It’s left out for deletes, when `excludeValues=true`, and when the record has changed since, so any value you get is current for its path.

The request’s `since` is a TID, and `limit` runs from 1 to 1000 with a default of 100 \[spec\].

Every page carries the repo’s current commit and its MAC \[spec\]. The syncer works through the pages like this:

1. For each op, it updates its copy of the repo and its running LtHash, subtracting the `prev` element and adding the `cid` element.
2. It keeps requesting pages until one comes back without a `cursor`. A full page always has a `cursor`, so the last page may be empty.
3. It compares `sha256(state)` with the last page’s commit `data`. If they match, it’s in sync. If not, the repo has diverged and the syncer recovers with `getRepo`.

The op log speeds up transport, but it isn’t committed data. A host may compact it to a backfill window, and it starts fresh after account migration \[spec\]. `listRepoOps` answers `RepoNotFound` for a repo that has never been written.

In `atproto-pds`, a request can send both `since` and `cursor`. Both apply, and whichever points later in the log decides where the page starts. A resume point older than the retained log returns the remaining ops and the commit. The fold then won’t match, so the syncer falls back to recovery \[crates\].

<a id="full-state-recovery-with-getrepo"></a>

### 7.1.3 Full-state recovery with getRepo

`getRepo` streams the whole repo as a STAR archive with `Content-Type: application/vnd.dasl.star`:

**Reference: The STAR archive layout** \[spec\]

<a id="figure-7-1"></a>

**Figure 7.1.** Anatomy of a STAR archive (diagram on the web page: https://atproto.how/atproto-spaces-field-guide/7-sync#figure-7-1)

**Anatomy of a STAR archive.** Read from top to bottom. This is the order the bytes arrive in.

**Header**, read once at the start.

1. `2A 6C 01 00` is the magic: four fixed bytes that open every STAR archive.
2. `B4 02` is a length, written as a varint. Here it says 308.
3. `A2 65 24 74 79 70 65 …` is the metadata: 308 bytes of DRISL holding `$type` and the commit. The spec caps it at 64 KiB.

**Record**, opened by a marker byte.

1. `01` says a record follows.
2. `20` is a length. Here it says 32.
3. `forum.example.post/3mfx2k7qd5c2a` is the path: 32 bytes of UTF-8 in the form `{collection}/{rkey}`. The spec caps it at 4 KiB.
4. `5D` is a length. Here it says 93.
5. `A3 64 62 6F 64 79 …` is the record: 93 bytes of canonical DRISL. The spec caps it at 1 MiB.

**Record**, the same shape again, as many times as needed.

1. `01` says a record follows.
2. `20` is a length of 32.
3. `forum.example.post/3mfx2m4wz7s2b` is the path.
4. `4A` is a length of 74.
5. `A3 64 62 6F 64 79 …` is the record.

**End**

1. `00` says the archive is complete. The stream stops here.

The metadata, every path, and every record are preceded by their length in bytes, so the reader always knows how far to read next.

An empty repo has no records, so the end marker follows the metadata directly.

The metadata is a DRISL map with `$type: "atproto-space-repo"` and every commit field. Records come in strict bytewise order of path \[spec\]. The commit’s MAC rides in the response’s HTTP signature, not in the metadata.

**Reference: Verifying a STAR archive as it streams** \[spec\]

1. Check the metadata’s `$type`, `ver`, `repo`, and `space`.
2. Verify the commit MAC, and check that `Atproto-Space-Commit` matches the metadata.
3. Fold each record’s `{collection}/{rkey}/{cid}` into a fresh LtHash, refusing any out-of-order or duplicate key.
4. After the `0x00` end byte, compare the digest to `data`.
5. On a match, replace the local copy, deleting records absent from the archive.

Refuse the whole archive on any parse error, non-canonical metadata, ordering problem, MAC mismatch, or digest mismatch.

For a copy that has drifted only slightly, `getLatestCommit` plus `listRecords?excludeValues=true` gives the path-to-CID map. Diff it against the local copy, then `getRecord` just the differing paths \[spec\]. This trades one large transfer for several small ones.

<a id="the-read-surface"></a>

### 7.1.4 The read surface

Every read a repo host offers takes `space` and `repo`, and accepts either the repo owner’s OAuth session or a space credential \[spec\]. Besides `getLatestCommit`, `listRepoOps`, and `getRepo`, a syncer can fetch one record with `getRecord`, list records with `listRecords`, and find and fetch blobs with `listBlobs` and `getBlob`. Only the reads that return a commit or a single record carry a MAC: `getLatestCommit`, `getRecord`, `listRepoOps`, and `getRepo`. Those are the answers a syncer can tie to the host that gave them. Parameters, limits, and errors for each read are in [Appendix A](https://atproto.how/atproto-spaces-field-guide/a-xrpc-methods.md).

<a id="staying-current"></a>

## 7.2 Staying current

Once your app has a copy, the question becomes how soon it hears about changes. It can poll on a schedule and live with some delay, or register for notifications and learn about a write moments after it lands. Notifications ask more of the app in return. It needs an endpoint the space host can reach, it has to answer a challenge to confirm the registration, and it has to renew the registration before it lapses.

<a id="write-notifications"></a>

### 7.2.1 Write notifications

Notifications carry no record data \[spec\].

When Ruth writes, her PDS sends [`com.atproto.space.notifyRepoUpdate`](https://lexicon.garden/nsid/com.atproto.space.notifyRepoUpdate) to the space host, with service auth (`lxm=com.atproto.space.notifyRepoUpdate`). It is skipped when the repo belongs to the authority \[spec\].

**Reference: `notifyRepoUpdate`** \[spec\]

Ruth’s PDS tells Marcus’s space host that her repo advanced.

```http
POST /xrpc/com.atproto.space.notifyRepoUpdate
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJFUz...
Content-Type: application/json

{
  "space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family",
  "repo": "did:plc:p4256dosynj6j6tkypz2q2l3",
  "repoRev": "3n2gtxdkr232p",
  "data": {
    "$bytes": "eVD7vKgDQrLKfOvN3VZJHYX0HGz158ocKa5oRd3kaYw"
  }
}
```

The repo host retries network failures and transient statuses with exponential backoff and stops on permanent errors. The space host rejects notifications for repos not authorized to write, ignores a `repoRev` that doesn’t increase, and never verifies `data`. It answers a `repoRev` too far in the future with `FutureRev`, and an unknown space with `SpaceNotFound` \[spec\].

The space host records the repo’s new state, assigns a new space-wide `spaceRev`, and sends [`com.atproto.space.notifySpaceUpdate`](https://lexicon.garden/nsid/com.atproto.space.notifySpaceUpdate) to every registered syncer, on a best-effort basis \[spec\].

<a id="registering-for-notifications"></a>

### 7.2.2 Registering for notifications

A syncer registers by including `notify` in `authorizeSpaceSync` \[spec\]:

**Reference: The `notify` object** \[spec\]

| Field | Meaning |
| --- | --- |
| `endpoint` | A base HTTPS URL the space host calls XRPC methods against |
| `token` | An opaque secret of at most 512 characters, such as 32 random bytes in base64 |

- Use a different token for each space and keep it stable across authorizations. A registration is identified by endpoint and token together; the same pair renews it, a different token creates another registration.
- Before creating a new registration, the space host calls [`com.atproto.space.confirmRegistration`](https://lexicon.garden/nsid/com.atproto.space.confirmRegistration) on the endpoint with `{space, token, challenge}`. The syncer checks that it issued that token for that space and answers `{challenge}`. Otherwise `authorizeSpaceSync` fails with `RegistrationNotConfirmed`.

  Each half stops something different. The token check protects a real syncer: if someone registers its endpoint with a token it never issued, it declines. The echo protects every other service on the internet. Plenty of URLs answer any POST with a 200, but only an endpoint that read the request can send back a fresh challenge, so a space host only delivers notifications to a service that asked for them.
  \* A registration stays active while the credential from its latest authorization is valid. To receive notifications continuously, keep reauthorizing with the same `notify`.

<a id="figure-7-2"></a>

**Figure 7.2.** A registration is confirmed once, then renewed by each authorization (diagram on the web page: https://atproto.how/atproto-spaces-field-guide/7-sync#figure-7-2)

Only a new registration triggers `confirmRegistration`. Reauthorizing with the same endpoint and token renews the registration without another challenge.

**Reference: `confirmRegistration`** \[spec\]

Marcus’s space host checks the family app’s endpoint the first time the app registers.

<a id="try-confirm-registration"></a>

**Try it 7.3** · Confirm a registration. This example is interactive on the web: https://atproto.how/atproto-spaces-field-guide/7-sync#try-confirm-registration

Request:

```http
POST /xrpc/com.atproto.space.confirmRegistration
Host: family.example
Content-Type: application/json

{
  "space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family",
  "token": "xIFHpilmY0Wlfxq62sqovyfp66i08zazz2dgpsT_38E",
  "challenge": "ij6vvo5y7rblrkvq2lxyyu63su"
}
```

Sample response:

```json
{
  "challenge": "ij6vvo5y7rblrkvq2lxyyu63su"
}
```

The family app recognizes the token as the one it issued for this space and echoes the challenge.

The reference PDS sends 16 random bytes in base32 as the challenge and gives the endpoint 10 seconds to answer. `atproto-pds` sends 32 random bytes in hex and allows the same 10 seconds \[crates\].

<a id="handling-an-update"></a>

### 7.2.3 Handling an update

The space host calls the syncer at `POST {endpoint}/xrpc/com.atproto.space.notifySpaceUpdate` with `{space, token, update}`. These calls carry no service auth. The token in the body is the only thing that authenticates them \[spec\]. A token can leak, so the syncer treats each notification as a reason to go and check, and never deletes anything because of a notification alone.

**Reference: `notifySpaceUpdate`** \[spec\]

Marcus’s space host tells the family app that Ruth’s repo advanced.

```http
POST /xrpc/com.atproto.space.notifySpaceUpdate
Host: family.example
Content-Type: application/json

{
  "space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family",
  "token": "xIFHpilmY0Wlfxq62sqovyfp66i08zazz2dgpsT_38E",
  "update": {
    "$type": "com.atproto.space.defs#repoWrite",
    "repo": "did:plc:p4256dosynj6j6tkypz2q2l3",
    "repoRev": "3n2gtxdkr232p",
    "data": {
      "$bytes": "eVD7vKgDQrLKfOvN3VZJHYX0HGz158ocKa5oRd3kaYw"
    },
    "spaceRev": "3n2gtxdkr222e",
    "prevSpaceRev": "3n2gtrxvls22e"
  }
}
```

The family app answers with an empty `200` and pulls Ruth’s repo afterward.

**Reference: Update types** \[spec\]

| `update.$type` | Meaning | Syncer action |
| --- | --- | --- |
| [`com.atproto.space.defs`](https://lexicon.garden/nsid/com.atproto.space.defs)`#repoWrite` | A repo advanced: `repo`, `repoRev`, `data`, `spaceRev`, `prevSpaceRev?` | Pull that repo from its host |
| [`com.atproto.space.defs`](https://lexicon.garden/nsid/com.atproto.space.defs)`#repoRemoved` | A repo left the writer set: `repo`, `spaceRev`, `prevSpaceRev?` | Stop treating it as part of the space |
| [`com.atproto.space.notifySpaceUpdate`](https://lexicon.garden/nsid/com.atproto.space.notifySpaceUpdate)`#spaceDeleted` | The space was deleted | Reauthorize; drop data only on a `SpaceDeleted` answer |
| [`com.atproto.space.notifySpaceUpdate`](https://lexicon.garden/nsid/com.atproto.space.notifySpaceUpdate)`#registrationExpired` | The registration lapsed: `spaceRev` | Reauthorize with `notify` and catch up |

The syncer’s `notifySpaceUpdate` handler works in this order:

1. Check the `token` and reject one the syncer didn’t issue for that space.
2. Match the update’s `$type` in full, and ignore any type it doesn’t recognize.
3. Answer quickly, and do the work afterward.

Delivery of `#repoWrite` and `#repoRemoved` is best effort \[spec\]. The reference PDS gives each call 10 seconds and never retries it, so a slow handler loses updates. `atproto-pds` queues each update in its notify outbox and retries a delivery that fails in a way that might clear, which covers a transport error, a timeout, and the statuses 408, 425, 429, and 5xx other than 501 \[crates\].

A `#repoWrite` says a repo advanced, but the space host never verifies `data`. If its `repoRev` is no newer than the syncer’s copy, there is nothing to do. Otherwise the syncer pulls the repo from its own host with `listRepoOps` from its last `repoRev`, checks the commit MAC, and folds the ops into its LtHash, as in incremental sync above. The new state counts only once that digest matches the host’s commit. After a successful pull, the syncer saves the notification’s `spaceRev` as its checkpoint. If `prevSpaceRev` is present and differs from the last `spaceRev` it saw, it missed an update and catches up as described below.

A `#repoRemoved` says the authority took a repo out of the writer set. Removal is destructive, so the syncer confirms it with `listWriters` before acting, then stops pulling that repo and stops serving its records as part of the space. Nothing changes on the repo’s own host. If its author writes again under the policy, the repo rejoins the writer set and arrives as a `#repoWrite`.

A `#spaceDeleted` says the space is gone. The syncer reauthorizes, and deletes its copy only if `authorizeSpaceSync` answers `SpaceDeleted`. Deletion notices are retried, so the same one can arrive more than once, and handling it twice must be harmless.

A `#registrationExpired` arrives in place of the first update after the syncer’s registration lapsed, and carries that update’s `spaceRev`. Until the syncer reauthorizes, the space host sends it nothing except a deletion notice \[spec\]. The syncer reauthorizes with the same `notify`, then catches up from its checkpoint with `listWriters`. The host retries expiry and deletion notices with exponential backoff for at least 72 hours, and may drop a registration it still can’t reach \[spec\]. In the reference PDS, an expiry notice is skipped if the syncer renewed in the meantime, and a pending deletion notice replaces a pending expiry notice.

A syncer that wants to stop receiving notifications stops reauthorizing and answers the expiry notice with a non-retryable error \[spec\]. An authorization that denies the syncer access also withdraws the registration it carries.

`atproto-pds` keeps one registration per (space, endpoint, token) until its credential expires. It retries expiry and deletion notices after 1 minute, 10 minutes, 1 hour, and 6 hours, then every 12 hours with 50 to 100 percent jitter, for at least 72 hours. It unregisters a syncer that refuses its expiry notice, and keeps a registration in place while the managing app is undecided or the authority is suspended \[crates\].

On the syncer side, `atproto-space-client` makes one design choice worth copying \[crates\]. Rather than generating a random notify token for each space and storing it, `notify_token(app_secret, &space)` derives the token as an HMAC-SHA256 of the space URI under a single app secret. That gives every space its own token, keeps each token stable across reauthorizations, and lets `verify_notify_token` recognize an incoming token by recomputing it, so the webhook handler needs no token table. The rest of the client maps directly onto the protocol. `SpaceSubscription` takes a `NotifyRegistration { endpoint, token }`, `ConfirmRegistrationInput::confirm()` answers the registration challenge, and `SpaceUpdate` models the update union with an `Unknown` arm, so new update types are ignored rather than rejected. The crate also recommends letting a registration lapse and reauthorizing on `#registrationExpired`, which costs less than reauthorizing every few minutes to keep it alive.

<a id="catching-up"></a>

### 7.2.4 Catching up

A syncer detects a missed notification from a gap between `prevSpaceRev` and the last `spaceRev` it saw, or by comparing the `spaceRev` returned by `authorizeSpaceSync` with its checkpoint. It catches up by calling `listWriters` with `cursor` set to that checkpoint \[spec\]. If its last seen `spaceRev` is more than 72 hours old, removed repos it missed may have been collected, so it lists the whole writer set instead and drops any repo that is missing or removed \[spec\].

<a id="figure-7-3"></a>

**Figure 7.3.** A gap sends the syncer to listWriters, from its checkpoint or from scratch (diagram on the web page: https://atproto.how/atproto-spaces-field-guide/7-sync#figure-7-3)

In `atproto-space-client`, `SpaceCheckpoint::observe` tracks revisions, `catch_up` returns `CatchUp { entries, complete }` (with `complete` meaning drop every repo not named), and `REMOVAL_RETENTION` is 72 hours. `pull_repo` brings one repo up to date, applying the op log and checking the last page’s commit, falling back to the archive on a mismatch, and treating `RepoNotFound` as empty. It returns `RepoPull::{Changes, Snapshot, Empty}` \[crates\].

<a id="removing-a-writer"></a>

### 7.2.5 Removing a writer

> *In the family space.* Marcus changes Jake’s access to read-only. Jake’s bookmark is still in his space repo on his PDS, and the family app still has a copy of it. What should the app do with that copy?

The authority drops an account from the writer set with `removeWriter` (`manage=update`, input `repo`). A removal also happens when `removeMembers` removes a member or `putMembers` revokes write access. Removals are sequenced like writes: the space host advances `spaceRev`, sends `#repoRemoved`, and lists the repo as `#repoRemoved` until it writes again. A later authorized write re-adds it with a `#repoWrite` \[spec\]. The repo’s records stay on its host. The space host may drop empty and removed repos from the writer set after at least 72 hours, with no notification \[spec\].

What an app does with its copy of a removed writer’s records is its own decision, and it shapes how the app behaves for its users. The spec asks only that the app stop treating the repo as part of the space. The safest choice is to hard delete that writer’s records once the removal is confirmed. A better alternative is to soft delete them, so they disappear from view at once, and garbage collect them after a set period. While they wait, the app can show a tombstone in their place, so readers can see that something was there even though it is no longer available.

<a id="blobs"></a>

## 7.3 Blobs

> *In the family space.* Elena’s post about Theo has two photos. The post record arrived with her space repo, and the photos did not.

Blobs stay on the author’s repo host, next to the records that reference them, and are fetched separately by CID \[spec\].

STAR archives don’t include blobs, so a syncer that recovers a repo with `getRepo` still fetches its blobs one at a time \[spec\].

<a id="uploading"></a>

### 7.3.1 Uploading

The reference PDS takes space blobs through the same [`com.atproto.repo.uploadBlob`](https://lexicon.garden/nsid/com.atproto.repo.uploadBlob) as public ones. An uploaded blob starts out untethered, which means the host has stored it but no record refers to it yet. It becomes permanent once a space record references it. When an update or delete drops a record’s reference, the blob is released from that record.

In `atproto-pds`, a blob that no public or space record references is deleted after a grace period, 24 hours by default \[crates\].

<a id="listing-blobs"></a>

### 7.3.2 Listing blobs

`listBlobs` returns the CIDs that a repo’s records in the space reference, each once \[spec\].

**Reference: `listBlobs`** \[spec\]

The family app asks Elena’s PDS which blobs her records in the family space reference, with Elena as the credential’s audience.

<a id="try-list-blobs"></a>

**Try it 7.4** · List Elena’s blobs. This example is interactive on the web: https://atproto.how/atproto-spaces-field-guide/7-sync#try-list-blobs

Request:

```http
GET /xrpc/com.atproto.space.listBlobs
  ?space=at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family
  &repo=did:plc:53ni6w7okqrxvjxezmopejoo
  &limit=500
Host: pds-a.example.com
Authorization: Atproto-Space-Credential <credential>
Atproto-Space-Audience: did:plc:53ni6w7okqrxvjxezmopejoo
Signature-Input: sig=("authorization" "atproto-space-audience");tag="atproto-space-credential"
Signature: sig=:<signature by the credential key>:
```

Headers:

- `Authorization`: The space credential the authority signed, naming the space and the key it is bound to. [Appendix C, Token types](https://atproto.how/atproto-spaces-field-guide/c-token-types.md)
- `Atproto-Space-Audience`: The host the request is for: the repo’s DID for repo methods, and otherwise the space’s authority. [Appendix B, Headers](https://atproto.how/atproto-spaces-field-guide/b-headers.md)
- `Signature-Input`: The two headers the binding signature covers. [Appendix B, Headers](https://atproto.how/atproto-spaces-field-guide/b-headers.md)
- `Signature`: The credential key’s signature over those headers, which shows the caller holds the key the credential is bound to. [Appendix B, Headers](https://atproto.how/atproto-spaces-field-guide/b-headers.md)

Sample response:

```json
{
  "cids": [
    "bafkreicy6rib4mitvvzbsmj3rktg2fpihkfhfomngc4kynwpvjp45bioya",
    "bafkreigne4u5q3h5hdcbhusc5osdwybrlkdpdl7222ufbklgo7swix4ore"
  ]
}
```

`limit` runs from 1 to 1000 and defaults to 500. The reference PDS sorts the CIDs in ascending order and returns a `cursor`, the last CID on the page, only when the page is full. Instead of listing, a syncer can collect the blob refs from the records it already holds \[spec\].

<a id="fetching-a-blob"></a>

### 7.3.3 Fetching a blob

`getBlob` takes `space`, `repo`, and `cid`, and returns the blob as originally uploaded \[spec\]. The credential signature from the listing works here too, since it covers only the credential and the audience.

**Reference: `getBlob`** \[spec\]

The family app fetches one of Elena’s two photos.

```http
GET /xrpc/com.atproto.space.getBlob
  ?space=at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family
  &repo=did:plc:53ni6w7okqrxvjxezmopejoo
  &cid=bafkreigne4u5q3h5hdcbhusc5osdwybrlkdpdl7222ufbklgo7swix4ore
Authorization: Atproto-Space-Credential eyJhbGciOiJFUzI1NksiLCJ0eXAiOi...
Atproto-Space-Audience: did:plc:53ni6w7okqrxvjxezmopejoo
Signature-Input: sig=("authorization"
  "atproto-space-audience");tag="atproto-space-credential"
Signature: sig=:Q/Ya6HSYi45IB5C1Of0GGLVVUAflbUmE033JyiRxNZgn0nf0rEC5IJe30snJsRUSa85igHDoeBdLhJutfXLV6A==:
```

```http
HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 1702
Content-Disposition: attachment; filename="bafkreigne4u5q3h5hdcbhusc5osdwybrlkdpdl7222ufbklgo7swix4ore"
Content-Security-Policy: default-src 'none'; sandbox
X-Content-Type-Options: nosniff
```

A blob response carries no MAC. Verify it by hashing the body with SHA-256 and comparing the digest with the CID, which uses the raw codec. The reference PDS serves the body as untrusted content, as the headers show, and an app that re-serves a blob should do the same. It answers `BlobNotFound` for a missing blob, and also for one the account stores but no record in that space references, so a credential for one space can’t probe for blobs from another.

<a id="why-this-scales"></a>

## 7.4 Why this scales

Sync is lighter than public sync. The public event stream carries every published record along with the MST nodes and signatures that prove cryptographically that its author wrote it. A space repo has none of that proof material to move. Load grows with the number of syncing applications, not the number of users, since each app pulls each repo once and fans out from its own copy. And because every sync call requires a credential, a host can rate-limit by credential holder \[spec\].

The cost lands on the apps. With no relay to share, every app runs its own syncer, and a first sync touches every writer’s PDS.

<a id="figure-7-4"></a>

**Figure 7.4.** Sync load grows with apps and repo hosts, not with users (diagram on the web page: https://atproto.how/atproto-spaces-field-guide/7-sync#figure-7-4)

A third app adds three pull paths, one per repo host, and a fourth repo host adds two, one per app. A thousand more users of App 1 add none.

<a id="common-questions"></a>

## 7.5 Common questions

**Is registering for notifications required?**

Registering is optional. An app that can tolerate delay can call `listWriters` and `listRepoOps` on its own schedule. Notifications only make updates arrive sooner.

**What if my app misses a notification?**

It catches up. Each notification carries the previous space revision, so a gap is easy to spot, and `listWriters` with your last checkpoint returns everything that changed since. If the checkpoint is more than 72 hours old, list the whole writer set instead.

**Does the space host send record data?**

It sends only metadata, such as which repo advanced and its new revision. Records always come from each writer’s own PDS, checked against that PDS’s commit.
