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

# Chapter 4 · Space repos and commits

A space repo is where one identity’s records live inside the boundary of a space. The first time an identity writes a record into a space, either someone else’s or their own, its account gets a space repo that belongs to that one space. In practice a space repo is an extension to the space authority’s atproto space data boundary. Underneath, it is a set of records summarized by a commit, and the commit’s `data` is a 32-byte digest of that set. A syncer computes the same digest from its own copy. If the two match, the syncer holds exactly the records the host holds.

> **If you’re building an app**
>
> Writing to a space looks almost exactly like writing a public record. [`com.atproto.space.createRecord`](https://lexicon.garden/nsid/com.atproto.space.createRecord), `putRecord`, `deleteRecord`, and `applyWrites` take the same inputs as their `com.atproto.repo.*` counterparts, plus a `space`. They leave out the `swapCommit` and `swapRecord` inputs \[spec\]. The record lands in the user’s space repo on their own PDS. The commit and its digest matter once your app reads spaces, since they’re how it confirms its copy is complete, and a library will usually handle that part for you.

<a id="what-a-space-repo-is"></a>

## 4.1 What a space repo is

> *In the family space.* Marcus has invited everyone to the summer reunion. Nora wants to answer maybe, because she has work commitments that week and can’t promise yet. Her answer should reach the family and nobody else. Where does that answer live?

Records in a space repo are scoped the same way public records are, by collection and record key. The keys are `{collection}/{rkey}` and the values are DRISL-encoded records \[spec\]. Nora has one space repo per space she has written to, each on her own PDS, each with its own revision.

The PDS offers its write methods under `com.atproto.space.*`. They mirror `com.atproto.repo.*`, with `space` added and `repo` naming the caller’s own DID \[spec\]. The separate namespace is a signal to developers. Authentication behaves differently for these calls than for public records and carries different constraints, and a PDS stores a space repo differently inside. With that much different underneath, separate XRPC methods were the practical choice.

**Reference: The write methods** \[spec\]

| Method | Input | Output | Errors |
| --- | --- | --- | --- |
| `createRecord` | `space`, `repo`, `collection`, `rkey?`, `validate?`, `record` | `uri`, `cid`, `validationStatus?` | `SpaceNotFound`, `RecordAlreadyExists` |
| `putRecord` | `space`, `repo`, `collection`, `rkey`, `validate?`, `record` | `uri`, `cid`, `validationStatus?` | `SpaceNotFound` |
| `deleteRecord` | `space`, `repo`, `collection`, `rkey` | empty | `SpaceNotFound` |
| `applyWrites` | `space`, `repo`, `validate?`, `writes` | `results?` | `SpaceNotFound`, `RecordNotFound`, `RecordAlreadyExists` |
| `clearRecords` | `space`, `repo` | empty | none declared |

`putRecord` creates or updates as needed, and `deleteRecord` also succeeds when the record is already absent. A delete is about the end state. The record should be gone when the call returns, so removing data is always safe, and calling it a second time does no harm. Reads go through `getRecord` and `listRecords`, covered with the other repo-host reads in [Chapter 7](https://atproto.how/atproto-spaces-field-guide/7-sync.md).

**Reference: `validate` and `validationStatus`**

Setting `validate` to `false` skips Lexicon validation, `true` requires it, and leaving it unset validates records whose Lexicon the PDS knows \[spec\]. `atproto-pds` answers `validationStatus` `"valid"` for a record it checked and `"unknown"` for one it had no Lexicon for, and leaves the field out when validation was skipped \[crates\].

A record write names its space explicitly:

<a id="try-create-record"></a>

**Try it 4.1** · Create an RSVP in the family space. This example is interactive on the web: https://atproto.how/atproto-spaces-field-guide/4-space-repos#try-create-record

Request:

```http
POST /xrpc/com.atproto.space.createRecord
Host: pds-b.example.com
Authorization: DPoP <access token>
DPoP: <proof JWT>
Content-Type: application/json

{
  "space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family",
  "repo": "did:plc:ashwgt3d5ntfxmlcfyizpu2g",
  "collection": "community.lexicon.calendar.rsvp",
  "record": {
    "$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#interested"
  }
}
```

Headers:

- `Authorization`: The session’s access token, bound to a key only the client holds. [Appendix G, OAuth requests](https://atproto.how/atproto-spaces-field-guide/g-worked-values.md#oauth-requests)
- `DPoP`: A proof signed with that key for this method and URL, so a copied token can’t be replayed. [Appendix G, OAuth requests](https://atproto.how/atproto-spaces-field-guide/g-worked-values.md#oauth-requests)

Sample response:

```json
{
  "uri": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family/did:plc:ashwgt3d5ntfxmlcfyizpu2g/community.lexicon.calendar.rsvp/3n2gtdo55s22p",
  "cid": "bafyreiautip3hgihuw4ypueftfdiv3iyliieamu5mdv4d4duqhhyetxs7a"
}
```

> *In the family space.* Ruth answered "interested" while she waited to hear from her doctor. Now she can travel, and she wants to change her answer to "going". The family’s list should never show two answers from her, or none.

`applyWrites` applies a batch in one commit. Its `writes` are a closed union of three objects defined in its own lexicon, and its `results` come back in the same order. Here Ruth replaces her RSVP in one commit, creating a new one marked going and deleting the first:

<a id="try-apply-writes"></a>

**Try it 4.2** · Replace an RSVP in one commit. This example is interactive on the web: https://atproto.how/atproto-spaces-field-guide/4-space-repos#try-apply-writes

Request:

```http
POST /xrpc/com.atproto.space.applyWrites
Host: pds-b.example.com
Authorization: DPoP <access token>
DPoP: <proof JWT>
Content-Type: application/json

{
  "space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family",
  "repo": "did:plc:p4256dosynj6j6tkypz2q2l3",
  "writes": [
    {
      "$type": "com.atproto.space.applyWrites#create",
      "collection": "community.lexicon.calendar.rsvp",
      "rkey": "3n2gtxdkr222p",
      "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"
      }
    },
    {
      "$type": "com.atproto.space.applyWrites#delete",
      "collection": "community.lexicon.calendar.rsvp",
      "rkey": "3n2gtkszes22p"
    }
  ]
}
```

Headers:

- `Authorization`: The session’s access token, bound to a key only the client holds. [Appendix G, OAuth requests](https://atproto.how/atproto-spaces-field-guide/g-worked-values.md#oauth-requests)
- `DPoP`: A proof signed with that key for this method and URL, so a copied token can’t be replayed. [Appendix G, OAuth requests](https://atproto.how/atproto-spaces-field-guide/g-worked-values.md#oauth-requests)

Sample response:

```json
{
  "results": [
    {
      "$type": "com.atproto.space.applyWrites#createResult",
      "uri": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family/did:plc:p4256dosynj6j6tkypz2q2l3/community.lexicon.calendar.rsvp/3n2gtxdkr222p",
      "cid": "bafyreiblr6f6oy3zi426nksahddwp4tgsfgedtqk27fyxqtav66kjvwkgu"
    },
    {
      "$type": "com.atproto.space.applyWrites#deleteResult"
    }
  ]
}
```

**Reference: `applyWrites` operations and results** \[spec\]

| Operation | Fields | Result |
| --- | --- | --- |
| `#create` | `collection`, `value`, and optionally `rkey` | `#createResult`: `uri`, `cid`, and optionally `validationStatus` |
| `#update` | `collection`, `rkey`, and `value` | `#updateResult`: `uri`, `cid`, and optionally `validationStatus` |
| `#delete` | `collection` and `rkey` | `#deleteResult`, which is empty |

<a id="lifecycle"></a>

## 4.2 Lifecycle

> *In the family space.* Jake shared one bookmark with the family before he and Nora broke up. Marcus has since taken him off the member list. The bookmark is still in Jake’s space repo on Jake’s PDS, where Marcus has no way to delete it.

A space repo doesn’t exist without data. It comes into being on its first write. This lazy creation is different from a public repo, which exists as soon as the account does. It was a deliberate design choice, and I agree with it. I’d like to see public repos work the same way. When the authority is someone else, Nora’s PDS accepts the write without asking whether the space exists; the space host decides later whether to track her. When the writer is the authority, as Marcus is, the space must already exist \[spec\].

That means Nora can write records into a space Marcus hasn’t created yet. The records sit in her space repo on her PDS, and her PDS notifies Marcus’s space host of the write as it always does \[spec\]. In `atproto-pds`, the space host answers `SpaceNotFound` for a space it doesn’t have, and her PDS stops there \[crates\]. Once Marcus creates the space and admits her, her next write notification puts her repo in the writer set \[spec\]. Syncers then pull her whole repo, and the earlier records come with it, so a syncer sees them as soon as it sees the repo.

An empty repo and a missing repo are the same thing, so an account deletes its space repo by clearing it. The cleared repo stays in the writer set, and its host keeps answering sync requests with a commit showing that the records are gone \[spec\]. `clearRecords` deletes every record (apart from any published configuration records in the authority’s repo, [Chapter 8](https://atproto.how/atproto-spaces-field-guide/8-policies.md#publishing-configuration-to-readers)), advances the repo to a new `rev` with the empty digest, clears the operation log, and sends a write notification to the space host \[spec\]. The space host and syncers learn the records are gone. Clearing a repo never deletes the space.

Removing a writer leaves that writer’s repo alone. The authority drops the account from the writer set, syncers stop treating the repo as part of the space, and the records stay on the writer’s PDS until the writer clears them \[spec\].

A host can throw an empty space repo away once the clear has had time to spread, and the spec asks it to wait at least 72 hours \[spec\]. That number is a commonly used safe margin. It is also the recovery window `did:plc` gives an identity to undo a bad operation. The spec doesn’t mention `did:plc` here, but I think the two are related.

**Reference: Garbage collection**

A repo host may discard an empty space repo, its commit, and any remaining state. It should wait at least 72 hours after the clear, so the clear reaches the space host and syncers first. Once collected, the host answers as if the repo never existed, syncers treat that the same as an empty repo, and no notification is sent \[spec\]. Account migration may also leave empty repos behind.

<a id="the-commit"></a>

## 4.3 The commit

> *In the family space.* The family app has pulled Ruth’s records from her PDS. Before it shows who is coming to the reunion, it needs to know that it holds every one of them, and that they came from her PDS.

A space repo’s commit carries no signature, and that is a deliberate design decision. A signed commit would prove who wrote the records to anyone who ever saw a copy, including someone outside the space \[spec\]. Spaces offer a measure of deniability instead ([Chapter 5](https://atproto.how/atproto-spaces-field-guide/5-cryptography.md)). No one can take one of your records and link it back to you in a way that can be checked cryptographically. That has costs as well as benefits, and the protocol’s judgment is that the benefits are far greater.

**Reference: The commit** \[spec\]

Ruth’s space repo after she changes her RSVP.

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

| Field | Type | Meaning |
| --- | --- | --- |
| `ver` | integer | Commit format version, `1` |
| `repo` | DID | Whose repo this is. A syncer checks it against the repo it asked for. |
| `space` | space-ref | Which space the repo is in. A syncer checks it the same way. |
| `rev` | TID | The revision of this commit. A syncer passes it to `listRepoOps` to ask what changed since. |
| `data` | 32 bytes | `sha256` of the 2048-byte LtHash state. A syncer compares it with the digest of its own copy. |

The lexicon definition is [`com.atproto.space.defs`](https://lexicon.garden/nsid/com.atproto.space.defs)`#commit` \[spec\]. In JSON, `data` is written as `{"$bytes": "<base64>"}`, the lexicon form for raw bytes. In a STAR archive, the binary format that `getRepo` returns ([Chapter 7](https://atproto.how/atproto-spaces-field-guide/7-sync.md#full-state-recovery-with-getrepo)), the commit is encoded in DRISL instead. DRISL is a strict form of CBOR, a binary format much like JSON, and there `data` is a plain byte string.

`rev` is a TID, the sortable, timestamp-based identifier that atproto uses for revisions \[spec\].

The commit also has no `prev` and no tree root. It binds the repo to its space and revision, and `data` summarizes exactly which records exist. The host proves the commit to each requester with an HTTP Message Signature carried in the response headers ([Chapter 5](https://atproto.how/atproto-spaces-field-guide/5-cryptography.md#macs-as-http-message-signatures)). A copy of the commit on its own proves nothing to anyone.

The empty repo’s `data` is always:

<a id="code-4-1"></a>

```text
e5a00aa9991ac8a5ee3109844d84a555
83bd20572ad3ffcd42792f3c36b183ad
```

<a id="why-a-set-hash-instead-of-a-tree"></a>

## 4.4 Why a set hash instead of a tree

Public atproto stores each repo as a Merkle Search Tree, so anyone can prove a record is in the repo or walk the changes between two versions. Space repos use something simpler. A syncer only needs to know whether its copy equals the host’s, and it learns what changed from the op log ([Chapter 7](https://atproto.how/atproto-spaces-field-guide/7-sync.md#incremental-sync-with-listrepoops)). A set hash answers the equality question with 32 bytes. It costs one vector addition per write, and depends only on which records exist. There is no dependency on the order they were written. The host keeps the full 2048-byte state and the commit carries a digest. A set hash gives up both of the tree’s abilities. It can’t prove that one record is in a repo, and it can’t say what changed between two versions, so a syncer that loses its place in the op log fetches the whole repo again ([Chapter 7](https://atproto.how/atproto-spaces-field-guide/7-sync.md)) \[spec\].

The first of those losses is deliberate. A Merkle Search Tree gives a chain of validation, from one record up to the root and from the root into a signed commit. A space leaves that chain out on purpose, so a record that leaks stays deniable ([Chapter 5](https://atproto.how/atproto-spaces-field-guide/5-cryptography.md)).

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

## 4.5 Common questions

**Can a user write to a space before it exists?**

When someone else is the authority, yes. The user’s PDS accepts the write without checking, and the space host decides later whether to track it. When the user is the authority, the space has to be created first.

**What happens to a user’s records when they’re removed from a space?**

They stay in the user’s space repo on the user’s PDS. Removing a writer tells syncers to stop treating that repo as part of the space. To delete the records as well, the user’s app calls `clearRecords`, which empties the repo in one step.

**Why doesn’t the commit carry a signature?**

A signature would prove who wrote the records to anyone who ever saw a copy, including someone outside the space. [Chapter 5](https://atproto.how/atproto-spaces-field-guide/5-cryptography.md) explains how spaces prove a commit to the one reader who asked, and to no one else.
