# Organisations

One organisation and one directory of people at Praecise. The organisation and its members are Praecise Spaces'; people are Praecise accounts; a product keeps references (the organisation's id, the person's address) and its own roles. Only the products the deployment names may call this door; any other gets 403 `forbidden`. Read [calling Spaces](calling-spaces.md) first.

- `GET https://inbox.praecise.com/api/spaces/orgs`: The organisations the account belongs to, with its role in each
- `POST https://inbox.praecise.com/api/spaces/orgs`: Make an organisation; the account becomes its admin (takes an `Idempotency-Key`)
- `GET https://inbox.praecise.com/api/spaces/orgs/{id}`: One organisation the account belongs to
- `GET https://inbox.praecise.com/api/spaces/orgs/{id}/role`: What role a person has in an organisation the account belongs to (null: not a member), with the version to cache it by
- `GET https://inbox.praecise.com/api/spaces/orgs/{id}/domains`: The verified domains of an organisation the account belongs to (any role)
- `GET https://inbox.praecise.com/api/spaces/orgs/{id}/mail`: An organisation's mail for a product's selectors: the mailboxes the account may use and the verified domains with whether mail is set up on each
- `GET https://inbox.praecise.com/api/spaces/orgs/{id}/mailboxes`: The mailboxes of an organisation the account may use
- `GET https://inbox.praecise.com/api/spaces/orgs/{id}/members`: The members of an organisation the account belongs to
- `PUT https://inbox.praecise.com/api/spaces/orgs/{id}/members`: Add a member or change a role; someone without a Praecise account is invited (takes an `Idempotency-Key`)
- `DELETE https://inbox.praecise.com/api/spaces/orgs/{id}/members/{email}`: Remove a member (an admin only) (takes an `Idempotency-Key`)

## Adding a member

`set_member` takes `{ email, role }` (`member` or `admin`) and is for admins of the organisation. If the address is new to the organisation, Spaces first asks the account service to invite it to Praecise (once, by whichever product adds them): `invitation` in the answer is `has-account`, `invited`, `already-invited` or `not-sent` (invitations are off here: the member is kept and let in at sign-in). If the invitation cannot be sent, nobody is added: 502, try again.

An organisation needs at least one admin.
