# Projects

> Projects (behind `NEXUS_PROJECTS`; off, each route answers 404): an organization's record that groups repositories and people. Owners and admins are admins of every project. Only a project admin changes its repositories and members; anyone in it reads it.

## List projects

`GET /v1/projects`

The live projects you are in, by name, each with its repositories and your role. Owners and admins see every live project. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Responses

- `200` OK (application/json, ProjectList)
  - `data` (array of Project, required)
    - `id` (string, required)
    - `name` (string, required)
    - `slug` (string, required)
    - `defaultAgent` (string | null, required): A coding agent's catalog id, or null for each person's own default
    - `repos` (array of ProjectRepo, required)
      - `repoKey` (string, required): `github:` and GitHub's numeric repository id: stable across renames
      - `fullName` (string, required): `owner/name` when it was added: shown, never matched on
      - `addedBy` (string, required)
      - `addedAt` (string (date-time), required)
    - `role` ("member" | "admin", required): Your role: your own row's, a team's, or admin as an owner or admin of the organization
    - `ownerKind` ("org" | "person", required): Who owns the project: the organization, or one person. A personal project is its owner's alone; its owner may move it to the organization, never back.
    - `ownerUserId` (string | null, required): The owner of a personal project; null for the organization's.
    - `createdBy` (string, required)
    - `createdAt` (string (date-time), required)
    - `updatedAt` (string (date-time), required)
    - `archivedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

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

### Example

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

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

## Create project

`POST /v1/projects`

Create a project; you are its first admin. The name is 1 to 80 characters of plain text (project_name_invalid). The slug is made from the name when absent, and is 1 to 63 lowercase letters, digits and dashes (project_slug_invalid), unique among live projects (409 project_slug_taken). The default agent is a coding agent Nexus knows (project_agent_unknown). At most 500 live projects per organization (409 project_limit). Audited as `project.created`. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

Permission: `projects.use` (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)

- `name` (string, required) [max length 80]
- `slug` (string) [pattern ^[a-z0-9][a-z0-9-]{0,62}$]
- `defaultAgent` (string | null)
- `ownerKind` ("org" | "person"): `org` (the default) or `person`: a personal project only you see and use.

### Responses

- `201` Created (application/json, Project)
  - `id` (string, required)
  - `name` (string, required)
  - `slug` (string, required)
  - `defaultAgent` (string | null, required): A coding agent's catalog id, or null for each person's own default
  - `repos` (array of ProjectRepo, required)
    - `repoKey` (string, required): `github:` and GitHub's numeric repository id: stable across renames
    - `fullName` (string, required): `owner/name` when it was added: shown, never matched on
    - `addedBy` (string, required)
    - `addedAt` (string (date-time), required)
  - `role` ("member" | "admin", required): Your role: your own row's, a team's, or admin as an owner or admin of the organization
  - `ownerKind` ("org" | "person", required): Who owns the project: the organization, or one person. A personal project is its owner's alone; its owner may move it to the organization, never back.
  - `ownerUserId` (string | null, required): The owner of a personal project; null for the organization's.
  - `createdBy` (string, required)
  - `createdAt` (string (date-time), required)
  - `updatedAt` (string (date-time), required)
  - `archivedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 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 |
| 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/projects" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Platform"
  }'
```

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

## Get project

`GET /v1/projects/{id}`

One project you are in, archived or not. A project you are not in is a 404 project_not_found, as one that does not exist. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

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

### Responses

- `200` OK (application/json, Project)
  - `id` (string, required)
  - `name` (string, required)
  - `slug` (string, required)
  - `defaultAgent` (string | null, required): A coding agent's catalog id, or null for each person's own default
  - `repos` (array of ProjectRepo, required)
    - `repoKey` (string, required): `github:` and GitHub's numeric repository id: stable across renames
    - `fullName` (string, required): `owner/name` when it was added: shown, never matched on
    - `addedBy` (string, required)
    - `addedAt` (string (date-time), required)
  - `role` ("member" | "admin", required): Your role: your own row's, a team's, or admin as an owner or admin of the organization
  - `ownerKind` ("org" | "person", required): Who owns the project: the organization, or one person. A personal project is its owner's alone; its owner may move it to the organization, never back.
  - `ownerUserId` (string | null, required): The owner of a personal project; null for the organization's.
  - `createdBy` (string, required)
  - `createdAt` (string (date-time), required)
  - `updatedAt` (string (date-time), required)
  - `archivedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

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

### Example

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

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

## Update project

`PATCH /v1/projects/{id}`

Change a project's name, slug or default agent; `defaultAgent: null` clears it. A project admin only (403 project_admin_required). An archived project takes no change (409 project_archived). Audited as `project.updated`. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The project's id (`prj_…`) |
| `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)

- `name` (string) [max length 80]
- `slug` (string) [pattern ^[a-z0-9][a-z0-9-]{0,62}$]
- `defaultAgent` (string | null): Null clears it; absent keeps it

### Responses

- `200` OK (application/json, Project)
  - `id` (string, required)
  - `name` (string, required)
  - `slug` (string, required)
  - `defaultAgent` (string | null, required): A coding agent's catalog id, or null for each person's own default
  - `repos` (array of ProjectRepo, required)
    - `repoKey` (string, required): `github:` and GitHub's numeric repository id: stable across renames
    - `fullName` (string, required): `owner/name` when it was added: shown, never matched on
    - `addedBy` (string, required)
    - `addedAt` (string (date-time), required)
  - `role` ("member" | "admin", required): Your role: your own row's, a team's, or admin as an owner or admin of the organization
  - `ownerKind` ("org" | "person", required): Who owns the project: the organization, or one person. A personal project is its owner's alone; its owner may move it to the organization, never back.
  - `ownerUserId` (string | null, required): The owner of a personal project; null for the organization's.
  - `createdBy` (string, required)
  - `createdAt` (string (date-time), required)
  - `updatedAt` (string (date-time), required)
  - `archivedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 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 |
| 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 PATCH "$NEXUS_URL/v1/projects/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Platform",
    "slug": "platform",
    "defaultAgent": "<defaultAgent>"
  }'
```

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

## Archive project

`DELETE /v1/projects/{id}`

Archive a project. Its rows stay, it takes no change after, and its slug is free again. A project admin only. Answers the archived project. Audited as `project.archived`. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The project's id (`prj_…`) |
| `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, Project)
  - `id` (string, required)
  - `name` (string, required)
  - `slug` (string, required)
  - `defaultAgent` (string | null, required): A coding agent's catalog id, or null for each person's own default
  - `repos` (array of ProjectRepo, required)
    - `repoKey` (string, required): `github:` and GitHub's numeric repository id: stable across renames
    - `fullName` (string, required): `owner/name` when it was added: shown, never matched on
    - `addedBy` (string, required)
    - `addedAt` (string (date-time), required)
  - `role` ("member" | "admin", required): Your role: your own row's, a team's, or admin as an owner or admin of the organization
  - `ownerKind` ("org" | "person", required): Who owns the project: the organization, or one person. A personal project is its owner's alone; its owner may move it to the organization, never back.
  - `ownerUserId` (string | null, required): The owner of a personal project; null for the organization's.
  - `createdBy` (string, required)
  - `createdAt` (string (date-time), required)
  - `updatedAt` (string (date-time), required)
  - `archivedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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 DELETE "$NEXUS_URL/v1/projects/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## Move project to organization

`POST /v1/projects/{id}/move-to-organization`

Move a personal project to the organization, one way: an organization's project never becomes personal. Its owner only; to anyone else it is a 404 project_not_found. The owner becomes its first admin. Its repositories, project secrets and setup stay with it. 409 project_not_personal for an organization's project, 409 project_slug_taken when a live organization project has its slug, 409 project_archived when archived. Answers the project. Audited as `project.moved_to_org`. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The project's id (`prj_…`) |
| `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, Project)
  - `id` (string, required)
  - `name` (string, required)
  - `slug` (string, required)
  - `defaultAgent` (string | null, required): A coding agent's catalog id, or null for each person's own default
  - `repos` (array of ProjectRepo, required)
    - `repoKey` (string, required): `github:` and GitHub's numeric repository id: stable across renames
    - `fullName` (string, required): `owner/name` when it was added: shown, never matched on
    - `addedBy` (string, required)
    - `addedAt` (string (date-time), required)
  - `role` ("member" | "admin", required): Your role: your own row's, a team's, or admin as an owner or admin of the organization
  - `ownerKind` ("org" | "person", required): Who owns the project: the organization, or one person. A personal project is its owner's alone; its owner may move it to the organization, never back.
  - `ownerUserId` (string | null, required): The owner of a personal project; null for the organization's.
  - `createdBy` (string, required)
  - `createdAt` (string (date-time), required)
  - `updatedAt` (string (date-time), required)
  - `archivedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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/projects/<id>/move-to-organization" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## Put project repo

`PUT /v1/projects/{id}/repos/{repoKey}`

Add one of the organization's linked repositories to a project, by its GitHub id (404 repository_not_linked otherwise). Adding it again changes nothing. A project admin only. At most 50 per project (409 project_repo_limit). Membership grants no repository access. Audited as `project.repo_added`. Answers the project. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The project's id (`prj_…`) |
| `repoKey` | path | string | yes | `github:` and GitHub's numeric repository 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, Project)
  - `id` (string, required)
  - `name` (string, required)
  - `slug` (string, required)
  - `defaultAgent` (string | null, required): A coding agent's catalog id, or null for each person's own default
  - `repos` (array of ProjectRepo, required)
    - `repoKey` (string, required): `github:` and GitHub's numeric repository id: stable across renames
    - `fullName` (string, required): `owner/name` when it was added: shown, never matched on
    - `addedBy` (string, required)
    - `addedAt` (string (date-time), required)
  - `role` ("member" | "admin", required): Your role: your own row's, a team's, or admin as an owner or admin of the organization
  - `ownerKind` ("org" | "person", required): Who owns the project: the organization, or one person. A personal project is its owner's alone; its owner may move it to the organization, never back.
  - `ownerUserId` (string | null, required): The owner of a personal project; null for the organization's.
  - `createdBy` (string, required)
  - `createdAt` (string (date-time), required)
  - `updatedAt` (string (date-time), required)
  - `archivedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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/projects/<id>/repos/<repoKey>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## Delete project repo

`DELETE /v1/projects/{id}/repos/{repoKey}`

Remove a repository from a project (404 project_repo_not_found when it is not in it). A project admin only. Audited as `project.repo_removed`. Answers the project. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The project's id (`prj_…`) |
| `repoKey` | path | string | yes | `github:` and GitHub's numeric repository 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, Project)
  - `id` (string, required)
  - `name` (string, required)
  - `slug` (string, required)
  - `defaultAgent` (string | null, required): A coding agent's catalog id, or null for each person's own default
  - `repos` (array of ProjectRepo, required)
    - `repoKey` (string, required): `github:` and GitHub's numeric repository id: stable across renames
    - `fullName` (string, required): `owner/name` when it was added: shown, never matched on
    - `addedBy` (string, required)
    - `addedAt` (string (date-time), required)
  - `role` ("member" | "admin", required): Your role: your own row's, a team's, or admin as an owner or admin of the organization
  - `ownerKind` ("org" | "person", required): Who owns the project: the organization, or one person. A personal project is its owner's alone; its owner may move it to the organization, never back.
  - `ownerUserId` (string | null, required): The owner of a personal project; null for the organization's.
  - `createdBy` (string, required)
  - `createdAt` (string (date-time), required)
  - `updatedAt` (string (date-time), required)
  - `archivedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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 DELETE "$NEXUS_URL/v1/projects/<id>/repos/<repoKey>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## List project members

`GET /v1/projects/{id}/members`

A project's member rows: people and teams, each a member or an admin. Anyone in the project reads them. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

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

### Responses

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

### Errors

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

### Example

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

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

## Put project member

`PUT /v1/projects/{id}/members/{subjectKind}/{subjectId}`

Add a person or a team to a project, or change their role. A person must be an active member of the organization (404 unknown_member); a team, one of its teams (404 unknown_team). A person is in a project through their own row or a row of a team they are in or a team above it. A project admin only. At most 500 rows per project (409 project_member_limit). Audited as `project.member_set`. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The project's id (`prj_…`) |
| `subjectKind` | path | string | yes | A person (`user`) or a team |
| `subjectId` | path | string | yes | The person's user id, or the team's id or slug |
| `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)

- `role` ("member" | "admin", required)

### Responses

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

### Errors

| Status | Code | When |
| --- | --- | --- |
| 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 |
| 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/projects/<id>/members/<subjectKind>/<subjectId>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "member"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fprojects%2F%7Bid%7D%2Fmembers%2F%7BsubjectKind%7D%2F%7BsubjectId%7D)

## Delete project member

`DELETE /v1/projects/{id}/members/{subjectKind}/{subjectId}`

Remove a person or a team from a project (404 project_member_not_found when they are not in it). Owners and admins stay admins of every project without a row. A project admin only. Audited as `project.member_removed`. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The project's id (`prj_…`) |
| `subjectKind` | path | string | yes | A person (`user`) or a team |
| `subjectId` | path | string | yes | The person's user id, or the team's id or slug |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Responses

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

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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 DELETE "$NEXUS_URL/v1/projects/<id>/members/<subjectKind>/<subjectId>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## List org secrets

`GET /v1/secrets/org`

List the organization's secrets: each one's name, who changed it last and when, by name. No route returns a value. An owner or admin of the organization only (403 role_required, before the body is read). Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.org_secrets`. 503 not_configured when Gateway has no database.

Permission: `projects.org_secrets` (Owner, Admin).

### Responses

- `200` OK (application/json, SecretList)
  - `data` (array of SecretName, required)
    - `name` (string, required) [pattern ^[A-Z_][A-Z0-9_]{0,127}$]
    - `scope` ("org" | "project" | "person", required)
    - `updatedBy` (string, required): The user id of who set it last
    - `updatedAt` (string (date-time), required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 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/secrets/org" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

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

## Put org secret

`PUT /v1/secrets/org/{secretName}`

Set one of the organization's secrets. The value is sealed with the organization's data key and is write-only: the answer is its name, never its value. A value is 1 to 32768 bytes (400 secret_value_invalid). At most 100 per scope (409 secret_limit). Audited as `secret.set`, without the value. An owner or admin of the organization only (403 role_required, before the body is read). Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.org_secrets`. 503 not_configured when Gateway has no database.

Permission: `projects.org_secrets` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `secretName` | path | string | yes | The secret's name: an environment variable's (`NPM_TOKEN`) |
| `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)

- `value` (string, required): The value, 1 to 32768 bytes. Write-only: no route returns it. [min length 1]

### Responses

- `200` OK (application/json, SecretName)
  - `name` (string, required) [pattern ^[A-Z_][A-Z0-9_]{0,127}$]
  - `scope` ("org" | "project" | "person", required)
  - `updatedBy` (string, required): The user id of who set it last
  - `updatedAt` (string (date-time), required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 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 |
| 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/secrets/org/<secretName>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "<value>"
  }'
```

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

## Delete org secret

`DELETE /v1/secrets/org/{secretName}`

Delete one of the organization's secrets (404 secret_not_found when there is none). Audited as `secret.deleted`. An owner or admin of the organization only (403 role_required, before the body is read). Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.org_secrets`. 503 not_configured when Gateway has no database.

Permission: `projects.org_secrets` (Owner, Admin).

### Parameters

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

### Responses

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

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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 DELETE "$NEXUS_URL/v1/secrets/org/<secretName>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## List my secrets

`GET /v1/secrets/me`

List your own secrets: each one's name, who changed it last and when, by name. No route returns a value. Only you read and change your own; they reach only your sessions. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Responses

- `200` OK (application/json, SecretList)
  - `data` (array of SecretName, required)
    - `name` (string, required) [pattern ^[A-Z_][A-Z0-9_]{0,127}$]
    - `scope` ("org" | "project" | "person", required)
    - `updatedBy` (string, required): The user id of who set it last
    - `updatedAt` (string (date-time), required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 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/secrets/me" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

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

## Put my secret

`PUT /v1/secrets/me/{secretName}`

Set one of your own secrets. The value is sealed with the organization's data key and is write-only: the answer is its name, never its value. A value is 1 to 32768 bytes (400 secret_value_invalid). At most 100 per scope (409 secret_limit). Audited as `secret.set`, without the value. Only you read and change your own; they reach only your sessions. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `secretName` | path | string | yes | The secret's name: an environment variable's (`NPM_TOKEN`) |
| `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)

- `value` (string, required): The value, 1 to 32768 bytes. Write-only: no route returns it. [min length 1]

### Responses

- `200` OK (application/json, SecretName)
  - `name` (string, required) [pattern ^[A-Z_][A-Z0-9_]{0,127}$]
  - `scope` ("org" | "project" | "person", required)
  - `updatedBy` (string, required): The user id of who set it last
  - `updatedAt` (string (date-time), required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 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 |
| 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/secrets/me/<secretName>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "<value>"
  }'
```

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

## Delete my secret

`DELETE /v1/secrets/me/{secretName}`

Delete one of your own secrets (404 secret_not_found when there is none). Audited as `secret.deleted`. Only you read and change your own; they reach only your sessions. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

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

### Responses

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

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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 DELETE "$NEXUS_URL/v1/secrets/me/<secretName>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## List project secrets

`GET /v1/projects/{id}/secrets`

List the project's secrets: each one's name, who changed it last and when, by name. No route returns a value. Anyone in the project reads the names; a project admin changes them (403 project_admin_required), never while it is archived (409 project_archived). 404 project_not_found when you are not in it. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

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

### Responses

- `200` OK (application/json, SecretList)
  - `data` (array of SecretName, required)
    - `name` (string, required) [pattern ^[A-Z_][A-Z0-9_]{0,127}$]
    - `scope` ("org" | "project" | "person", required)
    - `updatedBy` (string, required): The user id of who set it last
    - `updatedAt` (string (date-time), required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

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

### Example

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

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

## Put project secret

`PUT /v1/projects/{id}/secrets/{secretName}`

Set one of the project's secrets. The value is sealed with the organization's data key and is write-only: the answer is its name, never its value. A value is 1 to 32768 bytes (400 secret_value_invalid). At most 100 per scope (409 secret_limit). Audited as `secret.set`, without the value. Anyone in the project reads the names; a project admin changes them (403 project_admin_required), never while it is archived (409 project_archived). 404 project_not_found when you are not in it. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The project's id (`prj_…`) |
| `secretName` | path | string | yes | The secret's name: an environment variable's (`NPM_TOKEN`) |
| `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)

- `value` (string, required): The value, 1 to 32768 bytes. Write-only: no route returns it. [min length 1]

### Responses

- `200` OK (application/json, SecretName)
  - `name` (string, required) [pattern ^[A-Z_][A-Z0-9_]{0,127}$]
  - `scope` ("org" | "project" | "person", required)
  - `updatedBy` (string, required): The user id of who set it last
  - `updatedAt` (string (date-time), required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 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 |
| 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/projects/<id>/secrets/<secretName>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "<value>"
  }'
```

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

## Delete project secret

`DELETE /v1/projects/{id}/secrets/{secretName}`

Delete one of the project's secrets (404 secret_not_found when there is none). Audited as `secret.deleted`. Anyone in the project reads the names; a project admin changes them (403 project_admin_required), never while it is archived (409 project_archived). 404 project_not_found when you are not in it. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The project's id (`prj_…`) |
| `secretName` | path | string | yes | The secret's name: an environment variable's (`NPM_TOKEN`) |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Responses

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

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 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 DELETE "$NEXUS_URL/v1/projects/<id>/secrets/<secretName>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

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

## Get project setup

`GET /v1/projects/{id}/setup`

Read the project's setup: the current version's script, or null when the repository's own committed `.agents/setup` runs, and whether a cloud machine verified it (`unknown`, `verifying`, `ok` or `failed`, with the version and commit the last finished verification ran on). Anyone in the project reads it. 404 project_not_found when you are not in it. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

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

### Responses

- `200` OK (application/json, ProjectSetup)
  - `projectId` (string, required)
  - `currentVersion` (integer | null, required): The current version, or null for the repository's own `.agents/setup` [min 1]
  - `script` (string | null, required): The current version's script
  - `status` ("unknown" | "verifying" | "ok" | "failed", required)
  - `verifiedVersion` (integer | null, required) [min 1]
  - `verifiedCommit` (string | null, required) [pattern ^[0-9a-f]{7,64}$]
  - `verifiedAt` (string (date-time) | null, required)
  - `reportedByMachine` (string | null, required): The cloud machine whose host reported last
  - `updatedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

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

### Example

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

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

## List project setup versions

`GET /v1/projects/{id}/setup/versions`

List the project's saved setup versions, newest first, without their scripts. Anyone in the project reads them. 404 project_not_found when you are not in it. Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

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

### Responses

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

### Errors

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

### Example

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

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

## Save project setup version

`POST /v1/projects/{id}/setup/versions`

Save the next version of the project's setup script. It wins over the repository's `.agents/setup`, and the status goes back to `unknown`. Versions are never changed or deleted. A script is 1 to 65536 bytes (400 setup_script_invalid); at most 500 versions (409 setup_version_limit). Audited as `project.setup_saved`. A project admin only (403 project_admin_required), never while it is archived (409 project_archived). Behind `NEXUS_PROJECTS`: off, a 404. No agent link and no operator grant holds `projects.use`. 503 not_configured when Gateway has no database.

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

### Parameters

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

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

- `script` (string, required): Up to 65536 bytes [min length 1]

### Responses

- `201` Created (application/json, ProjectSetup)
  - `projectId` (string, required)
  - `currentVersion` (integer | null, required): The current version, or null for the repository's own `.agents/setup` [min 1]
  - `script` (string | null, required): The current version's script
  - `status` ("unknown" | "verifying" | "ok" | "failed", required)
  - `verifiedVersion` (integer | null, required) [min 1]
  - `verifiedCommit` (string | null, required) [pattern ^[0-9a-f]{7,64}$]
  - `verifiedAt` (string (date-time) | null, required)
  - `reportedByMachine` (string | null, required): The cloud machine whose host reported last
  - `updatedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

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

### Example

```sh
curl -X POST "$NEXUS_URL/v1/projects/<id>/setup/versions" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "script": "<script>"
  }'
```

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

## Report project setup status

`POST /v1/projects/{id}/setup/status`

A cloud machine's host reports a verification of the project's current setup, with the machine's own Nexus token (403 not_machine_token for any other). The machine's owner must be in the project (404 project_not_found). The report names the version it ran; 409 setup_version_stale when that is not the current one. `ok` and `failed` name the commit (400 setup_commit_invalid). 503 cloud_unavailable without cloud machines. Behind `NEXUS_PROJECTS`: off, a 404. 503 not_configured when Gateway has no database.

Permission: `cloud.machines.use` (Every member).

### Parameters

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

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

- `machineId` (string, required): The reporting cloud machine's id
- `version` (integer | null, required): The version it ran, or null for the repository's own setup [min 1]
- `status` ("verifying" | "ok" | "failed", required)
- `commit` (string): The commit it ran on; required for ok and failed [pattern ^[0-9a-f]{7,64}$]

### Responses

- `200` OK (application/json, ProjectSetup)
  - `projectId` (string, required)
  - `currentVersion` (integer | null, required): The current version, or null for the repository's own `.agents/setup` [min 1]
  - `script` (string | null, required): The current version's script
  - `status` ("unknown" | "verifying" | "ok" | "failed", required)
  - `verifiedVersion` (integer | null, required) [min 1]
  - `verifiedCommit` (string | null, required) [pattern ^[0-9a-f]{7,64}$]
  - `verifiedAt` (string (date-time) | null, required)
  - `reportedByMachine` (string | null, required): The cloud machine whose host reported last
  - `updatedAt` (string (date-time) | null, required)
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

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

### Example

```sh
curl -X POST "$NEXUS_URL/v1/projects/<id>/setup/status" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "machineId": "<machineId>",
    "version": 1,
    "status": "verifying"
  }'
```

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