# Gateway

> Organizations, keys, models, spend and the module registry.

## Create tenant

`POST /v1/tenants`

Sign up: create a tenant, its first user and an API key (shown once). The person's personal organization is made too (`personal` in the answer); `personal: true` without a name makes only the personal organization and returns its key.

Permission: `public` (Anyone, signed in or not).

### Request body (application/json, required)

- `name` (string) [max length 80]
- `email` (string)
- `personal` (boolean): Make only your personal organization (no name needed)

### Responses

- `201` Created (application/json, CreateTenantResponse)
  - `tenant` (object)
    - `id` (string)
    - `name` (string)
    - `budgetUsd` (number)
    - `kind` ("company" | "personal"): A company organization, or a person's own personal organization (one per person, one member)
    - `slug` (string): A personal organization's slug
  - `user` (object)
    - `id` (string)
    - `email` (string)
  - `apiKey` (string)
  - `personal` (OrgSummary): Your personal organization, made with the company organization
    - `id` (string, required)
    - `name` (string, required)
    - `slug` (string)
    - `clerkOrgId` (string): Its sign-in provider organization's id: Nexus UI's URL segment when it has no slug
    - `kind` ("company" | "personal", required): A company organization, or a person's own personal organization (one per person, one member)
    - `role` ("owner" | "admin" | "member")
    - `current` (boolean): The organization this request is in
    - `imageUrl` (string): Its logo, as the tenant's imageUrl (https://img.clerk.com/…); unset when it has none.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/tenants" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Platform",
    "email": "ada@example.com",
    "personal": false
  }'
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.createTenant("Acme");
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Ftenants)

## Current tenant

`GET /v1/tenants/me`

The calling token's organization (id, name, slug), the person and their role and permissions.

Permission: `org.read` (Every member).

### Responses

- `200` OK (application/json, CurrentTenantResponse)
  - `tenant` (object, required)
    - `id` (string, required)
    - `name` (string, required)
    - `createdAt` (string (date-time), required)
    - `slug` (string)
    - `kind` ("company" | "personal"): A company organization, or a person's own personal organization (one per person, one member)
    - `imageUrl` (string): The organization's logo, as Clerk serves it (https://img.clerk.com/…); unset when it has none.
    - `mark` ("staff" | "test" | "demo"): Set only when it is Nexus's own; unset for a customer's.
  - `user` (object): The person calling, when the key is a person's
    - `id` (string, required)
    - `email` (string)
    - `name` (string)
    - `mark` ("staff" | "test" | "demo"): Set only when it is Nexus's own; unset for a customer's.
  - `teams` (array of object): Your teams in this organization
    - `id` (string)
    - `slug` (string)
    - `name` (string)
    - `role` ("lead" | "member"): `lead` is reserved for the planned team-lead role and grants nothing extra yet.
  - `team` (object): Your default team
    - `id` (string)
    - `slug` (string)
    - `name` (string)
  - `features` (GatewayFeatures): The products this Gateway has on. Unset reads as all off.
    - `wiki` (boolean, required): Nexus Wiki is on. Off, its routes and Ask your code answer 404 wiki_off, and clients hide them.
    - `apps` (boolean): Nexus Apps (`NEXUS_APPS_ENABLED`): `nexus apps` and /v1/apps. An older Gateway leaves it out: off.
    - `agentSessionAudit` (boolean): Coding agent sessions write agent_session.started and agent_session.ended audit events (`NEXUS_AUDIT_AGENT_SESSIONS`). An older Gateway leaves it out: off.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/tenants/me" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.me();
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Ftenants%2Fme)

## List provider keys

`GET /v1/keys/providers`

List the tenant's own provider keys (last four characters only).

Permission: `org.read` (Every member).

### Responses

- `200` OK (application/json, object)
  - `providers` (array of ProviderKey): The organization's own keys.
    - `provider` (string)
    - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own.
    - `scopeId` (string): The team's or the person's id.
    - `last4` (string)
    - `createdAt` (string (date-time))
    - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it.
    - `checkedAt` (string (date-time))
    - `lastUsedOn` (string (date)): The UTC day a call last used the key.
    - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`.
      - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement.
      - `last4` (string, required)
      - `addedAt` (string (date-time), required)
      - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys.
  - `scopedKeys` (array of ProviderKey): The keys the organization's teams and people hold. An owner or admin reads every one; anyone else reads the teams' keys and their own. Absent when there is none. A call takes the caller's own key, then its team's, then each parent team's, then the organization's: the first one that is not disabled.
    - `provider` (string)
    - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own.
    - `scopeId` (string): The team's or the person's id.
    - `last4` (string)
    - `createdAt` (string (date-time))
    - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it.
    - `checkedAt` (string (date-time))
    - `lastUsedOn` (string (date)): The UTC day a call last used the key.
    - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`.
      - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement.
      - `last4` (string, required)
      - `addedAt` (string (date-time), required)
      - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/keys/providers" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.listProviderKeys();
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fkeys%2Fproviders)

## Add provider key

`POST /v1/keys/providers`

Store a provider key (BYOK), encrypted at rest. Used for this tenant's calls only.

Permission: `provider_keys.manage` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json, required)

- `provider` ("anthropic" | "openai", required)
- `key` (string, required)
- `team` (string): A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key.
- `user` (string): A person's key: `me` or a member's id. Name a team or a user, not both: both are a 400, and one the organization lacks is a 404.

### Responses

- `201` Created (application/json, ProviderKey)
  - `provider` (string)
  - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own.
  - `scopeId` (string): The team's or the person's id.
  - `last4` (string)
  - `createdAt` (string (date-time))
  - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it.
  - `checkedAt` (string (date-time))
  - `lastUsedOn` (string (date)): The UTC day a call last used the key.
  - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`.
    - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement.
    - `last4` (string, required)
    - `addedAt` (string (date-time), required)
    - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys.
- `400` Not valid: a provider not in the list (`provider_retired` for a retired one), a key not 8 to 512 characters once surrounding whitespace is trimmed, or both `team` and `user`. `provider_key_invalid_character`: the trimmed key holds a character outside visible ASCII, such as a space, a line break, a terminal's paste marker or an invisible mark, so it is never sent or stored. A NUL is refused before that as `nul_in_string`. `provider_key_rejected`: the provider refused the key when it was checked, and nothing is stored. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | Not valid: a provider not in the list (`provider_retired` for a retired one), a key not 8 to 512 characters once surrounding whitespace is trimmed, or both `team` and `user`. `provider_key_invalid_character`: the trimmed key holds a character outside visible ASCII, such as a space, a line break, a terminal's paste marker or an invisible mark, so it is never sent or stored. A NUL is refused before that as `nul_in_string`. `provider_key_rejected`: the provider refused the key when it was checked, and nothing is stored. |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/keys/providers" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "anthropic",
    "key": "<key>"
  }'
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.addProviderKey("anthropic", process.env.ANTHROPIC_API_KEY ?? "");
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fkeys%2Fproviders)

## Get provider key

`GET /v1/keys/providers/{provider}`

One provider key, in any state, with its versions: who added each, when, and its last four characters, never the value. 404 `provider_key_not_found` when none was ever stored.

Permission: `org.read` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `provider` | path | string | yes | The key's provider (`anthropic`, `openai`) |
| `team` | query | string | no | A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key. |
| `user` | query | string | no | A person's key: `me` or a member's id. Another person's key is an owner's or admin's to read: anyone else gets a 403. |

### Responses

- `200` OK (application/json, ProviderKey)
  - `provider` (string)
  - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own.
  - `scopeId` (string): The team's or the person's id.
  - `last4` (string)
  - `createdAt` (string (date-time))
  - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it.
  - `checkedAt` (string (date-time))
  - `lastUsedOn` (string (date)): The UTC day a call last used the key.
  - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`.
    - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement.
    - `last4` (string, required)
    - `addedAt` (string (date-time), required)
    - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 | `provider_key_not_found` | 404 `provider_key_not_found` when none was ever stored |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/keys/providers/anthropic" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fkeys%2Fproviders%2F%7Bprovider%7D)

## Replace provider key

`POST /v1/keys/providers/{provider}/replace`

Replace the stored provider key with `key`, checked against its provider first, as its next version. A disabled key stays disabled. 404 `provider_key_not_found` when none is stored, before the key is sent anywhere; 400 `provider_key_invalid_character` when the trimmed key holds a character outside visible ASCII, and nothing is sent; 400 `provider_key_rejected` when the provider refuses it, and the stored key stays. With `dryRun: true`, the key is checked and nothing is stored. Audited as `provider_key.replaced`.

Permission: `provider_keys.manage` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `provider` | path | string | yes | The key's provider (`anthropic`, `openai`) |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json, required)

- `key` (string, required)
- `dryRun` (boolean): Check and change nothing. [default false]
- `team` (string): A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key.
- `user` (string): A person's key: `me` or a member's id. Name a team or a user, not both: both are a 400, and one the organization lacks is a 404.

### Responses

- `200` OK (application/json, ProviderKeyChange)
  - `dryRun` (boolean, required)
  - `changed` (boolean, required): False when the key was already in the state asked for, so nothing was written.
  - `providerKey` (ProviderKey, required): The key after the change, or as it would be after a dry run.
    - `provider` (string)
    - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own.
    - `scopeId` (string): The team's or the person's id.
    - `last4` (string)
    - `createdAt` (string (date-time))
    - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it.
    - `checkedAt` (string (date-time))
    - `lastUsedOn` (string (date)): The UTC day a call last used the key.
    - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`.
      - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement.
      - `last4` (string, required)
      - `addedAt` (string (date-time), required)
      - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 | `provider_key_invalid_character` | 404 `provider_key_not_found` when none is stored, before the key is sent anywhere; 400 `provider_key_invalid_character` when the trimmed key holds a character outside visible ASCII, and nothing is sent; 400 `provider_key_rejected` when the provider refuses it, and the stored key stays |
| 400 | `provider_key_rejected` | 404 `provider_key_not_found` when none is stored, before the key is sent anywhere; 400 `provider_key_invalid_character` when the trimmed key holds a character outside visible ASCII, and nothing is sent; 400 `provider_key_rejected` when the provider refuses it, and the stored key stays |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 | `provider_key_not_found` | 404 `provider_key_not_found` when none is stored, before the key is sent anywhere; 400 `provider_key_invalid_character` when the trimmed key holds a character outside visible ASCII, and nothing is sent; 400 `provider_key_rejected` when the provider refuses it, and the stored key stays |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/keys/providers/anthropic/replace" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "key": "<key>"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fkeys%2Fproviders%2F%7Bprovider%7D%2Freplace)

## Disable provider key

`POST /v1/keys/providers/{provider}/disable`

Disable the stored provider key: it stays sealed, and no call opens it until it is enabled. Disabling a disabled key answers `changed: false`. 404 `provider_key_not_found` when none is stored. With `dryRun: true`, nothing changes. Audited as `provider_key.disabled`.

Permission: `provider_keys.manage` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `provider` | path | string | yes | The key's provider (`anthropic`, `openai`) |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json)

- `dryRun` (boolean): Check and change nothing. [default false]
- `team` (string): A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key.
- `user` (string): A person's key: `me` or a member's id. Name a team or a user, not both: both are a 400, and one the organization lacks is a 404.

### Responses

- `200` OK (application/json, ProviderKeyChange)
  - `dryRun` (boolean, required)
  - `changed` (boolean, required): False when the key was already in the state asked for, so nothing was written.
  - `providerKey` (ProviderKey, required): The key after the change, or as it would be after a dry run.
    - `provider` (string)
    - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own.
    - `scopeId` (string): The team's or the person's id.
    - `last4` (string)
    - `createdAt` (string (date-time))
    - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it.
    - `checkedAt` (string (date-time))
    - `lastUsedOn` (string (date)): The UTC day a call last used the key.
    - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`.
      - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement.
      - `last4` (string, required)
      - `addedAt` (string (date-time), required)
      - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 | `provider_key_not_found` | 404 `provider_key_not_found` when none is stored |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/keys/providers/anthropic/disable" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "dryRun": false,
    "team": "platform",
    "user": "<user>"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fkeys%2Fproviders%2F%7Bprovider%7D%2Fdisable)

## Enable provider key

`POST /v1/keys/providers/{provider}/enable`

Enable a disabled provider key, or check a rejected one again, after checking it against its provider: its state is what the provider answers. 400 `provider_key_rejected` when the provider still refuses it, and it stays as it was. 400 `provider_key_invalid_character` when the stored key holds a character outside visible ASCII: it is not sent, and only a replacement mends it. Enabling a key that is neither disabled nor rejected answers `changed: false`. 409 `provider_key_changed` when the key was replaced while it was checked. With `dryRun: true`, the key is checked and nothing changes. Audited as `provider_key.enabled`.

Permission: `provider_keys.manage` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `provider` | path | string | yes | The key's provider (`anthropic`, `openai`) |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json)

- `dryRun` (boolean): Check and change nothing. [default false]
- `team` (string): A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key.
- `user` (string): A person's key: `me` or a member's id. Name a team or a user, not both: both are a 400, and one the organization lacks is a 404.

### Responses

- `200` OK (application/json, ProviderKeyChange)
  - `dryRun` (boolean, required)
  - `changed` (boolean, required): False when the key was already in the state asked for, so nothing was written.
  - `providerKey` (ProviderKey, required): The key after the change, or as it would be after a dry run.
    - `provider` (string)
    - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own.
    - `scopeId` (string): The team's or the person's id.
    - `last4` (string)
    - `createdAt` (string (date-time))
    - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it.
    - `checkedAt` (string (date-time))
    - `lastUsedOn` (string (date)): The UTC day a call last used the key.
    - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`.
      - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement.
      - `last4` (string, required)
      - `addedAt` (string (date-time), required)
      - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 | `provider_key_rejected` | 400 `provider_key_rejected` when the provider still refuses it, and it stays as it was |
| 400 | `provider_key_invalid_character` | 400 `provider_key_invalid_character` when the stored key holds a character outside visible ASCII: it is not sent, and only a replacement mends it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 409 | `provider_key_changed` | 409 `provider_key_changed` when the key was replaced while it was checked |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/keys/providers/anthropic/enable" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "dryRun": false,
    "team": "platform",
    "user": "<user>"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fkeys%2Fproviders%2F%7Bprovider%7D%2Fenable)

## Remove provider key

`POST /v1/keys/providers/{provider}/remove`

Remove the stored provider key: its sealed value is deleted, its state is `removed`, and its versions stay. 404 `provider_key_not_found` when none is stored. With `dryRun: true`, nothing changes. Audited as `provider_key.removed`.

Permission: `provider_keys.manage` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `provider` | path | string | yes | The key's provider (`anthropic`, `openai`) |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json)

- `dryRun` (boolean): Check and change nothing. [default false]
- `team` (string): A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key.
- `user` (string): A person's key: `me` or a member's id. Name a team or a user, not both: both are a 400, and one the organization lacks is a 404.

### Responses

- `200` OK (application/json, ProviderKeyChange)
  - `dryRun` (boolean, required)
  - `changed` (boolean, required): False when the key was already in the state asked for, so nothing was written.
  - `providerKey` (ProviderKey, required): The key after the change, or as it would be after a dry run.
    - `provider` (string)
    - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own.
    - `scopeId` (string): The team's or the person's id.
    - `last4` (string)
    - `createdAt` (string (date-time))
    - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it.
    - `checkedAt` (string (date-time))
    - `lastUsedOn` (string (date)): The UTC day a call last used the key.
    - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`.
      - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement.
      - `last4` (string, required)
      - `addedAt` (string (date-time), required)
      - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 | `provider_key_not_found` | 404 `provider_key_not_found` when none is stored |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/keys/providers/anthropic/remove" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "dryRun": false,
    "team": "platform",
    "user": "<user>"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fkeys%2Fproviders%2F%7Bprovider%7D%2Fremove)

## Chat completion

`POST /v1/chat/completions`

OpenAI-compatible chat completion. Policy check, then the call's maximum cost is reserved against the budget, the provider is called, and the reservation settles on reported usage (also on errors). Model `nexus/auto` lets Gateway choose. `model` is a catalog id (any spelling), `nexus/auto` or `nexus/default` (the effective default within policy); the answer's `model` and `x-nexus-model` header say which model ran. An answer the auto router picked also names the router version in `x-nexus-router` and in `nexus.router`. A refused model: 403 `model_not_allowed` (policy, naming the level and rule), 404 `model_not_found`, 400 `model_not_supported` (coming soon); never sent upstream or reserved, recorded as a refused call. Who pays: the organization's own key; Nexus's own key for Nexus's own organizations; Nexus credit only for a module run's scoped key (a Nexus feature, such as a Wiki or Review run). Any other caller with no key of its own gets 403 `provider_key_required`, never Nexus credit. Tools (OpenAI's `tools`, `tool_choice`, `parallel_tool_calls`, an assistant's `tool_calls` and `tool` messages) work for Anthropic and OpenAI models alike, translated by Gateway. `stream: true` answers as server-sent events in OpenAI's `chat.completion.chunk` shape (the role, then text and tool-call pieces, a chunk with `finish_reason`, a last chunk with no choices and the `usage` and `nexus` cost, then `data: [DONE]`; a failure after the stream started is a `data: {"error": …}` event), so agent tools that speak Chat Completions (opencode's `@ai-sdk/openai-compatible` and the like) use `<gateway>/v1` as their provider. A stream is checked, reserved and refused exactly as a call that does not stream, and settles however it ends: on the reported usage, or on what streamed when the provider fails or the caller goes away.

Permission: `models.use` (Every member, module keys).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `x-nexus-team` | header | string | no | The team (slug) this call's spend goes to; you must be in it. Default: your default team. |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json, required)

- `model` (string, required)
- `messages` (array of ChatMessage, required)
  - `role` ("system" | "developer" | "user" | "assistant" | "tool", required): `developer` is taken as `system`. Answers are always `assistant`.
  - `content` (string | array of object | null): The text, or OpenAI's content parts: `{type: "text", text}` (joined) and, in a person's message, `{type: "image_url", image_url: {url}}` with a `data:` URL (Gateway fetches no URLs). An assistant turn that only calls tools may leave it out or send null. Answers carry a string.
  - `tool_calls` (array of ToolCall): The tools an assistant turn called (in an answer: when `finish_reason` is `tool_calls`).
    - `id` (string, required)
    - `type` ("function", required)
    - `function` (object, required)
      - `name` (string, required)
      - `arguments` (string, required): A JSON object, as a string.
  - `tool_call_id` (string): A `tool` message: the call it answers.
- `max_tokens` (integer): At most the lower of the deployment's cap (`NEXUS_MAX_TOKENS`) and the model's `max_output_tokens`; above it is a 400 `output_over_limit` before anything is reserved, with `error.nexus.limit`. A call skips a host whose output limit is below it; when no host it may use takes it, the same 400 names the largest limit of those hosts. A call also skips a host that does not read the call's images (400 `model_no_image_input` when no host does) and a host that does not take its `reasoning_effort` (400 `reasoning_effort_not_offered`). A host whose own context window may be too small for the prompt and `max_tokens` is tried after the hosts that surely hold them. Absent: the model's chat default, within that cap. [min 1]
- `temperature` (number)
- `stream` (boolean): Answer as server-sent events (`ChatCompletionChunk`). Absent or null: no stream. A value that is not a boolean is a 400 (`stream must be true or false`).
- `stream_options` (object): Accepted for compatibility; a stream always ends with its usage chunk.
  - `include_usage` (boolean)
- `tools` (array of object): Functions the model may call, in OpenAI's shape; translated for Anthropic models.
  - `type` ("function", required)
  - `function` (object, required)
    - `name` (string, required)
    - `description` (string)
    - `parameters` (object): A JSON Schema; `{"type": "object"}` when left out.
- `tool_choice` ("auto" | "none" | "required" | object): `auto` (the default), `none`, `required`, or one function by name (it must be in `tools`). `required` or a function on a model that does not take a forced choice is 400 `tool_choice_not_offered`, before anything is reserved.
- `parallel_tool_calls` (boolean): `false`: at most one tool call per answer.
- `reasoning_effort` (string): One of the model's `reasoning.efforts` (GET /v1/models). Absent: the provider's default. An effort the model does not offer is a 400 `reasoning_effort_not_offered` before anything is reserved; `error.nexus.offered` lists the model's efforts.
- `response_format` (object): OpenAI's `response_format`, sent on as written when the model offers its `type` (`text`, `json_object` or `json_schema`). A type the model does not offer is a 400 `response_format_not_offered` before anything is reserved; `error.nexus.offered` lists the model's types.
  - `type` (string, required)

### Responses

- `200` OK: the answer, or with `stream: true` its server-sent events (application/json, ChatCompletionResponse)
  - `id` (string)
  - `object` ("chat.completion")
  - `created` (integer)
  - `model` (string)
  - `choices` (array of object)
    - `index` (integer)
    - `message` (ChatMessage)
      - `role` ("system" | "developer" | "user" | "assistant" | "tool", required): `developer` is taken as `system`. Answers are always `assistant`.
      - `content` (string | array of object | null): The text, or OpenAI's content parts: `{type: "text", text}` (joined) and, in a person's message, `{type: "image_url", image_url: {url}}` with a `data:` URL (Gateway fetches no URLs). An assistant turn that only calls tools may leave it out or send null. Answers carry a string.
      - `tool_calls` (array of ToolCall): The tools an assistant turn called (in an answer: when `finish_reason` is `tool_calls`).
        - `id` (string, required)
        - `type` ("function", required)
        - `function` (object, required)
          - `name` (string, required)
          - `arguments` (string, required): A JSON object, as a string.
      - `tool_call_id` (string): A `tool` message: the call it answers.
    - `finish_reason` (string): Stop, length, or refusal when the provider declined to answer; its words are in nexus.refusal.
  - `usage` (object)
    - `prompt_tokens` (integer)
    - `completion_tokens` (integer)
    - `total_tokens` (integer)
  - `nexus` (object): What the call cost and who it was attributed to.
    - `cost_usd` (number)
    - `product` (string)
    - `capability` (string)
    - `provider` (string)
    - `funded_by` ("own_key" | "nexus_key" | "nexus_subsidy" | "nexus_credit" | "nexus_invoiced"): Who paid the provider. own_key: the organization's own key; nexus_key: Nexus's own key, for Nexus's own organizations; nexus_subsidy: a Nexus subsidy; nexus_credit: the organization's prepaid Nexus credits, charged the cost plus Nexus's rate; nexus_invoiced: an organization under contract, billed the cost plus Nexus's rate on its month's invoice. Unset on the mock provider
    - `refusal` (string): The provider's words when it declined to answer (a safety refusal); set exactly when finish_reason is "refusal". Billed as the provider billed it.
    - `router` (object): The auto router's pick, on an answer it routed or a chat session held. The answer also carries the header x-nexus-router with the version. Unset on every other answer. The pick's cost estimates stay on the spend record.
      - `version` (string, required): The router version that acted, e.g. auto-v0.0.1.
      - `class` ("light" | "standard" | "heavy"): The request's class. Unset on a held pick.
      - `reason` ("cheapest" | "below_floor" | "catalog_order"): Why the version chose its model. Unset on a held pick.
      - `held` (boolean, required): The chat session held its model, with no router run.
      - `default_model` (string): The model nexus/auto resolves to for the caller with no router.
      - `effort` (string): The reasoning effort the call ran at: the request's own reasoning_effort, else the one the router version picked. Unset when the call ran at the model's default.
- `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `402` The call's maximum cost is more than the budget left (`budget_exceeded`; `subsidy_exhausted` for the Nexus subsidy, or `credit_exhausted` for the organization's prepaid credits), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. (application/json, Error & object)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
  - `error` (object)
    - `nexus` (BudgetRefusal): The details (`error.nexus`) of a 402 `budget_exceeded` or `subsidy_exhausted`. Each money figure comes as its number (deprecated) and its exact decimal twin (`requestedUsd`, `requestedUsdDecimal`). A refusal below the person level names only what is left and what was asked, never a limit above the caller. `credit_exhausted` sends `remainingUsd` and `requestedUsd` as decimal strings already, without twins.
      - `level` ("organization" | "team" | "person" | "product"): The level whose limit refused the call (`budget_exceeded`)
      - `period` (string): The period the refusal counted in: `2026-10`, `2026-W44` or `2026-10-21`
      - `resetsAt` (string (date-time)): When the period ends (UTC)
      - `source` ("override" | "default"): Person level only: whether the limit was set for them or is the organization's default per person
      - `limitUsd` (number): Person level only: their monthly limit. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9).
      - `limitUsdDecimal` (string): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`.
      - `spentUsd` (number): Person level only: what they spent this month. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9).
      - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`.
      - `reservedUsd` (number): Person level only: what their calls in flight hold. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9).
      - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`.
      - `remainingUsd` (number): Every level, and `subsidy_exhausted`: what is left, never below 0. Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9).
      - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`.
      - `requestedUsd` (number): What the call may cost at most, the amount it asked to hold. Deprecated: read `requestedUsdDecimal`, the exact decimal string (root rule 9).
      - `requestedUsdDecimal` (string): `requestedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `requestedUsd`.
      - `notified` (boolean): `budget_exceeded`: true once Gateway has told the refused person and the organization's owners and admins
      - `fundedBy` (string): `subsidy_exhausted`: who funds the subsidy (`nexus`)
      - `next` (array of string): `subsidy_exhausted`: what the caller can do next (`billing`, `own_key`)
- `403` The caller may not do this: for example, the role does not have the permission (`role_required`), or the team named is not the caller's (`not_in_team`). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `404` Nothing matches. A path parameter outside its pattern is a 404 "no such endpoint", before the credential is checked. A team named that does not exist is `unknown_team`. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `408` The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `409` The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `413` The request body is over the operation's limit (`request_too_large`): 1,000,000 bytes, unless the operation says otherwise. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `422` The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `426` The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `502` The provider failed the call. `upstream_auth`: it refused the provider key the call ran on (its 401), never your Nexus API key. `upstream_forbidden`: it refused this model for that key (its 403); the key may still serve other models. `upstream_billing`: the provider account behind that key is out of credit (its 402), never your Nexus budget. The message says whose key it was: your organization's own, Nexus's, or the Nexus credit's. Any other provider 5xx is a 502 with no code. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `503` The provider's or the Gateway's own; every one may be retried. The provider's: it has no capacity now (its 529, or the 503 OpenAI documents as its overload), `upstream_overloaded`; retry after its `retry-after` when it sent one, or try another model. The Gateway's: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); it stopped before the call's first event (`gateway_stopping`, send the call again: it reaches a running Gateway); or its database is busy (`database_busy`: nothing was committed, retry shortly). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). |
| 400 | `model_not_supported` | 403 `model_not_allowed` (policy, naming the level and rule), 404 `model_not_found`, 400 `model_not_supported` (coming soon); never sent upstream or reserved, recorded as a refused call |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 402 | `budget_exceeded` | The call's maximum cost is more than the budget left (`budget_exceeded`; `subsidy_exhausted` for the Nexus subsidy, or `credit_exhausted` for the organization's prepaid credits), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | 403 `model_not_allowed` (policy, naming the level and rule), 404 `model_not_found`, 400 `model_not_supported` (coming soon); never sent upstream or reserved, recorded as a refused call |
| 403 | `provider_key_required` | Any other caller with no key of its own gets 403 `provider_key_required`, never Nexus credit |
| 404 |  | Nothing matches. A path parameter outside its pattern is a 404 "no such endpoint", before the credential is checked. A team named that does not exist is `unknown_team`. |
| 404 | `model_not_found` | 403 `model_not_allowed` (policy, naming the level and rule), 404 `model_not_found`, 400 `model_not_supported` (coming soon); never sent upstream or reserved, recorded as a refused call |
| 408 |  | The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). |
| 409 |  | The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 413 |  | The request body is over the operation's limit (`request_too_large`): 1,000,000 bytes, unless the operation says otherwise. |
| 422 |  | The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 426 |  | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |
| 502 |  | The provider failed the call. `upstream_auth`: it refused the provider key the call ran on (its 401), never your Nexus API key. `upstream_forbidden`: it refused this model for that key (its 403); the key may still serve other models. `upstream_billing`: the provider account behind that key is out of credit (its 402), never your Nexus budget. The message says whose key it was: your organization's own, Nexus's, or the Nexus credit's. Any other provider 5xx is a 502 with no code. |
| 503 |  | The provider's or the Gateway's own; every one may be retried. The provider's: it has no capacity now (its 529, or the 503 OpenAI documents as its overload), `upstream_overloaded`; retry after its `retry-after` when it sent one, or try another model. The Gateway's: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); it stopped before the call's first event (`gateway_stopping`, send the call again: it reaches a running Gateway); or its database is busy (`database_busy`: nothing was committed, retry shortly). |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/chat/completions" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nexus/auto",
    "messages": [
      {
        "role": "user",
        "content": "Hello"
      }
    ]
  }'
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.chatCompletion({ model: "nexus/auto", messages: [{ role: "user", content: "Hello" }] });
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fcompletions)

## Spend

`GET /v1/spend`

Budget, spend and reservations, by product and capability, with recent calls. Owners and admins (`spend.read_all`) get the organization's figures. Everyone else gets their own calls and, in place of the organization's budget, spent and reserved, only what is left for them (`remainingUsd`): the least room of the organization, the caps on the team their call is charged to (`x-nexus-team`, else their default team) and their monthly limit, the figure the next 402 gives, with the `period` and `resetsAt` of the cap that binds it.

Permission: `spend.read_own` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `x-nexus-team` | header | string | no | Members: the team (slug) the left-for-you figure is for, as for a call; you must be in it. Default: your default team. Owners and admins get the organization's figures whatever it says. |

### Responses

- `200` OK (application/json, Spend)
  - `budgetUsd` (number): The organization's budget, a cap per budgetPeriod. Owners and admins only: a member gets none of budgetUsd, spentUsd, reservedUsd, budgetPeriod and periodSpentUsd. Deprecated: read `budgetUsdDecimal`, the exact decimal string (root rule 9).
  - `budgetUsdDecimal` (string): `budgetUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `budgetUsd`.
  - `spentUsd` (number): The organization's spend since it began. Owners and admins only. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9).
  - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`.
  - `reservedUsd` (number): Held by the organization's calls in flight. Owners and admins only. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9).
  - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`.
  - `budgetPeriod` ("day" | "week" | "month"): Owners and admins only: the budget's period
  - `periodSpentUsd` (number): Owners and admins only: the spend of calls reserved in the budget's current period, what the budget counts. Deprecated: read `periodSpentUsdDecimal`, the exact decimal string (root rule 9).
  - `periodSpentUsdDecimal` (string): `periodSpentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `periodSpentUsd`.
  - `remainingUsd` (number): Owners and admins: what the organization's budget has left this period. Everyone else: what is left for them, the least room of the organization, their team's caps and their monthly limit, as the next 402 says it. Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9).
  - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`.
  - `period` (string): Not owners and admins: the period of the cap that binds remainingUsd (`2026-10-17`, `2026-W43` or `2026-10`). For the organization's budget, its current period
  - `resetsAt` (string): When the binding cap's period ends and remainingUsd comes back; for owners and admins, when the budget's period ends
  - `scope` ("org" | "own"): `org`: the whole organization's calls (owners and admins); `own`: only the caller's
  - `byProduct` (array of object)
    - `product` (string)
    - `capability` (string)
    - `costUsd` (number): Deprecated: read `costUsdDecimal`, the exact decimal string (root rule 9).
    - `costUsdDecimal` (string): `costUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `costUsd`.
    - `calls` (integer)
  - `recent` (array of object): Recent calls. fundedBy says who paid the provider (own_key, nexus_key for Nexus's own organizations, nexus_subsidy, nexus_credit for the organization's prepaid credits, or nexus_invoiced for a contract's invoice); unset on refusals, typed decisions and calls from before it was recorded. A call a Nexus subsidy paid also has fundingOrg, the organization whose stored key paid it. A call Nexus paid the provider for (nexus_key or nexus_subsidy) also has markupBps, Nexus's rate on it in basis points (500 is 5%), as it was when the call settled; costUsd stays the provider's cost. A call a Nexus subsidy paid also has subsidyMarkupBps, the rate the subsidy was charged at: the subsidy spent costUsd plus that rate. It is unset on older calls, which spent costUsd alone. An Anthropic call also has inferenceGeo (us or global), where the provider said it ran; unset on other providers and on calls from before it was recorded. Each call also names the caller's key, never its secret: keyId (a token id `key_…`; a module's scoped key id `scoped:<product>/<capability>/smk_…`, which POST /v1/auth/scoped-keys/revoke takes; an agent's link id `agl_…`, so a call of the agent differs from the person's own; `ui`; or a system caller's name) and keyKind (the audit log's actor kind: `api_key`, `cli`, `ui`, `module`, `service`, `sandbox`, `operator`, `agent` or `system`). Both are unset on calls from before they were recorded: an unknown key Each call's `costUsd`, and its `overspendPrevented.limitUsd` and `overUsd`, also come as exact decimal strings: `costUsdDecimal`, `limitUsdDecimal` and `overUsdDecimal`. The numbers are deprecated.
  - `subsidizedUsd` (number): Organizations with a Nexus subsidy: what calls the subsidy paid cost the subsidy, each at its provider cost plus Nexus's rate (in your scope: a member gets what it paid for their own calls). Deprecated: read `subsidizedUsdDecimal`, the exact decimal string (root rule 9).
  - `subsidizedUsdDecimal` (string): `subsidizedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `subsidizedUsd`.
  - `subsidy` (object): Owners and admins only: the organization's Nexus subsidy (a personal organization's starting credit), funded by Nexus, never the organization's own money. A member's answer has none of it
    - `grantedUsd` (number): Deprecated: read `grantedUsdDecimal`, the exact decimal string (root rule 9).
    - `grantedUsdDecimal` (string): `grantedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `grantedUsd`.
    - `spentUsd` (number): What settled calls cost the subsidy: each call's provider cost plus Nexus's rate, as for credits. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9).
    - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`.
    - `reservedUsd` (number): Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9).
    - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`.
    - `remainingUsd` (number): Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9).
    - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`.
    - `expiredUsd` (number): What was left of the free start when it expired, 30 days after its grant (pricing v2.0). Absent before. Deprecated: read `expiredUsdDecimal`, the exact decimal string (root rule 9).
    - `expiredUsdDecimal` (string): `expiredUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `expiredUsd`.
    - `fundedBy` ("nexus")
    - `usableForModelCalls` (boolean): Whether this Gateway pays a Nexus feature's model calls (chat sessions, module runs; never raw model access) of an organization with no key of its own from the subsidy (NEXUS_CREDIT_PROVIDER, and NEXUS_SUBSIDY_ORG's stored keys or a subsidy environment key)
  - `subsidiesPaid` (object): The funding organization (NEXUS_SUBSIDY_ORG), owners and admins: what its stored provider keys paid for other organizations' subsidized calls. Never part of its own spend, budget or limits
    - `usd` (number): Deprecated: read `usdDecimal`, the exact decimal string (root rule 9).
    - `usdDecimal` (string): `usd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `usd`.
    - `calls` (integer)
    - `organizations` (integer)
  - `credits` (object): Owners and admins: the organization's prepaid Nexus credits, its own money, never expiring, once it bought some. A Nexus feature's call spends them after the subsidy, at its provider cost plus `markupBps`. Decimal dollar strings.
    - `purchasedUsd` (string, required): Bought, over all time.
    - `spentUsd` (string, required): What settled calls cost the credits: each call's provider cost plus `markupBps`.
    - `reservedUsd` (string, required): Held by calls in progress.
    - `remainingUsd` (string, required): Bought, less spent, held and reversed. Below zero after a refund or a lost dispute took back credit that was already spent: then Nexus pays for no call (the free start, credits or the card after the fact) until a purchase pays it back.
    - `reversedUsd` (string): What refunds, lost disputes and operators took back, and what an open dispute holds of its purchase until it closes. A refund that fails gives its credit back. Only while something is taken back.
    - `markupBps` (integer, required): Nexus's rate in basis points (500 is 5%).
  - `payAfterTheFact` (boolean): Owners and admins (pricing v2.0): the organization pays after the fact, so calls the free start and the credits cannot pay still run on its card.
  - `nexusPays` (object): Every member: whether Nexus can pay for the organization's next model call, and why not. It reads the payers in the ledger's order: a contract, the free start, other Nexus grants, the credits, then the card when it pays after the fact; an unpaid invoice past its grace stops all of them. It answers for a small call to a model the free start pays for, so a pricier model or a larger call can still be refused. Absent where Nexus pays for no model calls on this Gateway.
    - `pays` (boolean, required)
    - `payer` ("contract" | "free_start" | "subsidy" | "credits" | "card" | null, required): Who pays the next call; null when `pays` is false
    - `reason` ("free_start_used_up" | "free_start_expired" | "credits_out" | "usage_limit_reached" | "charge_failed" | "card_needs_confirming" | "card_disputed" | "past_due" | "billing_off" | "charge_processing" | null, required): Why Nexus cannot pay; null when `pays` is true. `billing_off`: nothing was set up to pay (no free start, no credits, and the card does not pay after the fact). `card_disputed`: a payment on the card was disputed, and only another card pays. `past_due` comes first, also under a contract. A balance under a cent does not count as paying.
    - `changesAt` (string (date-time) | null, required): The next time this changes by itself: the free start's deadline while it pays, or the next month while the usage limit is reached; else null
    - `limitUsedPercent` (integer | null): While the card pays: how much of this UTC month's usage limit it paid, in whole percent, rounded down. Null while another payer pays, or nobody, and always null for a caller who sees only their own spend: only billing managers see it. Absent from an older Gateway. [min 0; max 100]
- `403` A member who names a team they are not in with `x-nexus-team` (`not_in_team`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `404` A member names, with `x-nexus-team`, a team that does not exist in the organization (`unknown_team`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 402 | `period` | The least room of the organization, the caps on the team their call is charged to (`x-nexus-team`, else their default team) and their monthly limit, the figure the next 402 gives, with the `period` and `resetsAt` of the cap that binds it |
| 403 | `role_required` | Your role does not have this permission |
| 404 |  | A member names, with `x-nexus-team`, a team that does not exist in the organization (`unknown_team`) |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/spend" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.spend();
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fspend)

## List spend calls

`GET /v1/spend/calls`

One page of the organization's model calls, newest first, with the filters below (owners and admins). People and teams by id only. A bad filter or a range over 366 days is a 400. One request reads at most 10,000 calls, so a narrow filter can answer a short page, even an empty one, with a `nextCursor` that resumes the scan.

Permission: `spend.read_all` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `from` | query | string (date) | no | The first UTC day, YYYY-MM-DD; default 29 days before `to` |
| `to` | query | string (date) | no | The last UTC day, YYYY-MM-DD, included; default today. A range covers at most 366 days |
| `team` | query | string | no | A team slug or id: that team and every team under it; `unassigned` for calls with no team |
| `person` | query | string | no | A person's user id |
| `model` | query | string | no | A model, as the rows name it; `-` for the calls with none (released calls), as Analytics groups them |
| `provider` | query | string | no | A provider, as the rows name it; `-` for the calls with none (refused and released calls), as Analytics groups them |
| `product` | query | string | no | A product (`agents`) or a product and capability (`intelligence/wiki`): Analytics' group key |
| `status` | query | string | no | A comma-separated set of `settled`, `failed`, `refused` and `released`; default all four |
| `session` | query | string | no | An agent session id or a chat session id: the calls attributed to it |
| `limit` | query | integer | no | Calls per page, 1 to 500 (default 50) |
| `cursor` | query | string | no | `nextCursor` from the previous page. It is bound to the organization, the caller and the query: anywhere else it is a 400 `invalid_cursor` |

### Responses

- `200` OK (application/json, SpendCallPage)
  - `from` (string (date), required): The first UTC day the page covers.
  - `to` (string (date), required): The last UTC day the page covers, included.
  - `calls` (array of SpendCall, required)
    - `id` (string, required): The call's record id.
    - `at` (string (date-time), required): When the ledger recorded the call.
    - `status` ("settled" | "failed" | "refused" | "released", required): `settled`, `failed`, `refused` (Nexus Gateway refused it, and no money moved) or `released` (its reservation closed without a settle, by a job's cleanup or the ledger's age sweep).
    - `model` (string | null, required): The model the call asked for; null for a released call, whose model the ledger did not record.
    - `provider` (string | null, required): The provider that served it; null for a refused or released call, which no provider served.
    - `product` (string, required): The product it is metered to: `core` for direct API calls, `agents`, `chat` or a module.
    - `capability` (string | null, required): The module's capability, such as `wiki`.
    - `userId` (string | null, required): The person who made the call.
    - `teamId` (string | null, required): The team the call was attributed to; null for none (`unassigned`).
    - `agentSessionId` (string | null, required): The coding-agent session the call belongs to.
    - `chatSessionId` (string | null, required): The chat session the call belongs to (metadata only, never its content).
    - `inputTokens` (integer | null, required): Prompt tokens, as the ledger charged them; null for a released call, whose tokens nobody reported.
    - `outputTokens` (integer | null, required): Completion tokens, as the ledger charged them; null for a released call.
    - `costUsd` (string, required): What the call was charged. [pattern ^-?[0-9]+\.[0-9]{6}$]
    - `reservedUsd` (string | null, required): What Nexus Gateway held for the call before it ran. [pattern ^-?[0-9]+\.[0-9]{6}$]
    - `reason` (string | null, required): The ledger's note on the call, with any secret redacted: why it was refused, failed or released, or what it charged past its hold.
    - `overspendLevel` ("organization" | "team" | "person" | "product" | null, required): The spend limit that refused the call.
    - `overspendLimitUsd` (string | null, required): The person's limit, when a person's limit refused the call. Null for a team's cap and the organization's budget: the ledger does not keep their limit on the call. [pattern ^-?[0-9]+\.[0-9]{6}$]
    - `overspendAmountUsd` (string | null, required): What the refused call asked to hold. [pattern ^-?[0-9]+\.[0-9]{6}$]
    - `overspendOverUsd` (string | null, required): How far over the limit it would have gone. [pattern ^-?[0-9]+\.[0-9]{6}$]
    - `overspendPeriod` (string | null, required): The limit's period (`2026-10`, `2026-W43` or `2026-10-23`).
    - `fundedBy` (string | null, required): `nexus_subsidy` for a call a Nexus subsidy paid, `nexus_credit` for one the organization's prepaid credits paid; null for the organization's own.
  - `nextCursor` (string | null, required): Pass as `cursor` for the next, older page; null on the last page.
- `400` A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, a `limit` outside 1 to 500 or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Only owners and admins list the organization's calls (`role_required`): a member without `spend.read_all` (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, a `limit` outside 1 to 500 or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/spend/calls" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.spendCalls({ from: "2026-10-01", status: "failed,refused" });
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fspend%2Fcalls)

## Get spend call

`GET /v1/spend/calls/{id}`

One of the organization's model calls, as its row in the files: what was reserved, what was charged and why it was refused (owners and admins). Another organization's call reads as missing: 404 `unknown_call`.

Permission: `spend.read_all` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The call's record id |

### Responses

- `200` OK (application/json, SpendCall)
  - `id` (string, required): The call's record id.
  - `at` (string (date-time), required): When the ledger recorded the call.
  - `status` ("settled" | "failed" | "refused" | "released", required): `settled`, `failed`, `refused` (Nexus Gateway refused it, and no money moved) or `released` (its reservation closed without a settle, by a job's cleanup or the ledger's age sweep).
  - `model` (string | null, required): The model the call asked for; null for a released call, whose model the ledger did not record.
  - `provider` (string | null, required): The provider that served it; null for a refused or released call, which no provider served.
  - `product` (string, required): The product it is metered to: `core` for direct API calls, `agents`, `chat` or a module.
  - `capability` (string | null, required): The module's capability, such as `wiki`.
  - `userId` (string | null, required): The person who made the call.
  - `teamId` (string | null, required): The team the call was attributed to; null for none (`unassigned`).
  - `agentSessionId` (string | null, required): The coding-agent session the call belongs to.
  - `chatSessionId` (string | null, required): The chat session the call belongs to (metadata only, never its content).
  - `inputTokens` (integer | null, required): Prompt tokens, as the ledger charged them; null for a released call, whose tokens nobody reported.
  - `outputTokens` (integer | null, required): Completion tokens, as the ledger charged them; null for a released call.
  - `costUsd` (string, required): What the call was charged. [pattern ^-?[0-9]+\.[0-9]{6}$]
  - `reservedUsd` (string | null, required): What Nexus Gateway held for the call before it ran. [pattern ^-?[0-9]+\.[0-9]{6}$]
  - `reason` (string | null, required): The ledger's note on the call, with any secret redacted: why it was refused, failed or released, or what it charged past its hold.
  - `overspendLevel` ("organization" | "team" | "person" | "product" | null, required): The spend limit that refused the call.
  - `overspendLimitUsd` (string | null, required): The person's limit, when a person's limit refused the call. Null for a team's cap and the organization's budget: the ledger does not keep their limit on the call. [pattern ^-?[0-9]+\.[0-9]{6}$]
  - `overspendAmountUsd` (string | null, required): What the refused call asked to hold. [pattern ^-?[0-9]+\.[0-9]{6}$]
  - `overspendOverUsd` (string | null, required): How far over the limit it would have gone. [pattern ^-?[0-9]+\.[0-9]{6}$]
  - `overspendPeriod` (string | null, required): The limit's period (`2026-10`, `2026-W43` or `2026-10-23`).
  - `fundedBy` (string | null, required): `nexus_subsidy` for a call a Nexus subsidy paid, `nexus_credit` for one the organization's prepaid credits paid; null for the organization's own.
- `403` Only owners and admins read the organization's calls (`role_required`): a member without `spend.read_all` (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `404` No call with this id in the caller's organization (`unknown_call`); another organization's call reads as missing (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No call with this id in the caller's organization (`unknown_call`); another organization's call reads as missing |
| 404 | `unknown_call` | 404 `unknown_call` |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/spend/calls/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.spendCall("<call id>");
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fspend%2Fcalls%2F%7Bid%7D)

## Export spend calls CSV

`GET /v1/spend/calls/export.csv`

Every model call of the organization that matches the filters, newest first, as CSV (owners and admins): the rows `listSpendCalls` pages through, with its filters. A series of files reads the calls written up to the newest one when its first file started. At most 100,000 rows a file: past that the file stops, and its manifest says `complete: false` and gives `nextCursor`. Each export is an audit event (`observability.exported`) with the file's manifest, never its rows. An organization runs at most 60 exports an hour: the 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's). A bad filter is a 400 before any row.

Permission: `spend.export` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `from` | query | string (date) | no | The first UTC day, YYYY-MM-DD; default 29 days before `to` |
| `to` | query | string (date) | no | The last UTC day, YYYY-MM-DD, included; default today. A range covers at most 366 days |
| `team` | query | string | no | A team slug or id: that team and every team under it; `unassigned` for calls with no team |
| `person` | query | string | no | A person's user id |
| `model` | query | string | no | A model, as the rows name it; `-` for the calls with none (released calls), as Analytics groups them |
| `provider` | query | string | no | A provider, as the rows name it; `-` for the calls with none (refused and released calls), as Analytics groups them |
| `product` | query | string | no | A product (`agents`) or a product and capability (`intelligence/wiki`): Analytics' group key |
| `status` | query | string | no | A comma-separated set of `settled`, `failed`, `refused` and `released`; default all four |
| `session` | query | string | no | An agent session id or a chat session id: the calls attributed to it |
| `cursor` | query | string | no | A cut file's `manifest.nextCursor`: the next file of the same query. A manifest's `watermark` also works: it starts the same series again. It is bound to the organization, the caller and the query: anywhere else it is a 400 `invalid_cursor` |

### Responses

- `200` CSV with a header row: one column per field of `SpendCall`, in its order. (text/csv, string)
- `400` A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Only owners and admins export the organization's calls (`role_required`): a member without `spend.export` (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `export_rate_limited` | The 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's) |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/spend/calls/export.csv" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.spendCallsExport("csv", { from: "2026-10-01" });
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fspend%2Fcalls%2Fexport.csv)

## Export spend calls JSON Lines

`GET /v1/spend/calls/export.jsonl`

Every model call of the organization that matches the filters, newest first, as JSON Lines (owners and admins): the rows `listSpendCalls` pages through, with its filters. A series of files reads the calls written up to the newest one when its first file started. At most 100,000 rows a file: past that the file stops, and its manifest says `complete: false` and gives `nextCursor`. Each export is an audit event (`observability.exported`) with the file's manifest, never its rows. An organization runs at most 60 exports an hour: the 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's). A bad filter is a 400 before any row.

Permission: `spend.export` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `from` | query | string (date) | no | The first UTC day, YYYY-MM-DD; default 29 days before `to` |
| `to` | query | string (date) | no | The last UTC day, YYYY-MM-DD, included; default today. A range covers at most 366 days |
| `team` | query | string | no | A team slug or id: that team and every team under it; `unassigned` for calls with no team |
| `person` | query | string | no | A person's user id |
| `model` | query | string | no | A model, as the rows name it; `-` for the calls with none (released calls), as Analytics groups them |
| `provider` | query | string | no | A provider, as the rows name it; `-` for the calls with none (refused and released calls), as Analytics groups them |
| `product` | query | string | no | A product (`agents`) or a product and capability (`intelligence/wiki`): Analytics' group key |
| `status` | query | string | no | A comma-separated set of `settled`, `failed`, `refused` and `released`; default all four |
| `session` | query | string | no | An agent session id or a chat session id: the calls attributed to it |
| `cursor` | query | string | no | A cut file's `manifest.nextCursor`: the next file of the same query. A manifest's `watermark` also works: it starts the same series again. It is bound to the organization, the caller and the query: anywhere else it is a 400 `invalid_cursor` |

### Responses

- `200` JSON Lines: one `SpendCall` per line, then one line `{"manifest": ExportManifest}`. (application/jsonl, string)
- `400` A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Only owners and admins export the organization's calls (`role_required`): a member without `spend.export` (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `export_rate_limited` | The 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's) |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/spend/calls/export.jsonl" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.spendCallsExport("jsonl", { from: "2026-10-01" });
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fspend%2Fcalls%2Fexport.jsonl)

## Modules

`GET /v1/modules`

Manifests of the registered capability modules.

Permission: `org.read` (Every member).

### Responses

- `200` OK (application/json, object)
  - `modules` (array of ModuleManifest)
    - `product` (object)
      - `slug` (string)
      - `name` (string)
    - `capability` (object)
      - `slug` (string)
      - `name` (string)
      - `description` (string)
    - `verbs` (array of "connect" | "run" | "report" | "apply" | "watch")
    - `inputs` (array of object)
    - `panel` (object)
      - `kind` (string)
    - `operations` (object)
  - `unavailable` (array of object)
    - `url` (string)
    - `error` (string)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/modules" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.modules();
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fmodules)

## Openapi

`GET /v1/openapi.json`

This document, merged with every registered module's operations.

Permission: `public` (Anyone, signed in or not).

### Responses

- `200` OpenAPI 3.1 document

### Errors

| Status | Code | When |
| --- | --- | --- |

### Example

```sh
curl "$NEXUS_URL/v1/openapi.json"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.openapi();
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fopenapi.json)

## Healthz

`GET /healthz`

Liveness: the process answers. It reads no database, and it stays 200 while Gateway drains.

Permission: `public` (Anyone, signed in or not).

### Responses

- `200` The process is alive. (application/json, object)
  - `status` ("ok", required)
  - `implementation` ("rust", required): The gateway that answered.
  - `version` (string, required): The Factory release this binary is (`info.version` of this document).
  - `edition` ("licensed" | "open", required): The build: `licensed`, or `open` for the open gateway (no licensed code; those routes answer 501 `licensed`).
  - `provider` ("live" | "mock", required): `NEXUS_PROVIDER`: `live` calls the providers; `mock` answers every chat and module model call with canned text.
  - `agentProvider` ("live" | "mock", required): `NEXUS_AGENT_PROVIDER`: the same for the agent gateway's pass-through.
  - `catalogFingerprint` (string | null, required): The SHA-256 of the catalog file this process loaded (`NEXUS_CATALOG_FILE`), in hex, as `sha256sum` prints it; null when no file is set. Processes with the same value run the same catalog.
  - `simSeed` (string): Local simulations only: the installed `NEXUS_SIM_SEED`, as a string. Absent everywhere else.

### Errors

| Status | Code | When |
| --- | --- | --- |

### Example

```sh
curl "$NEXUS_URL/healthz"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fhealthz)

## Readyz

`GET /readyz`

Readiness: whether to send this process traffic (`ready`, `degraded`, `draining` or `unavailable`).

Permission: `public` (Anyone, signed in or not).

### Responses

- `200` Send traffic: `ready`, or `degraded` with its reasons. (application/json, object | object)
- `503` Send no traffic: Gateway is stopping (`draining`), or the database ping failed (`database`) or did not answer in time (`database_timeout`). (application/json, object | object)

### Errors

| Status | Code | When |
| --- | --- | --- |
| 503 |  | Send no traffic: Gateway is stopping (`draining`), or the database ping failed (`database`) or did not answer in time (`database_timeout`). |

### Example

```sh
curl "$NEXUS_URL/readyz"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Freadyz)

## Cli version

`GET /cli/version`

The `nexus` CLI this Gateway serves: its version, SHA-256, download URL and the oldest CLI Gateway talks to.

Permission: `public` (Anyone, signed in or not).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `target` | query | string | no | A platform, `<os>-<arch>`: lowercase letters and digits, 16 at most each. |

### Responses

- `200` The build to install. `target` is present only when the request named one. (application/json, object)
  - `version` (string, required)
  - `sha256` (string, required) [pattern ^[0-9a-f]{64}$]
  - `url` (string (uri), required): Where to download it, on this Gateway's public URL.
  - `minimum` (string, required): `NEXUS_CLI_MINIMUM`: an older CLI gets 426 `cli_too_old` on `/v1`.
  - `target` (string): The platform asked for.
- `404` `cli_target_unavailable`: this Gateway publishes no native build for `target`. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `405` Not GET or HEAD. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `503` `cli_bundle_unavailable` (`server_error`): no `target`, and no CLI bundle is built on this Gateway. Also `overloaded` or `draining`, as every route outside the health checks. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 404 |  | `cli_target_unavailable`: this Gateway publishes no native build for `target`. |
| 405 |  | Not GET or HEAD. |
| 503 |  | `cli_bundle_unavailable` (`server_error`): no `target`, and no CLI bundle is built on this Gateway. Also `overloaded` or `draining`, as every route outside the health checks. |

### Example

```sh
curl "$NEXUS_URL/cli/version"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fcli%2Fversion)

## Stripe webhook

`POST /v1/stripe/webhook`

Stripe's webhook, signed by Stripe with STRIPE_WEBHOOK_SECRET (the Stripe-Signature header, t=<unix>,v1=<hex>; refused more than five minutes from now). Gateway keeps the verified event's identity once in an inbox and nothing else: a repeated delivery changes nothing, and an event whose livemode differs from the key's is kept as ignored. After it answers, Gateway reads the event's object again from Stripe and updates the organization's card on file (`GET /v1/billing`). A signed event Gateway cannot keep (a thin event, no id) is a 200 with `stored: false`, so Stripe does not retry it. An event that stopped (`unmatched`, or failed on its last try) runs again when Stripe sends it again, with all its tries. 400 for a body that is not JSON; 401 `invalid_signature` for a bad or old signature; 413 over 1 MB; 503 `not_configured` until STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are both set and well formed. The 503's message says only that Stripe is not configured; Gateway logs the reason at start.

Permission: `public` (Anyone, signed in or not).

### Responses

- `200` OK (application/json, object)
  - `ok` (boolean, required)
  - `event` (string | null, required): The event's type. Null when the signed event has no string `type` (or the body is not a JSON object); Stripe's own events always have one.
  - `stored` (boolean, required): True when this delivery added a row to process. False for a repeat that changes nothing. False too for a resend of a stopped (`dead`) or `unmatched` event: no row is added, but the event runs again from its first try. False for an event whose livemode differs from the key's: it is kept as `ignored` and never processed.
- `400` Not JSON (`invalid_request_error`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `401` The signature is bad or too old (`invalid_signature`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `413` Over 1 MB (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `503` Stripe is not configured (`not_configured`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 |  | Not JSON (`invalid_request_error`) |
| 401 | `invalid_signature` | 400 for a body that is not JSON; 401 `invalid_signature` for a bad or old signature; 413 over 1 MB; 503 `not_configured` until STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are both set and well formed |
| 413 |  | Over 1 MB |
| 503 |  | Stripe is not configured (`not_configured`) |
| 503 | `not_configured` | 400 for a body that is not JSON; 401 `invalid_signature` for a bad or old signature; 413 over 1 MB; 503 `not_configured` until STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are both set and well formed |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/stripe/webhook"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fstripe%2Fwebhook)

## Search

`GET /v1/search`

Search what you may read, grouped by type and ranked: your own chat sessions (titles and message text), artifacts shared with or by you, people, teams, models and model policies.

Permission: `search.use` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `q` | query | string | yes | What to search for, 1 to 200 characters. Words match as prefixes (`depl` finds deploy) |
| `types` | query | string | no | Comma-separated: chats, artifacts, people, teams, models (default: all you may read). `actions` and `pages` are accepted and ignored: the palette answers them itself |
| `limit` | query | integer | no | Results per group, 1 to 20 (default 5) |

### Responses

- `200` OK (application/json, SearchResponse)
  - `query` (string, required)
  - `types` (array of string, required): The types searched: those asked for that your role may read
  - `groups` (array of SearchGroup, required): Groups with results, best first
    - `type` (string, required)
    - `label` (string, required)
    - `results` (array of SearchResult, required)
      - `type` ("chats" | "artifacts" | "people" | "teams" | "models", required)
      - `entity` ("session" | "artifact" | "member" | "invitation" | "team" | "model" | "policy", required)
      - `id` (string, required)
      - `title` (string, required)
      - `titleMatches` (array of array of integer, required): Ranges of `title` that matched (UTF-16)
      - `subtitle` (string)
      - `snippet` (SearchSnippet)
        - `text` (string, required): An excerpt; `…` where cut
        - `matches` (array of array of integer, required): [start, end) ranges of `text` that matched, in UTF-16 code units
      - `url` (string, required): Nexus UI's page for it, under the organization's slug: /app/<org>/sessions/<id> (a chat message match ends in #m-<message id>)
      - `score` (number, required) [min 0; max 1]
      - `messageId` (string): Chats: the message that matched
    - `more` (boolean, required): More matched than `limit`
  - `tookMs` (number, required): The server's time for the search
- `400` A query parameter is not valid (`invalid_search`): `q` empty or over 200 characters, an unknown type in `types`, or `limit` not 1 to 20. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` The key does not hold `search.use` (`role_required`: a service account, a sandbox, or an agent not granted it), or the caller is not a person, such as a module key (`person_required`). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A query parameter is not valid (`invalid_search`): `q` empty or over 200 characters, an unknown type in `types`, or `limit` not 1 to 20. |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/search?q=%3Cq%3E" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fsearch)

## Decisions

`POST /v1/decisions`

Typed decisions: a batch of requests to a decision model (TypeSafe's Jev), each a `state` and its `questions`, answered with typed judgments and probabilities, never text. Metered as one model call: one model policy decision on the `decisions` surface, one reservation of the batch's maximum cost, one settlement on the summed reported input tokens, one spend record. Only decision models serve it, and `nexus/auto` does not resolve here.

Permission: `models.use` (Every member, module keys).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `x-nexus-team` | header | string | no | The team (slug) this batch's spend goes to; you must be in it. Default: your default team. |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json, required)

- `model` (string, required): A decision model: `typesafe/jev`
- `requests` (array of object, required) [at most 100 items]
  - `state` (string | object | array of any, required): What the questions are about: a string, an object or an array
  - `questions` (object, required): `{ <name>: { type, instructions, criteria } }`, passed through: `choice` (criteria: 1 to 255 options), `score` (an ordered list of 1 to 10 levels), `noul` (a yes/no probability; criteria optional)
- `team` (string): The team (slug), as `x-nexus-team`

### Responses

- `200` OK (application/json, DecisionsResponse)
  - `model` (string, required): The canonical model that answered
  - `results` (array of object | object, required): One per request, in order
  - `nexus` (object, required)
    - `cost_usd` (number, required): What the batch cost the organization
    - `input_tokens` (integer, required): The input tokens charged, summed
    - `notes` (array of string): What the caller should know about the answer; absent when there is none. When the batch's settlement failed, a note says the charge is not confirmed: cost_usd is then the Gateway's computed charge, not a ledger record.
- `402` The organization has nothing to pay the batch with (`subsidy_exhausted`, the shape a model call returns), the batch's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. (application/json, Error & object)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
  - `error` (object)
    - `nexus` (BudgetRefusal): The details (`error.nexus`) of a 402 `budget_exceeded` or `subsidy_exhausted`. Each money figure comes as its number (deprecated) and its exact decimal twin (`requestedUsd`, `requestedUsdDecimal`). A refusal below the person level names only what is left and what was asked, never a limit above the caller. `credit_exhausted` sends `remainingUsd` and `requestedUsd` as decimal strings already, without twins.
      - `level` ("organization" | "team" | "person" | "product"): The level whose limit refused the call (`budget_exceeded`)
      - `period` (string): The period the refusal counted in: `2026-10`, `2026-W44` or `2026-10-21`
      - `resetsAt` (string (date-time)): When the period ends (UTC)
      - `source` ("override" | "default"): Person level only: whether the limit was set for them or is the organization's default per person
      - `limitUsd` (number): Person level only: their monthly limit. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9).
      - `limitUsdDecimal` (string): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`.
      - `spentUsd` (number): Person level only: what they spent this month. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9).
      - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`.
      - `reservedUsd` (number): Person level only: what their calls in flight hold. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9).
      - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`.
      - `remainingUsd` (number): Every level, and `subsidy_exhausted`: what is left, never below 0. Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9).
      - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`.
      - `requestedUsd` (number): What the call may cost at most, the amount it asked to hold. Deprecated: read `requestedUsdDecimal`, the exact decimal string (root rule 9).
      - `requestedUsdDecimal` (string): `requestedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `requestedUsd`.
      - `notified` (boolean): `budget_exceeded`: true once Gateway has told the refused person and the organization's owners and admins
      - `fundedBy` (string): `subsidy_exhausted`: who funds the subsidy (`nexus`)
      - `next` (array of string): `subsidy_exhausted`: what the caller can do next (`billing`, `own_key`)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 402 | `budget_exceeded` | The organization has nothing to pay the batch with (`subsidy_exhausted`, the shape a model call returns), the batch's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. |
| 403 | `role_required` | Your role does not have this permission |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/decisions" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model>",
    "requests": [
      {
        "state": "…",
        "questions": {}
      }
    ]
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdecisions)

## List notifications

`GET /v1/notifications`

Your inbox in this organization: items not yet done, newest first, 50 a page.

Permission: `notifications.use` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `cursor` | query | string | no | A `nextCursor` this list returned |
| `unread` | query | boolean | no | Only items not yet read |
| `group` | query | "my_sessions" \| "usage_and_billing" \| "requests_and_approvals" \| "automations_and_integrations" \| "account_and_security" | no | Only this group's kinds |

### Responses

- `200` OK (application/json, NotificationPage)
  - `items` (array of NotificationItem, required)
    - `id` (string, required): `ntf_…`
    - `kind` (string, required): The kind's stable name, as GET /v1/notifications/kinds lists it
    - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required)
    - `subjectText` (string, required): The kind's fixed text
    - `title` (string): A month report's summary, from its figures only: the month and the total. Absent for other kinds
    - `detail` (string): A month report's second line, from its figures only: the calls. Absent for other kinds
    - `subject` (NotificationSubject, required)
      - `type` ("organization" | "team" | "user" | "artifact", required)
      - `id` (string, required)
    - `sources` (array of NotificationSource, required) [at most 20 items]
    - `count` (integer, required): The events this item collapses; it can pass the 20 sources kept [min 1]
    - `readAt` (string (date-time))
    - `doneAt` (string (date-time))
    - `createdAt` (string (date-time), required)
    - `updatedAt` (string (date-time), required)
  - `nextCursor` (string): Pass as `cursor` for the next page; absent on the last
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/notifications" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fnotifications)

## Read notification

`POST /v1/notifications/{id}/read`

Mark your item read. Not yours, or the audience rule no longer gives it to you: 404.

Permission: `notifications.use` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The item's id (`ntf_…`) |

### Responses

- `200` OK (application/json, NotificationItem)
  - `id` (string, required): `ntf_…`
  - `kind` (string, required): The kind's stable name, as GET /v1/notifications/kinds lists it
  - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required)
  - `subjectText` (string, required): The kind's fixed text
  - `title` (string): A month report's summary, from its figures only: the month and the total. Absent for other kinds
  - `detail` (string): A month report's second line, from its figures only: the calls. Absent for other kinds
  - `subject` (NotificationSubject, required)
    - `type` ("organization" | "team" | "user" | "artifact", required)
    - `id` (string, required)
  - `sources` (array of NotificationSource, required) [at most 20 items]
  - `count` (integer, required): The events this item collapses; it can pass the 20 sources kept [min 1]
  - `readAt` (string (date-time))
  - `doneAt` (string (date-time))
  - `createdAt` (string (date-time), required)
  - `updatedAt` (string (date-time), required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/notifications/<id>/read" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fnotifications%2F%7Bid%7D%2Fread)

## Done notification

`POST /v1/notifications/{id}/done`

Mark your item done (and read): it leaves the list. Not yours, or the audience rule no longer gives it to you: 404.

Permission: `notifications.use` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The item's id (`ntf_…`) |

### Responses

- `200` OK (application/json, NotificationItem)
  - `id` (string, required): `ntf_…`
  - `kind` (string, required): The kind's stable name, as GET /v1/notifications/kinds lists it
  - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required)
  - `subjectText` (string, required): The kind's fixed text
  - `title` (string): A month report's summary, from its figures only: the month and the total. Absent for other kinds
  - `detail` (string): A month report's second line, from its figures only: the calls. Absent for other kinds
  - `subject` (NotificationSubject, required)
    - `type` ("organization" | "team" | "user" | "artifact", required)
    - `id` (string, required)
  - `sources` (array of NotificationSource, required) [at most 20 items]
  - `count` (integer, required): The events this item collapses; it can pass the 20 sources kept [min 1]
  - `readAt` (string (date-time))
  - `doneAt` (string (date-time))
  - `createdAt` (string (date-time), required)
  - `updatedAt` (string (date-time), required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/notifications/<id>/done" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fnotifications%2F%7Bid%7D%2Fdone)

## List notification kinds

`GET /v1/notifications/kinds`

The notification catalogue: each kind's name, group, fixed text, whether it is required, and its default channels.

Permission: `notifications.use` (Every member).

### Responses

- `200` OK (application/json, NotificationKinds)
  - `kinds` (array of NotificationKind, required)
    - `name` (string, required)
    - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required)
    - `subjectText` (string, required)
    - `required` (boolean, required): A required kind can move between channels but never be muted
    - `defaults` (array of "inbox" | "email" | "push", required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/notifications/kinds" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fnotifications%2Fkinds)

## Get growth activation

`GET /v1/growth/activation`

When your organization first reached each value, computed on read (Growth Capabilities): activation through Gateway (the first agent session), through Nexus Wiki (the first Wiki run on a repository the organization links now; a repository unlinked since no longer counts), and the first settled model call, each with its minutes after sign-up. `exact` is false when older records were pruned or not listed, so the true first may be earlier. The Wiki row reads the Wiki module; when it is missing (`wiki_not_configured`) or fails (`wiki_unavailable`), that row carries `error` and the answer stays 200. Nothing here writes, and no person is named.

Permission: `growth.read` (Owner, Admin).

### Responses

- `200` OK (application/json, GrowthActivation)
  - `tenantId` (string, required)
  - `mark` ("staff" | "test" | "demo" | null, required): The organization's mark; null for a customer's. A figure that leaves the organization counts a marked one apart
  - `tenantZero` (boolean, required): Whether the organization is marked staff: Nexus's own, where C1 is measured. A figure that leaves it counts it apart
  - `signedUpAt` (string (date-time), required): The organization's creation: every `minutesAfterSignup` counts from it
  - `activated` (FirstValue, required): Activated by either definition: the earlier of `gateway` and `wiki`. Exact only when both are; carries the Wiki's `error`, since an unknown Wiki run may be the earlier
    - `at` (string (date-time) | null, required): When the organization first reached it; null when it has not, or when `error` says it could not be read
    - `minutesAfterSignup` (integer | null, required): Whole minutes from `signedUpAt` to `at`; 0 for a value recorded before the sign-up
    - `exact` (boolean, required): False when older records were pruned or not listed, so the true first may be earlier than `at`
    - `error` (string | null, required): `wiki_not_configured` or `wiki_unavailable`: why the value could not be read; the rest of the answer stands
  - `gateway` (FirstValue, required): Activated: Gateway. The first agent session through nexus claude or nexus codex
    - `at` (string (date-time) | null, required): When the organization first reached it; null when it has not, or when `error` says it could not be read
    - `minutesAfterSignup` (integer | null, required): Whole minutes from `signedUpAt` to `at`; 0 for a value recorded before the sign-up
    - `exact` (boolean, required): False when older records were pruned or not listed, so the true first may be earlier than `at`
    - `error` (string | null, required): `wiki_not_configured` or `wiki_unavailable`: why the value could not be read; the rest of the answer stands
  - `wiki` (FirstValue, required): Activated: Wiki. The first Nexus Wiki run
    - `at` (string (date-time) | null, required): When the organization first reached it; null when it has not, or when `error` says it could not be read
    - `minutesAfterSignup` (integer | null, required): Whole minutes from `signedUpAt` to `at`; 0 for a value recorded before the sign-up
    - `exact` (boolean, required): False when older records were pruned or not listed, so the true first may be earlier than `at`
    - `error` (string | null, required): `wiki_not_configured` or `wiki_unavailable`: why the value could not be read; the rest of the answer stands
  - `firstSettledCall` (FirstValue, required): The first model call that settled; refused and failed calls do not count
    - `at` (string (date-time) | null, required): When the organization first reached it; null when it has not, or when `error` says it could not be read
    - `minutesAfterSignup` (integer | null, required): Whole minutes from `signedUpAt` to `at`; 0 for a value recorded before the sign-up
    - `exact` (boolean, required): False when older records were pruned or not listed, so the true first may be earlier than `at`
    - `error` (string | null, required): `wiki_not_configured` or `wiki_unavailable`: why the value could not be read; the rest of the answer stands
- `403` Not an owner or admin (`permission_error`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/growth/activation" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fgrowth%2Factivation)

## Get growth member paths

`GET /v1/growth/paths`

How far your organization's members got on the path to first value, computed on read (Growth Capabilities): per step (joined, signed in on the CLI, first key, first agent session, first settled call), how many reached it, how many stopped just before it, and how long they waited from each member's previous step reached (shown from five waits, so no one person's wait shows). `stall` is the step the most members stopped just before. Counts only: no person is named. `exact` is false when older records were pruned or not read.

Permission: `growth.read` (Owner, Admin).

### Responses

- `200` OK (application/json, GrowthMemberPaths)
  - `tenantId` (string, required)
  - `mark` ("staff" | "test" | "demo" | null, required): The organization's mark, as in GrowthActivation
  - `tenantZero` (boolean, required): Whether the organization is marked staff, as in GrowthActivation
  - `members` (integer, required): The organization's members now with no mark; a removed member is not counted
  - `markedMembers` (integer, required): Its members marked staff, test or demo; no step counts them. At an organization marked staff, staff stay in members
  - `steps` (array of PathStep, required): Every step, over the members with no mark, in order
    - `step` ("joined" | "cli_signed_in" | "first_key" | "first_agent_session" | "first_settled_call", required)
    - `reached` (integer, required): Members who reached it
    - `waiting` (integer, required): Members whose furthest step is the one before it: they stopped there
    - `waitMinutes` (WaitMinutes | null, required): Whole minutes from each member's previous step reached to this one, never below 0; null for joined, and below five waits, so no one person's wait shows
    - `exact` (boolean, required): False when older records were pruned or not read, so a member may have reached it earlier, or at all
  - `stall` ("joined" | "cli_signed_in" | "first_key" | "first_agent_session" | "first_settled_call" | null, required): The step the most members stopped just before (the earlier one on a tie); null when no one stopped short
- `403` Not an owner or admin (`permission_error`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/growth/paths" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fgrowth%2Fpaths)

## List referrals

`GET /v1/referrals`

Your referral code and the people whose sign-up carried it, oldest first, each with when they joined and their email masked. The code is made on the first read: ten random characters of lowercase base 32, with no name in it, and it never changes after. A code made earlier from your name gets a random one on its next read, and the old code still works. It is a person's, whichever organization you call from. The people always page: the first 100 without `limit` or `cursor`.

Permission: `referrals.read` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `limit` | query | integer | no | People per page, 1 to 500 (default 100). |
| `cursor` | query | string | no | NextCursor from the previous page. A cursor whose person left the list answers 400 `invalid_cursor`. |

### Responses

- `200` OK (application/json, ReferralList)
  - `code` (string, required): Your referral code: ten random characters of lowercase base 32, made on the first read. A code made earlier from your name gets one on its next read, and the old code still works.
  - `referred` (array of ReferredPerson, required)
    - `joinedAt` (string (date-time), required): When their sign-up was recorded.
    - `email` (string | null, required): Their email with all but its first character before the `@` hidden (`a***@example.com`). `null` when they erased their account (`erased`), or when their sign-in carried no email Nexus could keep.
    - `erased` (boolean): Whether the person erased their account. A person with no email who is not erased is still live: a reward needs their email. Absent on older Gateways, which a client reads from a `null` email.
    - `rewarded` (boolean | null): Whether this referral earned the caller a reward. Absent or null when unavailable. No payment date is disclosed.
    - `reward` ("pending" | "rewarded" | "not_rewarded"): This referral's reward. `pending`: none yet, and one may come; a payment is never disclosed while a reward can still come. `rewarded`: your personal organization got it. `not_rewarded`: final, it never will (its reward was voided, you reached the lifetime limit, or you have no personal organization). Absent on older Gateways.
  - `nextCursor` (string): The next page's cursor, while more people follow.
  - `invitesLeft` (integer): While sign-up is invite-only: how many more people your code admits, as an operator approved. Only the people who joined through your code after the approval use one. Absent while sign-up is open, and for a staff member's code with no approval, which admits anyone. [min 0]
  - `invitesAllowed` (integer): While sign-up is invite-only: how many people an operator approved your code to admit in all, used or not. `0`: not approved. With `invitesLeft` `0` and this above `0`, you used every invitation. Absent while sign-up is open, for a staff member's code with no approval, and on older Gateways. [min 0]
  - `enabled` (boolean, required): False while the personal referral program is stopped. Existing referrals remain readable.
  - `rewardProgress` (ReferralRewardProgress): Lifetime referral rewards for the person's personal organization, across all pages, including credit already spent or expired, against its limit. Absent for a staff member, whose account has no limit, and on older Gateways.
    - `granted` (integer, required): How many referral rewards this account has received. [min 0]
    - `limit` (integer, required): The maximum number of rewarded referrals per account, currently 10. [min 1]
  - `rewardsGranted` (integer): How many referral rewards your personal organization got in all, across all pages, including credit already spent or expired, limit or not. Absent on older Gateways. [min 0]
  - `rewardUsdDecimal` (string): What one rewarded referral gives your personal organization, in US dollars with six decimals (`"1.000000"`). `"0.000000"` while no reward is set. Absent on older Gateways.
  - `rewardsActive` (boolean): Whether your referrals earn rewards now: the program is on, a reward and a program cap are set, the cap has room for one more reward, and you are below your lifetime limit (`rewardProgress`) or are staff, who have none. False: no referral of yours earns credit now. Absent on older Gateways, which a client reads as false.
- `400` A bad `limit` or `cursor` (`invalid_request_error`, `invalid_cursor`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Not a person: a module, a service account, an agent or an operator (`person_required`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 100 | `limit` | The first 100 without `limit` or `cursor` |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A bad `limit` or `cursor` (`invalid_request_error`, `invalid_cursor`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/referrals" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Freferrals)

## Send diagnostic reports

`POST /v1/diagnostics/reports`

Send the app's own error and crash reports to the observability store. Each report becomes one `nexus::client_report` line in the Gateway's log, which reaches Cloud Logging with the Gateway's other lines; the Gateway keeps no copy. A report names what failed and where, never content: its fields are a closed set, each one bounded, and its free text (`name`, `message`) is logged redacted, with quoted text, URL paths and queries, emails and anything shaped like a key or token taken out. A stack frame is logged only as a code location (`at <function> (<file>:<line>:<column>)` or `<binary> +0x<offset>`), with every key or token shape taken out; any other frame is logged as `[redacted]`.

Permission: `diagnostics.report` (Every member).

### Request body (application/json, required)

- `reports` (array of DiagnosticReport, required) [at most 20 items]
  - `kind` ("error" | "crash", required): `error`: an error in the app's JavaScript; `crash`: a native crash (the OS's, or a desktop panic) seen at the next start
  - `fatal` (boolean, required): Whether it ended the app
  - `name` (string, required): The error's name (`TypeError`), or the crash's exception and signal [min length 1; max length 120]
  - `message` (string): The error's message, already redacted by the app; may be empty [max length 500]
  - `stack` (array of string): The top frames: a function and its place in the bundle, or a binary and its offset [at most 64 items]
  - `occurredAt` (string (date-time), required): When it happened
  - `appVersion` (string, required): The app's version [min length 1; max length 40]
  - `appBuild` (string | null): The store build number, when the app knows it [min length 1; max length 40]
  - `platform` ("ios" | "android" | "macos" | "windows" | "linux" | "web", required)
  - `osVersion` (string, required): The OS version the report came from [min length 1; max length 40]

### Responses

- `202` Logged (application/json, DiagnosticReportsAccepted)
  - `accepted` (integer, required): How many reports went to the log
- `400` A report breaks the contract (`invalid_report`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Not one of the organization's people: a service account, a module or a sandbox (`permission_error`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A report breaks the contract (`invalid_report`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/diagnostics/reports" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "reports": [
      {
        "kind": "error",
        "fatal": false,
        "name": "Platform",
        "occurredAt": "2026-10-01T00:00:00Z",
        "appVersion": "<appVersion>",
        "platform": "ios",
        "osVersion": "<osVersion>"
      }
    ]
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdiagnostics%2Freports)

## Send activity heartbeat

`POST /v1/diagnostics/heartbeat`

Report one active minute of the caller on an app: the app's window has focus and the person acted in the last minute. The Gateway keeps active minutes per UTC day, organization, person, surface, app, app version and OS, and the last minute per app. Labels come from fixed lists and versions are bounded: no content, path or address is kept.

Permission: `diagnostics.report` (Every member).

### Request body (application/json, required)

- `surface` ("code" | "chat" | "wiki" | "review" | "pages" | "other", required): What the person looks at: Code (or an agent session), Chat, Wiki, Review, Pages (with Slides and Design), or any other screen
- `app` ("desktop" | "desktop-gpui" | "web" | "cli" | "mobile", required): The app that reports
- `appVersion` (string, required): The app's version, such as 0.31.0+abc1234 [pattern ^[0-9A-Za-z.+-]{1,32}$]
- `os` ("macos" | "windows" | "linux" | "ios" | "android" | "other", required): The OS family
- `osVersion` (string): The OS release, such as 15.1 [pattern ^[0-9A-Za-z._-]{1,32}$]
- `browser` ("chrome" | "safari" | "firefox" | "edge" | "other"): The web app's browser; the web app only
- `browserVersion` (string): The browser's major version; the web app only [pattern ^[0-9]{1,4}$]

### Responses

- `200` Checked; `recorded` says whether a minute counted (application/json, HeartbeatRecorded)
  - `recorded` (boolean, required): Whether the heartbeat counted a minute: false when collection is off, or when the person's minute on this app was already counted
- `400` A value outside its list or pattern (`invalid_heartbeat`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Not a person: a service account, a module, an agent link or an operator (`role_required`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A value outside its list or pattern (`invalid_heartbeat`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/diagnostics/heartbeat" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "surface": "code",
    "app": "desktop",
    "appVersion": "<appVersion>",
    "os": "macos"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdiagnostics%2Fheartbeat)

## Send client errors

`POST /v1/diagnostics/errors`

Report errors the caller's app caught, with no content: the app, its version and OS, a kind from a fixed list, and a component and a code the app names from its own code. Never a message, a stack, a path or a URL: the pattern refuses spaces, '/', ':' and '@', and the app must not put content in a name. The Gateway counts them per UTC day, organization, person, app, version, OS, kind, component and code, and keeps each person's last 50 per organization.

Permission: `diagnostics.report` (Every member).

### Request body (application/json, required)

- `errors` (array of ClientError, required) [at most 20 items]
  - `app` ("desktop" | "desktop-gpui" | "web" | "cli" | "mobile", required): The app that reports
  - `appVersion` (string, required): The app's version, such as 0.31.0+abc1234 [pattern ^[0-9A-Za-z.+-]{1,32}$]
  - `os` ("macos" | "windows" | "linux" | "ios" | "android" | "other", required): The OS family
  - `osVersion` (string): The OS release, such as 15.1 [pattern ^[0-9A-Za-z._-]{1,32}$]
  - `kind` ("crash" | "render" | "network" | "sign_in" | "update" | "agent" | "storage" | "other", required): Crash: a panic or native crash; render: a UI error boundary; network: a request from the app failed; sign_in; update: the updater; agent: a local agent did not start or ended badly; storage: local files or the keychain; other
  - `component` (string, required): The app's own name for where it failed, such as diff_view: never text from the error [pattern ^[a-z0-9_.-]{1,64}$]
  - `code` (string, required): The app's own error code, such as panic or callback_timeout: never text from the error [pattern ^[a-z0-9_.-]{1,64}$]
  - `fatal` (boolean): Whether it ended the app or the window; false when absent
  - `occurredAt` (string (date-time)): When it happened (RFC 3339); the Gateway's now when absent or out of bounds

### Responses

- `200` Checked; `recorded` says how many were stored (application/json, ClientErrorsRecorded)
  - `recorded` (integer, required): How many errors were stored: 0 when collection is off
- `400` A value outside its list or pattern (`invalid_client_error`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Not a person: a service account, a module, an agent link or an operator (`role_required`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A value outside its list or pattern (`invalid_client_error`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/diagnostics/errors" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "errors": [
      {
        "app": "desktop",
        "appVersion": "<appVersion>",
        "os": "macos",
        "kind": "crash",
        "component": "<component>",
        "code": "<code>"
      }
    ]
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdiagnostics%2Ferrors)

## Send frame failures

`POST /v1/diagnostics/frame-failures`

Report artifact frames that failed to load, with no content: the surface, how it failed, the app and browser versions, and the frame's host, the artifact's id and the HTTP status when the app knows them. Never a URL, a path, a share token or free text: each field is a fixed list or a pattern. The Gateway counts each failure in `nexus_gateway_artifact_frame_failures_total`, which holds no identity, and stores nothing. With `NEXUS_COLLECT_FRAME_FAILURES=true` it also writes one `nexus::artifact_frame_failure` log line per failure; off, the default, it logs nothing and `accepted` is 0.

Permission: `diagnostics.report` (Every member).

### Request body (application/json, required)

- `failures` (array of FrameFailure, required) [at most 10 items]
  - `surface` ("api" | "share_link" | "subdomain", required)
  - `kind` ("error" | "timeout" | "blocked" | "csp" | "http", required)
  - `app` ("web" | "desktop-gpui", required)
  - `appVersion` (string, required) [pattern ^[0-9A-Za-z.+-]{1,32}$]
  - `browser` ("chrome" | "safari" | "firefox" | "edge" | "webkit" | "other")
  - `browserVersion` (string) [pattern ^[0-9]{1,4}$]
  - `artifactId` (string) [pattern ^[A-Za-z0-9_-]{1,64}$]
  - `host` (string): The frame's host name: the sandbox subdomain [pattern ^[a-z0-9.-]{1,253}$]
  - `status` (integer) [min 100; max 599]
  - `occurredAt` (string (date-time)) [max length 40]

### Responses

- `202` Logged; `accepted` says how many (application/json, FrameFailuresAccepted)
  - `accepted` (integer, required): How many failures were logged: 0 while `NEXUS_COLLECT_FRAME_FAILURES` is off
- `400` A value outside its list or pattern (`invalid_frame_failure`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Not a person: a service account, a module, an agent link or an operator (`role_required`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A value outside its list or pattern (`invalid_frame_failure`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/diagnostics/frame-failures" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "failures": [
      {
        "surface": "api",
        "kind": "error",
        "app": "web",
        "appVersion": "<appVersion>"
      }
    ]
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdiagnostics%2Fframe-failures)

## Send public frame failures

`POST /v1/public/frame-failures`

Report artifact frames that failed to load from the public share-link viewer: the same body as the signed-in route. No credential; limited per address, one count per request, on the public artifact reads' limit. With logging on, the line carries `org` "public" and no person.

Permission: `public` (Anyone, signed in or not).

### Request body (application/json, required)

- `failures` (array of FrameFailure, required) [at most 10 items]
  - `surface` ("api" | "share_link" | "subdomain", required)
  - `kind` ("error" | "timeout" | "blocked" | "csp" | "http", required)
  - `app` ("web" | "desktop-gpui", required)
  - `appVersion` (string, required) [pattern ^[0-9A-Za-z.+-]{1,32}$]
  - `browser` ("chrome" | "safari" | "firefox" | "edge" | "webkit" | "other")
  - `browserVersion` (string) [pattern ^[0-9]{1,4}$]
  - `artifactId` (string) [pattern ^[A-Za-z0-9_-]{1,64}$]
  - `host` (string): The frame's host name: the sandbox subdomain [pattern ^[a-z0-9.-]{1,253}$]
  - `status` (integer) [min 100; max 599]
  - `occurredAt` (string (date-time)) [max length 40]

### Responses

- `202` Logged; `accepted` says how many (application/json, FrameFailuresAccepted)
  - `accepted` (integer, required): How many failures were logged: 0 while `NEXUS_COLLECT_FRAME_FAILURES` is off
- `400` A value outside its list or pattern (`invalid_frame_failure`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A value outside its list or pattern (`invalid_frame_failure`) |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/public/frame-failures" \
  -H "Content-Type: application/json" \
  -d '{
    "failures": [
      {
        "surface": "api",
        "kind": "error",
        "app": "web",
        "appVersion": "<appVersion>"
      }
    ]
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpublic%2Fframe-failures)

## Send daily active

`POST /v1/public/daily-active`

Report that this install of the open-source desktop app was used today: a random install ID, the day, the app version and release channel, the OS, its major and minor version, the CPU type, and how the app reached models. No credential: the app sends it at most once a day, only while its person has "Send usage data" on. Never a prompt, code, path, name or account. With `NEXUS_COLLECT_DAILY_ACTIVE=true` the Gateway keeps one row per UTC day and install ID for 90 days, then only counts with no install ID; off, the default, it keeps nothing and `accepted` is false. The client's address is never kept with the event.

Permission: `public` (Anyone, signed in or not).

### Request body (application/json, required)

- `install_id` (string, required): A random UUID v4 the app made when its person turned usage data on, in lower case. No account links to it [pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$]
- `day` (string (date), required): The UTC day the app was used, from a week ago to tomorrow
- `app_version` (string, required) [pattern ^[0-9A-Za-z.+-]{1,32}$]
- `channel` ("stable" | "beta" | "internal" | "other", required)
- `os` ("macos" | "linux" | "windows", required)
- `os_version` (string): Major and minor only. Absent when the system names none [pattern ^[0-9]{1,4}(\.[0-9]{1,4})?$]
- `arch` ("arm64" | "x86_64", required)
- `modes` (array of "own_subscription" | "own_key" | "own_model" | "cloud"): How the app reached models that day. `cloud`: signed in to Nexus Cloud [at most 4 items]

### Responses

- `202` Checked; `accepted` says whether it was kept (application/json, DailyActiveAccepted)
  - `accepted` (boolean, required): Whether the day was kept: false while `NEXUS_COLLECT_DAILY_ACTIVE` is off
- `400` A value outside its list or pattern, or a day outside the last week (`invalid_daily_active`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A value outside its list or pattern, or a day outside the last week (`invalid_daily_active`) |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/public/daily-active" \
  -H "Content-Type: application/json" \
  -d '{
    "install_id": "<install_id>",
    "day": "2026-10-01",
    "app_version": "<app_version>",
    "channel": "stable",
    "os": "macos",
    "arch": "arm64"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpublic%2Fdaily-active)

## Send feedback

`POST /v1/diagnostics/feedback`

Send feedback, a crash report the person chose to send, or a report on a model's answer (App Review 1.2), to Nexus's team. The Gateway posts one message to the feedback channel in Slack (`NEXUS_FEEDBACK_SLACK_WEBHOOK_URL`) and keeps no copy. The message names the person (name and email) and the organization, so the team can answer, with the app, its version, the OS and the screen. What the person wrote is shown as plain text, so it cannot mention a channel or a person, hide a link, or pass for the Gateway's own lines; names are code spans, and Slack previews no link. A crash shows its redacted name and message and its top frames, as `POST /v1/diagnostics/reports` logs them, and is logged as one `nexus::client_report` line too. A reported answer shows its reason and model, then the answer as plain text, as the app showed it.

Permission: `feedback.send` (Every member).

### Request body (application/json, required)

- `category` ("bug" | "idea" | "other" | "crash" | "report" | "triage", required): What it is. `crash` carries `crash`, and only it does; `report` carries `answer`, and only it does; `triage` is a report that `nexus triage`'s agent wrote, sent only by Nexus's own people to the triage channel (`NEXUS_TRIAGE_SLACK_WEBHOOK_URL`)
- `message` (string): What the person wrote: 1 to 4000 characters (12000 with `triage`), or empty with a crash or a report. Slack shows it as plain text [max length 12000]
- `screen` (string | null): The screen the person was on, as its route's shape (`/acme/sessions/:id`): letters, digits and / _ . ~ - :, never a query [min length 1; max length 120; pattern ^/[A-Za-z0-9/_.~:-]*$]
- `appVersion` (string, required): The app's version [min length 1; max length 40]
- `appBuild` (string | null): The build, when the app knows it [min length 1; max length 40]
- `platform` ("ios" | "android" | "macos" | "windows" | "linux" | "web", required)
- `osVersion` (string, required): The OS's version, or the browser's [min length 1; max length 40]
- `crash` (DiagnosticReport | null): The crash the app saw at this start, which the person chose to send; logged as a diagnostic report too
- `answer` (ReportedAnswer | null): With the category `report`: the model's answer the person reported, as the app showed it

### Responses

- `200` Posted to the channel (application/json, FeedbackSent)
  - `sent` (true, required)
- `400` Feedback that breaks the contract (`invalid_feedback`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Not one of the organization's people: a service account, a module or a sandbox (`permission_error`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `502` Slack did not take the message (`upstream_error`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `503` No feedback channel on this Gateway (`not_configured`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | Feedback that breaks the contract (`invalid_feedback`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |
| 502 |  | Slack did not take the message (`upstream_error`) |
| 503 |  | No feedback channel on this Gateway (`not_configured`) |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/diagnostics/feedback" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "category": "bug",
    "appVersion": "<appVersion>",
    "platform": "ios",
    "osVersion": "<osVersion>"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdiagnostics%2Ffeedback)

## Get notification settings

`GET /v1/notifications/settings`

Your notification settings in this organization: one row per group and channel.

Permission: `notifications.use` (Every member).

### Responses

- `200` OK (application/json, NotificationSettings)
  - `settings` (array of NotificationSetting, required)
    - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required)
    - `channel` ("inbox" | "email" | "push", required)
    - `setting` ("on" | "off", required): Your choice, else the default
    - `default` ("on" | "off", required): On when one of the group's kinds uses the channel before anyone chooses
    - `locked` (boolean, required): The inbox: always on, no setting changes it
    - `required` (boolean, required): The group holds a required kind, which off does not mute
    - `available` (boolean, required): The channel can reach the person on this Gateway. Always true: push reaches a desktop app, which collects its deliveries, even where Web Push has no keys. Kept for older clients
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/notifications/settings" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fnotifications%2Fsettings)

## Set notification settings

`PUT /v1/notifications/settings`

Change one or more of your notification settings. Answers with every setting.

Permission: `notifications.use` (Every member).

### Request body (application/json, required)

- `settings` (array of object, required) [at most 20 items]
  - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required)
  - `channel` ("email" | "push", required)
  - `setting` ("on" | "off", required)

### Responses

- `200` OK (application/json, NotificationSettings)
  - `settings` (array of NotificationSetting, required)
    - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required)
    - `channel` ("inbox" | "email" | "push", required)
    - `setting` ("on" | "off", required): Your choice, else the default
    - `default` ("on" | "off", required): On when one of the group's kinds uses the channel before anyone chooses
    - `locked` (boolean, required): The inbox: always on, no setting changes it
    - `required` (boolean, required): The group holds a required kind, which off does not mute
    - `available` (boolean, required): The channel can reach the person on this Gateway. Always true: push reaches a desktop app, which collects its deliveries, even where Web Push has no keys. Kept for older clients
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/notifications/settings" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "settings": [
      {
        "group": "my_sessions",
        "channel": "email",
        "setting": "on"
      }
    ]
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fnotifications%2Fsettings)

## Get notification push key

`GET /v1/notifications/push-key`

The public key a browser subscribes to Web Push with.

Permission: `notifications.use` (Every member).

### Responses

- `200` OK (application/json, NotificationPushKey)
  - `publicKey` (string, required): The application server's secp256r1 public key (VAPID), uncompressed, base64url without padding: the browser's applicationServerKey
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `503` Web Push is not configured on this Gateway (`not_configured`). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |
| 503 |  | Web Push is not configured on this Gateway (`not_configured`). |

### Example

```sh
curl "$NEXUS_URL/v1/notifications/push-key" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fnotifications%2Fpush-key)

## List notification devices

`GET /v1/notifications/devices`

Your devices that take push in this organization. No answer holds a token.

Permission: `notifications.use` (Every member).

### Responses

- `200` OK (application/json, NotificationDevices)
  - `devices` (array of NotificationDevice, required)
    - `id` (string, required)
    - `platform` ("web" | "desktop" | "ios" | "android", required)
    - `createdAt` (string (date-time), required)
    - `lastSeenAt` (string (date-time), required)
    - `revokedAt` (string (date-time))
    - `revokedReason` ("signed_out" | "lost" | "left" | "rejected" | "replaced")
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/notifications/devices" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fnotifications%2Fdevices)

## Register notification device

`POST /v1/notifications/devices`

Register this device for push, or refresh it. Registering the same token again answers the same device.

Permission: `notifications.use` (Every member).

### Request body (application/json, required)

- `platform` ("web" | "desktop" | "ios" | "android", required)
- `token` (string, required): The push service's token: for `web`, the browser's push subscription JSON (`endpoint` on a known push service, `keys.p256dh`, `keys.auth`), checked at registration; an APNs or FCM token otherwise. Sealed, never answered back. [min length 1; max length 4096]

### Responses

- `200` OK (application/json, NotificationDevice)
  - `id` (string, required)
  - `platform` ("web" | "desktop" | "ios" | "android", required)
  - `createdAt` (string (date-time), required)
  - `lastSeenAt` (string (date-time), required)
  - `revokedAt` (string (date-time))
  - `revokedReason` ("signed_out" | "lost" | "left" | "rejected" | "replaced")
- `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `409` You hold 20 live devices in this organization (`device_limit`). Remove one first. (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 409 |  | You hold 20 live devices in this organization (`device_limit`). Remove one first. |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/notifications/devices" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "web",
    "token": "<token>"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fnotifications%2Fdevices)

## Revoke notification device

`DELETE /v1/notifications/devices/{id}`

Stop push to one of your devices. Not yours, revoked already or unknown: 404.

Permission: `notifications.use` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The device's id (`ndv_…`) |
| `reason` | query | "lost" \| "signed_out" | no | Why the device stops: `lost` when omitted |

### Responses

- `200` OK (application/json, NotificationDevice)
  - `id` (string, required)
  - `platform` ("web" | "desktop" | "ios" | "android", required)
  - `createdAt` (string (date-time), required)
  - `lastSeenAt` (string (date-time), required)
  - `revokedAt` (string (date-time))
  - `revokedReason` ("signed_out" | "lost" | "left" | "rejected" | "replaced")
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X DELETE "$NEXUS_URL/v1/notifications/devices/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fnotifications%2Fdevices%2F%7Bid%7D)

## Collect notification deliveries

`POST /v1/notifications/devices/{id}/collect`

Collect a desktop device's notifications, once each. Not yours, revoked or unknown: 404.

Permission: `notifications.use` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The device's id (`ndv_…`) |

### Responses

- `200` OK (application/json, CollectedNotifications)
  - `items` (array of CollectedNotification, required)
    - `kind` (string, required): The kind's name
    - `eventId` (string, required): The inbox item's key
    - `title` (string, required): The kind's fixed subject, or a month report's summary from its figures only: no text a tenant wrote
    - `body` (string): A month report's second line, from its figures only. Absent for other kinds
    - `path` (string, required): The path the notice opens. It names no organization; a month report opens Usage on its month
    - `deliveryId` (string, required): The delivery's id (`ndl_…`)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/notifications/devices/<id>/collect" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fnotifications%2Fdevices%2F%7Bid%7D%2Fcollect)

## Create voice speech

`POST /v1/chat/voice-speech`

A piece of a voice-mode answer, said by ElevenLabs: the app plays the `audio/mpeg` it answers, and Nexus's own key stays on the Gateway.

Permission: `chat.use` (Every member).

### Request body (application/json, required)

- `text` (string, required): The text to say: 1 to 500 characters, not only spaces. [min length 1; max length 500]

### Responses

- `200` The speech, as MP3. (audio/mpeg, string (binary))
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/chat/voice-speech" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "<text>"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fvoice-speech)

## Create voice token

`POST /v1/chat/voice-token`

A short-lived token for dictation: the app's microphone button streams audio to AssemblyAI's speech to text with it, and Nexus's own key stays on the Gateway.

Permission: `chat.use` (Every member).

### Responses

- `200` OK (application/json, VoiceToken)
  - `token` (string, required): The streaming token. It opens one session.
  - `url` (string, required): The WebSocket to open, token included.
  - `sampleRate` (integer, required): The sample rate the audio must have: 16000.
  - `expiresInSeconds` (integer, required): Seconds from now until the token can no longer open a session.
  - `maxSessionSeconds` (integer, required): The longest one session may run, in seconds.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/chat/voice-token" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fvoice-token)

## Ask owners

`POST /v1/notifications/ask-owner`

Ask the organization's owners about a billing block: a reached usage limit, used-up credits or free start, a failed charge, an unpaid invoice, or the plan.

Permission: `notifications.use` (Every member).

### Request body (application/json, required)

- `block` ("usage_limit" | "credits_out" | "free_start_used" | "payment_failed" | "past_due" | "billing", required): What stops you: a reached usage limit, used-up credits, a used-up free start, a failed charge, an unpaid invoice, or `billing` for a question about the plan and its usage

### Responses

- `200` OK (application/json, AskOwnersResponse)
  - `status` ("sent" | "already_asked", required): `sent`: each owner gets an inbox item and an email now. `already_asked`: you asked about this block today (UTC), so nobody is told again.
- `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/notifications/ask-owner" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "block": "usage_limit"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fnotifications%2Fask-owner)
