Skip to content
NewNexus 2.0 is here, and it’s open source. Read the launch post

API reference

Service accounts

Service accounts: callers for CI and scripts. An owner or admin makes one, a member answers for it, a team owns it, and it expires (365 days at most). It is no member and holds no seat. Its keys (nxsa_…) are stored as a hash and shown once (a replay of the same Idempotency-Key within 24 hours shows one again), live 90 days by default, and stop when the account is revoked or expires, its owner leaves the organization, or its team is deleted. They reach the public endpoints only, until a Policy Engine statement admits them to more.

View as Markdown

List service accounts

get/v1/service-accounts

The organization's service accounts (owners and admins: service_accounts.manage), newest first. Each has every key it held, live or not, newest first. Never a token or its hash. limit and cursor page it.

service_accounts.manageOwner, AdminTry it in the API Explorer

Parameters

  • limitquery · integer

    Items per page, 1 to 500 (default 100). Without limit or cursor the answer holds the whole list.

  • cursorquery · string

    NextCursor from the previous page. A cursor whose item left the list answers 400 invalid_cursor.

Responses

200OKapplication/json

  • serviceAccountsarray of ServiceAccountrequired
    • idstringrequired

      sva_…

    • namestringrequired
    • ownerUserIdstringrequired

      The member who answers for it. Its keys stop when they leave the organization.

    • teamIdstringrequired

      The team that owns it. Its keys stop when the team is deleted.

    • createdBystringrequired

      The person who made it.

    • createdAtstring (date-time)required
    • expiresAtstring (date-time)required
    • revokedAtstring (date-time)
    • keysarray of ServiceAccountKeyrequired

      Every key it held, newest first.

      • idstringrequired

        sak_…

      • serviceAccountIdstringrequired
      • ownerUserIdstringrequired

        The member who answers for its account, as the account holds it now. The key stops when they leave the organization.

      • scopeServiceAccountScoperequired

        What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key.

        • teamIdstringrequired

          The team that owns the account. Its keys stop when the team is deleted.

      • prefixstringrequired

        The first characters of the token, to recognise it in a list.

      • labelstring
      • createdBystringrequired

        The person who issued it.

      • createdAtstring (date-time)required
      • expiresAtstring (date-time)required
      • revokedAtstring (date-time)
      • lastUsedAtstring (date-time)

        When the key last authenticated, written at most once an hour.

      • rotatedFromstring

        The key this one replaced in a rotation.

  • nextCursorstring

    The next page's cursor, while more items follow. Only when limit or cursor was sent.

429Over 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

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
429Over 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).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl "$NEXUS_URL/v1/service-accounts" \
  -H "Authorization: Bearer $NEXUS_API_KEY"

Create service account

post/v1/service-accounts

Make a service account, a caller for CI and scripts (owners and admins: service_accounts.manage). A member answers for it (ownerUserId, the caller by default) and a team owns it (team, its slug or id). It expires at expiresAt, at most 365 days from now. An organization holds at most 100 live accounts: the 101st is a 409 service_account_limit. It is no member and holds no seat. Its keys (nxsa_…) reach the public endpoints only, until a Policy Engine statement admits them to more: every other route answers 403. It has no key until one is issued. Audited as service_account.created. With dryRun: true everything is checked and nothing is written: the answer is a 200 with the account as it would be made, and its id is never used.

service_accounts.manageOwner, AdminTry it in the API Explorer

Parameters

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Request body · application/json

  • namestringrequired

    min length 1 · max length 64

  • ownerUserIdstring

    The member who answers for it. The caller by default.

  • teamstringrequired

    The team that owns it: its slug or id.

  • expiresAtstring (date-time)required

    In the future, at most 365 days from now.

  • dryRunboolean

    Check everything and write nothing.

    default false

Responses

200A dry run: the account as it would be madeapplication/json

  • idstringrequired

    sva_…

  • namestringrequired
  • ownerUserIdstringrequired

    The member who answers for it. Its keys stop when they leave the organization.

  • teamIdstringrequired

    The team that owns it. Its keys stop when the team is deleted.

  • createdBystringrequired

    The person who made it.

  • createdAtstring (date-time)required
  • expiresAtstring (date-time)required
  • revokedAtstring (date-time)
  • keysarray of ServiceAccountKeyrequired

    Every key it held, newest first.

    • idstringrequired

      sak_…

    • serviceAccountIdstringrequired
    • ownerUserIdstringrequired

      The member who answers for its account, as the account holds it now. The key stops when they leave the organization.

    • scopeServiceAccountScoperequired

      What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key.

      • teamIdstringrequired

        The team that owns the account. Its keys stop when the team is deleted.

    • prefixstringrequired

      The first characters of the token, to recognise it in a list.

    • labelstring
    • createdBystringrequired

      The person who issued it.

    • createdAtstring (date-time)required
    • expiresAtstring (date-time)required
    • revokedAtstring (date-time)
    • lastUsedAtstring (date-time)

      When the key last authenticated, written at most once an hour.

    • rotatedFromstring

      The key this one replaced in a rotation.

  • dryRunbooleanrequired

    A dry run's id is never used.

201Createdapplication/json

  • idstringrequired

    sva_…

  • namestringrequired
  • ownerUserIdstringrequired

    The member who answers for it. Its keys stop when they leave the organization.

  • teamIdstringrequired

    The team that owns it. Its keys stop when the team is deleted.

  • createdBystringrequired

    The person who made it.

  • createdAtstring (date-time)required
  • expiresAtstring (date-time)required
  • revokedAtstring (date-time)
  • keysarray of ServiceAccountKeyrequired

    Every key it held, newest first.

    • idstringrequired

      sak_…

    • serviceAccountIdstringrequired
    • ownerUserIdstringrequired

      The member who answers for its account, as the account holds it now. The key stops when they leave the organization.

    • scopeServiceAccountScoperequired

      What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key.

      • teamIdstringrequired

        The team that owns the account. Its keys stop when the team is deleted.

    • prefixstringrequired

      The first characters of the token, to recognise it in a list.

    • labelstring
    • createdBystringrequired

      The person who issued it.

    • createdAtstring (date-time)required
    • expiresAtstring (date-time)required
    • revokedAtstring (date-time)
    • lastUsedAtstring (date-time)

      When the key last authenticated, written at most once an hour.

    • rotatedFromstring

      The key this one replaced in a rotation.

  • dryRunbooleanrequired

    A dry run's id is never used.

400Not valid: no name (1 to 64 characters), an `expiresAt` that is not a future time within 365 days (`invalid_expiry`), an owner who is not a member (`owner_not_a_member`) or a team that is not the organization's (`unknown_team`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over 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

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
101service_account_limitThe 101st is a 409 `service_account_limit`
400invalid_request_errorA field is missing or not valid; the message names it
400Not valid: no name (1 to 64 characters), an `expiresAt` that is not a future time within 365 days (`invalid_expiry`), an owner who is not a member (`owner_not_a_member`) or a team that is not the organization's (`unknown_team`)
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over 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).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X POST "$NEXUS_URL/v1/service-accounts" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Platform",
    "team": "platform",
    "expiresAt": "2026-10-01T00:00:00Z"
  }'

Revoke service account

DEL/v1/service-accounts/{id}

Revoke a service account and every live key it holds, in one change (owners and admins: service_accounts.manage). Its keys answer as an unknown token from then on. Revoking a revoked account answers already: true and changes nothing. With ?dryRun=1 nothing changes: the answer counts the keys it would stop. Audited as service_account.revoked, with the ids of the keys it stopped. Another organization's account is a 404.

service_accounts.manageOwner, AdminTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The service account's id (sva_…)

  • dryRunquery · "1" | "true" | "0" | "false"

    1 or true: check and change nothing. 0 or false: the same as none. Any other value is a 400, so a mistyped flag never revokes.

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Responses

200OKapplication/json

  • idstringrequired
  • alreadybooleanrequired

    It was revoked before this request.

  • dryRunbooleanrequired
  • revokedAtstring (date-time) | null
  • keysRevokedintegerrequired

    The live keys it stopped (with dryRun, the ones it would stop).

400`dryRun` is not `1`, `true`, `0` or `false`application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

404No such service account in this organization (`unknown_service_account`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over 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

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400`dryRun` is not `1`, `true`, `0` or `false`
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No such service account in this organization (`unknown_service_account`)
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over 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).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X DELETE "$NEXUS_URL/v1/service-accounts/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

Issue service account key

post/v1/service-accounts/{id}/keys

Issue a key for a service account (owners and admins: service_accounts.manage). The token (nxsa_…) is in this answer, and in a replay of it (same Idempotency-Key, within 24 hours), as for POST /v1/auth/tokens: Gateway keeps only its hash. The key lives 90 days unless expiresAt says otherwise, and never past its account. An account holds at most 5 live keys: the sixth is a 409 service_account_key_limit. A revoked or expired account takes no key (409 service_account_revoked, service_account_expired). Audited as service_account.key_created, never with the token.

service_accounts.manageOwner, AdminTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The service account's id (sva_…)

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Request body · application/json

  • labelstring

    Required to issue a key. A rotation keeps the old label when it names none.

    min length 1 · max length 80

  • expiresAtstring (date-time)

    In the future and not past the account's own expiry. 90 days from now by default, or the account's expiry if that comes first. A rotation keeps the old key's lifetime by default.

Responses

201Createdapplication/json

  • idstringrequired

    sak_…

  • serviceAccountIdstringrequired
  • ownerUserIdstringrequired

    The member who answers for its account, as the account holds it now. The key stops when they leave the organization.

  • scopeServiceAccountScoperequired

    What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key.

    • teamIdstringrequired

      The team that owns the account. Its keys stop when the team is deleted.

  • prefixstringrequired

    The first characters of the token, to recognise it in a list.

  • labelstring
  • createdBystringrequired

    The person who issued it.

  • createdAtstring (date-time)required
  • expiresAtstring (date-time)required
  • revokedAtstring (date-time)
  • lastUsedAtstring (date-time)

    When the key last authenticated, written at most once an hour.

  • rotatedFromstring

    The key this one replaced in a rotation.

  • tokenstringrequired

    nxsa_…. In this answer, and in a replay of it (same Idempotency-Key) within 24 hours.

400No label (1 to 80 characters), or an `expiresAt` that is not a future time within the account's life (`invalid_expiry`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

404No such service account in this organization (`unknown_service_account`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

409The account is revoked or expired, or holds 5 live keysapplication/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over 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

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400No label (1 to 80 characters), or an `expiresAt` that is not a future time within the account's life (`invalid_expiry`)
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No such service account in this organization (`unknown_service_account`)
409The account is revoked or expired, or holds 5 live keys
409service_account_key_limitThe sixth is a 409 `service_account_key_limit`
409service_account_revokedA revoked or expired account takes no key (409 `service_account_revoked`, `service_account_expired`)
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over 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).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X POST "$NEXUS_URL/v1/service-accounts/<id>/keys" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "CI",
    "expiresAt": "2026-10-01T00:00:00Z"
  }'

Revoke service account key

DEL/v1/service-accounts/{id}/keys/{keyId}

Revoke one key of a service account (owners and admins: service_accounts.manage). The key answers as an unknown token from then on. A key that is already revoked answers as it was, and nothing changes. A key of another service account is a 404. Audited as service_account.key_revoked.

service_accounts.manageOwner, AdminTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The service account's id (sva_…)

  • keyIdpath · stringrequired

    The key's id (sak_…)

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Responses

200OKapplication/json

  • idstringrequired

    sak_…

  • serviceAccountIdstringrequired
  • ownerUserIdstringrequired

    The member who answers for its account, as the account holds it now. The key stops when they leave the organization.

  • scopeServiceAccountScoperequired

    What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key.

    • teamIdstringrequired

      The team that owns the account. Its keys stop when the team is deleted.

  • prefixstringrequired

    The first characters of the token, to recognise it in a list.

  • labelstring
  • createdBystringrequired

    The person who issued it.

  • createdAtstring (date-time)required
  • expiresAtstring (date-time)required
  • revokedAtstring (date-time)
  • lastUsedAtstring (date-time)

    When the key last authenticated, written at most once an hour.

  • rotatedFromstring

    The key this one replaced in a rotation.

404No such key in this service account (`unknown_service_account_key`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over 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

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No such key in this service account (`unknown_service_account_key`)
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over 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).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X DELETE "$NEXUS_URL/v1/service-accounts/<id>/keys/<keyId>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"

Rotate service account key

post/v1/service-accounts/{id}/keys/{keyId}/rotate

Replace a live key with a new one, in one change (owners and admins: service_accounts.manage). The old key stops at once. The answer holds the new key and its token, once (a replay with the same Idempotency-Key within 24 hours returns it again). The new key keeps the old label unless label names another, and lives as long as the old key did unless expiresAt says otherwise, never past its account. A key that is revoked or expired does not rotate (409 key_not_live). Audited as service_account.key_rotated, with the old key as before and the new as after.

service_accounts.manageOwner, AdminTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The service account's id (sva_…)

  • keyIdpath · stringrequired

    The key's id (sak_…)

  • Idempotency-Keyheader · string

    Send the same key again to retry safely: the request runs once. See Idempotency keys.

Request body (optional) · application/json

  • labelstring

    Required to issue a key. A rotation keeps the old label when it names none.

    min length 1 · max length 80

  • expiresAtstring (date-time)

    In the future and not past the account's own expiry. 90 days from now by default, or the account's expiry if that comes first. A rotation keeps the old key's lifetime by default.

Responses

200OKapplication/json

  • idstringrequired

    sak_…

  • serviceAccountIdstringrequired
  • ownerUserIdstringrequired

    The member who answers for its account, as the account holds it now. The key stops when they leave the organization.

  • scopeServiceAccountScoperequired

    What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key.

    • teamIdstringrequired

      The team that owns the account. Its keys stop when the team is deleted.

  • prefixstringrequired

    The first characters of the token, to recognise it in a list.

  • labelstring
  • createdBystringrequired

    The person who issued it.

  • createdAtstring (date-time)required
  • expiresAtstring (date-time)required
  • revokedAtstring (date-time)
  • lastUsedAtstring (date-time)

    When the key last authenticated, written at most once an hour.

  • rotatedFromstring

    The key this one replaced in a rotation.

  • tokenstringrequired

    nxsa_…. In this answer, and in a replay of it (same Idempotency-Key) within 24 hours.

400A label that is not 1 to 80 characters, or an `expiresAt` that is not a future time within the account's life (`invalid_expiry`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

404No such key in this service account, or no such service account (`unknown_service_account_key`, `unknown_service_account`)application/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

409The key is not live (`key_not_live`), or its account is revoked or expiredapplication/json

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

429Over 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

  • errorobject
    • messagestringrequired
    • typestringrequired

      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.

    • codestring

      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.

    • paramstring

      model when the error is a model refusal (a code starting with model_); absent otherwise.

    • nexusobject

      Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.

    • minimumstring

      On a 426 cli_too_old only: the oldest nexus CLI version Gateway supports.

Errors

StatusCodeWhen
400invalid_request_errorA field is missing or not valid; the message names it
400A label that is not 1 to 80 characters, or an `expiresAt` that is not a future time within the account's life (`invalid_expiry`)
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
404not_foundNothing matches the path in your organization
404No such key in this service account, or no such service account (`unknown_service_account_key`, `unknown_service_account`)
409The key is not live (`key_not_live`), or its account is revoked or expired
409key_not_liveA key that is revoked or expired does not rotate (409 `key_not_live`)
409idempotency_in_progressA request with the same Idempotency-Key is still running
409idempotency_interruptedThe first request with this Idempotency-Key was cut off and may have run in part
422idempotency_key_reusedThe Idempotency-Key was used with a different request
429Over 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).
429rate_limit_errorToo many requests from this key in a minute

Example

curl
curl -X POST "$NEXUS_URL/v1/service-accounts/<id>/keys/<keyId>/rotate" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "CI",
    "expiresAt": "2026-10-01T00:00:00Z"
  }'