# Groups A group is an atproto account that no one person owns. Yet someone has to start it, name it, say who may see what of it, and one day end it, and no one can do that by signing in with its password, since it has none. So the host keeps everything a group is in records the group writes in its own spaces, and its members act through the roles they hold there ([membership](membership.md)). ## What starting a group makes Each group is an account here with its own `did:plc`, a public repo, and the host as its PDS. The host makes the group's keys and signs the PLC genesis operation with its own rotation key, at first the only one on the DID ([DIDs and PLC](https://atproto.com/specs/did)). An account counts as a group only while its `members` space exists here, and anything else is `GroupNotFound`. A space is a set of records with a policy saying who reads and writes it ([spaces](https://atproto.com/guides/spaces)). The group is the authority for two, which come and go with it and can't be made again or deleted. Neither is in the index of the group's other spaces ([spaces](spaces.md#a-groups-spaces)). - `meta` holds `org.atgrp.about` (name, description, website, avatar) and `org.atgrp.config` (the join policy). It grants `member` and `admin` `read`, and anyone (`publicRead`) unless the group starts with `metaPublicRead: false`. - `members` holds roles, memberships keyed by DID, rules, the labeler, and the index. It grants `member` `read` and `write`, so a member's own confirmation there syncs, and the host refuses any policy that takes that away or opens it to anyone (`MembersSpaceFixed`). Starting writes `about` and `config` (`approval` unless another join policy is given), the roles `admin` and `member` ([membership](membership.md#roles-and-what-they-grant)), and the labeler ([moderation](moderation.md#labels-beside-what-they-mark)). Then the founder and each steward named get a membership with both roles, so the group starts with admins. If setup fails after the account is made, the host deletes it and tombstones the DID, so the handle is free again. Outside its records, the host keeps what a record can't hold: the account and its keys, the address and own-domain setting, join requests, invites, tokens, recovery keys and moderation state. ## Who may start one `createGroup` starts a group with the caller as founder and first admin. The caller signs in with service auth from their own PDS ([service auth](https://atproto.com/specs/xrpc)) or with the console's session cookie. `GROUP_FOUNDERS` lists who the host starts groups for (anyone when empty), and anyone else gets `NotAllowed`. An app named in `PROVISIONING_CLIENTS` may also start one for a person signed in to it, with `provisionGroup`, and gets an OAuth session on the new group narrowed to the founder's roles ([signing in](signing-in.md#apps-that-start-groups)). An account brought here from elsewhere becomes a group too ([moving](moving.md#bringing-an-account-here-as-a-group)). ## What each person sees, and finding a group `getGroup` answers by who's asking. Someone not signed in gets the DID and handle, even when `meta` is public. A reader of `meta` gets the profile and join policy, and a reader of `members` gets the rules, roles, member count and spaces. Spaces are listed `meta`, `members`, then the index in its order, then the rest, and one marked `unlisted` shows only to a caller who may read it. The host keeps no list of its groups to browse. A group that wants to be found writes an empty `org.atgrp.declaration` at `self` in its public repo. The host writes it when `meta` starts public, and writes or removes it whenever `meta`'s `publicRead` changes, and refuses a write of it while `meta` is private. `getActorGroups` lists the switched-on groups a person holds a role in that you're in too, so a person's other memberships stay private, and asking about yourself never shows a switched-off group. ## How relays hear of a group Apps learn of a group from relays reading the host's firehose, as for any account ([sync](https://atproto.com/specs/sync)). Making a group puts out `#identity`, `#account` and its first commits there, the declaration among them when `meta` is public. But a relay that stopped reading a host it couldn't reach reads it again only when asked. So the host asks each relay in `PDS_CRAWLERS` to crawl (`com.atproto.sync.requestCrawl`) as it starts, before anything is written, and every 20 minutes after, whether or not it wrote anything. The host never prunes its firehose, so a relay that reconnects with a cursor gets everything it missed. One that connects without a cursor starts at the present. A group whose first events no relay saw reaches relays with its next one, and an app that wants its earlier records reads the repo (`com.atproto.sync.getRepo`). ## Its address A group's first handle is one label under `HANDLE_DOMAIN` (`.test` by default), such as `book-club.test`. The host keeps it as the group's address, which never changes while the group is here and stays reserved after the group takes another handle. `checkAddress` says whether an address is free. At its address the host serves `/.well-known/` and `/xrpc/`, `/` redirects to the group's page in the console while the group is switched on, and anything else is a 404. ## A handle on its own domain A group may take a handle on a domain that resolves to its DID. The host resolves it through the domain's well-known file or the services in `HANDLE_RESOLVERS`, with a client that reaches only public addresses and follows no redirect. Under `HANDLE_DOMAIN`, a group may take only its own address. `updateGroupHandle` works in an order that keeps the old handle if a step fails. It checks the domain names the group (`NotPointing`), and that the host's key still controls the DID (`NotController`). It holds the handle in the database, publishes the PLC operation, puts the old handle back if PLC refuses, then emits `#identity`. The host makes a group's PLC changes one at a time. The handle goes with the group if it moves to another host, and the address stays behind ([moving](moving.md)). ## Its own domain A handle proves the group controls the domain, but not that the domain's web traffic reaches this host. So serving the group there is a separate switch, `putGroupDomain`. It checks the domain answers `describeServer` with this host's DID (`NotReaching` otherwise), at `https://` or at `DOMAIN_CHECK_AT`. Once it's on, the address and `www.` redirect (301) there, except for the host's own paths. Any handle change switches it off, and so does `deleteGroupDomain`. A proxy in front of the host asks `/tls/ask` before getting a certificate. It answers yes for a switched-on group's own-domain handle and `www.` under it, even before serving there is on, so the reach check can succeed ([deploying](../deploying.md)). ## Switching off, on and deleting To stop a group for a while without losing anything, a holder of `group.configure` calls `deactivateGroup`, and the host records who held it then as stewards. While it's off, its repo refuses reads, its spaces grant nothing to anyone, and its images aren't served. Only a kept steward may switch it back on with `activateGroup`. `deleteGroup` is for a holder of `group.configure`, or a kept steward while the group is off. The host tells each space's sync services it's gone, tombstones the DID, then deletes everything it kept for the group in one transaction, and emits `#account` with `status: deleted`. If PLC refuses, the delete fails and the group stays, so you can try again. The host tombstones only when its key is the only rotation key, and leaves a DID with a steward's recovery key for them ([recovery](recovery.md#moving-and-deleting)). What members wrote stays on their own PDSes, and MCP clients may switch a group off but never delete it ([MCP](mcp.md)). ## Changing its about record, rules and pictures `about`, `config` and the labeler live only at `self` and are never deleted. A write to them, or to a rule, is a write as the group, by a token whose member holds the permissions for it at that moment ([signing in](signing-in.md#checking-each-write)). An avatar is a PNG, JPEG or WebP blob the group uploaded, and an upload no record takes within a day is swept. The API reference lists the methods and checks. Details: - A display name is at most 64 graphemes, a description at most 2,000. - An avatar is at most 2,000,000 bytes.