Chapter 8
Policies
Policies are the core of how people interact with a space because policies are what enforces a space’s data perimeter. Stored with the space as a typed object, a policy decides whether an identity and app may read (get a credential), and whether an account may write (be tracked in the writer set, with syncers notified). Adding or removing a member is a common operation and a relatively straightforward one. It’s the policy that determines what adding a member means and what the side effects are.
A personal bookmark collection under personalspace has no members to add. It’s your own space, and no one else will use it. With memberspace, adding and removing members has all kinds of side effects. A member can be given read access, write access, or both. The space can also publish its policy as a record, and a record for each member.
With managedspace you are effectively handing all of the decision making to a third party. The managing app determines what access any given account has. Every PDS must support these three baseline policies and may support others spec. They won’t fit every community, and it’s relatively easy to create a new one.
The lifecycle methods#
An authority creates, changes, reads back, and deletes its space with four methods under com.atproto.space.*. They work the same way under every policy spec, and each one takes the authority’s OAuth session with the matching manage grant from Chapter 9.
Creating a space happens once, when someone sets one up, and the caller becomes its authority. The call needs manage=create for the space type. skey is optional, and the host generates a TID when it’s omitted. The response is the new space’s URI. A call that names a deleted space’s type and key recreates it under the same URI, with the new policy and no members crates. A second call with the same type and key fails with SpaceAlreadyExists, and a policy type the host doesn’t support fails with UnsupportedPolicy spec.
Reference
createSpace spec#
SpaceAlreadyExistsUnsupportedPolicyMarcus creates the family space on his PDS.
Changing a space’s rules is an updateSpace call, which needs manage=update. The new policy replaces the old one wholesale, so the request carries every field, not only the one that changes. Keeping the same $type is a configuration change. Switching to a different $type migrates the space, and the old policy’s state, such as a member list, is discarded. It doesn’t come back if the space later migrates back. A field the new policy leaves out takes its default, and the writer set isn’t re-evaluated. atproto-pds revokes early any outstanding credential the new policy wouldn’t issue, and brings the published records in line, so turning publishMembers off withdraws the member records crates.
Reference
updateSpace spec#
SpaceNotFoundNotAuthorizedUnsupportedPolicyMarcus stops publishing the family’s member list.
POST /xrpc/com.atproto.space.updateSpace
Authorization: DPoP eyJ0eXAiOiJhdCtqd3QiLCJhbGciOi…
DPoP: eyJhbGciOiJFUzI1NiIsInR5cCI6Im...
{
"space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family",
"policy": {
"$type": "com.atproto.memberspace.policy",
"publicRead": false,
"publicWrite": false,
"publishPolicy": true,
"publishMembers": false
}
}HTTP/1.1 200 OK
Content-Length: 0The lexicon declares no output, so success is a 200 with an empty body spec.
Reading a space’s current policy back is a getSpace call, such as when the family app opens its settings screen for Marcus. Only the authority can make it. Members who want to see the policy rely on the publishPolicy flag instead.
Reference
getSpace spec#
SpaceNotFoundNotAuthorizedMarcus’s family app loads the family space’s settings.
atproto-pds writes out every default and leaves allowedApps out when it’s unset, since its absence means any app may read crates.
Removing a space is a deleteSpace call, which needs manage=delete. One call starts a longer sequence. The host stops issuing credentials, deletes the authority’s own records in the space, and notifies every registered syncer, and each syncer then drops its copy. Chapter 10 walks through that sequence under Deleting a space. Members' own repo hosts aren’t told, and their records in the space become unreadable to anyone but their own accounts. Deleting a space that’s already deleted answers 200 and repeats none of this crates.
Reference
deleteSpace spec#
SpaceNotFoundNotAuthorizedMarcus deletes the family space.
POST /xrpc/com.atproto.space.deleteSpace
Authorization: DPoP eyJ0eXAiOiJhdCtqd3QiLCJhbGciOi…
DPoP: eyJhbGciOiJFUzI1NiIsInR5cCI6Im...
{
"space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family"
}HTTP/1.1 200 OK
Content-Length: 0As with updateSpace, the lexicon declares no output spec.
Every method that works on an existing space refuses a caller who isn’t the authority with NotAuthorized, and an unknown space with SpaceNotFound. That covers updateSpace, deleteSpace, getSpace, removeWriter, and exportSpaceMeta spec. atproto-pds sends NotAuthorized with status 400 crates.
Three rules hold under every policy spec:
The authority always reads and writes its own space.
Read access decides whether a credential is minted.
Write access decides only whether the space host tracks a writer and notifies syncers. It never blocks a write into an account’s own repo, and applications still choose which records to show.
personalspace#
com
{
"$type": "com.atproto.personalspace.policy"
}A bookmarks app asks for space:com (authority defaults to self), creates at:space/ on first run, and writes records there. Each of Jake’s apps needs its own read grant to reach it.
memberspace#
com
Reference
Memberspace policy fields spec#
| Field | Default | Effect |
|---|---|---|
publicRead | false | Anyone may read; no delegation token needed |
publicWrite | false | Track writes from accounts not on the member list |
allowedApps | any | Mint only for these attested client_id values (URIs) |
publishPolicy | false | Publish the policy as a record |
publishMembers | false | Publish one record per member |
Each member is a com#member with required did, read, and write spec. The list lives outside the policy object, so it survives configuration changes.
A member’s read and write are independent permissions spec. Each works as the three rules above describe, so a member can hold either without the other. A read-only member follows the space without being synced as a writer. A write-only member, with write: true and read: false, has their records synced to everyone who can read, but their apps can’t read anyone else’s repo, which suits a submissions or tip-line space, where members post and only the authority and readers see everything. Either way, a member can always read their own space repo on their own PDS with OAuth.
Adding members, or changing what existing members can do, is a putMembers call, which needs manage=update. Each entry sets read and write together, so upgrading a read-only member to read and write means sending true for both. A call takes at most 100 entries and applies them in one commit, so larger changes go in batches of 100 spec. In atproto-pds, a DID listed twice takes its last entry, a member given write: false leaves the writer set, and a member who loses read loses their outstanding credentials too crates.
Reference
putMembers spec#
SpaceNotFoundNotAuthorizedPolicyMismatchMarcus adds the family in one call, with Erin as a read-only member.
POST /xrpc/com.atproto.memberspace.putMembers
Authorization: DPoP eyJ0eXAiOiJhdCtqd3QiLCJhbGciOi…
DPoP: eyJhbGciOiJFUzI1NiIsInR5cCI6Im…
{
"space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family",
"members": [
{
"did": "did:plc:53ni6w7okqrxvjxezmopejoo",
"read": true,
"write": true
},
{
"did": "did:plc:p4256dosynj6j6tkypz2q2l3",
"read": true,
"write": true
},
{
"did": "did:plc:ashwgt3d5ntfxmlcfyizpu2g",
"read": true,
"write": true
},
{
"did": "did:plc:brthxhhoomvrib2avauses35",
"read": true,
"write": true
},
{
"did": "did:web:erin.example",
"read": true,
"write": false
}
]
}HTTP/1.1 200 OK
Content-Length: 0Reference
putMembers spec#
SpaceNotFoundNotAuthorizedPolicyMismatchMarcus changes Jake to read-only. The same call with "write": true would upgrade him back.
POST /xrpc/com.atproto.memberspace.putMembers
Authorization: DPoP eyJ0eXAiOiJhdCtqd3QiLCJhbGciOi…
DPoP: eyJhbGciOiJFUzI1NiIsInR5cCI6Im...
{
"space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family",
"members": [
{
"did": "did:plc:brthxhhoomvrib2avauses35",
"read": true,
"write": false
}
]
}HTTP/1.1 200 OK
Content-Length: 0Taking someone off the list is a removeMembers call, with the same manage=update grant and the same limit of 100. A DID that isn’t a member is ignored spec, writer-set entry and all. Each removed member leaves the list and the writer set together, and atproto-pds revokes their credentials unless the space is publicRead crates. Their records stay in their own space repo.
Reference
removeMembers spec#
SpaceNotFoundNotAuthorizedPolicyMismatchMarcus removes Jake.
POST /xrpc/com.atproto.memberspace.removeMembers
Authorization: DPoP eyJ0eXAiOiJhdCtqd3QiLCJhbGciOi…
DPoP: eyJhbGciOiJFUzI1NiIsInR5cCI6Im…
{
"space": "at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family",
"dids": [
"did:plc:brthxhhoomvrib2avauses35"
]
}HTTP/1.1 200 OK
Content-Length: 0Reading the member list back is a listMembers call. Only the authority can make it, and the authority itself never appears in the list. It pages with limit, from 1 to 1000 with a default of 100, and cursor spec. atproto-pds sorts members by DID and uses the last DID on a page as the cursor crates. Members who want to see the list rely on the publishMembers flag instead.
Reference
listMembers spec#
SpaceNotFoundNotAuthorizedPolicyMismatchInvalidCursorMarcus’s family app loads the member list after Jake’s removal.
GET /xrpc/com.atproto.memberspace.listMembers
?space=at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family
&limit=100
Authorization: DPoP eyJ0eXAiOiJhdCtqd3QiLCJhbGciOi…
DPoP: eyJhbGciOiJFUzI1NiIsInR5cCI6Im...{
"members": [
{
"did": "did:plc:53ni6w7okqrxvjxezmopejoo",
"read": true,
"write": true
},
{
"did": "did:plc:ashwgt3d5ntfxmlcfyizpu2g",
"read": true,
"write": true
},
{
"did": "did:plc:p4256dosynj6j6tkypz2q2l3",
"read": true,
"write": true
},
{
"did": "did:web:erin.example",
"read": true,
"write": false
}
]
}atproto-pds includes cursor only when more members remain, so this response has none. Its member store also returns at most 100 members a page, whatever limit asks for crates.
All three methods declare SpaceNotFound, NotAuthorized, and PolicyMismatch, which means the space isn’t a memberspace. listMembers adds InvalidCursor spec.
Reference
The memberspace access decision spec#
canRead(user, app):
if allowedApps set and app not in allowedApps: deny
if publicRead: allow
if user is none: deny
if user == authority: allow
if members[user].read: allow
deny
canWrite(user):
if user == authority: allow
if user in members: return members[user].write
if publicWrite: allow
denyWith publicRead, no delegation token is required, but allowedApps still applies, so a client attestation from a listed app is required when the list is set. Without allowedApps, any app may read and no attestation is needed, so public clients work. allowedApps applies only to reads, because a write notification authenticates the writer’s repo host, not the app spec.
When removeMembers removes a member, or putMembers revokes a member’s write access, the authority should also remove that account from the writer set, and the removal is announced to syncers. Under publicWrite, a removed writer is tracked again as soon as it writes, unless it is on the member list with write: false spec.
These three configurations cover a lot of use cases. The following examples show some of the ways the read and write flags can be used as common patterns. Each shows the body an organizer sends to create a space and manage a member list, and also describes what it means for readers and writers of those example spaces. They’re illustrative, so the people in them don’t appear in Appendix F.
A private group#
Alice (did:plc:ldianl3maiaomvmvyyt3xzhh) runs a small planning committee. Bob (did:plc:7gortyhgiwmpn47qdu6h2bhc) helps run it, and Carol (did:plc:5uf6dmcz5zmcw3evvgwl5jx4) follows along. A private group leaves every flag at its default and lists its members:
{
"spaceType": "com.example.group",
"skey": "planning-committee",
"policy": {
"$type": "com.atproto.memberspace.policy"
}
}{
"space": "at:space/did:plc:ldianl3maiaomvmvyyt3xzhh/com.example.group/planning-committee",
"members": [
{
"did": "did:plc:7gortyhgiwmpn47qdu6h2bhc",
"read": true,
"write": true
},
{
"did": "did:plc:5uf6dmcz5zmcw3evvgwl5jx4",
"read": true,
"write": false
}
]
}Only Alice, Bob, and Carol get credentials, so only their apps can read the group. Bob’s writes are tracked and reach syncers. Carol reads but isn’t synced as a writer. With publishPolicy and publishMembers off, nothing about the group shows up as a record in Alice’s repo.
An announcement space#
Alice also runs an announcements space, where Bob posts updates for anyone to read. An announcement space opens reads to everyone and keeps writing to its members:
{
"spaceType": "com.example.group",
"skey": "announcements",
"policy": {
"$type": "com.atproto.memberspace.policy",
"publicRead": true,
"publishPolicy": true
}
}{
"space": "at:space/did:plc:ldianl3maiaomvmvyyt3xzhh/com.example.group/announcements",
"members": [
{
"did": "did:plc:7gortyhgiwmpn47qdu6h2bhc",
"read": true,
"write": true
}
]
}Any app gets a credential without a delegation token, so anyone can follow along. Only Alice and Bob are tracked as writers. Anyone else can still write records into their own repo for this space, but the space host never lists them, so syncers never pull them. Setting allowedApps would limit reading to attested apps, and publishing the policy lets clients see that the space is public before they ask.
An open guestbook#
Finally, Alice opens a guestbook that anyone can sign, and Mallory (did:plc:3fuyksp4k46rff4lht3ihb3y) is one of the people who can. An open guestbook opens both reading and writing, and needs no member list:
{
"spaceType": "com.example.group",
"skey": "guestbook",
"policy": {
"$type": "com.atproto.memberspace.policy",
"publicRead": true,
"publicWrite": true
}
}Anyone can read, and any account that writes is tracked and synced. Moderation is handled after the fact. If Mallory were to post spam, Alice removes her ability to write with removeWriter:
{
"space": "at:space/did:plc:ldianl3maiaomvmvyyt3xzhh/com.example.group/guestbook",
"repo": "did:plc:3fuyksp4k46rff4lht3ihb3y"
}A removed writer is tracked again as soon as it writes, unless it is on the member list with write set to false spec. To keep Mallory out, Alice also adds her as a member who can read but not write:
{
"space": "at:space/did:plc:ldianl3maiaomvmvyyt3xzhh/com.example.group/guestbook",
"members": [
{
"did": "did:plc:3fuyksp4k46rff4lht3ihb3y",
"read": true,
"write": false
}
]
}managedspace#
com
Choosing managedspace hands the space’s access decisions, and with them its data perimeter, to a third party. That can be the right call for some situations. A managing app can be a specialized service with its own deployment and resource footprint, so the authority’s PDS doesn’t carry that work. It can also offer policies and features the PDS or space host doesn’t support, which bridges the gap for apps that want them.
The trade-offs are real, though. If the managing app is slow or prone to outages, the space is unavailable to apps and users while it’s down. The authority also gives up some control over important metadata about the space. Most important, the managing app can let people in without the authority’s consent, including itself. Weigh these before delegating to a third party, and before building managing-app endpoints for others to use with your applications.
{
"$type": "com.atproto.managedspace.policy",
"managingApp": "did:web:newsletter.example#newsletter_app",
"publishPolicy": true
}managingApp is a did#serviceId reference. The managing app serves comlxm=com) spec.
Reference
checkAccess spec#
A newsletter author’s PDS asks the managing app about one reader.
The authority passes the space, the identity being checked as repo, and the attested client_id if the request presented one. A check prompted by a write carries no client, since notifyRepoUpdate doesn’t identify the app spec.
read and write come back as independent answers. A paid newsletter falls out naturally, since subscribers read and only the author writes. A follower-gated space checks the follow graph instead.
In atproto-pds, a request without a delegation token asks with no repo. A managing app should answer read: true to that check only for spaces meant to be publicly readable. If the managing app can’t be reached, returns an error, or sends malformed output, the request fails with 502 UpstreamFailure rather than a denial. The managingApp value must be an absolute did:plc or did:web reference with a fragment, and the server checks it on create, update, and import crates.
Publishing configuration to readers#
By default a space’s policy and member list are visible only to the authority, through getSpace and listMembers. memberspace and managedspace carry a publishPolicy flag, and memberspace also carries publishMembers spec. When set, the authority’s PDS writes that state as records in the authority’s own repo in the space.
Not every space needs that transparency, and leaving the flags off is a normal choice. In a memberspace, the published records are extra data the space may not want or need. A space can also be built so that members don’t know who the other members are, such as a support group or a tip line.
Reference
Published configuration records spec#
| Flag | Collection | Record key | Record |
|---|---|---|---|
publishPolicy | com | self | policy, holding the current policy object |
publishMembers | com | the member’s DID | read, write |
With both flags set, Marcus’s repo in the family space holds a policy record and a record for each member, such as these two, at com and com spec:
{
"$type": "com.atproto.space.policy",
"policy": {
"$type": "com.atproto.memberspace.policy",
"publicRead": false,
"publicWrite": false,
"publishPolicy": true,
"publishMembers": true
}
}{
"$type": "com.atproto.memberspace.member",
"read": true,
"write": true
}The policy record wraps the policy in a policy field rather than being the policy object itself, so its $type stays com
The stored configuration stays the source of truth, and the PDS keeps the records in step. It rejects direct writes to those collections through repo CRUD, and clearRecords leaves them in place. Readers trust these records only in the authority’s repo, since any member could write look-alikes into their own spec. Members who have written can be enumerated through the writer set even when the member list is unpublished.
Other policies#
The baseline policies are neither the only permitted ones nor privileged ones spec. Any policy defines a policy object with its own $type, its access rules, its configuration, and any additional XRPC methods, by convention in the policy’s own namespace. A host that receives a $type it doesn’t implement answers UnsupportedPolicy, so clients can feature-detect.
New policies are expected, and writing one is a modest amount of work. Communities come in different shapes, and a policy is where a community states what its data perimeter allows. A policy outside the baseline is a full participant in the protocol, and it can be implemented by a PDS or by a space host built for the purpose spec.
Off the Clock, a members-only community application, is one example. Its community is a hyperspace, with a primary space that has its own members and inner spaces for smaller groups, and a member of an inner space has to be a member of the space above it first. Memberspace keeps each space’s list separate, with no way to make one list depend on another. A managedspace whose managing app checks the space above could do the job, but it would trust that app to get the check right every time. A policy of its own keeps the check and its validation in the space host that enforces the policy. The protocol gives no meaning to one space sitting beneath another, so the policy is where the host learns that relationship. Off the Clock defines usatproto-pds implements it crates.
An inner space names the space above it in its policy, in the parent field. A space that names none admits members directly. An inner space admits members of the space above it, and parentAccess sets what each of those members gets there without an entry of their own. When a member leaves or is removed from a space, the host removes their entries from every inner space beneath it, and from those spaces' writer sets, in the same change crates.
The cost is portability. Every PDS implements the baseline policies spec. A space under a custom policy needs a host that implements that policy, which narrows where its authority’s account can live. A practical answer is to make the community its own identity, as the space authority, and keep that identity’s account on a host that supports the policy. The admins and members are then free to keep their accounts anywhere.
Reference
us fields crates#
| Field | Default | Effect |
|---|---|---|
parent | none, so no space is above this one | The space above this one, under the same authority and the same policy |
parentAccess | read | What each member of the space above gets without an entry: read, write (which includes read), or none |
publicRead | false | Anyone may read, with or without a delegation token |
allowedApps | the list of the space above, or any app when there is none | Mint credentials for these attested client_id values |
publishPolicy | false | Publish the policy as a com |
publishMembers | not published | A space under the same authority, written <spaceType>/<skey>, that receives the member entries as records |
A member entry carries read, write, and admin, and an admin manages the member list of that one space. The policy’s methods live in its own namespace, us. They are putMembers, removeMembers, listMembers, listSubspaces, and leave crates.
Common questions#
- Is there a member list my app can read?#
If the authority sets
publishMembers, its repo in the space holds one record per member, and any reader of the space can see them. Otherwise only the authority can calllistMembers. The writer set is a different list, the accounts that have written, andlistSpacesis different again, the spaces where the caller’s own account keeps a repo or is the authority.- Can someone write to a space without being able to read it?#
Yes, under memberspace. A member with
write: trueandread: falseis a write-only member, as described under memberspace. Under managedspace, the managing app can answercheckAccessthe same way.- Can a space change policies?#
Yes.
updateSpacewith a policy of a different$typemigrates the space. The old policy’s state, such as its member list, is discarded.
Chapter 8 of 11 · AT Protocol Spaces: A Field Guide