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

API reference

Agent links

Agent links: the credential of an agent that acts for one person. A person links an agent and names what it may do (models.use, spend.read_own, connectors.use, chat.ask, chat.web, agents.memory). Its token (nxo_…) is stored as a hash and shown once. The agent holds that grant cut down to the person's role now, and never the routes that are the person's alone. The person, or an owner or admin, unlinks it, and the person's own tokens do not change.

View as Markdown
get/v1/agent-links

Your live agent links in this organization; ?all=1 for everyone's (owners and admins). Never a token or what it hashes to. Newest first; limit and cursor page it.

agent_links.manage_ownEvery memberTry it in the API Explorer

Parameters

  • allquery · "1"

    1 lists everyone's links. Only owners and admins may: anyone else answers 403 role_required.

  • 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

  • agentLinksarray of AgentLinkrequired
    • idstringrequired

      agl_…

    • userIdstringrequired

      The person the agent acts for.

    • agentstringrequired

      What the agent is, as a slug (slack).

    • labelstringrequired
    • grantarray of stringrequired

      The grant the agent holds: what the person granted, cut to what a link may hold now (models.use). The person's role limits it again at each call.

    • prefixstringrequired

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

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

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

  • nextCursorstring

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

403`?all=1` without the organization rung of the keys ladder (`role_required`)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
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/agent-links" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
post/v1/agent-links

Link an agent that acts for you (people only: a service account, a module key or another agent answers 403). grant names what it may do: models.use (the default), spend.read_own, connectors.use, chat.ask (Ask your code alone, askCode), chat.web (web search alone, askWeb) and agents.memory (your agent memory alone). The token (nxo_…) is in this answer, and again in a repeat with the same Idempotency-Key within 24 hours: Gateway keeps only its hash. The agent holds that grant cut down to your role now, and none of the routes that are yours alone. The link lives 90 days unless expiresAt says otherwise, at most 365. A person holds at most 20 live links in an organization: the next is 409 agent_link_limit. Audited as agent.linked, never with the token. With dryRun: true everything is checked and nothing is written: the answer is a 200 with no token.

agent_links.manage_ownEvery memberTry 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

  • agentstringrequired

    What the agent is, as a slug (slack).

    min length 1 · max length 40 · pattern ^[a-z0-9][a-z0-9-]*$

  • labelstringrequired

    min length 1 · max length 80

  • grantarray of "models.use" | "spend.read_own"

    What the agent may do. models.use by default.

  • expiresAtstring (date-time)

    In the future, at most 365 days from now. 90 days from now by default.

  • sessionboolean

    A link for one agent session: deleted, not kept, when it ends (DELETE /v1/agent-links/{id}), so a second end answers 404. It also ends after 15 to 30 minutes without use, so the link of a client that stopped without ending it does not stay live; the client makes a new one. Making one also deletes up to 20 of your ended session links. The audit keeps their history.

    default false

  • dryRunboolean

    Check everything and write nothing.

    default false

Responses

200A dry run: the link as it would be made, with no tokenapplication/json

  • idstringrequired

    agl_…

  • userIdstringrequired

    The person the agent acts for.

  • agentstringrequired

    What the agent is, as a slug (slack).

  • labelstringrequired
  • grantarray of stringrequired

    The grant the agent holds: what the person granted, cut to what a link may hold now (models.use). The person's role limits it again at each call.

  • prefixstringrequired

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

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

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

  • tokenstring

    nxo_…. In this answer, and again in a repeat with the same Idempotency-Key within 24 hours. None with dryRun.

  • dryRunbooleanrequired

    The link was not written. Its id is never used.

201Createdapplication/json

  • idstringrequired

    agl_…

  • userIdstringrequired

    The person the agent acts for.

  • agentstringrequired

    What the agent is, as a slug (slack).

  • labelstringrequired
  • grantarray of stringrequired

    The grant the agent holds: what the person granted, cut to what a link may hold now (models.use). The person's role limits it again at each call.

  • prefixstringrequired

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

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

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

  • tokenstring

    nxo_…. In this answer, and again in a repeat with the same Idempotency-Key within 24 hours. None with dryRun.

  • dryRunbooleanrequired

    The link was not written. Its id is never used.

400Not valid: an `agent` that is no slug (`invalid_agent`), no label (1 to 80 characters), an empty `grant` (`invalid_grant`), an action that cannot be granted (`grant_not_allowed`) an `expiresAt` that is not a future time within 365 days (`invalid_expiry`), or a field that the body does not defineapplication/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.

403The caller may not link: a module key (`module_key`), a service account or another agent (`role_required`), a caller that is no person (`person_required`), a person who is no longer a member (`not_a_member`), or a `grant` that the caller's role does not allow (`role_required`)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 person already holds 20 live links (`agent_link_limit`)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
400Not valid: an `agent` that is no slug (`invalid_agent`), no label (1 to 80 characters), an empty `grant` (`invalid_grant`), an action that cannot be granted (`grant_not_allowed`) an `expiresAt` that is not a future time within 365 days (`invalid_expiry`), or a field that the body does not define
401authentication_errorNo key, or a key Gateway does not accept
403role_requiredYour role does not have this permission
409The person already holds 20 live links (`agent_link_limit`)
409agent_link_limitThe next is 409 `agent_link_limit`
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/agent-links" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "claude",
    "label": "CI"
  }'
DEL/v1/agent-links/{id}

Unlink an agent: your own link, or anyone's for owners and admins (the keys ladder's organization rung). Its token answers as an unknown token from then on. Your own tokens and your other links do not change. Unlinking an ended link answers as it was and writes nothing. A session link is deleted when it ends, so unlinking it again answers 404. Audited as agent.unlinked.

agent_links.manage_ownEvery memberTry it in the API Explorer

Parameters

  • idpath · stringrequired

    The link's id (agl_…)

  • Idempotency-Keyheader · string

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

Responses

200OK: the link, with `revokedAt`application/json

  • idstringrequired

    agl_…

  • userIdstringrequired

    The person the agent acts for.

  • agentstringrequired

    What the agent is, as a slug (slack).

  • labelstringrequired
  • grantarray of stringrequired

    The grant the agent holds: what the person granted, cut to what a link may hold now (models.use). The person's role limits it again at each call.

  • prefixstringrequired

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

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

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

403Another person's link, and the caller is no owner or admin (`role_required`)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 link in this organization (`unknown_agent_link`)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 link in this organization (`unknown_agent_link`)
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/agent-links/<id>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"