# People and groups

Sync people and groups from an HR system, matched by your own IDs, and manage group categories and who belongs to which group.

> Part of [Tayl's API docs](https://tayl.pro/api/v1/docs.md): requests go to `https://tayl.pro` with `Authorization: Bearer <key>`, and [Errors](https://tayl.pro/api/v1/docs/errors.md) explains every error code.

## Syncing from an HR system or rota tool

1. Give every person, group and category your system's stable ID as its `external_id`. The `/by-external-id/…` operations then read, update and archive them without you storing Tayl's UUIDs.
2. Create people with `POST /api/v1/users/bulk`, up to 500 at a time, or one at a time with `POST /api/v1/users`. Update them with `PATCH`.
3. Create the groups, such as sites and teams, then add members with `POST /api/v1/groups/{group_id}/memberships` and remove them with `POST /api/v1/groups/{group_id}/memberships/bulk-remove`.
4. Archive people who leave with `DELETE`. Archiving keeps their training history, and `POST /api/v1/users/{id}/restore` brings them back.
5. Reconcile against a full list regularly, as [Conventions](https://tayl.pro/api/v1/docs/conventions.md) describes under incremental sync.

## Things to know

**People**

- New people get an invitation email unless you send `send_invite=false`. While the organisation is in Setup mode, invitations wait until an admin switches it to Active.
- Name a new person's `groups` by `group_id` or `group_external_id` to add them in the same request. A manager's personal key must name at least one group they manage, so the person lands in their reach, and adds existing people only to their own groups.
- On Tayl Learn Standard or Advanced, creating or restoring people past the plan's team size moves it up to the size that fits them and charges the difference, as adding them in Tayl does. A bulk request moves it up once for all its new people, so send a batch together rather than one at a time. Past what the plan can hold, or when moving up was declined, each person gets `422 validation_error` (`422 invalid_state_transition` when restoring) saying why; an admin fixes a declined payment in Tayl. If Tayl couldn't move the plan up just now, the message says so: retry shortly.
- Nobody can pause or archive themselves, the organisation's last admin or its group's last group admin (`422 would_lock_out`).
- Only Tayl staff or a fellow group admin can change an Organisation Group Admin. Any other key, organisation keys included, gets `403 not_permitted` for updating, archiving or restoring one.

**Groups**

- Automatic groups are kept up to date by Tayl from its own rules, so they and their memberships are read-only here (`422 automatic_group_read_only`). Their descriptions show the current rules, and a change to those rules updates the group and sends `group.updated`.
- A rule-based group holds everyone in both of the groups listed in its `rule_user_group_ids`. Only Tayl makes them, as a group category's subgroups, such as Bristol · Bar Staff when Location makes subgroups by Job Role, with `category_made: true`. `rule_user_group_ids` is read-only: Tayl ignores it on a create or update, which makes or changes a manual group. Tayl names and fills the groups it makes, so they're read-only here (`422 category_made_group_read_only`). Tayl adds and removes their members, with `source` `rule`, as soon as anyone joins or leaves those groups, and within moments of the group being made. You can also add people to one directly, as to a manual group: they're in each of its rule's groups through it, with `source` `inclusion`, and leave them when you remove them, unless something else keeps them there. It can't have sub-groups or be one.
- Deleting a group removes an empty manual group, releases its `external_id` and removes it from any parent groups. A group that still has members or an active sub-group returns `422 group_not_deletable`: remove them first. A rule-based group whose rule names it doesn't stop you: Tayl hides it with the group.
- Removing a member ends their direct membership only. Someone who is also in a sub-group of the group stays a member, now with `source` `inclusion`, until they leave that sub-group. Someone added directly to a rule-based group who still meets its rule stays too, with `source` `rule`.
- An archived person's group memberships can't be changed (`422 invalid_user_state`).
- A group category with groups attached can't be deleted (`422 category_not_deletable`), and the Automatic category is read-only.

## Not available yet

- Having a group category make subgroups by another. Turn subgroups on and off in Tayl.

## Operations

### Users

Create, update, archive, and restore people in your organisation.

#### List users

`GET https://tayl.pro/api/v1/users` · `listUsers` · Scope `users:read`

Lists the organisation's users, including archived ones but not people removed from the organisation or whose accounts were deleted. `since` considers changes to each person's membership of the organisation.

**Parameters**

- `page` (query, integer, at least 1, default `1`): Page to fetch.
- `per_page` (query, integer, 1–100, default `25`): Records per page.
- `email` (query, string): Exact email match (case-insensitive).
- `external_id` (query, ExternalId): Exact external_id match.
- `state` (query, one of `"pending"`, `"invited"`, `"onboarding"`, `"active"`, `"non_compliant"`, `"paused"`, `"suspended"`, `"archived"`): Return only records currently in this lifecycle state.
- `since` (query, date-time): Inclusive ISO 8601 cursor. Each endpoint documents which change timestamps it considers.
- `sort` (query, one of `"created_at"`, `"updated_at"`, `"email"`, default `"created_at"`): Field used to order the result set.
- `order` (query, one of `"asc"`, `"desc"`, default `"asc"`): Sort direction.

**Responses**

- `200` (UserList): A page of users. Headers: Link.
- Errors: `400`, `401`, `402`, `403`, `429`.

**Example response** (`200`)

```json
{"users":[{"id":"019cf5b0-7c00-7000-8000-000000000002","external_id":"usr-1042","email":"alex.chen@example.com","name":"Alex Chen","first_name":"Alex","last_name":"Chen","state":"active","invited_at":"2026-03-10T09:00:00Z","accepted_at":"2026-03-10T09:15:00Z","created_at":"2026-03-10T09:00:00Z","updated_at":"2026-03-16T10:00:00Z"}],"meta":{"page":1,"per_page":25,"total_pages":1,"total_count":1}}
```

#### Create a user

`POST https://tayl.pro/api/v1/users` · `createUser` · Scope `users:write`

Creates an organisation user. An invitation email is sent unless `send_invite=false`; the invitation flow links the person's Tayl account when they accept. While the organisation is in Setup mode, invitations are held whatever `send_invite` says: the request still returns 201, and the user stays `pending` with no `invited_at`. When the organisation switches to Active, an admin can send the held invitations or invite people one at a time.

**Parameters**

- `send_invite` (query, boolean, default `true`): Set to `false` to add the person without an invitation email.

**Body** (`application/json`): UserInput.

**Responses**

- `201` (User): The created user.
- Errors: `400`, `401`, `402`, `403`, `409`, `422`, `429`.

**Example request**

```json
{"email":"alex.chen@example.com","first_name":"Alex","last_name":"Chen","external_id":"usr-1042"}
```

#### Bulk create users

`POST https://tayl.pro/api/v1/users/bulk` · `bulkCreateUsers` · Scope `users:write`

Creates up to 500 users in one call. Each entry succeeds or fails on its own, and the status sums them up: 201 if all succeeded, 207 if some did, 422 if none did. While the organisation is in Setup mode, invitations are held whatever `send_invite` says: created users stay `pending` with no `invited_at`. When the organisation switches to Active, an admin can send the held invitations or invite people one at a time.

**Parameters**

- `send_invite` (query, boolean, default `true`): Set to `false` to add everyone without an invitation email.

**Body** (`application/json`): BulkUsersRequest.

**Responses**

- `201` (BulkUsersResult): Every user was created.
- `207` (BulkUsersResult): Some users were created; inspect per-entry statuses.
- `422` (BulkUsersResult): No user could be created; inspect per-entry errors.
- Errors: `400`, `401`, `402`, `403`, `429`.

**Example request**

```json
{"users":[{"email":"alex.chen@example.com","first_name":"Alex","last_name":"Chen","external_id":"usr-1042"},{"email":"sam.lee@example.com","first_name":"Sam","last_name":"Lee","external_id":"usr-1043"}]}
```

#### Get a user

`GET https://tayl.pro/api/v1/users/{id}` · `getUser` · Scope `users:read`

Returns one current or archived organisation user by Tayl UUID.

**Parameters**

- `id` (path, uuid, required): The user's Tayl UUID.

**Responses**

- `200` (User): The user.
- Errors: `400`, `401`, `402`, `403`, `404`, `429`.

**Example response** (`200`)

```json
{"id":"019cf5b0-7c00-7000-8000-000000000002","external_id":"usr-1042","email":"alex.chen@example.com","name":"Alex Chen","first_name":"Alex","last_name":"Chen","state":"active","invited_at":"2026-03-10T09:00:00Z","accepted_at":"2026-03-10T09:15:00Z","created_at":"2026-03-10T09:00:00Z","updated_at":"2026-03-16T10:00:00Z"}
```

#### Update a user

`PATCH https://tayl.pro/api/v1/users/{id}` · `updateUser` · Scope `users:write`

Applies only the supplied profile and external identifier fields; accepted users retain control of their account name and login email. Changing an invited user's email re-sends their invitation to the new address. In Setup mode the invitation is held instead, and the user returns to `pending`. If the invitation includes permissions, it is withdrawn (state `pending`) and an admin must invite them again.

**Parameters**

- `id` (path, uuid, required): The user's Tayl UUID.

**Body** (`application/json`): UserUpdateInput.

**Responses**

- `200` (User): The updated user.
- Errors: `400`, `401`, `402`, `403`, `404`, `409`, `422`, `429`.

**Example request**

```json
{"email":"alex.chen@example.net","external_id":"usr-1042"}
```

#### Archive a user

`DELETE https://tayl.pro/api/v1/users/{id}` · `archiveUser` · Scope `users:write`

Archives the user (they've left the organisation). Learning history is retained; incomplete tasks are cancelled, sessions are ended, and group memberships are suspended. Restoring reverses it. An Organisation Group Admin, or someone who is a group admin elsewhere in the organisation's group, can only be archived by Tayl staff or another group admin, so this returns `403 not_permitted` for them.

**Parameters**

- `id` (path, uuid, required): The user's Tayl UUID.

**Responses**

- `204`: User archived.
- Errors: `400`, `401`, `402`, `403`, `404`, `422`, `429`.

#### Restore an archived user

`POST https://tayl.pro/api/v1/users/{id}/restore` · `restoreUser` · Scope `users:write`

Restores a paused or suspended user to active. Archived linked users return to active; unlinked users return to their pending or invited state. Tasks cancelled by the archive are reinstated. An Organisation Group Admin, or someone who is a group admin elsewhere in the organisation's group, can only be restored by Tayl staff or another group admin, so this returns `403 not_permitted` for them.

**Parameters**

- `id` (path, uuid, required): The user's Tayl UUID.

**Responses**

- `200` (User): The restored user.
- Errors: `400`, `401`, `402`, `403`, `404`, `422`, `429`.

**Example response** (`200`)

```json
{"id":"019cf5b0-7c00-7000-8000-000000000002","external_id":"usr-1042","email":"alex.chen@example.com","name":"Alex Chen","first_name":"Alex","last_name":"Chen","state":"active","invited_at":"2026-03-10T09:00:00Z","accepted_at":"2026-03-10T09:15:00Z","created_at":"2026-03-10T09:00:00Z","updated_at":"2026-03-16T10:00:00Z"}
```

#### Get a user by external ID

`GET https://tayl.pro/api/v1/users/by-external-id/{external_id}` · `getUserByExternalId` · Scope `users:read`

Returns the user with this `external_id`, matched case-sensitively.

**Parameters**

- `external_id` (path, ExternalId, required): The user's `external_id`.

**Responses**

- `200` (User): The user.
- Errors: `400`, `401`, `402`, `403`, `404`, `429`.

**Example response** (`200`)

```json
{"id":"019cf5b0-7c00-7000-8000-000000000002","external_id":"usr-1042","email":"alex.chen@example.com","name":"Alex Chen","first_name":"Alex","last_name":"Chen","state":"active","invited_at":"2026-03-10T09:00:00Z","accepted_at":"2026-03-10T09:15:00Z","created_at":"2026-03-10T09:00:00Z","updated_at":"2026-03-16T10:00:00Z"}
```

#### Update a user by external ID

`PATCH https://tayl.pro/api/v1/users/by-external-id/{external_id}` · `updateUserByExternalId` · Scope `users:write`

Updates the user with this `external_id`, returning 404 if there's none: it doesn't create one.

**Parameters**

- `external_id` (path, ExternalId, required): The user's `external_id`.

**Body** (`application/json`): UserUpdateInput.

**Responses**

- `200` (User): The updated user.
- Errors: `400`, `401`, `402`, `403`, `404`, `409`, `422`, `429`.

**Example request**

```json
{"email":"alex.chen@example.net","external_id":"usr-1042"}
```

#### Archive a user by external ID

`DELETE https://tayl.pro/api/v1/users/by-external-id/{external_id}` · `archiveUserByExternalId` · Scope `users:write`

Archives the externally identified user while retaining learning history and allowing a later restore by UUID. Returns `403 not_permitted` for an Organisation Group Admin, as archiving by UUID does.

**Parameters**

- `external_id` (path, ExternalId, required): The user's `external_id`.

**Responses**

- `204`: User archived.
- Errors: `400`, `401`, `402`, `403`, `404`, `422`, `429`.

### Groups

Mirror your organisation's structure into Tayl groups.

#### List groups

`GET https://tayl.pro/api/v1/groups` · `listGroups` · Scope `groups:read`

Lists current groups. `since` considers group updated_at.

**Parameters**

- `page` (query, integer, at least 1, default `1`): Page to fetch.
- `per_page` (query, integer, 1–100, default `25`): Records per page.
- `external_id` (query, ExternalId): Exact external_id match.
- `category_id` (query, uuid): Return only groups assigned to this group category UUID.
- `automatic` (query, boolean): Filter to automatic (system-managed) or manual groups.
- `since` (query, date-time): Inclusive ISO 8601 cursor. Each endpoint documents which change timestamps it considers.
- `sort` (query, one of `"created_at"`, `"updated_at"`, `"name"`, default `"created_at"`): Field used to order the result set.
- `order` (query, one of `"asc"`, `"desc"`, default `"asc"`): Sort direction.

**Responses**

- `200` (GroupList): A page of groups. Headers: Link.
- Errors: `400`, `401`, `402`, `403`, `429`.

**Example response** (`200`)

```json
{"groups":[{"id":"019cf5b0-7c00-7000-8000-000000000003","external_id":"loc-london","name":"London","description":"People based at the London site","category_id":"019cf5b0-7c00-7000-8000-000000000004","automatic":false,"rule_user_group_ids":[],"category_made":false,"members_count":18,"created_at":"2026-02-01T09:00:00Z","updated_at":"2026-03-15T11:30:00Z"}],"meta":{"page":1,"per_page":25,"total_pages":1,"total_count":1}}
```

#### Create a group

`POST https://tayl.pro/api/v1/groups` · `createGroup` · Scope `groups:write` · Personal keys: admins only

Creates a manual group; automatic and rule-based groups are made only by Tayl.

**Body** (`application/json`): GroupInput.

**Responses**

- `201` (Group): The created group.
- Errors: `400`, `401`, `402`, `403`, `409`, `422`, `429`.

**Example request**

```json
{"name":"London","description":"People based at the London site","category_id":"019cf5b0-7c00-7000-8000-000000000004","external_id":"loc-london"}
```

#### Get a group

`GET https://tayl.pro/api/v1/groups/{id}` · `getGroup` · Scope `groups:read`

Returns one visible group, including its category and current active-member count.

**Parameters**

- `id` (path, uuid, required): The group's Tayl UUID.

**Responses**

- `200` (Group): The group.
- Errors: `400`, `401`, `402`, `403`, `404`, `429`.

**Example response** (`200`)

```json
{"id":"019cf5b0-7c00-7000-8000-000000000003","external_id":"loc-london","name":"London","description":"People based at the London site","category_id":"019cf5b0-7c00-7000-8000-000000000004","automatic":false,"rule_user_group_ids":[],"category_made":false,"members_count":18,"created_at":"2026-02-01T09:00:00Z","updated_at":"2026-03-15T11:30:00Z"}
```

#### Update a group

`PATCH https://tayl.pro/api/v1/groups/{id}` · `updateGroup` · Scope `groups:write` · Personal keys: admins only

Updates a manual group's supplied fields; automatic and category-made groups are read-only.

**Parameters**

- `id` (path, uuid, required): The group's Tayl UUID.

**Body** (`application/json`): GroupUpdateInput.

**Responses**

- `200` (Group): The updated group.
- Errors: `400`, `401`, `402`, `403`, `404`, `409`, `422`, `429`.

**Example request**

```json
{"name":"London team","description":"People based at the London site"}
```

#### Delete a group

`DELETE https://tayl.pro/api/v1/groups/{id}` · `deleteGroup` · Scope `groups:write` · Personal keys: admins only

Soft-deletes an empty manual group and removes its links to parent groups; the parents remain. Non-deleted memberships and active sub-groups block deletion (422). A category-made group can't be deleted here, and doesn't block deleting a group its rule names: it's hidden with that group. Deleting releases the group's external_id for reuse.

**Parameters**

- `id` (path, uuid, required): The group's Tayl UUID.

**Responses**

- `204`: Group deleted.
- Errors: `400`, `401`, `402`, `403`, `404`, `422`, `429`.

#### Get a group by external ID

`GET https://tayl.pro/api/v1/groups/by-external-id/{external_id}` · `getGroupByExternalId` · Scope `groups:read`

Returns the group with this `external_id`, matched case-sensitively.

**Parameters**

- `external_id` (path, ExternalId, required): The group's `external_id`.

**Responses**

- `200` (Group): The group.
- Errors: `400`, `401`, `402`, `403`, `404`, `429`.

**Example response** (`200`)

```json
{"id":"019cf5b0-7c00-7000-8000-000000000003","external_id":"loc-london","name":"London","description":"People based at the London site","category_id":"019cf5b0-7c00-7000-8000-000000000004","automatic":false,"rule_user_group_ids":[],"category_made":false,"members_count":18,"created_at":"2026-02-01T09:00:00Z","updated_at":"2026-03-15T11:30:00Z"}
```

#### Update a group by external ID

`PATCH https://tayl.pro/api/v1/groups/by-external-id/{external_id}` · `updateGroupByExternalId` · Scope `groups:write` · Personal keys: admins only

Updates the group with this `external_id`, returning 404 if there's none: it doesn't create one.

**Parameters**

- `external_id` (path, ExternalId, required): The group's `external_id`.

**Body** (`application/json`): GroupUpdateInput.

**Responses**

- `200` (Group): The updated group.
- Errors: `400`, `401`, `402`, `403`, `404`, `409`, `422`, `429`.

**Example request**

```json
{"name":"London team","description":"People based at the London site"}
```

#### Delete a group by external ID

`DELETE https://tayl.pro/api/v1/groups/by-external-id/{external_id}` · `deleteGroupByExternalId` · Scope `groups:write` · Personal keys: admins only

Soft-deletes the externally identified group under the same rules as deletion by ID. Non-deleted memberships and active sub-groups block deletion (422); a rule-based group whose rule names it does not. Deleting releases its external identifier for reuse.

**Parameters**

- `external_id` (path, ExternalId, required): The group's `external_id`.

**Responses**

- `204`: Group deleted.
- Errors: `400`, `401`, `402`, `403`, `404`, `422`, `429`.

### Group memberships

Manage which users belong to which groups.

#### List group members

`GET https://tayl.pro/api/v1/groups/{group_id}/memberships` · `listGroupMemberships` · Scope `groups:read`

Lists current members from every source; only memberships whose source is `direct` can be removed through this API.

**Parameters**

- `group_id` (path, uuid, required): The group's Tayl UUID.
- `page` (query, integer, at least 1, default `1`): Page to fetch.
- `per_page` (query, integer, 1–100, default `25`): Records per page.

**Responses**

- `200` (MembershipList): A page of the group's active memberships. Headers: Link.
- Errors: `400`, `401`, `402`, `403`, `404`, `429`.

**Example response** (`200`)

```json
{"memberships":[{"user_id":"019cf5b0-7c00-7000-8000-000000000002","user_external_id":"usr-1042","email":"alex.chen@example.com","name":"Alex Chen","source":"direct","created_at":"2026-03-12T14:30:00Z"}],"meta":{"page":1,"per_page":25,"total_pages":1,"total_count":1}}
```

#### Add members to a group

`POST https://tayl.pro/api/v1/groups/{group_id}/memberships` · `addGroupMembers` · Scope `groups:write`

Adds current users to the group as direct members, entry by entry: existing members report 200, new or restored memberships 201, and archived users 422. A 200 entry keeps its membership's `source`; one from an included group or an integration is kept in step by Tayl and can't be removed through this API. Not available on automatic groups.

**Parameters**

- `group_id` (path, uuid, required): The group's Tayl UUID.

**Body** (`application/json`): MembershipsRequest.

**Responses**

- `200` (BulkMembershipsResult): Every entry succeeded and at least one user was already a member (inspect per-entry statuses).
- `201` (BulkMembershipsResult): Every membership was created.
- `207` (BulkMembershipsResult): Some entries succeeded; inspect per-entry statuses.
- `422` (BulkMembershipsResult or Error): The group is automatic (error envelope), or no entry could be processed because its identifier or user state is invalid (per-entry results).
- Errors: `400`, `401`, `402`, `403`, `404`, `429`.

**Example request**

```json
{"memberships":[{"user_external_id":"usr-1042"},{"user_external_id":"usr-1043"}]}
```

#### Remove members from a group

`POST https://tayl.pro/api/v1/groups/{group_id}/memberships/bulk-remove` · `removeGroupMembers` · Scope `groups:write`

Removes current users' direct memberships. Someone also in a group that this group includes stays a member, with `source` `inclusion`. Archived users report a per-entry 422. Inclusion, automatic, and integration memberships are derived and cannot be removed (per-entry 404). Not available on automatic groups.

**Parameters**

- `group_id` (path, uuid, required): The group's Tayl UUID.

**Body** (`application/json`): MembershipsRequest.

**Responses**

- `200` (BulkMembershipsResult): Every membership was removed.
- `207` (BulkMembershipsResult): Some entries succeeded; inspect per-entry statuses.
- `422` (BulkMembershipsResult or Error): The group is automatic (error envelope), or no entry could be processed because its identifier or user state is invalid (per-entry results).
- Errors: `400`, `401`, `402`, `403`, `404`, `429`.

**Example request**

```json
{"memberships":[{"user_external_id":"usr-1042"},{"user_external_id":"usr-1043"}]}
```

#### Remove a member from a group

`DELETE https://tayl.pro/api/v1/groups/{group_id}/memberships/{user_id}` · `removeGroupMember` · Scope `groups:write`

Removes a current user's direct membership. Someone also in a group that this group includes stays a member, with `source` `inclusion`. Archived users receive 422; users without a direct membership receive 404. Not available on automatic groups.

**Parameters**

- `group_id` (path, uuid, required): The group's Tayl UUID.
- `user_id` (path, uuid, required): The member's Tayl user UUID.

**Responses**

- `204`: Membership removed.
- Errors: `400`, `401`, `402`, `403`, `404`, `422`, `429`.

#### Remove a member from a group by external ID

`DELETE https://tayl.pro/api/v1/groups/{group_id}/memberships/by-external-id/{user_external_id}` · `removeGroupMemberByExternalId` · Scope `groups:write`

Removes a current user's direct membership, naming them by `external_id`; memberships from included groups or integrations stay as Tayl keeps them. Someone also in a group that this group includes stays a member, with `source` `inclusion`.

**Parameters**

- `group_id` (path, uuid, required): The group's Tayl UUID.
- `user_external_id` (path, ExternalId, required): The member's `external_id`.

**Responses**

- `204`: Membership removed.
- Errors: `400`, `401`, `402`, `403`, `404`, `422`, `429`.

### Group categories

Organise groups by type, such as department or location.

#### List group categories

`GET https://tayl.pro/api/v1/group-categories` · `listGroupCategories` · Scope `groups:read`

Lists the organisation's taxonomy in display order, including the read-only Automatic category.

**Parameters**

- `page` (query, integer, at least 1, default `1`): Page to fetch.
- `per_page` (query, integer, 1–100, default `25`): Records per page.
- `external_id` (query, ExternalId): Exact external_id match.

**Responses**

- `200` (GroupCategoryList): A page of group categories, ordered by position. Headers: Link.
- Errors: `400`, `401`, `402`, `403`, `429`.

**Example response** (`200`)

```json
{"group_categories":[{"id":"019cf5b0-7c00-7000-8000-000000000004","external_id":"category-location","name":"Location","description":"The site where a person works","colour":"blue","icon":"map-pin","position":2,"automatic":false,"created_at":"2026-01-12T08:30:00Z","updated_at":"2026-03-01T12:00:00Z"}],"meta":{"page":1,"per_page":25,"total_pages":1,"total_count":1}}
```

#### Create a group category

`POST https://tayl.pro/api/v1/group-categories` · `createGroupCategory` · Scope `groups:write` · Personal keys: admins only

Adds a category used to organise manual groups in manager views and integrations.

**Body** (`application/json`): GroupCategoryInput.

**Responses**

- `201` (GroupCategory): The created category.
- Errors: `400`, `401`, `402`, `403`, `409`, `422`, `429`.

**Example request**

```json
{"name":"Location","description":"The site where a person works","colour":"blue","icon":"map-pin","external_id":"category-location"}
```

#### Get a group category

`GET https://tayl.pro/api/v1/group-categories/{id}` · `getGroupCategory` · Scope `groups:read`

Returns one organisation group category by Tayl UUID.

**Parameters**

- `id` (path, uuid, required): The category's Tayl UUID.

**Responses**

- `200` (GroupCategory): The category.
- Errors: `400`, `401`, `402`, `403`, `404`, `429`.

**Example response** (`200`)

```json
{"id":"019cf5b0-7c00-7000-8000-000000000004","external_id":"category-location","name":"Location","description":"The site where a person works","colour":"blue","icon":"map-pin","position":2,"automatic":false,"created_at":"2026-01-12T08:30:00Z","updated_at":"2026-03-01T12:00:00Z"}
```

#### Update a group category

`PATCH https://tayl.pro/api/v1/group-categories/{id}` · `updateGroupCategory` · Scope `groups:write` · Personal keys: admins only

Updates the supplied name, visual treatment, or external identifier; the Automatic category is read-only.

**Parameters**

- `id` (path, uuid, required): The category's Tayl UUID.

**Body** (`application/json`): GroupCategoryUpdateInput.

**Responses**

- `200` (GroupCategory): The updated category.
- Errors: `400`, `401`, `402`, `403`, `404`, `409`, `422`, `429`.

**Example request**

```json
{"description":"The primary site where a person works","colour":"indigo"}
```

#### Delete a group category

`DELETE https://tayl.pro/api/v1/group-categories/{id}` · `deleteGroupCategory` · Scope `groups:write` · Personal keys: admins only

Categories with groups attached cannot be deleted (422); recategorise the groups first.

**Parameters**

- `id` (path, uuid, required): The category's Tayl UUID.

**Responses**

- `204`: Category deleted.
- Errors: `400`, `401`, `402`, `403`, `404`, `422`, `429`.

#### Get a group category by external ID

`GET https://tayl.pro/api/v1/group-categories/by-external-id/{external_id}` · `getGroupCategoryByExternalId` · Scope `groups:read`

Returns the category with this `external_id`, matched case-sensitively.

**Parameters**

- `external_id` (path, ExternalId, required): The category's `external_id`.

**Responses**

- `200` (GroupCategory): The category.
- Errors: `400`, `401`, `402`, `403`, `404`, `429`.

**Example response** (`200`)

```json
{"id":"019cf5b0-7c00-7000-8000-000000000004","external_id":"category-location","name":"Location","description":"The site where a person works","colour":"blue","icon":"map-pin","position":2,"automatic":false,"created_at":"2026-01-12T08:30:00Z","updated_at":"2026-03-01T12:00:00Z"}
```

#### Update a group category by external ID

`PATCH https://tayl.pro/api/v1/group-categories/by-external-id/{external_id}` · `updateGroupCategoryByExternalId` · Scope `groups:write` · Personal keys: admins only

Updates supplied fields on the externally identified category; it never creates a missing category.

**Parameters**

- `external_id` (path, ExternalId, required): The category's `external_id`.

**Body** (`application/json`): GroupCategoryUpdateInput.

**Responses**

- `200` (GroupCategory): The updated category.
- Errors: `400`, `401`, `402`, `403`, `404`, `409`, `422`, `429`.

**Example request**

```json
{"description":"The primary site where a person works","colour":"indigo"}
```

#### Delete a group category by external ID

`DELETE https://tayl.pro/api/v1/group-categories/by-external-id/{external_id}` · `deleteGroupCategoryByExternalId` · Scope `groups:write` · Personal keys: admins only

Deletes the externally identified category only when no groups still use it.

**Parameters**

- `external_id` (path, ExternalId, required): The category's `external_id`.

**Responses**

- `204`: Category deleted.
- Errors: `400`, `401`, `402`, `403`, `404`, `422`, `429`.

## Schemas

### ExternalId

Caller-owned identifier, unique within the organisation. Matched case-sensitively; surrounding whitespace is stripped. String, at most 255 characters.

### UserList

One page of organisation users and its pagination metadata.

- `users` (array of User, required): Users on this page.
- `meta` (Meta, required): Metadata describing this page or bulk operation.

### User

A member of the organisation (an OrganisationUser). `state` tracks the membership lifecycle; archived users are retained with their learning history.

- `id` (uuid, required): Tayl UUID.
- `external_id` (NullableExternalId, required): Caller-owned identifier used to reconcile this record with the source system.
- `email` (email, required): The organisation contact email, normalised to lowercase.
- `name` (string, required): Display name: the linked account's name, the invited name, or the email.
- `first_name` (string or null, required): From the linked user account; null until the invitation is accepted.
- `last_name` (string or null, required): From the linked user account; null until the invitation is accepted.
- `state` (one of `"pending"`, `"invited"`, `"onboarding"`, `"active"`, `"non_compliant"`, `"paused"`, `"suspended"`, `"archived"`, required): Current lifecycle state of the resource.
- `invited_at` (date-time or null, required): When Tayl most recently sent the invitation; null when no invitation was sent.
- `accepted_at` (date-time or null, required): When the person accepted their invitation; null until acceptance.
- `created_at` (date-time, required): When the record was created, as an ISO 8601 UTC timestamp.
- `updated_at` (date-time, required): When the represented record last changed, as an ISO 8601 UTC timestamp.

### Meta

Pagination details on every list. Page links also come in the RFC 8288 `Link` header, as `first`, `prev`, `next` and `last`.

- `page` (integer, required): Current page (1-based).
- `per_page` (integer, required): Records per page (default 25, max 100).
- `total_pages` (integer, required): Number of pages available for the current filters.
- `total_count` (integer, required): Total records matching the current filters.

### NullableExternalId

Caller-owned identifier, unique within the organisation. Matched case-sensitively; surrounding whitespace is stripped. String or null, at most 255 characters.

### UserInput

Fields for adding one person.

- `email` (email, required): The organisation contact email, normalised to lowercase.
- `first_name` (string): Stored with last_name as the invited display name, returned in `name`. `first_name`/`last_name` read null until the person accepts and links their account.
- `last_name` (string): See first_name.
- `external_id` (NullableExternalId): Caller-owned identifier used to reconcile this record with the source system.
- `groups` (array of UserGroupReference, at most 100 items): Manual or rule-based groups to add the person to. A manager's personal key must name at least one group they manage, so the person lands in their reach; an entry naming a group the key can't add people to fails with `422 validation_error`.

### UserGroupReference

Names a group by exactly one of `group_id` (Tayl UUID) or `group_external_id` (yours).

- `group_id` (uuid): The group's Tayl UUID.
- `group_external_id` (ExternalId, at least 1 character): The group's `external_id`.

### BulkUsersRequest

Up to 500 users, each checked and added on its own.

- `users` (array of BulkUserInput, 1–500 items, required): Users on this page.

### BulkUsersResult

One entry per submitted user, in submission order. The HTTP status is 201 when every entry succeeded, 207 on partial success, 422 when every entry failed.

- `results` (array of object, required): Per-entry outcomes in the same order as the submitted entries.
- `results[].index` (integer, required): Position in the submitted array.
- `results[].status` (integer, required): Per-entry outcome: 201 created, 409 duplicate external_id, 422 invalid.
- `results[].user` (User or null): Created user, or null when this entry failed.
- `results[].errors` (array of ErrorItem, required): Structured errors; empty for a successful bulk entry.
- `meta` (object, required): Metadata describing this page or bulk operation.
- `meta.total` (integer, required): Number of submitted entries.
- `meta.succeeded` (integer, required): Number of entries that succeeded.
- `meta.failed` (integer, required): Number of entries that failed.

### BulkUserInput

Same fields as UserInput, but deliberately without schema-level required fields: entries are validated server-side per entry, so a missing or invalid field (email included) fails that entry with a per-entry 422, never the whole request.

- `email` (email): The organisation contact email, normalised to lowercase.
- `first_name` (string): Stored with last_name as the invited display name, returned in `name`. `first_name`/`last_name` read null until the person accepts and links their account.
- `last_name` (string): See first_name.
- `external_id` (NullableExternalId): Caller-owned identifier used to reconcile this record with the source system.
- `groups` (array of UserGroupReference, at most 100 items): Manual or rule-based groups to add the person to. A manager's personal key must name at least one group they manage, so the person lands in their reach; an entry naming a group the key can't add people to fails with `422 validation_error`.

### ErrorItem

One machine-readable problem in the standard API error envelope.

- `code` (string, required): Machine-readable error code, such as `validation_error`.
- `message` (string, required): Human-readable description.
- `field` (string): Offending field, for validation errors.
- `pointer` (string): JSON pointer to the offending field.
- `existing_id` (uuid): For duplicate_external_id errors: the Tayl UUID of the record already holding the external_id, when the key can see it.
- `documentation_url` (uri, required): The error reference's entry for this code: what it means and how to fix it.

### UserUpdateInput

Fields you leave out keep their values. Name fields are refused once the user has accepted their invitation, as the name then belongs to their account, and `first_name` and `last_name` must be sent together, as the invited name is stored as one string. For accepted users, changing `email` changes only the address the organisation contacts and matches them by, as HR sync does; their Tayl sign-in email is theirs and stays as it is. The changed address stays unconfirmed until the person confirms it, and emails only go there if they choose it. For invited users, changing `email` re-sends their invitation to the new address, and the previous invitation link stops working.

- `email` (email): The organisation contact email, normalised to lowercase.
- `first_name` (string): The person's given name.
- `last_name` (string): The person's family name.
- `external_id` (NullableExternalId): Caller-owned identifier used to reconcile this record with the source system.

### GroupList

One page of groups and its pagination metadata.

- `groups` (array of Group, required): Groups on this page.
- `meta` (Meta, required): Metadata describing this page or bulk operation.

### Group

A group of people. Automatic groups (`automatic: true`) are maintained by Tayl and read-only through the API. Rule-based groups (a non-empty `rule_user_group_ids`, `category_made: true`) are made only by Tayl, as a group category's subgroups: each holds everyone in both of the groups its rule names, and is read-only here apart from its memberships. People added to one directly (`source` `direct`) are in those groups through it.

- `id` (uuid, required): Tayl UUID.
- `external_id` (NullableExternalId, required): Caller-owned identifier used to reconcile this record with the source system.
- `name` (string, required): Human-readable name shown in Tayl.
- `description` (string or null, required): Optional explanatory text. Automatic groups describe the organisation's current criteria; changing those criteria advances updated_at and emits group.updated for the current group.
- `category_id` (uuid or null, required): Group category UUID (see /group-categories).
- `automatic` (boolean, required): Whether Tayl maintains it automatically, so it can't be changed by hand or through the API.
- `rule_user_group_ids` (array of uuid, required): For a rule-based group, the two groups its members are all in: the group it is a subgroup of, then the other. Empty for a manual or automatic group. Only Tayl makes rule-based groups, so a create or update ignores this field.
- `category_made` (boolean, required): Whether Tayl made this rule-based group as a group category's subgroup, such as Bristol · Bar Staff when Location makes subgroups by Job Role. Tayl names it and keeps it up to date, so it can't be changed or deleted through the API, though people can be added to it directly.
- `members_count` (integer, required): Active member count.
- `created_at` (date-time, required): When the record was created, as an ISO 8601 UTC timestamp.
- `updated_at` (date-time, required): When the represented record last changed, as an ISO 8601 UTC timestamp.

### GroupInput

Fields accepted when creating a group.

- `name` (string, required): Human-readable name shown in Tayl.
- `description` (string or null): Optional explanatory text shown with the resource.
- `category_id` (uuid or null): Must be a category in your organisation (see /group-categories).
- `external_id` (NullableExternalId): Caller-owned identifier used to reconcile this record with the source system.

### GroupUpdateInput

Fields you leave out keep their values.

- `name` (string): Human-readable name shown in Tayl.
- `description` (string or null): Optional explanatory text shown with the resource.
- `category_id` (uuid or null): Must be a category in your organisation (see /group-categories).
- `external_id` (NullableExternalId): Caller-owned identifier used to reconcile this record with the source system.

### MembershipList

One page of active memberships for a group.

- `memberships` (array of Membership, required): Memberships in the request, result, or current page.
- `meta` (Meta, required): Metadata describing this page or bulk operation.

### Membership

A person's membership of a group. `source` records how it arose; only `direct` memberships can be managed through the API.

- `user_id` (uuid, required): The member's Tayl user UUID.
- `user_external_id` (NullableExternalId, required): Caller-owned identifier of the learner, when set.
- `email` (email, required): The organisation contact email, normalised to lowercase.
- `name` (string, required): Human-readable name shown in Tayl.
- `source` (one of `"direct"`, `"inclusion"`, `"automatic"`, `"integration"`, `"rule"`, required): How the membership was created and whether callers can remove it.
- `created_at` (date-time, required): When the record was created, as an ISO 8601 UTC timestamp.

### MembershipsRequest

Users to add to or remove from a group, identified independently.

- `memberships` (array of MembershipEntry, 1–500 items, required): Memberships in the request, result, or current page.

### BulkMembershipsResult

One entry per submitted membership, in submission order. Add: 201 added (or restored), 200 already a member (idempotent). Remove: 200 direct membership removed (the user stays a member through any group this group includes), 404 not a direct member.

- `results` (array of object, required): Per-entry outcomes in the same order as the submitted entries.
- `results[].index` (integer, required): Zero-based position of the submitted entry.
- `results[].status` (integer, required): This entry's outcome: 200 or 201 succeeded, 404 user or membership not found, 422 invalid identifier or archived user.
- `results[].membership` (Membership or null): Affected membership, or null when this entry failed.
- `results[].errors` (array of ErrorItem, required): Structured errors; empty for a successful bulk entry.
- `meta` (object, required): Metadata describing this page or bulk operation.
- `meta.total` (integer, required): Number of submitted entries.
- `meta.succeeded` (integer, required): Number of entries that succeeded.
- `meta.failed` (integer, required): Number of entries that failed.

### Error

Standard error envelope returned by every error response the API renders. An unhandled 500 is built outside the API and carries Rails' default JSON error instead.

- `errors` (array of ErrorItem, required): Structured errors; empty for a successful bulk entry.
- `request_id` (string, required): Identifies the request. Include it when contacting support.

### MembershipEntry

Names a current user by exactly one of `user_id` (Tayl UUID) or `user_external_id` (yours). Entries in one request can mix them. Each entry is checked on its own, so a malformed identifier, an archived user, or an entry naming both identifiers or neither fails with its own 422, never the whole request.

- `user_id` (uuid): UUID of the learner or organisation user.
- `user_external_id` (ExternalId, at least 1 character): Caller-owned identifier of the learner, when set.

### GroupCategoryList

One ordered page of group categories and its pagination metadata.

- `group_categories` (array of GroupCategory, required): Group categories on this page.
- `meta` (Meta, required): Metadata describing this page or bulk operation.

### GroupCategory

A group category, one of the ways the organisation sorts its groups, such as Department or Location. The system "Automatic" category is read-only.

- `id` (uuid, required): Tayl UUID.
- `external_id` (NullableExternalId, required): Caller-owned identifier used to reconcile this record with the source system.
- `name` (string, required): Human-readable name shown in Tayl.
- `description` (string or null, required): Optional explanatory text shown with the resource.
- `colour` (CategoryColour, required): Named colour used to distinguish the category in Tayl.
- `icon` (CategoryIcon, required): Named icon used to represent the category in Tayl.
- `position` (integer, required): Zero-based display order within the organisation's categories.
- `automatic` (boolean, required): Whether Tayl maintains it automatically, so it can't be changed by hand or through the API.
- `created_at` (date-time, required): When the record was created, as an ISO 8601 UTC timestamp.
- `updated_at` (date-time, required): When the represented record last changed, as an ISO 8601 UTC timestamp.

### CategoryColour

One of Tayl's category colours. One of `"gray"`, `"slate"`, `"red"`, `"orange"`, `"amber"`, `"yellow"`, `"lime"`, `"green"`, `"teal"`, `"blue"`, `"indigo"`, `"purple"`, `"pink"`.

### CategoryIcon

One of Tayl's category icons. One of `"tag"`, `"badge"`, `"badge-check"`, `"book"`, `"briefcase"`, `"briefcase-business"`, `"briefcase-medical"`, `"brush"`, `"building"`, `"camera"`, `"chart-line"`, `"clipboard-check"`, `"clipboard-list"`, `"clock"`, `"droplet"`, `"film"`, `"flame"`, `"flask-conical"`, `"globe"`, `"graduation-cap"`, `"hand-heart"`, `"headset"`, `"heart"`, `"hotel"`, `"id-card"`, `"laptop"`, `"leaf"`, `"lightbulb"`, `"map-pin"`, `"map-pinned"`, `"palette"`, `"pencil"`, `"puzzle"`, `"scale"`, `"settings"`, `"shield"`, `"sparkles"`, `"star"`, `"store"`, `"truck"`, `"users"`, `"utensils"`, `"wrench"`.

### GroupCategoryInput

Fields accepted when adding an organisation taxonomy category.

- `name` (string, required): Human-readable name shown in Tayl.
- `description` (string or null): Optional explanatory text shown with the resource.
- `colour` (CategoryColour): Named colour used to distinguish the category in Tayl.
- `icon` (CategoryIcon): Named icon used to represent the category in Tayl.
- `external_id` (NullableExternalId): Caller-owned identifier used to reconcile this record with the source system.

### GroupCategoryUpdateInput

Fields you leave out keep their values.

- `name` (string): Human-readable name shown in Tayl.
- `description` (string or null): Optional explanatory text shown with the resource.
- `colour` (CategoryColour): Named colour used to distinguish the category in Tayl.
- `icon` (CategoryIcon): Named icon used to represent the category in Tayl.
- `external_id` (NullableExternalId): Caller-owned identifier used to reconcile this record with the source system.
