# Models and policies

> The model catalog (supported and coming soon), model access policies (allow and deny lists per organization, team and coding agent; a deny always wins; levels only narrow), and the policy test. Nexus calls providers directly.

## List models

`GET /v1/models`

The models you may use under your organization's, team's and key's policies (OpenAI-compatible list, with Nexus's fields: each supported model's context window, output limit, reasoning and list prices, enough for a client to offer it without a catalog of its own). Send the key as `Authorization: Bearer <key>` or `x-api-key: <key>`. **With a key**: `status=allowed` (the default) gives the models you may use; `status=all` the whole catalog with `allowed` and `status`; `supported` or `coming_soon` filter it. `team`: as for a call (else `x-nexus-team`, else your default team). **Without a key** (the public catalog, for the model pages and other readers): the catalog itself, the same for everyone, `supported` models by default and `status=all` or `coming_soon` on request, with no `allowed` field, no `status=allowed` and no `team` (asking for `status=allowed` or a team, by `team` or `x-nexus-team`, is a 401); limited per address, and cacheable (`Cache-Control: public`, `Vary: Authorization, X-Api-Key, X-Nexus-Ui-Secret`). A wrong key is a 401, as on every route.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `status` | query | "allowed" \| "all" \| "supported" \| "coming_soon" | no | With a key: `allowed` (the default), `all`, `supported` or `coming_soon`. Without a key: `supported` (the default), `all` or `coming_soon`; `allowed` needs a key and is a 401 without one. |
| `team` | query | string | no |  |

### Responses

- `200` OK (application/json, object)
  - `object` ("list")
  - `data` (array of Model)
    - `id` (string): Canonical: maker/model
    - `object` ("model")
    - `created` (integer)
    - `owned_by` (string): The maker: who made the model, the first part of its id
    - `provider` (string): Supported models: the host that serves it, whose rules price it and whose key pays for it
    - `name` (string)
    - `family` (string)
    - `status` ("supported" | "coming_soon")
    - `allowed` (boolean)
    - `surfaces` (array of string)
    - `input` (array of "text" | "image"): Supported models: what it reads; `image` when chat questions with images may use it
    - `provider_model` (string)
    - `context_window` (integer): Supported models: input and output tokens together, at most
    - `web_search_usd` (number): One hosted web search's list price in US dollars, set when the model can run a chat's web search; absent otherwise
    - `max_output_tokens` (integer): Supported models: the longest output, which Core reserves when a call names no limit. It holds on the agents' pass-through (`/v1/anthropic`, `/v1/openai`); the chat paths cap output at the deployment's limit (`NEXUS_MAX_TOKENS`, 4,096 by default): `/v1/chat/completions` refuses a larger `max_tokens` with a 400, and Nexus chat answers within it, except rounds that offer the `write_page` tool, which ask for up to 16,384 tokens within the model's own limit
    - `reasoning` (object): Supported models: how it reasons
      - `mode` ("effort" | "budget" | "none"): How a call steers it: an effort level (`efforts`), a token budget (Anthropic extended thinking, `budget_tokens`), or not at all (the model does not reason)
      - `efforts` (array of "low" | "medium" | "high" | "xhigh" | "max"): The values the provider's effort setting takes (Anthropic `output_config.effort`, OpenAI `reasoning.effort`), lowest first; empty unless `mode` is `effort`
      - `default_effort` (string | null): The provider's default effort; null where the provider states none
      - `can_disable` (boolean): Whether a call may turn reasoning off with the provider's own switch (Anthropic `thinking: {"type": "disabled"}`, OpenAI `reasoning.effort: "none"`), at some effort at least: see `disable_max_effort`
      - `disable_max_effort` ("low" | "medium" | "high" | "xhigh" | "max" | null): The highest effort at which `can_disable` holds (Claude Opus 5 and Claude Haiku 5.5: `high`); null when it holds at every effort, or `can_disable` is false
    - `pricing` (object): List prices Core meters with, per million tokens (supported models). An OpenAI model's `cache_write` sizes a call's reservation, but settlement does not charge it yet
      - `input` (number)
      - `output` (number)
      - `cache_read` (number): Cache reads
      - `cache_write` (number): Cache writes (Anthropic: 5-minute writes; 0 where the provider does not price them)
      - `cache_write_1h` (number): Anthropic: 1-hour cache writes
      - `long_context` (object): The rates above `above` input tokens, where the model has a long-context tier
        - `above` (integer)
        - `input` (number)
        - `output` (number)
        - `cache_read` (number): Cache reads
        - `cache_write` (number): Cache writes (Anthropic: 5-minute writes; 0 where the provider does not price them)
        - `cache_write_1h` (number): Anthropic: 1-hour cache writes
      - `unit` (string)
    - `default_for` (array of string)
    - `note` (string)
    - `openWeights` (boolean | null): Catalog classification. True means open weights. Null means unclassified.
  - `unavailable` (array of object): Models the Gateway knows of but cannot serve yet, each with why. They are not in `data` and cannot be called. A model may move from here to `data` without notice.
    - `id` (string, required)
    - `reason` (string, required)
  - `team` (string)
- `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.
- `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.
- `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.
- `503` Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Retry after `Retry-After` 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.
- `504` The request passed Gateway's deadline, 30 seconds by default (`timeout`). Model calls that may stream are outside it. (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 |
| 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`. |
| 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 |
| 503 |  | Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Retry after `Retry-After` seconds. |
| 504 |  | The request passed Gateway's deadline, 30 seconds by default (`timeout`). Model calls that may stream are outside it. |

### Example

```sh
curl "$NEXUS_URL/v1/models" \
  -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.models({ status: "all" });
```

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

## List providers

`GET /v1/providers`

The providers the Gateway calls, from the catalog: each one's id, name, country, whether an organization may bring its own key (`byok`), whether the Gateway calls it (`status`), how many listed models it hosts, its `rates` (what a model on it costs beyond its input and output prices), the host of its API (`apiHost`) and what the Gateway calls it for (`serving`). Send the key as `Authorization: Bearer <key>` or `x-api-key: <key>`. **With a key**: each BYOK provider also carries `key`, the state of the organization's own key: `none` (none stored, or disabled), `valid` or `rejected`. It never returns the key or any part of it; `listProviderKeys` shows the last four characters. **Without a key**: the same list for everyone, with no `key` field; limited per address with the public model catalog, and cacheable (`Cache-Control: public`, `Vary: Authorization, X-Api-Key, X-Nexus-Ui-Secret`). A wrong key is a 401, as on every route.

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

### Responses

- `200` OK (application/json, object)
  - `object` ("list", required)
  - `data` (array of Provider, required)
    - `id` (string, required): Its id in stored keys, spend records and the policy's `providers` lists (`anthropic`).
    - `name` (string, required): Its name in messages (`Anthropic`).
    - `country` (string, required): The ISO 3166-1 alpha-2 code of the country it is headquartered in.
    - `byok` (boolean, required): Whether an organization may bring its own key for it (`addProviderKey`).
    - `status` ("active" | "inactive", required): Whether the Gateway calls it. A model on an inactive provider is neither listed nor callable.
    - `models` (integer, required): How many listed models it hosts. [min 0]
    - `rates` (ProviderRates, required): What a model on the provider costs beyond its input and output prices, where the model states no price of its own. `listModels` gives each model's own prices.
      - `cacheReadShare` (number | null, required): A cache read's price, as a share of the model's input price (`0.1` is 10%). `null`: each model has its own cache-read price.
      - `cacheWrite` (object | object, required): How a cache write is priced. `multipliers`: a multiple of the model's input price, by how long the cache entry lives. `model_rate`: the model's own cache-write price, or its input price when it has none.
      - `webSearchUsd` (string | null, required): One hosted web search, in US dollars, as a decimal string (`"0.010000"`). `null`: the Gateway runs no hosted web search on this provider.
    - `apiHost` (string, required): The host of the provider's public API (`api.anthropic.com`).
    - `serving` ("model_api" | "decisions", required): What the Gateway calls the provider for. `model_api`: its models, on chat completions and the pass-through APIs. `decisions`: typed decisions only (`POST /v1/decisions`).
    - `key` ("none" | "valid" | "rejected"): With a key, on a BYOK provider only: the organization's own key. `none`: none stored, or disabled. `rejected`: the provider refused it. `valid`: a call uses it.
    - `enabled` (boolean): With a key: whether the organization's provider policy (`ModelRule.providers`) lets calls use it.
- `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 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.
- `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/providers" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

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

## Get organization policy

`GET /v1/policies/organization`

The organization's model policy, what it inherits from this Gateway, and what it allows.

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

### Responses

- `200` OK (application/json, ModelPolicy)
  - `level` ("organization" | "team" | "agent")
  - `subject` (string)
  - `team` (object)
  - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported).
    - `allow` (array of string) [at most 100 items]
    - `deny` (array of string) [at most 100 items]
    - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists.
      - `chat` (string)
      - `claude` (string)
      - `codex` (string)
    - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows.
      - `input` (number) [min 0]
      - `output` (number) [min 0]
    - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows.
      - `maker` (array of string)
      - `provider` (array of string)
    - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`.
      - `allow` (array of string)
      - `deny` (array of string)
  - `custom` (boolean): False: no rule at this level
  - `migrated` (boolean): Read from the old agent policy, not saved since
  - `updatedAt` (string (date-time))
  - `inherited` (array of object)
  - `effective` (object): What the levels down to this one allow, and the defaults they resolve to
  - `notes` (array of string)
- `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_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 |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_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). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/policies/organization" \
  -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.policy("organization");
```

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

## Set organization policy

`PUT /v1/policies/organization`

Replace the organization's model policy (owners and admins). An empty rule removes it. Audited as `policy.changed`.

Permission: `policy.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)

- `allow` (array of string) [at most 100 items]
- `deny` (array of string) [at most 100 items]
- `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists.
  - `chat` (string)
  - `claude` (string)
  - `codex` (string)
- `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows.
  - `input` (number) [min 0]
  - `output` (number) [min 0]
- `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows.
  - `maker` (array of string)
  - `provider` (array of string)
- `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`.
  - `allow` (array of string)
  - `deny` (array of string)

### Responses

- `200` OK (application/json, ModelPolicy)
  - `level` ("organization" | "team" | "agent")
  - `subject` (string)
  - `team` (object)
  - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported).
    - `allow` (array of string) [at most 100 items]
    - `deny` (array of string) [at most 100 items]
    - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists.
      - `chat` (string)
      - `claude` (string)
      - `codex` (string)
    - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows.
      - `input` (number) [min 0]
      - `output` (number) [min 0]
    - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows.
      - `maker` (array of string)
      - `provider` (array of string)
    - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`.
      - `allow` (array of string)
      - `deny` (array of string)
  - `custom` (boolean): False: no rule at this level
  - `migrated` (boolean): Read from the old agent policy, not saved since
  - `updatedAt` (string (date-time))
  - `inherited` (array of object)
  - `effective` (object): What the levels down to this one allow, and the defaults they resolve to
  - `notes` (array of string)
- `400` Not a valid rule (`invalid_policy`), or `providers` names an id that is not a catalog provider (`unknown_provider`), or `providers.allow` is empty (`providers_allow_empty`): omit `allow` to allow every provider (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 caller does not hold `policy.manage`: only owners and admins set the organization's policy (`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 |  | Not a valid rule (`invalid_policy`), or `providers` names an id that is not a catalog provider (`unknown_provider`), or `providers.allow` is empty (`providers_allow_empty`): omit `allow` to allow every provider |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins set the organization's policy (`role_required`). |
| 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 PUT "$NEXUS_URL/v1/policies/organization" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "deny": [
      "anthropic/claude-fable-*"
    ]
  }'
```

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

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.setPolicy("organization", undefined, { deny: ["anthropic/claude-fable-*"] });
```

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

## Get team policy

`GET /v1/policies/teams/{slug}`

A team's model policy: its own rule, the organization's and its parent teams' (it only narrows them), and what they add up to.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `slug` | path | string | yes |  |

### Responses

- `200` OK (application/json, ModelPolicy)
  - `level` ("organization" | "team" | "agent")
  - `subject` (string)
  - `team` (object)
  - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported).
    - `allow` (array of string) [at most 100 items]
    - `deny` (array of string) [at most 100 items]
    - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists.
      - `chat` (string)
      - `claude` (string)
      - `codex` (string)
    - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows.
      - `input` (number) [min 0]
      - `output` (number) [min 0]
    - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows.
      - `maker` (array of string)
      - `provider` (array of string)
    - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`.
      - `allow` (array of string)
      - `deny` (array of string)
  - `custom` (boolean): False: no rule at this level
  - `migrated` (boolean): Read from the old agent policy, not saved since
  - `updatedAt` (string (date-time))
  - `inherited` (array of object)
  - `effective` (object): What the levels down to this one allow, and the defaults they resolve to
  - `notes` (array of string)
- `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_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.
- `404` No team with this slug or id in this 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 |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No team with this slug or id in this 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/policies/teams/platform" \
  -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.policy("team", "platform");
```

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

## Set team policy

`PUT /v1/policies/teams/{slug}`

Replace a team's model policy (owners and admins; a team lead for a team they lead or one under it, and only to narrow it). Audited.

Permission: `policy.manage_team` (Owner, Admin, Team lead).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `slug` | path | string | yes |  |
| `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)

- `allow` (array of string) [at most 100 items]
- `deny` (array of string) [at most 100 items]
- `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists.
  - `chat` (string)
  - `claude` (string)
  - `codex` (string)
- `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows.
  - `input` (number) [min 0]
  - `output` (number) [min 0]
- `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows.
  - `maker` (array of string)
  - `provider` (array of string)
- `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`.
  - `allow` (array of string)
  - `deny` (array of string)

### Responses

- `200` OK (application/json, ModelPolicy)
  - `level` ("organization" | "team" | "agent")
  - `subject` (string)
  - `team` (object)
  - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported).
    - `allow` (array of string) [at most 100 items]
    - `deny` (array of string) [at most 100 items]
    - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists.
      - `chat` (string)
      - `claude` (string)
      - `codex` (string)
    - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows.
      - `input` (number) [min 0]
      - `output` (number) [min 0]
    - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows.
      - `maker` (array of string)
      - `provider` (array of string)
    - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`.
      - `allow` (array of string)
      - `deny` (array of string)
  - `custom` (boolean): False: no rule at this level
  - `migrated` (boolean): Read from the old agent policy, not saved since
  - `updatedAt` (string (date-time))
  - `inherited` (array of object)
  - `effective` (object): What the levels down to this one allow, and the defaults they resolve to
  - `notes` (array of string)
- `400` Not a valid rule (`invalid_policy`). `providers` is refused here too: it is set on the organization's policy only. (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 caller is not an owner, an admin or a team lead (`role_required`); a lead names a team outside their teams (`outside_led_teams`); or a lead's rule widens the stored one (`policy_widens`) (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.
- `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 a valid rule (`invalid_policy`). `providers` is refused here too: it is set on the organization's policy only. |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | The caller is not an owner, an admin or a team lead (`role_required`); a lead names a team outside their teams (`outside_led_teams`); or a lead's rule widens the stored one (`policy_widens`) |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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`. |
| 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 PUT "$NEXUS_URL/v1/policies/teams/platform" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "allow": [
      "anthropic/*"
    ],
    "defaults": {
      "chat": "anthropic/claude-haiku-5.5"
    }
  }'
```

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

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.setPolicy("team", "platform", { allow: ["anthropic/*"] });
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Fteams%2F%7Bslug%7D)

## Get agent policy

`GET /v1/policies/agents/{agent}`

A coding agent's model policy (was the old agent policy, migrated as its allow list and default).

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `agent` | path | "claude" \| "codex" \| "antigravity" \| "cursor" \| "opencode" | yes |  |

### Responses

- `200` OK (application/json, ModelPolicy)
  - `level` ("organization" | "team" | "agent")
  - `subject` (string)
  - `team` (object)
  - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported).
    - `allow` (array of string) [at most 100 items]
    - `deny` (array of string) [at most 100 items]
    - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists.
      - `chat` (string)
      - `claude` (string)
      - `codex` (string)
    - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows.
      - `input` (number) [min 0]
      - `output` (number) [min 0]
    - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows.
      - `maker` (array of string)
      - `provider` (array of string)
    - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`.
      - `allow` (array of string)
      - `deny` (array of string)
  - `custom` (boolean): False: no rule at this level
  - `migrated` (boolean): Read from the old agent policy, not saved since
  - `updatedAt` (string (date-time))
  - `inherited` (array of object)
  - `effective` (object): What the levels down to this one allow, and the defaults they resolve to
  - `notes` (array of string)
- `400` The path names no coding agent: `agent` must be `claude`, `codex`, `antigravity` or `cursor` (`invalid_request`); or it names one without a Gateway route, which has no model policy (`route_unsupported`). (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 credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_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 |  | The path names no coding agent: `agent` must be `claude`, `codex`, `antigravity` or `cursor` (`invalid_request`); or it names one without a Gateway route, which has no model policy (`route_unsupported`). |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). |
| 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 "$NEXUS_URL/v1/policies/agents/claude" \
  -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.policy("agent", "claude");
```

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

## Set agent policy

`PUT /v1/policies/agents/{agent}`

Replace a coding agent's model policy (owners and admins). Audited.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `agent` | path | "claude" \| "codex" \| "antigravity" \| "cursor" \| "opencode" | yes |  |
| `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)

- `allow` (array of string) [at most 100 items]
- `deny` (array of string) [at most 100 items]
- `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists.
  - `chat` (string)
  - `claude` (string)
  - `codex` (string)
- `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows.
  - `input` (number) [min 0]
  - `output` (number) [min 0]
- `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows.
  - `maker` (array of string)
  - `provider` (array of string)
- `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`.
  - `allow` (array of string)
  - `deny` (array of string)

### Responses

- `200` OK (application/json, ModelPolicy)
  - `level` ("organization" | "team" | "agent")
  - `subject` (string)
  - `team` (object)
  - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported).
    - `allow` (array of string) [at most 100 items]
    - `deny` (array of string) [at most 100 items]
    - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists.
      - `chat` (string)
      - `claude` (string)
      - `codex` (string)
    - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows.
      - `input` (number) [min 0]
      - `output` (number) [min 0]
    - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows.
      - `maker` (array of string)
      - `provider` (array of string)
    - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`.
      - `allow` (array of string)
      - `deny` (array of string)
  - `custom` (boolean): False: no rule at this level
  - `migrated` (boolean): Read from the old agent policy, not saved since
  - `updatedAt` (string (date-time))
  - `inherited` (array of object)
  - `effective` (object): What the levels down to this one allow, and the defaults they resolve to
  - `notes` (array of string)
- `400` Not a valid rule (`invalid_policy`), including `providers`, which is set on the organization's policy only; or the path names no coding agent (`invalid_request`); or it names one without a Gateway route, which has no model policy (`route_unsupported`). (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 caller does not hold `policy.manage`: only owners and admins set the coding agents' policies (`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 |  | Not a valid rule (`invalid_policy`), including `providers`, which is set on the organization's policy only; or the path names no coding agent (`invalid_request`); or it names one without a Gateway route, which has no model policy (`route_unsupported`). |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins set the coding agents' policies (`role_required`). |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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 PUT "$NEXUS_URL/v1/policies/agents/claude" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "allow": [
      "anthropic/claude-opus-*",
      "anthropic/claude-haiku-*"
    ],
    "defaults": {
      "claude": "anthropic/claude-opus-5.5"
    }
  }'
```

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

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.setPolicy("agent", "claude", { allow: ["anthropic/claude-opus-*", "anthropic/claude-haiku-*"], defaults: { claude: "anthropic/claude-opus-5.5" } });
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Fagents%2F%7Bagent%7D)

## Test policy

`POST /v1/policies/test`

Would this person (or key) be allowed this model, in this team, with this agent, and by which rule? The same decision enforcement makes, plus warnings (e.g. a rule that blocks Claude Code's small background Haiku model). Testing for someone else needs owner or admin.

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

### 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)

- `as` (string): An email, a user id or a key id; default: you
- `team` (string)
- `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`.
- `model` (string): Default: nexus/default
- `surface` ("chat" | "anthropic_messages" | "openai_responses" | "decisions")

### Responses

- `200` OK (application/json, ModelDecision & object)
  - `allowed` (boolean)
  - `requested` (string)
  - `model` (string | null): Canonical id of the model that runs (or would)
  - `providerModel` (string)
  - `surface` ("chat" | "anthropic_messages" | "openai_responses" | "decisions")
  - `reason` (string)
  - `rule` (PolicyRuleRef)
    - `level` ("deployment" | "organization" | "team" | "agent" | "key" | "catalog" | "none")
    - `subject` (string)
    - `list` ("allow" | "deny" | "defaults" | "maxPrice" | "denyCountries" | "providers")
    - `pattern` (string)
  - `code` ("model_not_allowed" | "model_not_found" | "model_not_supported" | "provider_disabled")
  - `resolvedFrom` ("nexus/auto" | "nexus/default")
  - `defaultFrom` (PolicyRuleRef)
    - `level` ("deployment" | "organization" | "team" | "agent" | "key" | "catalog" | "none")
    - `subject` (string)
    - `list` ("allow" | "deny" | "defaults" | "maxPrice" | "denyCountries" | "providers")
    - `pattern` (string)
  - `notes` (array of string)
  - `as` (object)
  - `team` (string)
  - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`.
  - `allowedModels` (array of string)
  - `warnings` (array of string)
- `400` A field has the wrong type or value: `agent` is not `claude`, `codex`, `antigravity` or `cursor`, `surface` is not one of its values, or `as`, `team` or `model` is not a string (`invalid_request`); or `agent` has no Gateway route (`route_unsupported`). (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` `as` names someone else and the caller does not hold `policy.manage`: only owners and admins test the policy for others (`role_required`). A credential without `policy.read` (a service account or sandbox key) gets the same code; a scoped module key gets `module_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.
- `404` `team` names no team in this organization (`unknown_team`), or `as` names no member or key in it (`not_found`). (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 field has the wrong type or value: `agent` is not `claude`, `codex`, `antigravity` or `cursor`, `surface` is not one of its values, or `as`, `team` or `model` is not a string (`invalid_request`); or `agent` has no Gateway route (`route_unsupported`). |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | `as` names someone else and the caller does not hold `policy.manage`: only owners and admins test the policy for others (`role_required`). A credential without `policy.read` (a service account or sandbox key) gets the same code; a scoped module key gets `module_key`. |
| 404 |  | `team` names no team in this organization (`unknown_team`), or `as` names no member or key in it (`not_found`). |
| 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/policies/test" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "claude",
    "model": "claude-haiku-5-5"
  }'
```

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

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.testPolicy({ agent: "claude", model: "claude-haiku-5-5" });
```

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

## List write grants

`GET /v1/policies/grants`

The organization's write grants (owners, admins, leads and members: `policy.read`; not module keys): which module may write through which connector operation (for Nexus Review: robustness/review may github/pull_review, check_run, issue_comment, reaction, resolve_thread; pull_review also covers pull_review_dismiss; pull_ready, pull_merge, pull_edit, pull_state, pull_reviewers and pull_labels each have their own grant, and no other grant covers a merge), who granted each and when, and the write operations that may be granted. A connector write without its grant is refused (403 write_not_granted).

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

### Responses

- `200` OK (application/json, WriteGrants)
  - `grants` (array of WriteGrant, required)
    - `module` (string, required): `<product>/<capability>`
    - `connector` (string, required)
    - `action` (string, required): The write operation
    - `grantedBy` (string | null): The user id of who granted it
    - `at` (string (date-time), required)
  - `grantable` (object, required): The write operations that may be granted, by connector
- `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_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.

### 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 |
| 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

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

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

## Set write grants

`PUT /v1/policies/grants/{product}/{capability}`

Set the write operations of one connector a module may run in this organization (owners and admins: `policy.manage`), in full: the operations not listed are revoked, and an empty list revokes them all. Each grant and each revocation is audited (connector_grant.granted, connector_grant.revoked); a revocation applies from the module's next call. Policy's decide_call reads these grants before every scoped connector call. Each write attempt is audited as connector.write: outcome written; denied with the refusal's code (no grant, a review event other than COMMENT, a thread of another repository); or failed with the error's code and status when an allowed write failed (a rate limit, a timeout). A grant is per organization, module, connector and operation, not per repository: the module scopes repositories itself.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `product` | path | string | yes | The module's product slug (`robustness`) |
| `capability` | path | string | yes | The module's capability slug (`review`) |
| `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)

- `connector` (string, required)
- `actions` (array of string, required)

### Responses

- `200` OK (application/json, WriteGrantsSet)
  - `module` (string, required)
  - `connector` (string, required)
  - `actions` (array of string, required): What the module now holds for this connector
  - `granted` (array of string, required)
  - `revoked` (array of string, required)
- `400` Not a connector with writes, or not one of its write operations (`invalid_grant`) (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 caller does not hold `policy.manage`: only owners and admins grant connector writes (`role_required`). Under an operator grant, only a revoke (an empty `actions` list) is allowed (`operator_scope`). (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 a connector with writes, or not one of its write operations (`invalid_grant`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins grant connector writes (`role_required`). Under an operator grant, only a revoke (an empty `actions` list) is allowed (`operator_scope`). |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/policies/grants/<product>/<capability>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "connector": "github",
    "actions": [
      "pull_review",
      "check_run"
    ]
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Fgrants%2F%7Bproduct%7D%2F%7Bcapability%7D)

## Get review events

`GET /v1/policies/review-events`

Which review events a module may post on this organization's pull requests (owners, admins, leads and members: `policy.read`; not module keys): `comment` (COMMENT only), `request_changes` (COMMENT and REQUEST_CHANGES) or `full` (COMMENT, REQUEST_CHANGES and APPROVE). `full` by default: `default` is true while the organization never chose.

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

### Responses

- `200` OK (application/json, ReviewEventSetting)
  - `level` ("comment" | "request_changes" | "full", required): `comment`: COMMENT only. `request_changes`: COMMENT and REQUEST_CHANGES. `full`: COMMENT, REQUEST_CHANGES and APPROVE.
  - `default` (boolean, required): The organization never chose: full
  - `changedBy` (string)
  - `changedAt` (string (date-time))

### 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/policies/review-events" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

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

## Set review events

`PUT /v1/policies/review-events`

Choose which review events a module may post on this organization's pull requests (owners and admins: `policy.manage`; an operator may only lower it to `comment`). The github connector refuses a `pull_review` whose event is above it (403 `review_event_refused`) on the next call. Nexus Review reads it to choose its event: it requests changes on a failing check and approves a pull request it read in full with none, each only where the level allows. Audited as review_event_setting.changed with the setting before and after.

Permission: `policy.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)

- `level` ("comment" | "request_changes" | "full", required): `comment`: COMMENT only. `request_changes`: COMMENT and REQUEST_CHANGES. `full`: COMMENT, REQUEST_CHANGES and APPROVE.

### Responses

- `200` OK (application/json, ReviewEventSetting)
  - `level` ("comment" | "request_changes" | "full", required): `comment`: COMMENT only. `request_changes`: COMMENT and REQUEST_CHANGES. `full`: COMMENT, REQUEST_CHANGES and APPROVE.
  - `default` (boolean, required): The organization never chose: full
  - `changedBy` (string)
  - `changedAt` (string (date-time))
- `400` Not a level (`invalid_setting`) (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 a level (`invalid_setting`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `review_event_refused` | The github connector refuses a `pull_review` whose event is above it (403 `review_event_refused`) on the next call |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/policies/review-events" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "level": "comment"
  }'
```

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

## List connector availability

`GET /v1/policies/connectors`

Every connector Gateway offers, with its availability in this organization (owners, admins, leads and members: `policy.read`): disabled, available (members opt in) or enabled_for_all, the teams it is limited to, and whether it is the connector's default (the organization never chose: enabled_for_all for github, disabled for every other connector).

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

### Responses

- `200` OK (application/json, ConnectorAvailabilityList)
  - `connectors` (array of ConnectorAvailability, required)
    - `name` (string, required)
    - `availability` ("disabled" | "available" | "enabled_for_all", required): Available: members opt in
    - `teams` (array of string | null, required): Team slugs (a deleted team's id); null for the whole organization
    - `default` (boolean, required): The connector's default: the organization never chose
    - `offered` (boolean, required): Whether this Gateway offers the connector. The organization's choice of one it does not offer is kept; no one uses it, and it may only be set to disabled
    - `changedBy` (string)
    - `changedAt` (string (date-time))
- `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_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.

### 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 |
| 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

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

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

## Set connector availability

`PUT /v1/policies/connectors/{name}`

Set one connector's availability in this organization, in full (owners and admins: `policy.manage`; an operator may only turn it off). With teams, only their members and the members of the teams under them may use it, and a module acting for no person may not. Every connector call reads it first: a person, or a module acting for one, it does not reach is refused with 403 connector_disabled. Audited as connector_availability.changed with the availability before and after.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `name` | path | string | yes | The connector (`github`) |
| `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)

- `availability` ("disabled" | "available" | "enabled_for_all", required): Available: members opt in
- `teams` (array of string): Team slugs; leave it out for the whole organization

### Responses

- `200` OK (application/json, ConnectorAvailability)
  - `name` (string, required)
  - `availability` ("disabled" | "available" | "enabled_for_all", required): Available: members opt in
  - `teams` (array of string | null, required): Team slugs (a deleted team's id); null for the whole organization
  - `default` (boolean, required): The connector's default: the organization never chose
  - `offered` (boolean, required): Whether this Gateway offers the connector. The organization's choice of one it does not offer is kept; no one uses it, and it may only be set to disabled
  - `changedBy` (string)
  - `changedAt` (string (date-time))
- `400` Not an availability: an empty or unknown team, or a state the connector cannot hold (`available` for one only the organization connects, `enabled_for_all` for one only a person connects) (`invalid_availability`) (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 caller does not hold `policy.manage`: only owners and admins choose which connectors members may use (`role_required`). Under an operator grant, only `disabled` is allowed (`operator_scope`). A connector this Gateway does not offer may only be set to `disabled` (`connector_not_offered`). (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 such connector (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 an availability: an empty or unknown team, or a state the connector cannot hold (`available` for one only the organization connects, `enabled_for_all` for one only a person connects) (`invalid_availability`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins choose which connectors members may use (`role_required`). Under an operator grant, only `disabled` is allowed (`operator_scope`). A connector this Gateway does not offer may only be set to `disabled` (`connector_not_offered`). |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No such connector |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/policies/connectors/Platform" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "availability": "disabled"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Fconnectors%2F%7Bname%7D)

## Get chat writes

`GET /v1/policies/chat-writes`

Whether this organization lets a person's confirmed write from chat run, and which connector operations it may run (owners, admins, leads and members: `policy.read`). On with every registered connector write by default. Saved organization choices, including empty operation lists, take precedence. `default` is true while the organization never chose.

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

### Responses

- `200` OK (application/json, ChatWriteSetting)
  - `enabled` (boolean, required)
  - `default` (boolean, required): The organization never chose: on with every registered write
  - `operations` (array of ChatWriteOperation, required): The effective allowed connector writes, sorted. Defaults to every registered write; saved lists take precedence
    - `connector` (string, required) [pattern ^[a-z][a-z0-9-]*$]
    - `operation` (string, required) [pattern ^[a-z][a-z0-9_-]*$]
  - `changedBy` (string)
  - `changedAt` (string (date-time))

### 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/policies/chat-writes" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

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

## Set chat writes

`PUT /v1/policies/chat-writes`

Turn writes from chat on or off for this organization and, with `operations`, replace its allowlist of connector operations; left out, the list is kept (owners and admins: `policy.manage`; an operator may only turn them off, and never sets the list). Each entry must be a connector write Core has. A write of an operation the list does not name is refused (403 `operation_not_allowed`), even with a confirmed record. Off, a chat agent's approval record is not made, confirmed or used, so a record confirmed before stops working too. What an allowed write lets a member's agent do: a `github` write runs as that member's own GitHub account, connected with POST /v1/connections/github/oauth, so GitHub allows it only what it allows the member, and it is refused (403 `connection_required`) while they have none connected; a module's write runs as the Nexus GitHub App. Audited as chat_write_setting.changed with the setting before and after.

Permission: `policy.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)

- `enabled` (boolean, required)
- `operations` (array of ChatWriteOperation): Replaces the allowlist. Left out, the list is kept
  - `connector` (string, required) [pattern ^[a-z][a-z0-9-]*$]
  - `operation` (string, required) [pattern ^[a-z][a-z0-9_-]*$]

### Responses

- `200` OK (application/json, ChatWriteSetting)
  - `enabled` (boolean, required)
  - `default` (boolean, required): The organization never chose: on with every registered write
  - `operations` (array of ChatWriteOperation, required): The effective allowed connector writes, sorted. Defaults to every registered write; saved lists take precedence
    - `connector` (string, required) [pattern ^[a-z][a-z0-9-]*$]
    - `operation` (string, required) [pattern ^[a-z][a-z0-9_-]*$]
  - `changedBy` (string)
  - `changedAt` (string (date-time))
- `400` Not a setting, or an entry that is no connector write (`invalid_setting`) (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 a setting, or an entry that is no connector write (`invalid_setting`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `operation_not_allowed` | A write of an operation the list does not name is refused (403 `operation_not_allowed`), even with a confirmed record |
| 403 | `connection_required` | A `github` write runs as that member's own GitHub account, connected with POST /v1/connections/github/oauth, so GitHub allows it only what it allows the member, and it is refused (403 `connection_required`) while they have none connected; a module's write runs as the Nexus GitHub App |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/policies/chat-writes" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": false
  }'
```

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

## Get agent writes

`GET /v1/policies/agent-writes`

Whether your agents may write in this organization: with it on, your agent links make the connector writes the organization allows its agents (`/v1/policies/chat-writes`) with no approval record per call. On by default; a saved OFF choice restores approval records per call. Your own session or key only (`approvals.decide`): an agent link gets 403 `person_only`.

Permission: `approvals.decide` (Every member).

### Responses

- `200` OK (application/json, AgentWriteSetting)
  - `enabled` (boolean, required): Whether your agent links make the organization's allowed writes with no record per call
- `403` Not your own session or key: an agent link or any other credential (`person_only`) (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 |
| 403 | `person_only` | An agent link gets 403 `person_only` |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/policies/agent-writes" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

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

## Set agent writes

`PUT /v1/policies/agent-writes`

Turn your agents' writes on or off in this organization. On, your agent links make the connector writes the organization allows its agents, while it has them on, with no approval record per call; the agent's own mode decides whether it asks first. A `github` write runs as your own GitHub account (POST /v1/connections/github/oauth), never as the Nexus GitHub App: without one connected it is refused (403 `connection_required`). Off, a write needs a record you confirmed. Your own session or key only (`approvals.decide`): no agent link and no operator grant holds it. Audited as agent_write_setting.changed with the setting before and after.

Permission: `approvals.decide` (Every member).

### 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)

- `enabled` (boolean, required): Whether your agent links make the organization's allowed writes with no record per call

### Responses

- `200` OK (application/json, AgentWriteSetting)
  - `enabled` (boolean, required): Whether your agent links make the organization's allowed writes with no record per call
- `400` Not a setting (`invalid_setting`) (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 your own session or key: an agent link or any other credential (`person_only`) (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 a setting (`invalid_setting`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `connection_required` | Without one connected it is refused (403 `connection_required`) |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/policies/agent-writes" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": false
  }'
```

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

## Create approval

`POST /v1/approvals`

Ask Policy for an approval record bound to one exact connector call: the person, this agent link, the connector, the operation and a SHA-256 of the arguments' canonical JSON (keys sorted at every depth, no spaces). It keeps the arguments, so the person sees them. It is pending, expires in 30 minutes and allows the call once, after the person confirms it in Nexus (`confirmUrl`). A chat agent's link only (`connectors.use`): any other caller gets 403 `agent_only`. Refused while chat writes are off (`chat_writes_off`) and for an operation the organization's allowlist does not name (`operation_not_allowed`). Audited as policy.approval.requested, with the hash and never the arguments.

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

### 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)

- `connector` (string, required) [pattern ^[a-z][a-z0-9-]*$]
- `operation` (string, required) [pattern ^[a-z][a-z0-9_-]*$]
- `arguments` (object, required): The body the write will send, exactly

### Responses

- `201` Created (application/json, Approval)
  - `id` (string, required) [pattern ^apr_[0-9a-f]{32}$]
  - `connector` (string, required)
  - `operation` (string, required)
  - `arguments` (object, required): The call's body, as stored: what the person confirms, and what the write must send
  - `argumentsHash` (string, required): SHA-256 of the arguments' canonical JSON [pattern ^[0-9a-f]{64}$]
  - `status` ("pending" | "confirmed" | "denied" | "used" | "expired", required)
  - `expired` (boolean, required): Its expiry passed: it can no longer be confirmed or used
  - `createdAt` (string (date-time), required)
  - `expiresAt` (string (date-time), required)
  - `decidedAt` (string (date-time))
  - `decidedBy` ("person" | "agent"): Who decided it: the person (confirm or deny in Nexus), or the agent link that cancelled it
  - `usedAt` (string (date-time))
  - `confirmUrl` (string (uri)): Nexus UI's page where the person confirms or denies it, when Gateway knows Nexus UI's URL (`NEXUS_UI_URL`)
- `400` Not a body (`invalid_approval`), or the operation only reads (`not_a_write`) (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 chat agent's link (`agent_only`), chat writes are off (`chat_writes_off`), or the operation is not on the allowlist (`operation_not_allowed`) (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 such connector operation (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 a body (`invalid_approval`), or the operation only reads (`not_a_write`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `agent_only` | Any other caller gets 403 `agent_only` |
| 404 |  | No such connector operation |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/approvals" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "connector": "<connector>",
    "operation": "<operation>",
    "arguments": {}
  }'
```

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

## Get approval

`GET /v1/approvals/{id}`

One approval record, with its arguments. The agent link that asked (`connectors.use`), or its person from their own session or key: any other caller of the organization gets 404 `approval_not_found`, and a caller that is neither a link nor a person 403 `agent_only`.

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

### Parameters

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

### Responses

- `200` OK (application/json, Approval)
  - `id` (string, required) [pattern ^apr_[0-9a-f]{32}$]
  - `connector` (string, required)
  - `operation` (string, required)
  - `arguments` (object, required): The call's body, as stored: what the person confirms, and what the write must send
  - `argumentsHash` (string, required): SHA-256 of the arguments' canonical JSON [pattern ^[0-9a-f]{64}$]
  - `status` ("pending" | "confirmed" | "denied" | "used" | "expired", required)
  - `expired` (boolean, required): Its expiry passed: it can no longer be confirmed or used
  - `createdAt` (string (date-time), required)
  - `expiresAt` (string (date-time), required)
  - `decidedAt` (string (date-time))
  - `decidedBy` ("person" | "agent"): Who decided it: the person (confirm or deny in Nexus), or the agent link that cancelled it
  - `usedAt` (string (date-time))
  - `confirmUrl` (string (uri)): Nexus UI's page where the person confirms or denies it, when Gateway knows Nexus UI's URL (`NEXUS_UI_URL`)
- `403` Neither an agent link nor a person (`agent_only`) (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 such approval of this link's or this person's (`approval_not_found`) (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 |
| 403 | `agent_only` | Any other caller of the organization gets 404 `approval_not_found`, and a caller that is neither a link nor a person 403 `agent_only` |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No such approval of this link's or this person's (`approval_not_found`) |
| 404 | `approval_not_found` | Any other caller of the organization gets 404 `approval_not_found`, and a caller that is neither a link nor a person 403 `agent_only` |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

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

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

## Confirm approval

`POST /v1/approvals/{id}/confirm`

The record's person confirms it, once, before it expires, from their own session in Nexus UI or their own key (`approvals.decide`). An agent link never confirms: it gets 403 `person_only`, so a link cannot approve its own write. Another person's record is 404 `approval_not_found`. Confirmed again, it answers the stored record. Refused while chat writes are off, and for an operation the allowlist does not name. Audited as policy.approval.confirmed, with the person as its actor.

Permission: `approvals.decide` (Every member).

### Parameters

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

### Responses

- `200` OK (application/json, Approval)
  - `id` (string, required) [pattern ^apr_[0-9a-f]{32}$]
  - `connector` (string, required)
  - `operation` (string, required)
  - `arguments` (object, required): The call's body, as stored: what the person confirms, and what the write must send
  - `argumentsHash` (string, required): SHA-256 of the arguments' canonical JSON [pattern ^[0-9a-f]{64}$]
  - `status` ("pending" | "confirmed" | "denied" | "used" | "expired", required)
  - `expired` (boolean, required): Its expiry passed: it can no longer be confirmed or used
  - `createdAt` (string (date-time), required)
  - `expiresAt` (string (date-time), required)
  - `decidedAt` (string (date-time))
  - `decidedBy` ("person" | "agent"): Who decided it: the person (confirm or deny in Nexus), or the agent link that cancelled it
  - `usedAt` (string (date-time))
  - `confirmUrl` (string (uri)): Nexus UI's page where the person confirms or denies it, when Gateway knows Nexus UI's URL (`NEXUS_UI_URL`)
- `403` An agent link or another credential that is no person (`person_only`), chat writes are off (`chat_writes_off`), or the operation is not on the allowlist (`operation_not_allowed`) (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 such approval of this person's (`approval_not_found`) (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` Expired (`approval_expired`), or already decided another way or used (`approval_settled`) (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 |
| 403 | `person_only` | It gets 403 `person_only`, so a link cannot approve its own write |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No such approval of this person's (`approval_not_found`) |
| 404 | `approval_not_found` | Another person's record is 404 `approval_not_found` |
| 409 |  | Expired (`approval_expired`), or already decided another way or used (`approval_settled`) |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/approvals/<id>/confirm" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## Deny approval

`POST /v1/approvals/{id}/deny`

The record's person denies it, once, from their own session in Nexus UI or their own key (`approvals.decide`). An agent link gets 403 `person_only` and cancels instead. Another person's record is 404 `approval_not_found`. Denied again, it answers the stored record. Audited as policy.approval.denied.

Permission: `approvals.decide` (Every member).

### Parameters

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

### Responses

- `200` OK (application/json, Approval)
  - `id` (string, required) [pattern ^apr_[0-9a-f]{32}$]
  - `connector` (string, required)
  - `operation` (string, required)
  - `arguments` (object, required): The call's body, as stored: what the person confirms, and what the write must send
  - `argumentsHash` (string, required): SHA-256 of the arguments' canonical JSON [pattern ^[0-9a-f]{64}$]
  - `status` ("pending" | "confirmed" | "denied" | "used" | "expired", required)
  - `expired` (boolean, required): Its expiry passed: it can no longer be confirmed or used
  - `createdAt` (string (date-time), required)
  - `expiresAt` (string (date-time), required)
  - `decidedAt` (string (date-time))
  - `decidedBy` ("person" | "agent"): Who decided it: the person (confirm or deny in Nexus), or the agent link that cancelled it
  - `usedAt` (string (date-time))
  - `confirmUrl` (string (uri)): Nexus UI's page where the person confirms or denies it, when Gateway knows Nexus UI's URL (`NEXUS_UI_URL`)
- `403` An agent link or another credential that is no person (`person_only`) (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 such approval of this person's (`approval_not_found`) (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` Expired (`approval_expired`), or already decided another way or used (`approval_settled`) (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 |
| 403 | `person_only` | An agent link gets 403 `person_only` and cancels instead |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No such approval of this person's (`approval_not_found`) |
| 404 | `approval_not_found` | Another person's record is 404 `approval_not_found` |
| 409 |  | Expired (`approval_expired`), or already decided another way or used (`approval_settled`) |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/approvals/<id>/deny" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## Cancel approval

`POST /v1/approvals/{id}/cancel`

The agent link that asked cancels its own pending record (`connectors.use`): it moves to denied, once. Cancelling never confirms, so it needs no person. Any other caller gets 403 `agent_only`, and another link's record is 404 `approval_not_found`. Cancelled again, it answers the stored record; a confirmed or used one is 409 `approval_settled`. Audited as policy.approval.cancelled.

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

### Parameters

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

### Responses

- `200` OK (application/json, Approval)
  - `id` (string, required) [pattern ^apr_[0-9a-f]{32}$]
  - `connector` (string, required)
  - `operation` (string, required)
  - `arguments` (object, required): The call's body, as stored: what the person confirms, and what the write must send
  - `argumentsHash` (string, required): SHA-256 of the arguments' canonical JSON [pattern ^[0-9a-f]{64}$]
  - `status` ("pending" | "confirmed" | "denied" | "used" | "expired", required)
  - `expired` (boolean, required): Its expiry passed: it can no longer be confirmed or used
  - `createdAt` (string (date-time), required)
  - `expiresAt` (string (date-time), required)
  - `decidedAt` (string (date-time))
  - `decidedBy` ("person" | "agent"): Who decided it: the person (confirm or deny in Nexus), or the agent link that cancelled it
  - `usedAt` (string (date-time))
  - `confirmUrl` (string (uri)): Nexus UI's page where the person confirms or denies it, when Gateway knows Nexus UI's URL (`NEXUS_UI_URL`)
- `403` Not a chat agent's link (`agent_only`) (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 such approval of this link's (`approval_not_found`) (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` Already confirmed or used (`approval_settled`) (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 |
| 403 | `agent_only` | Any other caller gets 403 `agent_only`, and another link's record is 404 `approval_not_found` |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No such approval of this link's (`approval_not_found`) |
| 404 | `approval_not_found` | Any other caller gets 403 `agent_only`, and another link's record is 404 `approval_not_found` |
| 409 |  | Already confirmed or used (`approval_settled`) |
| 409 | `approval_settled` | Cancelled again, it answers the stored record; a confirmed or used one is 409 `approval_settled` |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/approvals/<id>/cancel" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## List operator controls

`GET /v1/policies/controls`

The operator controls in force (`policy.read`). Owners and admins see every unexpired control of the organization. A lead or member sees only the controls that apply to them: the organization's, those on every team they are in and the teams above them, their own and their key's. An expired control is not listed.

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

### Responses

- `200` OK (application/json, OperatorControls)
  - `controls` (array of OperatorControl, required)
    - `id` (string, required)
    - `tenantId` (string, required)
    - `kind` (string, required)
    - `subjectLevel` (string, required)
    - `subject` (string)
    - `models` (array of string)
    - `reason` (string, required)
    - `createdBy` (string)
    - `createdAt` (string, required)
    - `expiresAt` (string, required)
- `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_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.

### 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 |
| 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

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

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

## Set operator control

`POST /v1/policies/controls`

Put an operator control in force (owners and admins: `policy.manage`). A pause refuses every model call of its subject, a limit allows only the listed models and an override allows the listed models over the rules. A control expires at `expiresAt` and applies from the next decision. An unknown team, person or key answers 404. It is audited (policy.control_set).

Permission: `policy.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)

- `kind` ("pause" | "limit" | "override", required)
- `level` ("organization" | "team" | "person" | "key", required)
- `subject` (string): A team's slug, a user id or a key id. Ignored for `organization`.
- `models` (array of string): Required for a `limit` or an `override`; not allowed for a `pause`.
- `reason` (string, required)
- `expiresAt` (string, required): An ISO 8601 time in the future.

### Responses

- `201` Created (application/json, OperatorControl)
  - `id` (string, required)
  - `tenantId` (string, required)
  - `kind` (string, required)
  - `subjectLevel` (string, required)
  - `subject` (string)
  - `models` (array of string)
  - `reason` (string, required)
  - `createdBy` (string)
  - `createdAt` (string, required)
  - `expiresAt` (string, required)
- `400` Not a valid control (`invalid_control`): an unknown kind, level or model, no reason, an expiry in the past, models on a pause, or none on a limit or an override. Also when the organization already holds 200 live controls. (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 caller does not hold `policy.manage`: only owners and admins set an organization-wide control (`role_required`). Team leads use the team's controls route. (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 such team, person or key in this organization (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 a valid control (`invalid_control`): an unknown kind, level or model, no reason, an expiry in the past, models on a pause, or none on a limit or an override. Also when the organization already holds 200 live controls. |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins set an organization-wide control (`role_required`). Team leads use the team's controls route. |
| 404 |  | No such team, person or key in this organization |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/policies/controls" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "pause",
    "level": "organization",
    "reason": "<reason>",
    "expiresAt": "<expiresAt>"
  }'
```

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

## Clear operator control

`DELETE /v1/policies/controls/{id}`

Take an operator control out of force (owners and admins: `policy.manage`). It answers with the cleared control. It is audited (policy.control_cleared).

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

### Parameters

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

### Responses

- `200` OK (application/json, OperatorControl)
  - `id` (string, required)
  - `tenantId` (string, required)
  - `kind` (string, required)
  - `subjectLevel` (string, required)
  - `subject` (string)
  - `models` (array of string)
  - `reason` (string, required)
  - `createdBy` (string)
  - `createdAt` (string, required)
  - `expiresAt` (string, required)
- `403` The caller does not hold `policy.manage`: only owners and admins clear a control here (`role_required`). Team leads use the team's controls route. (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 such control in this organization (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 |
| 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins clear a control here (`role_required`). Team leads use the team's controls route. |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No such control in this organization |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X DELETE "$NEXUS_URL/v1/policies/controls/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## List team operator controls

`GET /v1/policies/teams/{slug}/controls`

The operator controls in force on a team, on the teams under it, and on the people and keys in them (owners and admins; a team lead for a team they lead). Controls on the organization and on the teams above it are not listed. An expired control is not listed.

Permission: `policy.manage_team` (Owner, Admin, Team lead).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `slug` | path | string | yes |  |

### Responses

- `200` OK (application/json, OperatorControls)
  - `controls` (array of OperatorControl, required)
    - `id` (string, required)
    - `tenantId` (string, required)
    - `kind` (string, required)
    - `subjectLevel` (string, required)
    - `subject` (string)
    - `models` (array of string)
    - `reason` (string, required)
    - `createdBy` (string)
    - `createdAt` (string, required)
    - `expiresAt` (string, required)
- `403` The caller is not an owner, an admin or a team lead (`role_required`), or the team is not one they lead (`outside_led_teams`) (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 such team in this 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.

### 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 such team in this organization (`unknown_team`) |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/policies/teams/platform/controls" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Fteams%2F%7Bslug%7D%2Fcontrols)

## Set team operator control

`POST /v1/policies/teams/{slug}/controls`

Put an operator control in force on a team, or on a person or key in it or in a team under it (owners and admins; a team lead for a team they lead, who may pause or limit but not override). It works as `setOperatorControl` otherwise. It is audited (policy.control_set).

Permission: `policy.manage_team` (Owner, Admin, Team lead).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `slug` | path | string | yes |  |
| `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)

- `kind` ("pause" | "limit" | "override", required)
- `level` ("organization" | "team" | "person" | "key", required)
- `subject` (string): A team's slug, a user id or a key id. Ignored for `organization`.
- `models` (array of string): Required for a `limit` or an `override`; not allowed for a `pause`.
- `reason` (string, required)
- `expiresAt` (string, required): An ISO 8601 time in the future.

### Responses

- `201` Created (application/json, OperatorControl)
  - `id` (string, required)
  - `tenantId` (string, required)
  - `kind` (string, required)
  - `subjectLevel` (string, required)
  - `subject` (string)
  - `models` (array of string)
  - `reason` (string, required)
  - `createdBy` (string)
  - `createdAt` (string, required)
  - `expiresAt` (string, required)
- `400` Not a valid control (`invalid_control`): an unknown kind, level or model, no reason, an expiry in the past, models on a pause, or none on a limit or an override. Also when the organization already holds 200 live controls. (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 caller is not an owner, an admin or a team lead (`role_required`), the team is not one they lead (`outside_led_teams`), the subject is outside the team and the teams under it (`outside_team`), or a lead asked for an override (`override_needs_admin`) (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 such team in this organization (`unknown_team` for the team in the path), or no such team, person or key as the subject (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 a valid control (`invalid_control`): an unknown kind, level or model, no reason, an expiry in the past, models on a pause, or none on a limit or an override. Also when the organization already holds 200 live controls. |
| 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 such team in this organization (`unknown_team` for the team in the path), or no such team, person or key as the subject |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/policies/teams/platform/controls" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "pause",
    "level": "organization",
    "reason": "<reason>",
    "expiresAt": "<expiresAt>"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpolicies%2Fteams%2F%7Bslug%7D%2Fcontrols)

## Clear team operator control

`DELETE /v1/policies/teams/{slug}/controls/{id}`

Take an operator control on a team, or on a person or key in it or in a team under it, out of force (owners and admins; a team lead for a team they lead, only a control that lead set and never an override). It answers with the cleared control. It is audited (policy.control_cleared).

Permission: `policy.manage_team` (Owner, Admin, Team lead).

### Parameters

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

### Responses

- `200` OK (application/json, OperatorControl)
  - `id` (string, required)
  - `tenantId` (string, required)
  - `kind` (string, required)
  - `subjectLevel` (string, required)
  - `subject` (string)
  - `models` (array of string)
  - `reason` (string, required)
  - `createdBy` (string)
  - `createdAt` (string, required)
  - `expiresAt` (string, required)
- `403` The caller is not an owner, an admin or a team lead (`role_required`), the team is not one they lead (`outside_led_teams`), the control's subject is outside the team and the teams under it (`outside_team`), a lead tried to clear an override (`override_needs_admin`), or a lead tried to clear a control someone else set (`control_needs_admin`) (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 such team (`unknown_team`), or no such control in this organization (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 such team (`unknown_team`), or no such control in this organization |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X DELETE "$NEXUS_URL/v1/policies/teams/platform/controls/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## List team keys

`GET /v1/policies/teams/{slug}/keys`

The live API keys of the people in a team and the teams under it (owners and admins; a team lead for a team they lead). Key-minted CLI tokens are not listed. Lets a lead pick a key to pause or limit. It grants no revoke.

Permission: `policy.manage_team` (Owner, Admin, Team lead).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `slug` | path | string | yes |  |

### Responses

- `200` OK (application/json, object)
  - `tokens` (array of Token)
    - `id` (string, required)
    - `userId` (string, required)
    - `kind` ("api" | "cli" | "ui", required)
    - `prefix` (string, required)
    - `label` (string)
    - `createdAt` (string (date-time), required)
    - `expiresAt` (string (date-time))
    - `current` (boolean)
  - `nextCursor` (string): Never set: this route returns every key in one page.
- `403` The caller is not an owner, an admin or a team lead (`role_required`), the team is not one they lead (`outside_led_teams`), or the caller acts under an operator grant (`operator_scope`) (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 such team in this 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.

### 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 such team in this organization (`unknown_team`) |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

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

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

## Connect

`POST /v1/connections/{connector}`

Connect an account with the connector's key form (GET /v1/connectors lists who may connect and the form). The vendor checks the key first; nothing it refuses is kept. `scope: org` connects the organization's account (owners and admins: `policy.manage`); otherwise it is yours, and the organization must have made the connector available to you. Connecting an account again replaces its credential. Audited as connector_credential.added or .replaced, with the last four characters only.

Permission: `connections.manage_own` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `connector` | path | string | yes | The connector (`jira`) |
| `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)

- `scope` ("user" | "org") [default "user"]

### Responses

- `200` OK (application/json, object)
  - `connections` (array of Connection, required)
    - `connector` (string, required)
    - `scope` ("user" | "org", required): A person's own (user) or the organization's (org)
    - `scopeId` (string, required): The person's user id, or the organization's id
    - `account` (string, required): The vendor's stable id for the account (an Atlassian cloud id)
    - `name` (string, required): The account's name, as a call's `account` may name it
    - `data` (object): What reaches the account and is not secret (its host)
    - `identity` (string): Who the vendor says the holder is there
    - `status` ("active" | "needs_reconnect", required)
    - `suspended` (boolean, required): Its connector is in preview and this Gateway does not offer it: no call uses the connection until the connector is offered. It can still be disconnected
    - `kind` ("api_key" | "basic" | "oauth2" | "installation", required)
    - `last4` (string): The last four characters of its secret; never the secret
    - `scopes` (array of string)
    - `expiresAt` (string (date-time))
    - `createdAt` (string (date-time), required)
- `400` A field the form does not take, a host the vendor does not serve, or a key the vendor refused (`credential_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.
- `403` The organization's needs an owner or admin (`role_required`); the connector is not available to you (`connector_disabled`) (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 such connector (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` The vendor is rate limiting the check (`rate_limited`, with `retry_after`) (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 vendor failed the check (`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.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | A field the form does not take, a host the vendor does not serve, or a key the vendor refused (`credential_refused`) |
| 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 such connector |
| 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 |  | The vendor is rate limiting the check (`rate_limited`, with `retry_after`) |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |
| 502 |  | The vendor failed the check (`upstream_error`) |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/connections/<connector>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "scope": "user"
  }'
```

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

## List connections

`GET /v1/connections`

Your own live connections and the organization's (what it may lend), never a secret. The organization's GitHub App installations are listed too, as its github connections (the account is the installation id). A member sees the organization's without whose account it is or its last four characters.

Permission: `connections.manage_own` (Every member).

### Responses

- `200` OK (application/json, object)
  - `connections` (array of Connection, required)
    - `connector` (string, required)
    - `scope` ("user" | "org", required): A person's own (user) or the organization's (org)
    - `scopeId` (string, required): The person's user id, or the organization's id
    - `account` (string, required): The vendor's stable id for the account (an Atlassian cloud id)
    - `name` (string, required): The account's name, as a call's `account` may name it
    - `data` (object): What reaches the account and is not secret (its host)
    - `identity` (string): Who the vendor says the holder is there
    - `status` ("active" | "needs_reconnect", required)
    - `suspended` (boolean, required): Its connector is in preview and this Gateway does not offer it: no call uses the connection until the connector is offered. It can still be disconnected
    - `kind` ("api_key" | "basic" | "oauth2" | "installation", required)
    - `last4` (string): The last four characters of its secret; never the secret
    - `scopes` (array of string)
    - `expiresAt` (string (date-time))
    - `createdAt` (string (date-time), required)

### 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

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

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

## Disconnect

`DELETE /v1/connections/{connector}/{account}`

Disconnect your own connection to an account (or, with `scope=org`, the organization's: owners and admins). The account is named by its id, name or host. Its credential is revoked once no live connection uses it; an OAuth grant is then revoked at the vendor too, and `vendorRevoked` says whether the vendor confirmed it. Audited as connector_credential.revoked.

Permission: `connections.manage_own` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `connector` | path | string | yes |  |
| `account` | path | string | yes | The account's id, name or host |
| `scope` | query | "user" \| "org" | no |  |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Responses

- `200` OK (application/json, object)
- `400` The connector takes no connection at that scope: a GitHub installation is unlinked with DELETE /v1/github/installations/{id} (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 live connection to that account (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 connector takes no connection at that scope: a GitHub installation is unlinked with DELETE /v1/github/installations/{id} |
| 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 live connection to that account |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X DELETE "$NEXUS_URL/v1/connections/<connector>/<account>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## Start oauth connection

`POST /v1/connections/{connector}/oauth`

Start connecting an account with OAuth: the vendor's authorize URL, good once for ten minutes. `scope: org` connects the organization's (owners and admins); otherwise it is yours, and the organization must have made the connector available to you. The vendor returns the person to Nexus UI, which finishes with POST /v1/connections/oauth/finish.

Permission: `connections.manage_own` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `connector` | path | string | yes | The connector (`notion`) |
| `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)

- `scope` ("user" | "org") [default "user"]
- `access` ("read" | "write"): Only when the server asks for write scopes on demand (NEXUS_CONNECTOR_WRITE_CONSENT); otherwise refused with 400. `read` asks the vendor for the connector's reads only. `write` asks for its reads and its write scopes: send it after a write answered 403 `write_consent_required`. The new tokens replace the connection's. [default "read"]

### Responses

- `200` OK (application/json, object)
  - `authorizeUrl` (string (uri), required)
- `403` The organization's needs an owner or admin (`role_required`); the connector is not available to you (`connector_disabled`) (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 such connector (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` This gateway has no OAuth app for the connector (`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 |
| 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 such connector |
| 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 | `rate_limit_error` | Too many requests from this key in a minute |
| 503 |  | This gateway has no OAuth app for the connector (`not_configured`) |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/connections/<connector>/oauth" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "scope": "user",
    "access": "read"
  }'
```

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

## Finish oauth connection

`POST /v1/connections/oauth/finish`

Finish connecting an account with OAuth: the vendor returned the person to Nexus UI (`/settings/connectors/oauth`), which hands back its `code` (or `error`) and `state` with the person's session. Only the person who started may finish, so an authorize link sent to someone else connects nothing; availability and role are checked again. The tokens are kept for the holder the state names.

Permission: `connections.manage_own` (Every member).

### 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)

- `state` (string, required)
- `code` (string)
- `error` (string)
- `realmId` (string): The company QuickBooks names on its return, which Gateway checks with the new token. Another vendor's return adds nothing.

### Responses

- `200` OK (application/json, object)
  - `connector` (string)
  - `connections` (array of Connection)
    - `connector` (string, required)
    - `scope` ("user" | "org", required): A person's own (user) or the organization's (org)
    - `scopeId` (string, required): The person's user id, or the organization's id
    - `account` (string, required): The vendor's stable id for the account (an Atlassian cloud id)
    - `name` (string, required): The account's name, as a call's `account` may name it
    - `data` (object): What reaches the account and is not secret (its host)
    - `identity` (string): Who the vendor says the holder is there
    - `status` ("active" | "needs_reconnect", required)
    - `suspended` (boolean, required): Its connector is in preview and this Gateway does not offer it: no call uses the connection until the connector is offered. It can still be disconnected
    - `kind` ("api_key" | "basic" | "oauth2" | "installation", required)
    - `last4` (string): The last four characters of its secret; never the secret
    - `scopes` (array of string)
    - `expiresAt` (string (date-time))
    - `createdAt` (string (date-time), required)
- `400` No state (`oauth_state_missing`); a state Nexus did not issue, not yours, or already finished (`oauth_state_invalid`); the person declined (`oauth_denied`); the vendor refused the code, or the account it names (`credential_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.
- `403` The organization's needs an owner or admin (`role_required`); the connector is no longer available to you (`connector_disabled`) (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` Your state is older than ten minutes (`oauth_state_invalid`): connect 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.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | No state (`oauth_state_missing`); a state Nexus did not issue, not yours, or already finished (`oauth_state_invalid`); the person declined (`oauth_denied`); the vendor refused the code, or the account it names (`credential_refused`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 409 |  | Your state is older than ten minutes (`oauth_state_invalid`): connect 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 |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/connections/oauth/finish" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "state": "…"
  }'
```

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