Chapter 3
Spaces and addressing
Spaces introduce a new way to reference both spaces and the records they contain. Spaces only exist in the context of a space owner, referred to as the space authority, a modality, referred to as the space type, and an instance of that modality in the context of the authority, referred to as the space key. These three pieces of information are how you can refer to the data boundary that is a space.
Public atproto records also contain three pieces of information including the record authority, collection, and record key. Combined, a fully qualified AT-URI for a space record includes these six pieces of information that can tell you what you need to access record data. One small but important piece of information is that an AT-URI for a space or a space record begins with "at:space/", where a public AT-URI begins with "at://", to assist with disambiguation.
The URI#
Space references and space record references take the form of an AT-URI that contains the space literal, authority, type, and key, followed, in a record reference, by the record authority, collection, and key. These values have an "at:space/" prefix and use "/" characters for separators.
at:space/[space-authority]/[space-type]/[space-key]/[record-authority]/[record-collection]/[record-key]Reference
The URI of Nora’s RSVP in the family space#
at:space/did:plc:ejjl2znzqp3ci25dqaslpkk2/com.example.familyUpdates/our-family/did:plc:ashwgt3d5ntfxmlcfyizpu2g/community.lexicon.calendar.rsvp/3n2gtdo55s22p| # | Segment | In Nora’s RSVP | Meaning |
|---|---|---|---|
| 1 | Space literal | space | Fixed marker for a space URI |
| 2 | Space authority | did:plc:ejjl2znzqp3ci25dqaslpkk2 | Marcus’s identity |
| 3 | Space type | com | What kind of space it is |
| 4 | Space key | our-family | Which space of that type |
| 5 | Record authority | did:plc:ashwgt3d5ntfxmlcfyizpu2g | Nora, who wrote the record |
| 6 | Record collection | community | What kind of record it is |
| 7 | Record key | 3n2gtdo55s22p | Which record of that kind |
The literal space comes directly after the at: scheme, where a public URI has //, so a parser tells the two forms apart from the prefix alone spec. Truncating after the space key gives a space reference, which lexicons type with the space-ref string format spec.
function uriKind(uri) {
if (uri.startsWith("at:space/")) {
const parts = uri.slice("at:space/".length).split("/")
if (parts.length === 3) return "space reference"
if (parts.length === 6) return "space record"
return "other"
}
if (uri.startsWith("at://")) {
const parts = uri.slice("at://".length).split("/")
if (parts.length === 3) return "public record"
}
return "other"
}In a public URI the first DID is the author. In a space URI the first DID is the authority, and the author is the second DID.
Take a URI apart below, then look up the space it names. The console replays a recorded response, so no real space is called.
Responses name spaces by reference in a field called space.
Reference
Looking up the family space#
The family app calls getSpace on Marcus’s PDS with his session.
The authority#
The authority is the root of trust for the space. It may be a user’s own identity, as for bookmarks or drafts, or a dedicated identity for a shared space, which lets the space pass between people without depending on any one of them spec. The authority always reads and writes its own spaces, under every policy, without appearing on any member list spec.
The authority comes first after the literal because it is the root, and every part after it is scoped by the parts before it. Marcus is the authority. Under his identity is a kind of space, named by the space type, and under that type the space key picks out one space. The record’s parts continue the pattern, with an author in that space, a collection of that author’s, and a record key in that collection.
The space type#
The type is an NSID naming the modality. It resolves to a space type declaration, a lexicon whose main definition has "type": "space":
Reference
The family space’s type declaration#
Marcus’s identity publishes it as the record at://, and the DNS record _lexicon.example.com names that identity.
{
"$type": "com.atproto.lexicon.schema",
"lexicon": 1,
"id": "com.example.familyUpdates",
"defs": {
"main": {
"type": "space",
"description": "A family's private space for updates, photos, and events",
"key": "any",
"title": "Family updates",
"title:lang": {
"es": "Novedades familiares"
},
"collections": [
"com.example.familyUpdates.post",
"community.lexicon.calendar.event",
"community.lexicon.calendar.rsvp",
"community.lexicon.bookmarks.bookmark",
"com.atproto.label.record"
]
}
}
}Reference
Fields of a space type declaration spec#
| Field | Required | Meaning |
|---|---|---|
type | yes | "space", on the main definition |
description | no | For developers; not shown to users |
key | yes | Recommended space key type, like a record key type |
title | no | Short name shown on consent screens |
title:lang | no | Localized titles by language code |
collections | yes | Collections clients should expect; no wildcard |
A space type declaration is a public lexicon, published like any other: a com_lexicon DNS record. Anyone can resolve it. A PDS has to, because it shows the title on the consent screen and reads the collections when it checks a bare scope spec.
A space’s records are permissioned, but its type is always public; there is no private space type declaration. The reason is the way lexicon resolution works today. The _lexicon DNS record says which repository holds the schemas, and it has no way to carry a space’s authority, type, and key as well. Resolution ends at a public repo, so the declaration has to be published there. The side effect is that the kinds of records a space of that type is expected to hold are public. Someone who also knows who is in a space can start to piece together what it contains.
A lexicon author can add a record type to a space type later, and existing sessions pick it up without the user consenting again. That works because the declaration’s collections are the default write set for a bare space: scope (Chapter 9), and the default is read from the declaration each time a grant is checked spec. An app that wants a fixed write set lists the collections in its scope. The list may name NSIDs from any namespace. A space may still hold records of any collection. The type also tells a reader what kind of data to expect before any network call, and its title is what users see on the OAuth consent screen, with the NSID shown when there is no title spec.
The space key#
The space key, written skey in the spec and the lexicons, distinguishes spaces of the same type under one authority. It follows record-key syntax, up to 512 bytes spec. The declaration’s key field recommends a key style the way a record schema does: self for a singleton like a user’s bookmarks, a slug like our-family, a TID for spaces created on demand, or a cryptographic identifier.
Reference
Space key syntax#
A space key is 1 to 512 bytes, drawn from A-Z, a-z, 0-9, and . _ : ~ -, and it is never . or .. spec. atproto-space checks this when it builds a SpaceKey crates.
Spaces used together#
An application often treats several spaces under one space authority as one whole. This guide calls that set a hyperspace. A hyperspace has a primary space, which holds the main content or community and which the other spaces are organized around. A hyperspace can hold a single space, with the other positions unfilled.
Two or more spaces are in syzygy (pronounced "SIZ-ih-jee") when they share the same space authority and the same space key but have different space types, as at:space/ and at:space/ do. Each is the other’s syzygy space. The standard example is a community space and its moderation space.
An inner space sits beneath another space in the same hyperspace, such as a subgroup focused on specific content for members of the space above it. It has the same space authority and its own space key, and it can have a syzygy of its own.
That gives a hyperspace two directions. Along the type dimension the key stays and the type changes, which is where syzygy lives. Along the key dimension the key changes, which is where inner spaces live.
These are conventions an application adopts. Every space in a hyperspace is a full space with its own policy and member list, and the application arranges how they relate.
Common shapes#
| Use | Authority | Type | Space key |
|---|---|---|---|
| Bookmarks | the user | com.example.bookmarks | self |
| A family’s updates | a family member | com | our-family |
| A shared photo album | the creator | com.example.album | a TID |
| A community and its moderation space | the community’s identity | one type for each space | the same key for both |
| A subgroup inside a community | the community’s identity | the community’s type or one of its own | a key of its own |
Common questions#
- How can I tell a space record’s URI from a public one?#
Look at the prefix. A space URI begins with
at:space/, and a public URI begins withat://. The short function earlier in this chapter does exactly that.- Can I create my own space type?#
Yes. A space type is a lexicon, so anyone who controls an NSID’s domain can publish one. Publish it like any other lexicon, give it a
titlepeople will recognize on the consent screen, and list the collections your app writes.- Can a space hold records outside its type’s collections?#
Yes. The
collectionslist sets which collections a barespace:scope lets an app write by default. A space can still hold any record type, so an app with a broader scope can write other kinds of records into it.
Chapter 3 of 11 · AT Protocol Spaces: A Field Guide