~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0
536 lines · 68.8 KB Raw History
# HTTP and XRPC API

This is what the host answers over HTTP, at `PUBLIC_URL` ([config](config.md)).
Each `org.atgrp.*` method has its lexicon under
`lexicons/org/atgrp`, which says what it takes and answers, and the
docs site shows it under the method. The `org.atgrp.internal.*`
methods, under `lexicons/org/atgrp/internal`, are this host's own,
for its console, its command and its operators. They aren't part of the
Atmosphere Groups spec, and may change. The design pages say why each part
works the way it does.

An XRPC error is JSON, the same as atproto's servers send: an HTTP status
and `{"error", "message"}`. Besides the names a method's lexicon lists,
any method may answer these:

| Error                                                          | When                                                                                                                                                                                                                                                   |
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `InvalidRequest`                                               | a parameter is missing or bad, or a method is asked with the wrong HTTP method. The host checks a `org.atgrp.*` method's parameters and JSON input against its lexicon before anything else, as atproto's reference server does, and says where and what is wrong (`Input/roles/2/role must not be longer than 64 bytes`) |
| `PayloadTooLargeError`                                         | a JSON input is over 2 MiB                                                                                                                                                                                                                             |
| `AuthMissing`                                                  | the method needs a caller and there isn't one                                                                                                                                                                                                          |
| `BadJwt`, `BadJwtAudience`, `BadJwtIss`, `BadJwtLexiconMethod` | service auth doesn't hold up: a bad token, a token for another service, a signer whose key can't be found, or a token for another method                                                                                                               |
| `Forbidden`                                                    | the caller's roles lack the action (`missing <action>`)                                                                                                                                                                                                |
| `GroupNotFound`                                                | the DID isn't a group here                                                                                                                                                                                                                             |
| `RepoDeactivated`                                              | the group is switched off                                                                                                                                                                                                                              |
| `RateLimitExceeded`                                            | a 429: the caller has asked more than a [limit](../design/limits.md) allows in its window. `Retry-After` says in how many seconds to ask again, and `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset` and `RateLimit-Policy` say which limit |
| `InternalServerError`                                          | the host's database, or a server it asked, failed; the message says no more than `Internal Server Error`, and the host's log says what                                                                                                                 |

The atproto methods answer with atproto's own names (`RepoNotFound`,
`BlobNotFound`, `InvalidSwap`, `CredentialRevoked`, …). When an app
writes a record as a group in one of our own `org.atgrp.*`
collections, the host checks it against its lexicon and answers
`validationStatus: "valid"`. It keeps a record of any other collection
without reading it and answers `unknown`. A GET or POST under `/xrpc/`
that no route answers gets 501 `MethodNotImplemented`, unless it carries
`atproto-proxy` and a group's token: then the host sends it on
([signing in](../design/signing-in.md#calling-other-services-as-the-group)).

## Who asks

The host's own methods know their caller in one of two ways:

- Service auth. That's `Authorization: Bearer <jwt>`, from the caller's
  own PDS (`com.atproto.server.getServiceAuth`), with the host's
  `SERVICE_DID` as `aud` (or `SERVICE_DID#<service>`, the way a PDS
  proxying to the host's `#atgrp` service names it) and the
  method's NSID as `lxm`. An app, or the `atgrp` command, calls as
  a person this way.
- The console's cookie, `__Host-group_host_session` (`group_host_session`
  where the console isn't on https). The host signs it once someone
  signs in to the console ([signing in](../design/signing-in.md#signing-people-in-to-the-console)).
  The host uses it only when no `Authorization` is sent, and only from
  the console's own pages. A request with another `Origin` counts as
  coming from nobody.

What a caller may then do in a group is what their roles there allow
([membership](../design/membership.md)), and a method's lexicon names the
permission it needs. An app signed in as a group, with the host's OAuth
([signing in](../design/signing-in.md)), writes to the group's repo and
spaces through the atproto methods below.

## Groups

| Method                                  | What it does                                                                                                                                                                                                                              |
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST org.atgrp.internal.createGroup`       | starts a group, with the caller as its founder and first admin. `metaPublicRead: false` keeps its `meta` space from anyone but its members. `joinPolicy` is `open`, `approval` or `invite` (`approval` unless given). A handle already held here fails `HandleTaken` |
| `GET org.atgrp.internal.getGroup`           | shows a group as the caller may see it. Someone signed in who may read `meta` gets its about record (`displayName`, `description`, `avatar`, `website`) and its config's `joinPolicy`. One who may read `members` also gets its rules, its labels, its member count, roles and spaces. Spaces come `meta` and `members` first, then the index's in its order, then the group's others, with an `unlisted` one only for someone who reads it. A member is told, as `grantable`, which actions' permissions and permission sets they hold enough of to give a role, as `labelSpaces` the spaces where their roles write labels, and as `accepted` whether their own repo in `members` holds any record. One holding `admit` gets up to 100 waiting `joinRequests`, and someone waiting to join gets their own as `viewer.request`. While the group is switched off, someone signed in gets only its DID, handle, address and two spaces' URIs, `deactivated: true` and `viewer.steward`. Someone not signed in gets only its DID and handle |
| `GET org.atgrp.internal.checkAddress`       | says whether an address (one label under `HANDLE_DOMAIN`) is free for a new group. Anyone may ask                                                                                                                                         |
| `GET org.atgrp.internal.checkGroupHandle`   | says whether a domain names the group yet, so it can be its handle                                                                                                                                                                        |
| `POST org.atgrp.internal.updateGroupHandle` | gives the group a handle on its own domain, or gives its address back. It refuses a bad handle (`InvalidHandle`), a name under `HANDLE_DOMAIN` but its own address (`UnsupportedDomain`), another account's handle (`HandleNotAvailable`), a domain that doesn't name the group yet (`NotPointing`), and a DID the host's key no longer controls (`NotController`) |
| `POST org.atgrp.internal.putGroupDomain`    | serves the group at its handle's own domain once that domain answers as this host. Its address and `www.` under the domain redirect there (`NoOwnDomain`, `NotReaching`) ([its own domain](../design/groups.md#its-own-domain)) |
| `POST org.atgrp.internal.deleteGroupDomain` | stops serving the group at its own domain                                                                                                                                                                                                 |
| `POST org.atgrp.internal.deactivateGroup`   | switches a group off until `activateGroup`                                                                                                                                                                                                |
| `POST org.atgrp.internal.activateGroup`     | switches a deactivated group back on                                                                                                                                                                                                      |
| `POST org.atgrp.internal.deleteGroup`       | deletes a group for good ([groups](../design/groups.md)). It answers `tombstoned`, which is `false` when a steward's recovery key is on the DID, since the host leaves the DID to them |

A group's address, and its own domain once it's served there, answer
these too. A request to the host's own name never does:

| Route | What it does |
| --- | --- |
| `GET`, `HEAD` `https://<address>/` | redirects to the group's page in the console while the group is on. Any other path, besides `/.well-known/` and `/xrpc/`, which the host keeps for itself there, is a plain 404 |
| `https://<address>/<path>`, `https://www.<domain>/<path>` | while the group is served at its own domain, redirect (301) to the same path and query there |
| `GET /tls/ask?domain=<domain>` | answers 200 if the proxy in front may get a certificate for `domain`, and 404 otherwise. A domain qualifies if it's a group's own domain, or `www.` under it, while the group is on, whether or not the group is served there yet |

## Membership

| Method | What it does |
| --- | --- |
| `GET org.atgrp.internal.listMembers` | lists the group's members and their roles, a page at a time in DID order (`limit`, `cursor`), filtered to those whose handle or DID contains `q`, ignoring case. It's for a caller who may read the members space. A page is 50 by default, 100 at most |
| `POST org.atgrp.leaveGroup` | leaves a group (`GroupNotFound`, `NotAMember`), unless the caller is its only admin (`LastConfigurer`) |
| `POST org.atgrp.requestJoin` | asks to join, or redeems an `invite` in the caller's inbox. It answers `status` `admitted` with the `membership`, or `pending` with the `request`. A named `invite` must be the caller's waiting invite from this group (`InvalidInvite`), and a waiting invite admits them whatever the policy. Under `open`, the caller is let in, even with a request left waiting from before. Under `approval` or `invite`, a caller who already asked gets their waiting request back, with its first message and time. Under `invite`, one who hasn't asked is refused (`JoinClosed`). A member gets their membership. A `message` is 2,000 graphemes at most. A group not here fails `GroupNotFound`, and a switched-off one `RepoDeactivated` |
| `GET org.atgrp.internal.getJoinRequest` | shows the caller's own request to join while it waits |
| `POST org.atgrp.cancelJoinRequest` | withdraws that request (`GroupNotFound`, `JoinRequestNotFound`) |
| `GET org.atgrp.listJoinRequests` | lists the waiting requests, newest first, for those who admit people. A page is 50 by default, 100 at most (`InvalidCursor`) |
| `POST org.atgrp.denyJoinRequest` | turns a request down, for the same (`JoinRequestNotFound`) |
| `GET org.atgrp.internal.listInvites` | lists the group's invites that are still waiting and unexpired, newest first, each with the invitee's handle, for those who may invite. A page is 50 by default, 100 at most |
| `GET org.atgrp.internal.getActorInvites` | lists the caller's own invites from groups here |
| `POST org.atgrp.internal.declineInvite` | turns an invite down, taking it out of the caller's inbox and the host's list, so the group may invite again (`InviteNotFound`) |

A group's roles, what each may do, and who holds them are records in its
members space: `org.atgrp.role`, each with its `permissions` and the
roles it may assign (`canAssign`, `*` for every role), and `org.atgrp.membership`.
A role's ID is lowercase letters and `-`, 3 to 64 of them. A role also
holds an optional display name (64 graphemes) and description (2,000),
and its `default` and `bot` flags. Its `permissions` and `canAssign`
hold 100 entries each at most. A membership's key is the member's DID,
and its `roles` (100 at most) name only roles the group defines
(`InvalidRequest` otherwise).
They're written as the group with the `com.atproto.space.*` writes
[below](#signing-apps-in-as-a-group). Writing a membership for someone
waiting to join lets them in. Writing one for a member changes their
roles, and deleting one puts the member out
([membership](../design/membership.md#writing-roles-and-memberships)).

| Refusal | Why |
| --- | --- |
| `LastConfigurer` | nobody would be left holding a role that configures the group |
| `RoleInUse` | a deleted role is still held |
| `NotAssignable` | the writer may not assign a role being given or taken, or one whose grant is changing, or may not give every role (`*`) |
| `ScopeNotHeld` | the writer's roles don't hold a permission being given |
| `MemberRole` | a membership leaves out `member` |
| `JoinRequestNotFound` | a membership is made for someone who isn't waiting to join |

The host's methods ask about eleven actions. A role holds one when its
permissions include the one below, or another that covers it:

| Action | Permission |
| --- | --- |
| `group.configure` | `include:org.atgrp.authManageAdmin` |
| `space.create`, `space.configure`, `space.delete` | `space:*?manage=create`, `space:*?manage=update`, `space:*?manage=delete` |
| `admit`, `role.assign`, `eject` | `space:org.atgrp.members?skey=self&collection=org.atgrp.membership&action=create`, with `action=update` or `action=delete` in its place |
| `invite` | `space:org.atgrp.inbox?authority=*&skey=self&collection=org.atgrp.invite&action=read_self&action=create&action=update&action=delete` |
| `mod.read` | `rpc:org.atgrp.mod.querySubjects?aud=*` |
| `mod.resolve` | `rpc:org.atgrp.mod.updateSubject?aud=*` |
| `label` | `space:*?collection=com.atproto.label.record` |

The group's permission sets give these, with what else each writes:

| Set | Actions | Also |
| --- | --- | --- |
| `org.atgrp.authManageBasic` | none | the about record and rules |
| `org.atgrp.authManageMembers` | `invite`, `admit`, `role.assign`, `eject` | `listJoinRequests`, `denyJoinRequest`, `listInvites` |
| `org.atgrp.authModerate` | `mod.read`, `mod.resolve`, `eject` | labels in `meta` and `members` only, so no `label` · the moderation queue and `getModSubjectBlob` |
| `org.atgrp.authManageAdmin` | all of the above, and `group.configure` | the config, labeler and roles · `manage=update` on `meta` and `members` |

A new group has two roles. `member` is everyone's. The founder's `admin`
holds `include:org.atgrp.authManageAdmin`,
`space:*?collection=com.atproto.label.record`, `space:*?manage=update`,
`space:*?manage=create&manage=delete`, `space:*?collection=*` and
`repo:*`, and may assign every role (`*`).

`org.atgrp.authParticipate` is for a person's own session at their PDS,
never a group's. It reads `meta`, writes the person's own confirmation
in `members`, makes their inbox, and calls the methods a person calls
about their own place in a group (`requestJoin`, `leaveGroup`,
`declineInvite`, `submitReport`, `submitAppeal` and the rest).

A group invites someone by writing an `org.atgrp.invite` record in
their inbox as the group. It takes the invite back by deleting it, with
the same writes ([membership](../design/membership.md#invites)). An
inbox, at `self`, takes `org.atgrp.invite` records alone, and one write
at a time (`InvalidRequest`). An invite's `message` is 2,000 graphemes
at most, and its `expiresAt` must be a time to come (`InvalidRequest`).

## People

| Method                              | What it does                                                                                                                                                                                                                   |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `GET org.atgrp.internal.getViewer`      | says who's asking, by the console's cookie or service auth. It also lists the other accounts the browser is signed in to (`accounts`), and where someone without an account makes one (`signUpAt`, `SIGNUP_PDS`)               |
| `GET org.atgrp.internal.getActor`       | gives a person's DID and handle to someone signed in, about themselves or anyone the host shows (a member of a group here, or someone asking to join one). Asked about themselves, it also says whether they may start a group |
| `GET org.atgrp.internal.getActorGroups` | lists the groups here a person is in, as far as the caller shares them                                                                                                                                                         |
| `GET org.atgrp.internal.searchActors`   | finds accounts whose handle matches what's typed, from the source `ACTOR_SEARCH` names. Anyone may ask                                                                                                                         |
| `GET /img/<did>/<cid>`              | serves a group's or a person's image to anyone who may see it. That's anyone for an image in a public repo, and otherwise only someone signed in to the console. One the group has taken down in a space, by its writer or a record holding it, it serves to nobody. A moderator reads it through `getModSubjectBlob` |

## Spaces

A group's spaces, and the records in them ([spaces](../design/spaces.md)).

| Method | What it does |
| --- | --- |
| `GET org.atgrp.internal.listSpaceRecords` | lists the records in a space from the host's index of it, for someone signed in who may read it, but none the group has taken down with a `!takedown` label, for a moderator as for anyone. It brings the index up to date first, waiting 5 seconds at most, then answers newest first, by when the index first saw that version of a record. It filters by `collection`, by `field` and `equals`, or to one `uri`. A page is 50 by default, 100 at most |
| `GET org.atgrp.internal.getSpaceBlob` | serves a file in a space, read from the repo of whoever wrote it, unless the group has taken down its writer or a record holding it. It reads only from a writer the space still lets write, up to 5 MiB, and checks the bytes against the CID. It's served with `nosniff`, a sandboxing CSP and a private cache of an hour |

The host is the spaces' authority and the PDS of the group's own repo in
each, so it answers the space alpha's methods:

| Method                                                                                                                                                                                                                                                    | What it does                                                                                                                                                                                                                                                                                                                                                                                                     |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST com.atproto.space.authorizeSpaceSync`                                                                                                                                                                                                               | gives a credential to read a space, bound to `credentialKey`, with the space's revision (`spaceRev`). It gives one to a user it lets in (`delegationToken`), or to anyone for a space open to all. With `notify`, it registers an endpoint, once the endpoint confirms, to hear of changes until the credential lapses. A refusal also withdraws any registration of the `notify` it names. The endpoint is https (http while the host is), its token 512 bytes at most, and its confirmation is read to 4 KiB within 10 seconds (`SpaceDeleted`, `RepoDeactivated`, `InvalidDelegationToken`, `RegistrationNotConfirmed`) |
| `POST com.atproto.space.notifyRepoUpdate`                                                                                                                                                                                                                 | hears about a member's write in a space, by service auth from the writer. A `repoRev` more than 5 minutes ahead fails `FutureRev` |
| `GET com.atproto.space.listWriters`                                                                                                                                                                                                                       | lists the space's writer set in the order of its revisions, each a `repoWrite` or a `repoRemoved`. A page holds up to 1000 (100 by default), and `cursor` is the last one's `spaceRev`                                                                                                                                                                                                                           |
| `POST com.atproto.space.notifyCredentialsRevoked`                                                                                                                                                                                                         | hears from a space's authority that credentials no longer hold, from that authority alone, for a repo here, 1 to 100 at a time |
| `GET com.atproto.space.getRecord`, `GET com.atproto.space.listRecords`, `GET com.atproto.space.getRepo`, `GET com.atproto.space.getLatestCommit`, `GET com.atproto.space.listRepoOps`, `GET com.atproto.space.getBlob`, `GET com.atproto.space.listBlobs` | serve the group's own repo in a space, for a credential that may read it. `getRecord`, `getRepo` (a STAR archive, `application/vnd.dasl.star`), `getLatestCommit` and `listRepoOps` (its `commit` on every page) need a MAC asked for in `Accept-Signature` (`InvalidSpaceMac`). A malformed cursor fails with `InvalidCursor`. A page of `listRecords` is 50 by default, of `listRepoOps` 100, and of `listBlobs` 500, each 1000 at most. Answers are `Cache-Control: private` and vary with `authorization` and `accept-signature`. A credential that doesn't hold up fails `MissingJwt`, `BadJwtSub`, `BadJwtIss`, `BadSpaceSignature`, `CredentialRevoked`, `BadSpaceAudience` or `InvalidCredential` |

The host sends `com.atproto.space.notifySpaceUpdate` to the endpoint of
a service registered for a space. It sends one for each change to the
writer set, for a lapsed registration, and when the space is deleted
([spaces](../design/spaces.md#hearing-of-writes)). A change goes to
50 registrations at a time, once. It tells a lapsed registration at the
next change after it lapsed, in that change's place. A lapse or
deletion notice is retried after 1 minute, 10 minutes, an hour and 6
hours, then every 12 hours, for three days. A syncer that refuses its
lapse notice, or never gets it, is unregistered.

When the group writes in a space whose authority is elsewhere, the host
tells that authority with `notifyRepoUpdate`. It keeps only the newest
notice owed for each repo and space, and retries it with waits doubling
from 10 seconds up to an hour, for a day. An answer of 4xx, other than
408, 425 or 429, drops it.

To keep its index, the host reads a writer's repo in a group space with
`listRepoOps`, 500 a page, or whole with `getRepo`, up to 64 MiB.

## Signing apps in as a group

The host is each group's OAuth server ([signing in](../design/signing-in.md)):

| Route                                                                                      | What it does                                                                       |
| ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
| `GET /.well-known/oauth-authorization-server`, `GET /.well-known/oauth-protected-resource` | its metadata                                                                       |
| `POST /oauth/par`, `GET /oauth/authorize`, `POST /oauth/token`, `POST /oauth/revoke`       | atproto OAuth's endpoints. `par` takes only scopes the client's metadata declares, `atproto` among them, and all it declares when `scope` is left out. `authorize` sends the browser to the console to approve, and answers a plain 400 page for a request that's unknown, lapsed or another client's. `token` answers the approving member's DID as `member` beside the group's as `sub`. A refresh token works once, and using it again fails `invalid_grant` while the grant goes on. `revoke` ends the grant of either token, and what it bought of the group's spaces, and answers the same whether it found one or not |
| `GET /img/app?id=<client_id>` | serves an app's logo, the `logo_uri` of its client metadata, so a reader's browser never asks the app's server. It serves one only on the client id's own origin, over https, and only a PNG, JPEG, GIF or WebP image of at most 256 KiB, by its bytes, never SVG. It keeps each for 10 minutes, 100 apps' at most, and answers 404 for anything else |

The host takes a client by its metadata:

- A native app on the same machine may use the loopback client id
  `http://localhost`. An http redirect to `127.0.0.1` or `[::1]` may be
  registered without its port, and then matches whatever port the app
  listens on.
- A native app is a public client (`token_endpoint_auth_method: none`).
- A confidential client signs its client assertion with a key from its
  metadata's `jwks` or its `jwks_uri`. A key not among the kept set has
  the set fetched once more.
- A client keeps authenticating the same way, with the same key, for
  the grant's life.
- A DPoP proof is ES256 or ES256K and carries the host's nonce
  (`use_dpop_nonce` otherwise). A proof to a resource carries `ath`, the
  hash of its access token, and one to the OAuth endpoints carries
  none. A proof is good once.

| Method                                     | What it does                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST org.atgrp.internal.provisionGroup`       | lets an app that `PROVISIONING_CLIENTS` names start a group for a person, and signs the app in to it. It takes `metaPublicRead` as `createGroup` does. The app sends its `clientId`, a client assertion if it's confidential, a DPoP proof and a `scope`, which must hold `atproto` and only scopes its metadata declares (`UntrustedApp`, `InvalidScope`). It answers `did`, `meta`, `members` and `session`, a token response narrowed to the founder's roles. The session is an ordinary grant: it refreshes at `/oauth/token`, lasts as an OAuth grant does, and shows in `listGroupTokens`. An OAuth failure comes back named by its OAuth code (`invalid_client`, `invalid_dpop_proof`, `use_dpop_nonce`, …) |
| `POST org.atgrp.internal.getGroupAuth`         | gives a member with a DPoP proof a 15-minute token to act as the group. In one of the group's spaces, it's scoped to what their roles may write there as the group, and to the `manage=` operations they may use on it. For a space not made yet, that's `manage=create`, if their roles hold `space.create`. In someone's inbox, it lets a member who may invite write invites there. It answers `Forbidden` if that's nothing. It answers `did`, `accessJwt` (an opaque token, not a JWT), `pds`, `collections`, `repoCollections`, `scope` and `expiresAt`. The token is never refreshed |
| `GET org.atgrp.internal.getAuthorization`      | shows an app's request to sign in as a group, as the caller would approve it. It names the app by its client metadata, giving its home page and logo only where `/img/app` would show them. It offers the switched-on group a `login_hint` names, if it's here, or else every switched-on group where the caller holds a role, each with what the app would get and what it wouldn't (`granted`, `withheld`), and the group's display name and avatar where the caller reads its `meta` |
| `POST org.atgrp.internal.approveAuthorization` | approves the request with what the caller's roles allow, for a switched-on group here where the caller holds a role, and the one the app named, if it named one (`Forbidden`). It answers the redirect, with a code good for 60 seconds. A request no longer waiting fails `ExpiredRequest` |
| `POST org.atgrp.internal.declineAuthorization` | declines the request, redirecting the app with `access_denied` |
| `GET org.atgrp.internal.listGroupTokens`       | lists the grants in force, for a member with `group.configure`, and the latest 20 entries of the group's [activity log](#the-activity-log), each with the handle of whoever let it in or acted. Each app comes as its client metadata names it, where that can be read (`client`: name, home page, logo). A write also comes in its parts (`write`: operation, collection, key, space), with what its kind of record is when that's another app's lexicon the host can read (`write.description`), and with whom it's about (`subject`). Making, changing or ending a space comes as `space`: the space, the operation, and `publicRead` when the change opened it to anyone (`true`) or closed it to those its policy names (`false`) |
| `POST org.atgrp.internal.revokeGroupToken`     | signs one app out, for a member with `group.configure` (`NotFound` for another group's grant or an unknown one) |
| `POST org.atgrp.internal.createAppPassword`    | makes an app password for the group, for an app that signs in with one ([app passwords](#app-passwords)) |
| `GET org.atgrp.internal.listAppPasswords`      | lists the group's app passwords, each with its owner's handle and when it was last used. A member with `group.configure` sees every one. Anyone else sees their own, if their roles hold `repo:*` (`Forbidden` otherwise). It never shows the passwords |
| `POST org.atgrp.internal.revokeAppPassword`    | revokes one, and signs out its apps, for its maker or a member with `group.configure` (`NotFound`) |

An app signed in this way, or with an app password, uses these as the
group:

| Method                                                                                                                                                                                 | What it does                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET com.atproto.server.getSession`                                                                                                                                                    | describes the group a token acts as: its DID, its handle, and whether it's switched on                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `POST com.atproto.server.createSession`, `POST com.atproto.server.refreshSession`, `POST com.atproto.server.deleteSession`                                                             | handle an app password's sessions ([app passwords](#app-passwords)). `createSession` answers as a PDS does, with `emailConfirmed: false`, `active`, `status` and `didDoc` |
| `POST com.atproto.repo.createRecord`, `POST com.atproto.repo.putRecord`, `POST com.atproto.repo.deleteRecord`, `POST com.atproto.repo.applyWrites`, `POST com.atproto.repo.uploadBlob` | write to the group's public repo. `applyWrites` takes 200 writes at most. `putRecord` and `deleteRecord` honour `swapRecord` and `swapCommit`, and `createRecord` and `applyWrites` honour `swapCommit`. `uploadBlob` needs the group switched on, a member whose roles still let them write something as the group, and a scope that takes the file's type (`ScopeMissing`). A file no record takes within a day is swept |
| `POST com.atproto.space.createRecord`, `POST com.atproto.space.putRecord`, `POST com.atproto.space.deleteRecord`, `POST com.atproto.space.applyWrites`                                 | write to the group's repo in a space. That's one of its own spaces, or someone's inbox, where it writes and deletes its invites to them (`InviteNotFound`, and `InvalidRequest` for an invite to a member). A label (`com.atproto.label.record`) is written and deleted in any of the group's spaces, beside its subject. A label on a member's record in their public repo goes in the members space ([moderation](../design/moderation.md#labels-beside-what-they-mark))                                                                                                                                                                                     |
| `POST com.atproto.space.createSpace`                                                                                                                                                   | makes a space of `spaceType` (and `skey`, or a new one) under `policy`, an `org.atgrp.policy`. It publishes the policy and lists the space in the index unless the policy sets `unlisted`, and answers the `space`. It needs `manage=create` in the scope (`ScopeMissing`) and a role holding `space.create` (`NotAuthorized`). It refuses another policy type (`UnsupportedPolicy`), the meta and members types, a grant of a role the group lacks, two grants of one role, and a grant whose `permissions` include one that's no space permission (`InvalidRequest`). A space already at that address fails `SpaceAlreadyExists` ([spaces](../design/spaces.md#making-changing-and-ending-a-space)) |
| `POST com.atproto.space.updateSpace`                                                                                                                                                   | puts the group's `space` under a new `policy`, published, and listed or unlisted as it says. It needs `manage=update` in the scope (`ScopeMissing`), and a role holding `space.configure` or a `manage=update` permission in the space's own policy (`NotAuthorized`). It refuses changing the grant of a role the caller may not assign, adding a permission their roles don't hold, and granting `read` or `write`, or turning on `publicRead`, where they don't have it (`NotAuthorized`). On the members space, it refuses a policy that takes `read` or `write` from `member` or turns on `publicRead` (`MembersSpaceFixed`). It refuses a policy as `createSpace` does, and a space the group doesn't have (`SpaceNotFound`) |
| `POST com.atproto.space.deleteSpace`                                                                                                                                                   | ends the group's `space`: out of the index, its syncers told, and the group's repo in it gone. It needs `manage=delete` in the scope (`ScopeMissing`), and a role holding `space.delete` or a `manage=delete` permission in the space's policy (`NotAuthorized`). The meta and members spaces are never deleted (`NotAuthorized`), and a space the group doesn't have fails `SpaceNotFound`                                                                                                                                                                                                                    |
| `GET com.atproto.space.getSpace`                                                                                                                                                       | answers the group's `space` and its `policy`, for a scope that reads it (`ScopeMissing`) and a member who reads it or may change it (`NotAuthorized`, `SpaceNotFound`)                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `GET com.atproto.space.getDelegationToken` | answers a delegation `token` the group signs for its `space`, which buys a credential from `authorizeSpaceSync` to read the space as any reader does: the group's repo there, here, and its members' repos at their PDSes. It's for a scope that reads the space (`ScopeMissing`) and a member who reads it themselves at that moment (`NotAuthorized`), in one of the group's own spaces (`SpaceNotFound`) |
| `GET com.atproto.server.getServiceAuth` | answers a `token`, service auth the group signs with its key, for `aud` (a DID, or `did#service`), `lxm` if given, lapsing at `exp` (a minute from now unless asked; within an hour for one method, a minute for any: `BadExpiration`). A token's scope must hold calling `lxm` (or any method) at `aud` (`ScopeMissingError`), and its member still hold `repo:*` (`Forbidden`). An app password's session gets one for anything but chat and `createAccount`, unless it may use chat. Never for a method managing an account directly (`InvalidRequest`) |
| any other method, with `atproto-proxy: <did>#<service>` | sent on to that service, signed as the group (`aud` the service's DID, `lxm` the method, a minute), and its answer streamed back, as an account's PDS does. Refused as `getServiceAuth` refuses, and with `InvalidToken` for a method managing an account directly or, for an app password that may not, chat. It's `InvalidRequest` for a header that doesn't parse, a service its document doesn't name, or this host itself, and `UpstreamFailure` for a service that isn't at a public address or doesn't answer. [Proxying](#proxying) has what it sends and passes back |

A group's about record and config, in `meta`, and its rules and roles,
in `members`, change only this way. An app writes the records as the
group, and the host checks each one beyond its lexicon:

- `meta` takes only `org.atgrp.about`, `org.atgrp.config` and labels,
  and `members` only `org.atgrp.rule`, `org.atgrp.labeler`,
  `org.atgrp.role`, `org.atgrp.membership` and labels. Any other
  collection there is `Forbidden`.
- The about record, config and labeler are kept at `self` and never
  deleted (`InvalidRequest`).
- The about record's `displayName` is more than spaces, and its
  `website` an http or https address. Its `avatar` must be one of the
  group's own uploads, a PNG, JPEG or WebP image, with the `mimeType`
  and `size` the host kept at upload.
- The config names a join policy the host knows.
- A rule is kept at a TID, so a label citing it keeps its URI, and has a
  `title` that's more than spaces.

Rules are shown by `order`, lowest first, then by when they were
written. A file is removed once no record in the group's repos
references it.

### Proxying

A call sent on with `atproto-proxy` carries `accept-encoding` (`identity`
if there's none), `accept-language`, `atproto-accept-labelers`,
`x-bsky-topics` and every `x-atproto-*` header. A POST also carries its
body, up to `BLOB_UPLOAD_LIMIT`, with its `content-type` and
`content-encoding`. The host asks only a public address, over https
unless `PUBLIC_URL` is http, and waits 60 seconds.

The answer passes back `atproto-repo-rev`, `atproto-content-labelers`
and `retry-after`, and a success streams back with its content's
headers. A failure comes back as `{error, message}` with the service's
own names, or the name atproto gives its status if it gave none. A
service's 500 comes back as a 502, still with the service's name
(`InternalServerError` if it gave none). So `UpstreamFailure` means
the host couldn't reach the service, or the service answered 502 with
no name of its own. It logs
each call's method, service and status, never its token or body.

### App passwords

An app password is for an app that signs in with a handle and password
through `createSession`. A member whose roles hold `repo:*` makes one
with `createAppPassword`, and it stays theirs. It's shown once, as
`xxxx-xxxx-xxxx-xxxx`.

| Limit | What it is |
| --- | --- |
| name | 1 to 64 characters (`InvalidName`), unique in the group (`DuplicateName`) |
| how many | 25 in a group at most (`TooManyAppPasswords`) |
| scope | `atproto transition:generic`: the group's public repo and files, and calls to other services, never a space. `privileged: true` adds `transition:chat.bsky` |
| tokens | Bearer JWTs, not bound to a DPoP key. An access token lasts 2 hours, and a session 90 days unless refreshed. A refresh rotates both, and `deleteSession` takes the refresh token |
| an expired access token | 400 `ExpiredToken`, an app's cue to refresh. Any other bad token is 401 `InvalidToken` |
| its maker | must still hold `repo:*` at each sign-in, use and refresh. Once they don't, every app password of theirs in the group goes, with its sessions, for good |

Each session is a grant, with source `appPassword` and client
`app-password:<name>`. Sign-ins are [limited](../design/limits.md) per
handle and address.

### The activity log

Each grant records its member, its client, its source (`oauth`,
`getGroupAuth`, `appPassword` or `provisionGroup`), its scope, when it
was made and when it was last used. The host marks a grant used at most
once a minute.

The group's activity log records, with the member, the client and the
time:

- a sign-in with OAuth, `provisionGroup` or an app password
- a group token taken (`took a token for <space>`)
- each write made with a token, invites, labels and MCP's writes among
  them
- a space made, changed, opened, closed or ended
- an app password made or revoked
- a grant ended with `revokeGroupToken`
- an account moved here as a group, and the group moved away
- a recovery key added or removed

It doesn't record refreshes, or grants that end at `/oauth/revoke`, at
`deleteSession` or when their member is put out. The host keeps the
log until the group is deleted, and `listGroupTokens` answers its
latest 20 entries.

### Lifetimes

| What | How long |
| --- | --- |
| a pushed request (`/oauth/par`) | 5 minutes |
| an authorization code | 60 seconds, and good once |
| an OAuth access token | 1 hour |
| an OAuth grant | 14 days for a public client and 90 days for a confidential one, unless refreshed. Each refresh starts it again |
| a group token (`getGroupAuth`) | 15 minutes, never refreshed |
| an app password's access token, and its session | 2 hours, and 90 days unless refreshed |
| a console sign-in under way | 15 minutes |
| the console's cookie | 30 days |
| an account's session while it moves here | 24 hours at most |
| a DPoP proof | 60 seconds old at most, with 10 seconds' skew. The nonce changes every 3 minutes, and the one either side is taken too |
| a client assertion | its `iat` within 300 seconds |
| a client's metadata, its key set, another app's permission set, an app's logo | kept 10 minutes. Metadata is read to 64 KiB, and kept for 1000 clients at most |
| a proxied call | 60 seconds, and its service auth a minute |
| `getServiceAuth`'s token | a minute unless asked. An hour at most for one method, and a minute for any |
| an MCP client's request, access token and refresh token | 10 minutes, 1 hour, and 30 days unused |
| an MCP client registered and never used | 24 hours |
| `migratePrepare`'s export token | 1 hour |

## MCP

An MCP client (an AI app) connects to a group over MCP ([MCP](../design/mcp.md)).
Its tools are in [MCP tools](mcp.md).

| Route                                                                                              | What it does                                                                               |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| `POST /mcp`                                                                                        | the MCP server, which answers each JSON-RPC message as the member who connected the client |
| `GET /.well-known/oauth-protected-resource/mcp`, `GET /.well-known/oauth-authorization-server/mcp` | its metadata                                                                               |
| `POST /mcp/register`, `GET /mcp/authorize`, `POST /mcp/token`                                      | its own OAuth server                                                                       |

| Method                                   | What it does                                          |
| ---------------------------------------- | ----------------------------------------------------- |
| `GET org.atgrp.internal.listConnectedApps`   | lists the MCP clients the caller connected to a group |
| `POST org.atgrp.internal.revokeConnectedApp` | disconnects one                                       |

## Moderation

| Method | What it does |
| --- | --- |
| `POST org.atgrp.mod.submitReport` | reports a member, a record in one of the group's spaces here, or a member's record in their public repo: `subject` is an account's DID or a record's URI, with an optional `cid`. The reporter must be able to read its space (the members space for a member or their public record), and the group's labeler must take reports of its kind and reason. `reasonType` is one of the `org.atgrp.mod.defs#reason*` tokens (`reasonSpam`, `reasonViolation`, `reasonMisleading`, `reasonNsfw`, `reasonRude`, `reasonOther`), and a `rule` it cites is a rule in the members space. A reason the labeler doesn't take is `InvalidRequest`. The host doesn't check that a reported record exists or that its `cid` matches. It answers the report's `eventId` and `createdAt` (`GroupNotFound`, `InvalidSubject`) |
| `POST org.atgrp.mod.submitAppeal` | appeals a label or an ejection on the caller's own account or record, with an optional `note`, and reopens the subject. It takes an appeal from someone who has left the group too. It answers the appeal's `eventId` and `createdAt` (`GroupNotFound`, `InvalidSubject` for a subject that isn't the caller's, `NotAppealable` for one with no live label or ejection) |
| `GET org.atgrp.mod.querySelfHistory` | lists what the group did to the caller's account and records, or to one `subject` of theirs, newest first unless `sort` is `oldest`. It leaves out reports, tags, notes and who acted, and works for former members (`GroupNotFound`, `InvalidSubject`, `InvalidCursor`) |
| `GET org.atgrp.mod.querySubjects` | lists the moderation queue: every status unless `status` is `open` or `resolved`, and only subjects with any of `tags` when given. `sort` is `oldest` (the default) or `newest` by when the subject entered the queue, or `updated`, the latest changed first (`InvalidCursor`). Each subject comes with its account as `actor` and its `reportCount` |
| `GET org.atgrp.mod.querySubjectHistory` | lists a subject's events (`reportEvent`, `appealEvent`, `statusEvent`, `tagEvent`, `labelEvent`, `ejectEvent`), newest first unless `sort` is `oldest`, a page at a time. Each event names the version it's about (`cid`), and who acted as `createdBy` (a DID) and `creator`. With a `cid`, it lists those about that version. For a record in one of the group's spaces that the caller may read, it also answers the `record` as the host's index holds it, with `takenDown` true if the group has taken that version down (`InvalidSubject`, `InvalidCursor`) |
| `GET org.atgrp.internal.getModSubjectBlob` | serves a file the record `subject` holds, by its `cid`, to someone with `mod.read` whom the record's space lets read it, even if the group has taken the record down. A file the record doesn't hold, or a record the caller can't read there, fails with `NotFound` |
| `POST org.atgrp.mod.updateSubject` | changes a subject in the queue: its `status` (`open` or `resolved`), a `note`, and its tags (`addTags`, `removeTags`, lowercase letters and `-`, 128 characters at most, 25 at most each). What it leaves out stays as it is. It answers the subject (`InvalidSubject`, `SubjectNotFound`) |
| `POST org.atgrp.internal.putLabelDefinition` | defines or changes one of the group's own labels (lowercase letters and hyphens) in its labeler, for someone with `group.configure`. Its name (64 graphemes at most) and description (2,000) are in `lang` (`en` unless given), and replace only those in that language. The label is 100 characters at most. Unless asked, `severity` is `inform`, `blurs` is `none` and `defaultSetting` is `warn`, and `adultOnly` is set only when true. It answers the definition, and `getGroup` answers them as `labels` |
| `POST org.atgrp.internal.deleteLabelDefinition` | stops defining one. Labels already applied stay |

A report's `reason`, and an appeal's or update's `note`, is 2,000
characters at most (20,000 bytes). Reports and appeals share a limit of
10 in 5 minutes and 100 a day for each caller
([limits](../design/limits.md)). The queue's lists answer 50 a page by
default and 100 at most, and an unknown `sort` is `InvalidRequest`.

The group's labeler decides what reports it takes. Its `reasonTypes`
lists the reasons, its `subjectTypes` `account` or `record`, and its
`subjectCollections` the collections of records. A field left out takes
anything. A member's record in their public repo counts as a `record` of
its collection.

A label is a `com.atproto.label.record` with `uri`, `val` (128 bytes at
most) and `cts`, and an optional `cid` and `exp`. The host checks only
the shape of its `uri`. It doesn't check that the subject exists, or
that its `cid` matches.

`mod.querySubjects`, `mod.querySubjectHistory` and `mod.updateSubject`,
like `listJoinRequests` and `denyJoinRequest`, answer a member by service
auth or the console's cookie, who names the group as `group`
(`InvalidRequest` without it). They also answer an app signed in as the
group (a DPoP token) whose scope names the method (`rpc:`, or a set
listing it), as its member, while their roles hold the method's action
([signing in](../design/signing-in.md#narrowing-at-approval)). That app
leaves `group` out, since its session names it, and one naming another
group gets `Forbidden`.

## Operating the host

These are for its operators, the accounts `HOST_ADMINS` names
([config](config.md)), by service auth or the console's cookie. The host
refuses anyone else with `Forbidden`.

| Method                        | What it does                                                                                                                                                                                                                                                                                                                                                |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET org.atgrp.internal.getLogs`  | returns the lines the host logged, oldest first, each as it wrote it. It returns one request's lines by its `trace`, or the last lines of a `message`, at a `level` and above, or that took `minMs` or longer. It returns 100 unless `limit` asks for up to 500, and 500 for a trace. The read itself is logged as `logs read`, with who asked and for what |
| `GET org.atgrp.internal.getStats` | shows how the host was used over the last `days` (7 by default, 400 at most), day by day in UTC, and what it holds. It counts requests by route and by status class, slow ones, MCP tools called by name, and groups and spaces made. Nothing in it names who asked                                                                                         |

The host logs every request as a `request` line, with its method, route,
path (never its query), status and `duration_ms`. When it refuses or
fails a request, the line also has the `error` and `error_message` it
answered. Each response carries `x-trace-id`, the trace that every line
logged while answering it carries. The trace is the host's own, or the
one a W3C `traceparent` header names. Since the caller names that one, a
trace read may hold the lines of another request that named it too. A
method other than HTTP's own seven is counted as `OTHER`.

When the host calls another server others' data names (resolving an
identity, checking a token, signing someone in, reading a client's
metadata, sending a call on, telling a PDS or a syncer), it logs each
attempt of each call it makes as a `call` line, with the server's `host`,
the `path`, the `status` or `error`, `resend` (0 for the first attempt,
then 1 for a retry after a broken connection or a fresh DPoP nonce) and
`duration_ms`. A call made while answering a request is logged in that
request's trace and sends a `traceparent` header naming it. A refusal an
XRPC call gets back is logged as `refused`, with the server's `origin`,
the `status` and the `error`.

## Recovery

| Method                                  | What it does                                                                                     |
| --------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `GET org.atgrp.internal.listRecoveryKeys`   | lists the rotation keys on the group's `did:plc` that matter ([recovery](../design/recovery.md)) |
| `POST org.atgrp.internal.addRecoveryKey`    | adds a steward's key, ahead of the host's                                                        |
| `POST org.atgrp.internal.removeRecoveryKey` | takes one off                                                                                    |

## Moving

Moving groups between hosts, and accounts here to become groups ([moving](../design/moving.md)).

| Method                                   | What it does                                                       |
| ---------------------------------------- | ------------------------------------------------------------------ |
| `POST org.atgrp.internal.migratePrepare`     | on the host a group leaves, starts the move, while the directory's last operation for the group lists this host's rotation key (`NotController`). It answers service auth the group signs for `destDid` to call `migrateReceive`, good for an hour, the group's handle, address and spaces, and an export token good for an hour. Preparing again replaces the token |
| `GET org.atgrp.internal.migrateExport`       | on that host, serves what the destination pulls of the group: the list of its files, one file, and a space's state and repo (`InvalidToken`, `BlobNotFound`) |
| `POST org.atgrp.internal.migrateReceive`     | on the destination, takes the group in, switched off, for a founder here (`NotAllowed`), who must hold `group.configure` in the records it brings (`Forbidden`). It pulls from the PDS the group's DID document names, reading a file to `BLOB_UPLOAD_LIMIT`, a repo or space to 256 MiB, and any other answer to 16 MiB. The group's handle here is its old address's first label under `HANDLE_DOMAIN`. A handle on its own domain comes along only while that domain still names the group. It answers what it took and `recommendedCreds`. It refuses a group already here (`AlreadyHere`), service auth that isn't the group's (`BadServiceJwt`), an address or handle that's taken (`HandleNotAvailable`), and a source that answers with a failure (`SourceUnreadable`) |
| `POST org.atgrp.internal.migrateComplete`    | on the host it leaves, points its DID at the destination, then switches the group off there and answers `movedTo`. It refuses an ended DID, or one that no longer lists this host's key (`NotController`), and says the directory's words when it refuses the operation (`InvalidOperation`) |
| `POST org.atgrp.internal.migrateActivate`    | on the destination, switches it on and answers how many `spaces` it has. Until the DID document names this host and the signing key made here, it fails `NotYet`, so ask again once the directory catches up. A DID document it can't read is `SourceUnreadable` |
| `GET org.atgrp.internal.checkImport`         | shows what moving an account here would make of it: its `handle`, `address`, `label`, whether it `keeps` its handle, its `pds`, and a `refused` reason. The account keeps its handle only if it isn't `handle.invalid`, isn't under `HANDLE_DOMAIN` or a domain its old server gives out (`availableUserDomains`), and still names the account. To whoever is moving the account, it answers `recommendedCreds` too (`NotPlc`) |
| `POST org.atgrp.internal.importAccount`      | starts moving an account here, for a founder (`NotAllowed`), never their own account (`SameAccount`), and only a `did:plc` (`NotPlc`). Its address is the label asked for, or else its handle's first label, either made lowercase, each run of other characters a dash, and cut to 63 characters (`InvalidHandle`, `HandleNotAvailable`). The group's about record takes its name and description from the account's `app.bsky.actor.profile`, with the label as the name if it has none. It refuses an account someone else is moving (`AlreadyHere`) |
| `POST org.atgrp.internal.importAccountSpace` | brings over one of its spaces while the move waits, a part at a time: `meta`, then each `blob`, then `repo`. An archive is 100 MiB at most, and a file `BLOB_UPLOAD_LIMIT` (`TooLarge`). It refuses the group's own meta and members spaces (`SpaceReserved`), a space it doesn't own (`NotSpaceOwner`), a bad archive (`InvalidArchive`), and a repo before its space's meta (`NotFound`) |
| `POST org.atgrp.internal.completeImport`     | finishes the move with the operation the account's server signed. It must name this host as PDS, the keys made here, this host's rotation key and the handle here (`InvalidOperation`) |
| `GET org.atgrp.internal.getAccountMove`      | shows the account the caller signed in to from the console to move |
| `POST org.atgrp.internal.startAccountMove`   | starts that move. An account server whose `describeServer` can't be read stops it |
| `POST org.atgrp.internal.finishAccountMove`  | finishes it with the code the account's server emailed (`NotStarted`) |
| `POST org.atgrp.internal.cancelAccountMove`  | stops it                                                           |

`migratePrepare`, `migrateComplete` and `migrateActivate` need
`group.configure` in the group (`Forbidden`).

## The console

| Route                                                                 | What it does                                                                                                                                                                                                     |
| --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET /console/login`, `GET /console/callback`, `POST /console/logout` | sign in to the console as yourself (`?handle=`), sign up at `SIGNUP_PDS` (`?create`), and sign out. Signing in again keeps the earlier account beside the new one, up to 4 others, and signing out switches to the one used last. The session's cookie lasts 30 days, and signing out ends every cookie signed before it for that account, in any browser. A sign-in comes back only to the browser that started it |
| `POST /console/switch`                                                | switches to another account the browser is signed in to (`did`), and goes back to the page `back`, a path on the console (`/` otherwise). It and `logout` answer 403 to a page at another `Origin` |
| `GET /console/move/login`, `GET /console/move/callback`               | signs in to an account to move here                                                                                                                                                                              |
| `GET /console/client-metadata.json`                                   | the host's metadata as the console's OAuth client, a confidential web client's as atproto's profile has one; 500 where `CONSOLE_URL` cannot be one (not https at a public name)                                  |
| `GET org.atgrp.internal.getBrand`                                     | how the host shows itself, as its operator names it ([config](config.md#how-it-shows-itself)): its `name`, its `logo`, `links` to its operator's home page, privacy policy, terms of service and support, the `backgrounds` of the page an app's request is approved on, light and dark, its `colors`, and the console's palette it's in (`palette`), each only when set. Anyone may ask |
| `GET /img/host`, `GET /img/background-light`, `GET /img/background-dark` | serve the host's logo (`LOGO_URL`) and backgrounds (`BACKGROUND_LIGHT_URL`, `BACKGROUND_DARK_URL`), as `/img/app` serves an app's logo: from a public address, only a PNG, JPEG, GIF or WebP image, of at most 256 KiB for the logo and 2 MiB for a background, kept for 10 minutes. Each answers 404 when the host has none, or when what it names is no such image |

## The PDS

The host is the PDS of every group it hosts, and answers for their public
repos as any PDS does:

| Method                                                                                                                                                                     | What it does                                                                                                                                                               |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GET com.atproto.server.describeServer`                                                                                                                                    | describes the host as a PDS: its DID, the domain it names its groups under, `BLOB_UPLOAD_LIMIT`, that no one signs up, and its privacy policy, terms of service (`links`) and email address (`contact`) where its operator sets them |
| `GET com.atproto.repo.describeRepo`, `GET com.atproto.repo.getRecord`, `GET com.atproto.repo.listRecords`                                                                  | serve a group's public repo                                                                                                                                                |
| `GET com.atproto.sync.getRepo`, `GET com.atproto.sync.getRecord`, `GET com.atproto.sync.getLatestCommit`, `GET com.atproto.sync.listRepos`, `GET com.atproto.sync.getBlob`, `GET com.atproto.sync.listBlobs` | sync the repos. `getRecord` answers a CAR rooted at the repo's signed commit, with the tree's nodes proving the record, and the record when it is there; a record not there is proved absent the same way. A blob only a space holds isn't served or listed. `listRepos` and `listBlobs` answer pages of up to 1000 (500 by default), as atproto's lexicons have them |
| `GET com.atproto.sync.subscribeRepos`                                                                                                                                      | the firehose, over a WebSocket                                                                                                                                             |
| `GET com.atproto.identity.resolveHandle`                                                                                                                                   | resolves a handle here to its DID. For a caller who's signed in, it resolves any handle through `HANDLE_RESOLVERS`                                                         |
| `GET /.well-known/did.json`                                                                                                                                                | the host's own DID document when `SERVICE_DID` is a `did:web`, with its `#atproto_pds` and `#atgrp` services at `PUBLIC_URL`                                          |
| `GET /.well-known/atproto-did`                                                                                                                                             | the DID of the group whose address the request's host names                                                                                                                |
| `GET /xrpc/_health`                                                                                                                                                        | says the host is up, with its `version` and the `commit` its image was built from (`null` in a build of a checkout)                                                        |

A switched-off group's public repo answers `RepoDeactivated`, and
`listRepos` shows it as `active: false`.

## From a browser

The OAuth routes, the `/mcp` routes, and the methods an app calls with a
token (the writes, the sessions, `provisionGroup`, `getGroupAuth`) answer
any origin. So do the methods a space is read by. Those are its
authority's `authorizeSpaceSync` and `listWriters`, and the reads of a
repo in it (`getRepo`, `listRepoOps` and the rest), which an app's page
makes. The rest are for the console,
at its own origin.