# Clients & contacts

Read and manage client organisations and their contacts.

14 operation(s) for tokens, 5 app-only. The full schemas are in [openapi.json](https://docs.youniton.com/openapi.json) (search the operation ID).

## The directory and the organisation picker

`GET /client-organisations`

- Operation ID: `listClientOrganisations`
- Call with: Personal access token, ability `relationships:read`
- Feature: F-REL-01

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `q` | query | string | no |  |
| `filter[status]` | query | string | no |  |
| `filter[pinned]` | query | string | no | F-REL-01.R20: true keeps only the organisations that the reader pinned (`/me/client-pins`). |
| `page[number]` | query | integer | no |  |
| `page[size]` | query | integer | no |  |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | The visible organisations with totals and segment counts. | application/json | `object` |
| 400 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Create a client organisation

`POST /client-organisations`

- Operation ID: `createClientOrganisation`
- Call with: Personal access token, ability `relationships:write`
- Feature: F-REL-01

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `Idempotency-Key` | header | string | yes | Durable command receipt key (05-api §7.2); the generated client sends one UUIDv7 per user intent. |

Request body (application/json, required): `ClientOrganisationCreateRequest`

| Status | Description | Content type | Type |
|---|---|---|---|
| 201 | The new organisation. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 422 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## The client card — details, counts and the reader's projects

`GET /client-organisations/{organisationId}`

- Operation ID: `getClientCard`
- Call with: Personal access token, ability `relationships:read`
- Feature: F-REL-01

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `organisationId` | path | string (uuid) | yes |  |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | The card; the ETag carries the version. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Rename an organisation or change its website

`PATCH /client-organisations/{organisationId}`

- Operation ID: `updateClientOrganisation`
- Call with: Personal access token, ability `relationships:write`
- Feature: F-REL-01

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `organisationId` | path | string (uuid) | yes |  |
| `If-Match` | header | string | yes | The resource version in quotes (05-api §7.1); missing answers 428, different answers 412. |

Request body (application/merge-patch+json, required): `ClientOrganisationPatch`

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | The updated organisation. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 412 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 422 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 428 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Archive an organisation — hidden from pickers, every reference kept

`POST /client-organisations/{organisationId}/archive`

- Operation ID: `archiveClientOrganisation`
- Call with: Personal access token, ability `relationships:write`
- Feature: F-REL-01

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `organisationId` | path | string (uuid) | yes |  |
| `If-Match` | header | string | yes | The resource version in quotes (05-api §7.1); missing answers 428, different answers 412. |
| `Idempotency-Key` | header | string | yes | Durable command receipt key (05-api §7.2); the generated client sends one UUIDv7 per user intent. |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | The archived organisation. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 409 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 412 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 428 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## The contacts of an organisation with their portal status — the card's table

`GET /client-organisations/{organisationId}/contacts`

- Operation ID: `listOrganisationContacts`
- Call with: Personal access token, ability `relationships:read`
- Feature: F-REL-02

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `organisationId` | path | string (uuid) | yes |  |
| `q` | query | string | no |  |
| `filter[status]` | query | string | no |  |
| `page[number]` | query | integer | no |  |
| `page[size]` | query | integer | no |  |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | A page of contacts by name. | application/json | `ContactPage` |
| 400 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Add a contact to an organisation

`POST /client-organisations/{organisationId}/contacts`

- Operation ID: `createContact`
- Call with: Personal access token, ability `relationships:write`
- Feature: F-REL-02

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `organisationId` | path | string (uuid) | yes |  |
| `Idempotency-Key` | header | string | yes | Durable command receipt key (05-api §7.2); the generated client sends one UUIDv7 per user intent. |

Request body (application/json, required): `ContactCreateRequest`

| Status | Description | Content type | Type |
|---|---|---|---|
| 201 | The new contact. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 409 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 422 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## The projects of an organisation in the reader's scope, past the card's first 25

`GET /client-organisations/{organisationId}/projects`

- Operation ID: `listClientProjects`
- Call with: Personal access token, ability `relationships:read`
- Feature: F-REL-01

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `organisationId` | path | string (uuid) | yes |  |
| `page[cursor]` | query | string | no | The opaque cursor of the previous page's links.next (05-api §5). |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | A page of at most 50 projects by name. | application/json | `ClientProjectPage` |
| 400 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Restore an archived organisation

`POST /client-organisations/{organisationId}/restore`

- Operation ID: `restoreClientOrganisation`
- Call with: Personal access token, ability `relationships:write`
- Feature: F-REL-01

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `organisationId` | path | string (uuid) | yes |  |
| `If-Match` | header | string | yes | The resource version in quotes (05-api §7.1); missing answers 428, different answers 412. |
| `Idempotency-Key` | header | string | yes | Durable command receipt key (05-api §7.2); the generated client sends one UUIDv7 per user intent. |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | The restored organisation. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 409 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 412 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 428 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## The contact picker across the organisations the caller may see

`GET /contacts`

- Operation ID: `searchContacts`
- Call with: Personal access token, ability `relationships:read`
- Feature: F-REL-02

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `q` | query | string | no |  |
| `filter[organisationId]` | query | string (uuid) | no |  |
| `filter[projectKey]` | query | string | no |  |
| `filter[status]` | query | string | no |  |
| `page[number]` | query | integer | no |  |
| `page[size]` | query | integer | no |  |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | Matching contacts with their organisation. | application/json | `ContactPickerPage` |
| 400 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## The contact panel

`GET /contacts/{contactId}`

- Operation ID: `getContact`
- Call with: Personal access token, ability `relationships:read`
- Feature: F-REL-02

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `contactId` | path | string (uuid) | yes |  |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | The contact with its organisation, linked guest and portal entries; the ETag carries the version. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Edit a contact — name and e-mail only while unlinked

`PATCH /contacts/{contactId}`

- Operation ID: `updateContact`
- Call with: Personal access token, ability `relationships:write`
- Feature: F-REL-02

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `contactId` | path | string (uuid) | yes |  |
| `If-Match` | header | string | yes | The resource version in quotes (05-api §7.1); missing answers 428, different answers 412. |

Request body (application/merge-patch+json, required): `ContactPatch`

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | The updated contact. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 409 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 412 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 422 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 428 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Archive a contact — hidden from pickers, link and access kept

`POST /contacts/{contactId}/archive`

- Operation ID: `archiveContact`
- Call with: Personal access token, ability `relationships:write`
- Feature: F-REL-02

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `contactId` | path | string (uuid) | yes |  |
| `If-Match` | header | string | yes | The resource version in quotes (05-api §7.1); missing answers 428, different answers 412. |
| `Idempotency-Key` | header | string | yes | Durable command receipt key (05-api §7.2); the generated client sends one UUIDv7 per user intent. |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | The archived contact. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 409 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 412 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 428 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Restore an archived contact

`POST /contacts/{contactId}/restore`

- Operation ID: `restoreContact`
- Call with: Personal access token, ability `relationships:write`
- Feature: F-REL-02

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | no | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `contactId` | path | string (uuid) | yes |  |
| `If-Match` | header | string | yes | The resource version in quotes (05-api §7.1); missing answers 428, different answers 412. |
| `Idempotency-Key` | header | string | yes | Durable command receipt key (05-api §7.2); the generated client sends one UUIDv7 per user intent. |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | The restored contact. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 409 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 412 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 422 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 428 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Delete an organisation that nothing refers to

`DELETE /client-organisations/{organisationId}`

- Operation ID: `deleteClientOrganisation`
- Call with: Session of the Youniton apps (app only)
- Feature: F-REL-01

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | yes | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `organisationId` | path | string (uuid) | yes |  |

| Status | Description | Content type | Type |
|---|---|---|---|
| 204 | Deleted. |  |  |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 409 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## CSV of a selection of contacts or of a filtered set

`POST /contacts/export`

- Operation ID: `exportContacts`
- Call with: Session of the Youniton apps (app only)
- Feature: F-REL-08

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | yes | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `Idempotency-Key` | header | string | yes | Durable command receipt key (05-api §7.2); the generated client sends one UUIDv7 per user intent. |

Request body (application/json, required): `ContactExportRequest`

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | A streamed text/csv attachment (up to 100,000 rows); the audit record was committed before the first byte. | text/csv | `string` |
| 202 | An export operation for larger sets; its result is the file id and row count, read with GET /operations/{id}. | application/json | `object` |
| 400 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 409 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 422 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 429 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Erase a contact — irreversible

`POST /contacts/{contactId}/erase`

- Operation ID: `eraseContact`
- Call with: Session of the Youniton apps (app only)
- Feature: F-REL-08

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | yes | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `contactId` | path | string (uuid) | yes |  |
| `Idempotency-Key` | header | string | yes | Durable command receipt key (05-api §7.2); the generated client sends one UUIDv7 per user intent. |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | The erased contact's pseudonym and whether the certificate has been recorded; a repeat returns the same. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 503 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## Invite a contact to a project's client portal

`POST /contacts/{contactId}/invite`

- Operation ID: `inviteContactToPortal`
- Call with: Session of the Youniton apps (app only)
- Feature: F-REL-03

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | yes | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `contactId` | path | string (uuid) | yes |  |
| `Idempotency-Key` | header | string | yes | Durable command receipt key (05-api §7.2); the generated client sends one UUIDv7 per user intent. |

Request body (application/json, required): `ContactInviteRequest`

| Status | Description | Content type | Type |
|---|---|---|---|
| 201 | The invitation was created, or resent. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 409 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 422 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 429 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |

## The projects a contact can be invited to, with their client versions and the contact's state on each

`GET /contacts/{contactId}/invite-options`

- Operation ID: `getContactInviteOptions`
- Call with: Session of the Youniton apps (app only)
- Feature: F-REL-03

| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
| `X-Kanso-Tenant` | header | string (uuid) | yes | The tenant id of the call (05-api §8.3); unknown, foreign or inactive answers 404 tenant.not_found. |
| `contactId` | path | string (uuid) | yes |  |

| Status | Description | Content type | Type |
|---|---|---|---|
| 200 | Eligibility, the reason when there is none, and the eligible projects. | application/json | `object` |
| 403 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
| 404 | A problem (application/problem+json); the code names the reason. | application/problem+json | `Problem` |
