# Organization

This page says who may invite, what a role opens, how the seats are counted, and what renaming or deleting the organization does. It teaches the routes `GET /members`, `GET /members/seats`, `GET|POST /members/invitations`, `DELETE /members/invitations/:id`, `PATCH|DELETE /members/:userId`, `POST /members/leave`, `PATCH /organization` and `DELETE /organization` of [the API](https://durablesdk.com/docs/reference/api.md). The dashboard's Members and Settings pages open the same doors.

## Who may invite

An **admin** invites, sets roles, removes members, renames the organization and deletes it. A **member** deploys, sets secrets, adds domains and acts in the Console tab, and may leave. Every one of these acts is a person's: a request under an API key is refused by name (`plane.member.by_person`, `plane.organization.by_person`), however wide the key's scope, so a leaked key can never change who belongs to the organization or end it. Reading the members (`GET /members`, `GET /members/seats`) takes any `read` key; reading the pending invitations (`GET /members/invitations`) carries addresses and is an admin's.

## Seats

A seat is a member or a pending invitation. The Free tier holds three; Pro holds as many as you pay for, a seat each; Enterprise as many as the contract says. An invitation past the cap is refused before anything is sent (`plane.member.seats_full`: "every seat is taken: 3 of 3, invitations counted"); revoke a pending invitation or remove a member to free one, or move to a tier with more seats ([pricing and tiers](https://durablesdk.com/docs/operate/pricing-and-tiers.md)). `GET /members/seats` answers the members, the pending invitations, the cap (`null` for no limit) and the admins.

## Roles

Two roles, one ladder, in the words the keys use:

| Role     | Does                                                                                              | Mints keys up to |
| -------- | ------------------------------------------------------------------------------------------------- | ---------------- |
| `admin`  | invites, sets roles, makes and deletes apps, revokes any key, renames or deletes the organization | `admin`          |
| `member` | deploys, promotes, rolls back, sets secrets, adds domains, the Console                            | `deploy`         |

A role is set with `PATCH /members/:userId` and a body `{ "role": "admin" }` or `{ "role": "member" }`. Two refusals keep the organization standing: you never change your own role or remove yourself (`plane.member.self`; leave with `POST /members/leave` instead), and the last admin stays (`plane.member.last_admin`; make someone else an admin first). A demotion revokes every key the person minted under the organization in the same run, as a removal does.

## Invitations

```bash
curl -s https://durablesdk.com/api/v1/members/invitations \
  -H "Authorization: Bearer $DURABLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email":"cy@example.com","role":"member"}'
```

The request above is refused: a key never invites. From the dashboard, signed in as an admin, Invite takes one address per line or commas (ten at most), judges each address by its shape, and sends one email per address; a bad address names its position before anything is sent. An address already a member (`plane.member.already_member`) or already invited (`plane.member.already_invited`) is skipped and said, before anything is sent; a seat short is `plane.member.seats_full`. The link in the email lands the person in the plane's own sign-in room, where it signs them in, or makes their account, and joins them to the organization; an invitation expires after thirty days. `DELETE /members/invitations/:id` revokes a pending one (the link stops working), and the way to send again is to revoke and invite. Nothing retries a send: an answer lost on the way is said as doubt, and the next invite of the address finds the standing invitation and says so.

## The organization's name and its end

An admin renames the organization from the Settings page (`PATCH /organization` with `{ "name": "Acme Ltd" }`); the slug stays, and it names nothing on a hostname. Deleting the organization (`DELETE /organization`, the slug typed to confirm on the page) revokes every key, puts every app into the deletion hold for the tier's days ([the hold](https://durablesdk.com/docs/hosting.md)), and takes the organization from its members; the dashboard then lands on the next organization the person belongs to, or on the choice of one. Nothing is restored: a deleted organization is made again as a new one.

## The audit

Every act leaves a fact an admin reads on the Members page's last line and in the plane's runs: `member.invited`, `member.invitation.revoked`, `member.role.changed`, `member.removed`, `member.joined`. A fact carries ids and roles and never an address; a run's ledger names an invitation by a digest of its address, never the address itself. A change made outside the plane (your identity provider's own dashboard) reaches the same facts through the webhook, recorded under the identity actor rather than a person.

## What the CLI does not do yet

The CLI carries no `members` verb: inviting, setting a role and removing are a person's acts on the dashboard, and `durable-sdk explain plane.member.<word>` answers every refusal above offline.

---

Prompt for an agent:

```text
Read https://durablesdk.com/docs/operate/organization.md, then invite a teammate as a member, then make them an admin; run durable-sdk doctor --host before and after; a refused line is a refusal id: durable-sdk explain <id>
```
