# The organisation

> With organisation:admin an integration manages its organisation's settings, people, single sign-on, templates, check lists, fail-reason lists and other integrations.

An integration with `organisation:admin`, such as a company's user directory or ERP, can keep the organisation's settings, people and library in step with its own system. It acts as an admin of its own organisation only and never reaches another organisation's people or settings.

## What it needs

| Operation | Scope |
|:----------|:------|
| Read the organisation | `projects:read` |
| Read the organisation's templates, check lists and fail-reason lists | `inspections:read` |
| Everything else on this page | `organisation:admin` |

The scope picker warns on `organisation:admin`. The organisation's admin picks the scopes; see [Create an integration](/en/integrations/create-an-integration/).

## Settings

`GET /v1/organisation` reads the organisation. `PATCH` changes the default language, the GS1 company prefix, and whether AI assistants and the REST API are on:

```sh
curl -X PATCH "https://api.whatsbuilt.fi/v1/organisation" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"default_language":"fi","gs1_company_prefix":"6430001"}'
```

Turning `mcp_enabled` off ends every AI assistant connection of the organisation; sending its current value changes nothing. `"public_api_enabled": false` turns the API off for the whole organisation, this integration included: its next call answers `403 PUBLIC_API_DISABLED`, and an admin turns it back on in the app.

## People

`GET /v1/organisation/users` lists the organisation's people. Integrations are never on the list. Invite a person:

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/organisation/users" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"email":"matti.virtanen@example.com","name":"Matti Virtanen","role":"inspector"}'
```

The person gets an invitation e-mail and chooses their own password. **The API never sets a password**, so a body with `temp_password` answers `400`. An address that already has a user answers `409 EMAIL_IN_USE`. The role is `viewer`, `inspector` or `admin`.

`PATCH /v1/organisation/users/{userId}` changes a name or role, and `DELETE` removes the person; a person who is the only member of a project answers `409 USER_SOLE_PROJECT_MEMBER`. The organisation's last person admin stays: demoting or removing them answers `409 LAST_ADMIN`.

`POST …/reset-password` e-mails the person a way to set a new password. `POST …/require-password-change` does what *Force Password Change* does in the app: the person's password stops working at once and **no e-mail is sent**. They sign in again after `reset-password` e-mails them a new temporary password, which they change at sign-in. An integration's id, the integration's own included, and a person of another organisation answer `404`.

## Single sign-on

`GET /v1/organisation/sso` reads the identity provider and its e-mail domains; secrets are never in the answer. `PUT` sets SAML, and `DELETE` removes it:

```sh
curl -X PUT "https://api.whatsbuilt.fi/v1/organisation/sso" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"provider":"saml","ssoDomains":["example.com"],"metadataUrl":"https://login.example.com/saml/metadata"}'
```

From then on the people of those domains sign in through the identity provider. A domain another organisation signs in with answers `409`. OIDC is not available: `"provider":"oidc"` answers `400 SSO_OIDC_UNSUPPORTED` and changes nothing.

## Templates, check lists and fail-reason lists

These are the organisation's own, used in all its projects: `/v1/organisation/templates`, `/v1/organisation/check-lists` and `/v1/organisation/fail-reason-lists`. Each has `GET` for the list, `POST` to create, `PUT …/{id}` to change and `DELETE …/{id}` to delete; `GET …/{id}` reads one template or check list with its steps or items.

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/organisation/templates" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"name":"Element reception","steps":[{"name":"Dimensions","check_group_id":"…"},{"name":"Surfaces"}]}'
```

The four creates on this page (people, templates, check lists and fail-reason lists) take an `Idempotency-Key` header. A repeat with the same key and body returns what the first call made with `200`; the same key with another body answers `422 IDEMPOTENCY_KEY_REUSED`. Once that person or row is deleted, the key answers `410 RESOURCE_DELETED` and creates nothing. Keys are the integration's own. When two invitations with the same key arrive at once, one invites the person; the other returns that person with `200`, or answers `422` if its body differs, and invites nobody.

A project's own template or check list answers `404` here. Changing a check list's items makes a new version; checks already recorded keep theirs. Something still in use answers `409` with what uses it.

## Other integrations

`/v1/integrations` lists, creates and changes the organisation's integrations, adds and revokes their keys, and reads their change history and calls. **An integration never gives more than it has:**

- A new integration's scopes must be ones the calling integration holds itself; otherwise `403 SCOPE_NOT_HELD` names the missing ones in `details.scopes`. `read` covers every `:read` scope.
- The caller changes an integration only when it holds every scope the integration has after the change, so a weaker caller can change a stronger one only by also taking away the scopes it lacks. Its projects must also be ones the caller reaches (`403 PROJECTS_NOT_HELD`).
- A key is added, and a disabled integration enabled, only when the caller holds all of the target's scopes and projects. An integration that another organisation's project has admitted gets a key or is enabled only by a person admin in the app (`403 INTEGRATION_ON_OTHER_PROJECTS`).
- An integration never changes itself, the integration that created it, or any integration further up that chain: their scopes, keys, status and projects answer `403 INTEGRATION_SELF`. An admin does that in the app.

Disabling, revoking and removing a key are allowed on any integration of the organisation except the caller and the integrations up its creator chain.

The error codes are on [Errors and limits](/en/integrations/errors-and-limits/) and the fields in the [API reference](/en/api-reference/operations/createuser/).
