# Nexus docs > Run AI through one API, with model policies, attribution and an audit trail, from the CLI, the API or Nexus UI. Nexus Gateway routes every model call your organization makes, from your coding agents, your products and your own code, through one API. Each call is checked against your model policies, metered, and attributed to a person and a team. Everything is available three ways: the `nexus` CLI, the Nexus API, and Nexus UI. - [Quickstart](/docs/quickstart): Install the CLI, sign in and run Claude Code through Nexus. - [Authentication](/docs/authentication): Google or email sign-in, CLI login with a one-time code, and API keys. - [API reference](/docs/api): Every endpoint, with its permission, schemas and examples. - [CLI reference](/docs/cli): Every `nexus` command and option. ## For agents Every page is also plain Markdown: add `.md` to its URL, or `?format=md`. [`/llms.txt`](/llms.txt) indexes every page, and [`/llms-full.txt`](/llms-full.txt) is all of them in one file. ## Products - [Nexus Gateway](/gateway): The control plane of your factory: any model through one gateway, on your own keys, under one set of controls. [Docs](/docs/quickstart). --- # Quickstart > Install the CLI, sign in, run Claude Code through Nexus and see what it cost. You need curl, a Nexus organization (sign in to [Nexus UI](/app) with your Google account or email; your first sign-in creates your personal organization), and [Claude Code](https://docs.anthropic.com/en/docs/claude-code) installed. Nexus never installs a coding agent for you: ```sh curl -fsSL https://claude.ai/install.sh | bash ``` ## 1. Install the CLI ```sh curl -fsSL https://api.nexus.inc/install.sh | bash ``` The installer downloads the `nexus` CLI from Nexus Gateway, checks it against its SHA-256 checksum and installs it to `~/.nexus/bin/nexus` (set `NEXUS_INSTALL_DIR` to change the folder). It installs the native binary for your machine when Gateway publishes one. Otherwise it installs the JavaScript CLI, which needs Node.js 22.6 or later. If that folder isn't on your `PATH`, it prints the line to add. Open a new terminal and check: ```sh nexus --version ``` ## 2. Sign in ```sh nexus auth login ``` The CLI shows a one-time code and opens Nexus UI. Check that the code matches, and approve it for your organization. The CLI then has a token of its own: it is yours, lasts 90 days and can be revoked. Codes expire after ten minutes. ```sh nexus auth status # your organization, you, your role, and whether Gateway accepts your token ``` ## 3. Add your Anthropic key Through Nexus Gateway, Claude Code's calls go to Anthropic with your organization's own key. An owner or admin adds it once: ```sh nexus keys add anthropic sk-ant-… ``` The key is encrypted at rest and used for your organization only. `nexus keys list` shows which providers have a key. ## 4. Run Claude Code through Nexus ```sh nexus claude --api ``` Claude Code starts as usual, with every model call going through Nexus Gateway: reserved against your organization's budget, metered, checked against its policy and attributed to you and to this session. Arguments go to Claude Code unchanged: ```sh nexus claude --api -p "Summarize this repository in five bullet points" ``` Without `--api`, `nexus claude` takes your saved route (`nexus agents use`). The default is your own Claude plan: Nexus records the session but does not meter it (see [Choose a route](/docs/guides/coding-agents#choose-a-route)). ## 5. See what it cost ```sh nexus spend ``` You get the budget, what is spent, reserved and remaining (a member gets what is left for them), spend by product and capability (Claude Code's calls show under `agents › claude`) and the latest calls. Nexus UI shows the same under **Usage**, and your agent sessions on **Overview**. > **Over budget.** Every call reserves its maximum cost before it runs. A call that would go over what is left of the budget is refused > with `402`, so a budget is never overspent. Owners and admins set the organization's budget with > [`POST /v1/orgs/budget`](/docs/api/organizations#set-budget). ## Next - [Authentication](/docs/authentication): API keys for CI and scripts. - [Claude Code](/docs/guides/claude-code) and [Codex](/docs/guides/codex): each one through Nexus Gateway, step by step. - [Coding agents](/docs/guides/coding-agents): the two routes, models and budget. - [Teams](/docs/concepts/teams): attribute spend to the teams of your organization. - [API reference](/docs/api): every endpoint of the Nexus API. --- # Authentication > Sign in to Nexus UI with Google or email, sign the CLI in with a one-time code, and use API keys in CI and scripts. Everything you do in Nexus is done as you, in one organization, with your role there. Nexus UI, the CLI and the API use the same credentials underneath: a personal Nexus token. | Credential | How you get it | Lifetime | Used by | | --- | --- | --- | --- | | Nexus UI session | Sign in to Nexus UI | 12 hours | Nexus UI in your browser | | CLI token | `nexus auth login` | 90 days, revocable | The `nexus` CLI on one machine | | API key | `nexus auth tokens create`, Nexus UI → **Settings** → **Keys**, or `POST /v1/auth/tokens` | Until revoked | CI, scripts, your own code | | Service account key | `nexus service-accounts keys create` (owners and admins) | 90 days by default, never past its account | CI and scripts that act for no person | Personal tokens start with `nx_`, and service account keys start with `nxsa_`. An agent you link to act for you gets its own key (`nxo_…`); you see and revoke it under **Settings** → **Keys**. Products running on Nexus get their own short-lived scoped keys (`nxs_…`) that can only call models and connectors; you never handle those. ## Nexus UI: sign in with Google or email Open [Nexus UI](/app) and sign in with your Google account, or with your email. Your first sign-in creates your personal organization. You can also create an organization for your company, or open one you were invited to. Whoever creates an organization is its owner. ## The CLI: a one-time code ```sh nexus auth login ``` 1. The CLI asks Gateway for a one-time code ([`POST /v1/auth/device`](/docs/api/auth#start-device-login)) and opens Nexus UI's approval page. Use `--no-browser` to only print the link, for example over SSH. 2. You check that the code matches and approve it for the organization selected in Nexus UI. 3. The CLI, polling [`POST /v1/auth/token`](/docs/api/auth#poll-device-login), receives a CLI token and saves it. Codes last ten minutes and work once. The token is saved in `~/.nexus/factory/config.json`, readable by you only (`NEXUS_CONFIG` moves it). `--url` signs in to another Nexus Gateway. ```sh nexus auth status # organization, user, role, Gateway URL, token (masked), and whether Gateway accepts it nexus auth logout # revokes the token on Gateway and forgets it ``` ## API keys Create an API key with the CLI, signed in as yourself: ```sh nexus auth tokens create --label "CI deploys" ``` The key is shown once. It belongs to you and acts with your role: if you are a member, so is the key. List and revoke your keys with the CLI. Owners and admins see and revoke everyone's (`--all`). ```sh nexus auth tokens # your API keys and CLI sign-ins, with their ids nexus auth tokens revoke ``` Nexus UI does the same under **Settings** → **Keys**. The API is [`POST /v1/auth/tokens`](/docs/api/auth#create-api-key), [`GET /v1/auth/tokens`](/docs/api/auth#list-tokens) and [`DELETE /v1/auth/tokens/{id}`](/docs/api/auth#revoke-token). ### In CI: `--with-token` ```sh echo "$NEXUS_API_KEY" | nexus auth login --with-token ``` The CLI reads the key from stdin, so it never appears in your shell history or the process list. `nexus auth logout` then only forgets the key; revoke it with `nexus auth tokens revoke ` when you no longer need it. ## Calling the API Send your token as a bearer token: ```sh curl "$NEXUS_URL/v1/tenants/me" -H "Authorization: Bearer $NEXUS_API_KEY" ``` `$NEXUS_URL` is your Nexus Gateway, for example `https://api.nexus.inc`. The answer names your organization, you, your role and the permissions you have. The agent gateway (the Anthropic and OpenAI pass-through) also accepts the token as `x-api-key`, the header Anthropic's clients send. A missing or unknown token is `401`; a permission your role doesn't have is `403` `role_required`, naming who may. See [Errors](/docs/api/errors). --- # Chat and sessions > Nexus UI's home is a chat. Ask any model your organization allows, in sessions that are private to you. Nexus UI opens on a chat. Write a question, pick a model, and the answer streams in. Each conversation is a **session**: it keeps its messages, the model that ran, the team its spend goes to and what it cost. The same sessions are in the CLI (`nexus chat`) and the API (`/v1/chat/sessions`). ## Asking Chat answers with any model your organization allows. `nexus/auto` is the default: Nexus chooses within your model policy, and every answer says which model ran. Web search is off by default. When an owner or admin turns it on under Settings › Policy, the model may search the web, and the answer lists its web sources. ## Models, policies and cost Every message takes the same path as any other model call through Nexus: your [model policy](/docs/concepts/models-and-policies) decides first (a block always wins), the call's maximum cost is reserved against the budget, and the [ledger](/docs/concepts/ledger) settles what it really cost. The spend is [attributed](/docs/concepts/attribution) to you, your team and the product `chat`, so it shows in Usage like the rest. The model picker lists the models you may use, with coming-soon models muted; blocked models are not listed. If a policy refuses a model, for example after an owner changes it, the refusal is kept in the session with its reason, and nothing is sent or charged. Choose another model and continue. ## Privacy and retention - **Sessions are private to the person who starts them.** Nobody else can read them, owners and admins included, unless you share one: see [Artifacts: share chats and pages](/docs/guides/artifacts). Owners and admins see counts only (sessions, messages, people and cost), through [`GET /v1/analytics/chat`](/docs/api/analytics#get-chat-usage). - **Message content never enters the audit log.** The [audit log](/docs/concepts/audit-log) records that a session was created or deleted, never its title or messages. - **Messages are kept for 90 days by default.** Owners and admins choose from 1 to 3650 days for the organization, under Settings › Data or with [`PUT /v1/orgs/settings`](/docs/api/organizations#set-org-settings); the change is audited. Older messages, and sessions with no activity in that window, are deleted. A shorter window applies at once. ## In Nexus UI The sidebar starts with **New session** and your recent sessions, with a search. A session's page shows its messages, the model, the team and the running cost, and lets you rename, archive or delete it. Enter sends; Shift+Enter starts a new line. **Get started**, under the composer on the home page, tracks the first steps for your organization: link your subscriptions or a provider key, connect GitHub, install the CLI, invite a teammate and try a first prompt. ## From the CLI ```sh nexus chat "How should we structure our onboarding docs?" # continues the session you used last nexus chat "Where is billing handled?" --new # a new session nexus chat "Shorter, please" --model anthropic/claude-haiku-5-5 nexus chat sessions # your sessions nexus chat sessions show nexus chat sessions rename "Onboarding docs" nexus chat sessions archive # --undo brings it back nexus chat sessions delete ``` The answer streams as it is written. `--team ` attributes the session to a team you are in, `--session ` picks a session, and `--json` prints the stored question and answer. See the [CLI reference](/docs/cli). ## Through the API ```sh # Start a session (model: nexus/auto unless you name one) curl -X POST "$NEXUS_URL/v1/chat/sessions" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' # Send a message: the answer streams as server-sent events curl -N -X POST "$NEXUS_URL/v1/chat/sessions//messages" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{"content": "Where is billing handled?"}' ``` The stream uses OpenAI's `chat.completion.chunk` events. The first carries the session and the stored question, the next ones carry the text, and the last carries `usage`, the cost and the stored answer. `data: [DONE]` ends it. Send `"stream": false` to get the question and answer as JSON once the answer is done. A refusal is answered before any stream starts, with Gateway's error (`403 model_not_allowed`, naming the policy level and rule, or `402 budget_exceeded`); `error.nexus` names the session and the stored message. With an [`Idempotency-Key`](/docs/concepts/idempotency), a message that settled is not run or charged again. The full reference: [Chat sessions](/docs/api/chat). --- # Artifacts: share chats and pages > Share a chat or a page as an artifact with your organization, chosen teams or members, named people outside it, or anyone with the link, within limits your organization sets. Write pages with chat, comment on them and edit them together. Sessions are private. To show one to someone, share it as an artifact: a read-only snapshot with its own link. You choose who can open it: your whole organization, chosen teams, chosen members, named people outside your organization, or anyone with the link. Your organization's settings decide which of these you may use. [Pages](#pages), standalone HTML, Markdown or React files, are shared the same way. A page share can also let members of your organization edit the page with you. ## What an artifact holds A shared chat is a copy of the session at the moment you share it: the messages and their images, the model that wrote each answer, the mode, the title, who shared it and what the answers cost. Messages you send afterwards are not included, and the artifact stays as it was if you rename, change or delete the session. - Sharing again makes a new version (v2, v3…) with its own link. Older versions keep working until you revoke them. - Revoking a version stops it opening for its readers. Owners and admins can also revoke an artifact they can read. - If you let readers continue, a reader can carry the conversation on in a private copy: a new session of their own, starting from the artifact's messages and paid for by their own organization. - A shared chat and its images are kept as long as your organization keeps chat messages, counted from the moment it was shared. - The [audit log](/docs/concepts/audit-log) records sharing, revoking, continuing, access changes, access requests and reports, never the content. For people outside, it records email domains, not addresses. Every shared chat and every one of your sessions downloads as Markdown: YAML front matter (title, link, organization, author, date, models, mode, visibility, audience, version), the conversation with code, tables and math as written, its sources, and the cost of each answer and in total. Images are noted, not included; `nexus artifacts images` saves them. ## Who can open it Inside your organization, an artifact opens for its audience: everyone, chosen teams (with the teams under them) or chosen members. You can always open your own, and owners and admins can open everything shared outside the organization. Anyone else gets a 404, as for an artifact that does not exist. Named people outside open the link signed in to Nexus with the email address you shared it with, once that address is verified. Nexus does not email them, so send them the link yourself. Anyone else who signs in and opens the link can ask you for access, with an optional note. You, an owner or an admin approve or deny the request, or remove someone later. Nexus tells you of new requests in your Inbox in Nexus UI, with one item a day. The person who asked gets an Inbox item when you answer. Anyone with a public link opens it without signing in. Search engines are asked not to list it, and readers can report it as spam, phishing, malware, illegal content or something else. Once it expires or is revoked, the link says it doesn't work. Nexus UI caches a public link's page and drops it when the link is revoked; if that signal fails, the old page can show for up to an hour. Readers outside see the author's name and your organization's name, never the cost, the author's email or team names. They see the images, and can download the chat as Markdown without the cost. If they continue it, the copy is made in their personal organization, which Nexus makes for them if they have none. Your organization never pays for it. ## Your organization's limits Owners and admins set these in Settings › Data, under Sharing outside, with `nexus org settings set `, or with [`PUT /v1/orgs/settings`](/docs/api/organizations#set-org-settings). Everyone in the organization can read them, and every change is in the audit log. They apply to new shares: a link already shared keeps working until it is revoked, unless a page setting below says otherwise. - `artifacts.external` is `public` by default: members may share with named people and with anyone with the link. `named` allows named people only, and `off` keeps every artifact inside. - `artifacts.external.who` is `everyone` by default. `admins` lets only owners and admins share outside. - `artifacts.external.domains` lists the email domains named people may have, as `{"allow": [], "deny": []}`. A domain includes its subdomains, deny wins over allow, and an empty allow list allows any domain. - `artifacts.external.expiry` limits public links, as `{"maxDays": null, "required": false}`. With `maxDays`, no public link stays open longer, and one shared without an expiry gets that maximum. With `required`, every public link needs an expiry. - `artifacts.external.continue` is on by default. When it is off, readers outside cannot continue your chats. - `artifacts.pages` is on by default. When it is off, nobody can write or share pages, and no page shows in its frame. People can still list, delete and read the source of their own. - `artifacts.pages.public` is off by default in a company organization and on in a personal one. When it is off, nobody can share a page by public link, and public page links already shared stop opening. Settings › Data shows all eight settings. An organization can create at most 20 public links an hour. ## Pages A page is a standalone HTML or Markdown file, or one React component in a `.jsx` or `.tsx` file. You publish one with `nexus pages publish` or `POST /v1/pages`. Each later write makes a new version, and versions never change. Restoring an old version writes it again as the newest. A write that names the version it was built on (`--base`) is refused if someone wrote a newer one since. - A version holds at most 16 MiB. A page keeps at most 500 versions, and you can create at most 200 pages a day in an organization. - Gateway refuses a page with a password field, a form that submits somewhere, a meta refresh, an iframe, an object or embed tag, or `eval` of decoded text, and says which. - A page is yours until you share it. Nobody else can list or open it, owners and admins included. - Deleting a page deletes every version, its comments and its stored data, and revokes its shares. Chat writes pages too. Ask it for a page, a site, an app or a dashboard, and it writes one with its `write_page` tool. In a session that has a page, ask for a change, and chat writes the next version. For a small change it uses `edit_page`, which replaces only the parts that change. Chat offers these tools when your message asks for a page, and on every later message in a session that has a page. A question such as "how do I build a website?" gets an ordinary answer. When a page uses something the sandbox blocks, chat is told and writes a fixed version in the same turn. Coding agents write pages with the CLI. `nexus claude` and `nexus codex` tell the agent to publish a page with `nexus pages publish` and to change it with `nexus pages update`. For Claude Code, they also turn off Claude's own artifacts, so its pages stay in your organization. Sharing a page works like sharing a chat, with the same audiences and limits, plus `artifacts.pages.public` for public links. A share shows the latest version, so readers follow along as it changes, or pins one version. It holds no copy of the page, so it lasts as long as the page does, whatever your chat retention. A share with your organization, teams or members can also let them edit the page: see [Editing together](#editing-together). Nobody can continue a shared page or download it as Markdown. A signed-in reader can remix it instead. Remix copies the version on screen into a new page of the reader's own, as version 1, and opens a new chat that holds it. The original page does not change. A page never runs on Nexus's own domains. Gateway checks that the reader may open it, then gives Nexus UI a link that works for five minutes on `nexususercontent.dev`, where each page has its own host and no Nexus cookie exists. Nexus UI shows it in a sandboxed frame. An HTML page there may load scripts from cdnjs.cloudflare.com, cdn.jsdelivr.net, unpkg.com, cdn.tailwindcss.com and code.jquery.com and fonts from Google Fonts, and may fetch only from its own host. It cannot load images from other sites, submit forms, open windows, navigate away or download files. Markdown pages run no scripts. A React page may use Tailwind classes. It may import only react, react-dom, recharts, lucide-react, d3, three, lodash, papaparse, mathjs and chart.js. An HTML or React page that marks its screens as artboards opens as a design canvas that you zoom and pan. Readers outside your organization see "Content is user-generated and unverified." in place of the author. Revoking a page share stops new links at once. A page that is already open stays open, and a link given out just before the revoke keeps loading until its five minutes run out. ### What a page can call An HTML page in Nexus UI or the desktop app can use `window.nexus`, a bridge to the window around it. The page holds no token or cookie. Nexus UI makes each call with the reader's own session. - `window.nexus.complete(prompt)`, or `complete({ messages, maxTokens })`, asks the model and returns the answer's text. Nexus picks the model. The reader pays, and the reader's policies and budgets apply. The first call asks the reader to allow calls from that page, and the browser keeps the answer. A call takes at most 50 messages and 50,000 characters; a prompt string is one message. Its answer has at most 4,096 tokens, and 1,024 by default. - `window.nexus.storage` keeps text values by key, with `get`, `set`, `delete` and `list`. Each page has its own storage, which no other page reads. A value belongs to the reader by default, and nobody else can read it. Pass `{ shared: true }` last for a value that every reader sees and can change. Before a page's first shared write, Nexus UI asks the reader to allow it. A value holds at most 5 MiB, and a page keeps at most 20 MiB in all. - `window.fs.readFile(name)` reads a data file attached in the chat that wrote the page: CSV, TSV, JSON, text, Markdown or XLSX. The page keeps read-only copies of the files its source names, at most 20 files and 50 MiB a version. A remix copies none. A page opened from a public link cannot call the model, keep data or read files. Markdown pages run no scripts, so they have no bridge. ### Comments Anyone who may open a page can comment on it when signed in: its owner, and the readers of its active shares. A public link alone is not enough. - A thread quotes a passage of one version. Paste or type the passage, or select it in Code and choose Quote selection. Readers reply in the thread. - The author of a thread or the page's owner can resolve and reopen it. The author of a comment or the owner can delete it. Deleting a thread's first comment deletes its replies, other readers' replies included. - A reader of a pinned share sees only the threads on that share's version. Readers outside your organization do not see who wrote the other comments. - The owner can choose Ask Nexus on a thread. It opens a new chat that holds the page and sends it the comment. The chat writes the next version, and the thread links to the chat. You pay for that chat as for any other. - A page holds at most 1,000 comments, and a comment at most 4,000 characters. ### Editing together The owner edits a page in Nexus UI under Edit: the page's source, with a live preview below it. A share with Can edit lets others edit it too. Can edit works for your organization, chosen teams or chosen members, never for people outside or a public link. An edit share always follows the latest version. - Everyone who edits works on one shared draft. Edits merge as people type, and each editor's cursor shows their name. - Choose Save, or stop typing for 5 seconds, and the draft becomes the next version. - Editors cannot delete, share or restore the page. Their chat can write it, as the owner's can. - A version written another way, by chat, a restore or the CLI, replaces the draft for everyone. Edits not yet saved are lost. - Revoking the share, or sharing again with Can view, stops an editor at once. Everyone with the page open sees a new version within about a second, unless their share is pinned to a version. ## In Nexus UI In a session, choose **Share** in its header. The menu shows four choices: Only you, Anyone in your organization, Anyone with the link, and Specific people. Specific people shares with chosen teams, chosen members or people outside by email. Picking a choice applies it at once and revokes the earlier versions, so one audience stays open. A choice your organization's settings forbid stays visible as Blocked by policy, with the reason. Share latest makes a new version for the same audience and keeps the older ones. Under More options you can let readers continue, set when a public link expires, and revoke any version. For a share outside, the menu also shows how often it was opened, by whom, who asked for access and how many reports it has, with Approve, Deny and Remove. Shared sessions are marked in the sidebar and on the Sessions page. **Artifacts**, in the sidebar, has four tabs: All, My drafts (your pages), Shared with me (from other organizations too) and Shared by me. A shared chat opens read-only, with Continue in a new chat (when allowed), Copy as Markdown and Download .md. Owners and admins also get Shared outside: everything the organization shared outside it, with opens, readers, requests, reports and expiry, filters, and revoking in bulk. Your pages are under My drafts in **Artifacts**, and pages shared with you are under Shared with me. Your page opens with a version picker, Preview, Code and Edit, Copy and Download of its source, Comments and Share. The page's share menu has the same four choices and Always show the latest version; untick it to pin the version on screen. For your organization, teams or members, it also asks whether they Can view or Can edit. A page shared with you has Remix, Comments, and Edit when you may edit it. While a page shows its latest version, new versions appear as they are written. The phone app lists your pages and the pages shared with you, and opens them. Share or delete a page in Nexus UI or with the CLI. People outside your organization open a link on a plain page of its own. A public link has Report this page. A link shared with named people asks them to sign in, and anyone else to ask for access. When the author allows it, Continue in Nexus copies the chat into a private session of the reader's own after they sign in, with any question they typed in its chat box. ## From the CLI ```sh nexus chat share --team web --allow-continue # or --org, or --people ada@acme.com,lin@acme.com nexus chat share --to ada@partner.com # named people outside, by email nexus chat share --public --expires 30d # anyone with the link; --replace revokes older versions nexus chat share --private # only you again: every version revoked nexus agents share latest --org # this folder's newest Claude Code session (nexus claude) nexus agents share --private # stop sharing it: every version revoked nexus artifacts list # shared with you and by you; --external: everything outside nexus artifacts access --grant lin@partner.com # who has it and who asked; or --deny, --remove nexus artifacts request # ask for access to an artifact shared outside nexus artifacts continue # a new private session from it nexus artifacts export --md --out answer.md nexus artifacts revoke # owners and admins can name several at once nexus pages publish report.html # then update, versions, restore or delete it nexus pages share --public --pin 2 # or --org, --team, --people, --to ``` `nexus agents share` shares a Claude Code session that ran on your machine. It reads the session's transcript from `~/.claude/projects`. Give the session's id, or `latest` for the newest one in the current folder. It takes the same audiences as `nexus chat share`. Sharing it again makes a new version and revokes the earlier ones. The share holds the prompts, the answers, the tool calls with their results, your approvals, images and the cost. It leaves out the agent's thinking unless you add `--include-thinking`, and it leaves out sub-agents. Long tool results are cut short so the session fits in 4 MB. Readers cannot continue a coding session. Common key and token formats are hidden, and your home folder's name becomes `~`. Other secrets in tool output, and anything in an image, are not, so check the session before you share it. Every command takes `--json`. See the [CLI reference](/docs/cli). ## Through the API ```sh # Share a session with anyone with the link for 30 days, revoking its earlier versions curl -X POST "$NEXUS_URL/v1/chat/sessions//share" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{"audience": "public", "expiresIn": "30d", "replace": true}' # Share a page's version 1 with a person outside your organization curl -X POST "$NEXUS_URL/v1/pages//share" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"audience": "external", "people": ["ada@partner.com"], "version": 1}' # Let the web team edit a page with you curl -X POST "$NEXUS_URL/v1/pages//share" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"audience": "teams", "teams": ["web"], "role": "edit"}' ``` `audience` is `org`, `teams`, `people`, `external` (people outside, by email, in `people`) or `public`. `role` is `view` by default, or `edit` for `org`, `teams` and `people`. Someone outside an artifact's audience gets a 404. A signed-in person outside a share with named people gets 403 `artifact_access_required` and may ask for access. Every endpoint is in the API reference, under [Artifacts](/docs/api/artifacts) and [Pages](/docs/api/pages): comments, the shared draft, storage, the event stream and remix are under Pages. ## Not built yet - Nexus does not review reports. A report goes to your organization's owners and admins, who can revoke the link in Shared outside. - Nexus does not tell the people you share with or email you when someone asks for access. Requests show in the share menu and in Shared outside. Send a shared link to its reader yourself. - Teams cannot narrow the organization's settings. - A share outside always includes the chat's images; there is no switch to leave them out. - The CLI cannot comment, remix or share a page with Can edit. Use Nexus UI or the API. - You cannot select text inside a page to comment on it. Paste the passage, or select it in Code. --- # Coding agents > The two routes a Claude Code or Codex run can take, how to choose one, and how models and budget apply. `nexus claude` and `nexus codex` start the real Claude Code and Codex. Nothing else about the agents changes: same terminal, same commands, same arguments. Each run takes one of two routes: | Route | Model calls go | Metered, budgeted, checked against policy | Recorded in Nexus | | --- | --- | --- | --- | | **Your own plan** (the default) | Straight to Anthropic or OpenAI, on your Claude Pro/Max or ChatGPT plan | No | The session, and the usage the agent reports | | **Gateway** | Through Nexus Gateway, on your organization's provider key | Yes | The session, and every call's spend | With nothing saved, a run uses your own plan. See [Choose a route](#choose-a-route) to change that. ## Set up For the Gateway route, follow [Claude Code through Nexus Gateway](/docs/guides/claude-code) or [Codex through Nexus Gateway](/docs/guides/codex). Those pages are generated from each agent's recipe: the limits to read first, the steps, the check, and what Nexus changes for a run. For your own plan, install the agent yourself (Nexus never installs it), [sign in](/docs/authentication) with `nexus auth login` so the session is recorded, and sign the agent in to your plan once: `claude auth login` (not `--console`, which bills the API), or `codex login` with ChatGPT. ## Run ```sh nexus claude # Claude Code, interactive nexus claude -p "hello" --model claude-opus-5-5 # arguments go to Claude Code unchanged nexus codex exec "hello" # Codex likewise nexus claude --team platform # this session's spend goes to the platform team ``` Arguments after Nexus's own flags (`--json`, `--team`) go to the agent unchanged; put them after `--` to pass a flag Nexus would otherwise read, such as `nexus claude -- --help` for Claude Code's own help. The exit code is the agent's. `codex exec` refuses to run outside a git repository or a directory Codex trusts. Run it inside a repository, or add `--skip-git-repo-check`: `nexus codex exec --skip-git-repo-check "hello"`. Nexus prints one line before the agent starts and a short summary after it exits, and nothing in between. The line names the route. With `--json`, one JSON summary on stdout at the end. ## Choose a route ```sh nexus claude --api # this run through Gateway (--subscription for your plan) nexus agents use claude gateway # always, everywhere you sign in to Nexus export NEXUS_CLAUDE_AUTH=gateway # this shell (NEXUS_CODEX_AUTH for Codex) ``` A flag wins over the variable, and the variable over your saved route. `--via gateway` and `--via subscription` work too. **On your own plan**, the agent keeps its own login and calls its provider directly. Gateway never sees those calls, so there is no metering, budget or spend for them (`nexus spend` shows nothing); which model it starts on still follows your [model policies](#models). Nexus still records the session and turns on the agent's own usage report for the run, with prompts redacted, so the session shows the tokens, models and list-price estimate the agent reports. Your plan pays; Nexus charges nothing. **Owners and admins can turn the plan route off** for the organization with `nexus org settings set agentSubscriptions false`, or the Agents on personal plans switch in Nexus UI, under Settings › Policy. Then `--subscription` is refused with `subscriptions_disabled`, and plain `nexus claude` and `nexus codex` go through Gateway instead. ## Antigravity `nexus agy` starts Google's Antigravity (`agy`). It runs only on your own Google AI plan. Its calls go straight to Google, and Nexus records the session. ```sh curl -fsSL https://antigravity.google/cli/install.sh | bash # install agy nexus agy # agy signs in on its first start nexus agy -- --conversation # resume a conversation ``` `--api` is not available: `nexus agy --api` fails with `route_unsupported`. Run `nexus agy --subscription` instead. `--model auto` is not available either; name a model by `agy`'s own id. `nexus agy` does not start while `~/.gemini/antigravity-cli/settings.json` sets `modelProvider`. Remove that key to run on your plan. When your organization turns off agents on personal plans, `nexus agy` does not start. ## Cursor Run Cursor in Nexus Desktop or with the Rust CLI on macOS and Linux. Install the Cursor CLI and run `cursor-agent login` to sign in to your Cursor plan. ```sh nexus cursor-agent nexus cursor-agent -- --resume ``` In Desktop, Cursor starts in Accept edits. Select Plan only to ask Cursor for a plan. Nexus waits for Cursor to confirm the mode before sending your first prompt. Cursor sends model calls directly. Nexus records the session. Usage totals are unavailable. Your organization must allow agents on personal plans. ## Sessions What Nexus changes for a Gateway run is on each agent's page. On either route, each run opens a session, which you can see in Nexus UI with its person, agent, model, duration and status, and closes it with the exit code however the agent ends. ## Models When you don't name a model, Nexus passes the default that a [model policy](/docs/concepts/models-and-policies) sets for the agent (the agent's own, else your team's or your organization's). With no such policy it passes none, and the agent starts on the model it picks for itself: the one its own release and settings choose, which is not necessarily Nexus's default below and can change when you update the agent. `nexus claude --model auto` asks Nexus to choose: the policy default, else Nexus's own (Claude Opus 5.5 for Claude Code, GPT-5.3-Codex for Codex). This choice is a policy lookup on both routes, your own plan included: if no model is allowed for `--model auto`, the run stops before the agent starts. On the Gateway route, every call the agent makes is also checked against your organization's [model policies](/docs/concepts/models-and-policies): the organization's, your team's and the agent's own, where a deny always wins. A refused model never reaches the provider and is answered with `403` `model_not_allowed` in the provider's own error format, so the agent shows it like any provider error. Owners and admins set the agent's rule: ```sh nexus policy set agent/claude --allow "anthropic/claude-opus-*,anthropic/claude-haiku-*" --default anthropic/claude-opus-5.5 nexus policy test --agent claude --model claude-haiku-5-5 # would it be allowed, and by which rule? ``` Claude Code also calls a small Haiku model in the background. A rule that refuses it refuses those calls too; the policy test warns you when a rule would. ## Budget On the Gateway route, every call reserves its maximum cost before it is sent: the request's size as input, plus the most output it may produce. A long session with a large output limit reserves a lot per call, so the organization's budget must cover the largest call its agents make, or the call is refused with `402` in the provider's own error format. See [the ledger](/docs/concepts/ledger). ## Calling the agent gateway yourself The same pass-through is an API: [`POST /v1/anthropic/v1/messages`](/docs/api/agent-gateway#anthropic-messages) and [`POST /v1/openai/v1/responses`](/docs/api/agent-gateway#openai-responses) take the providers' own requests and answer their own responses, streaming included. Authenticate with a Nexus token as `Authorization: Bearer` or `x-api-key`; your Nexus key is never sent to the provider. --- # Claude Code through Nexus Gateway > Set up Claude Code so every model call goes through Nexus Gateway on your organization's key, metered and recorded. > **Status: unclaimed.** A recorded run, claude-code-2026-10-27-1 on 2026-10-27, Claude Code 2.1.312 and nexus 0.14.0+69e1c09, reached a first call in 1m 50s, but no claims register backs this page yet, so it makes no claim about the tool. ## Read this first - This is the Gateway route. Every call goes through Nexus Gateway on your organization's Anthropic key: reserved, metered, checked against your organization's policy and attributed to you. Nexus credit never pays for it. Your own Claude plan is not used. - Plain `nexus claude`, with no route flag, runs on your own Claude plan instead, unless you saved another route. Every command below names `--api`. - Every call reserves the most it could cost before it is sent, and Claude Code asks for its model's full output limit. On a large model one call can reserve more than a small monthly limit has left, and Gateway refuses it with `402` before it runs. Name a smaller model with `--model`, or ask an owner or admin about your limit. ## Set up and run 1. Install the nexus CLI. It needs Node.js 22.6 or later and curl. If the installer says its folder is not on your PATH, add the line it prints to your shell's profile, then open a new terminal. ```sh curl -fsSL https://api.nexus.inc/install.sh | bash ``` 2. Install Claude Code. Nexus never installs it for you. If `claude` is not found afterwards, add `~/.local/bin` to your PATH. ```sh curl -fsSL https://claude.ai/install.sh | bash ``` 3. Sign in to Nexus and approve the code in Nexus UI. The code expires after ten minutes. ```sh nexus auth login ``` 4. **Owner or admin.** If `nexus keys list` shows no Anthropic key, add the organization's key, once. Without a key, Gateway refuses the call with `403`. ```sh nexus keys add anthropic ``` 5. Run one prompt through Gateway, on a small model so even a $1 monthly limit covers the call. ```sh nexus claude --api --model claude-haiku-5-5 -p "Reply with the single word pong" ``` ## Check it worked The call shows in your spend under `agents › claude`, and the session in Nexus UI. ```sh nexus spend ``` ## What Nexus changes for the run For each run with `--api`, Nexus points Claude Code at your Gateway's `/v1/anthropic` with your Nexus sign-in as `ANTHROPIC_AUTH_TOKEN`, and changes no file. It removes `ANTHROPIC_API_KEY`, `CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_VERTEX`, `CLAUDE_CODE_USE_FOUNDRY` from Claude Code's environment, so its calls can only go through Nexus. ## How it is tested - One prompt through Gateway by the steps above, recorded in `nexus spend` | Run | Date | Claude Code | nexus | First call | Steps skipped | Result | | --- | --- | --- | --- | --- | --- | --- | | claude-code-2026-10-26-1 | 2026-10-26 | 2.1.310 | 0.12.0+7d18f42 | 2m 03s | `provider_key` | pass | | claude-code-2026-10-27-1 | 2026-10-27 | 2.1.312 | 0.14.0+69e1c09 | 1m 50s | `provider_key` | pass | Each run is a record in `eng/factory/kit/recipes/runs/`, with its steps' times, the call and what got in the way. --- # Codex through Nexus Gateway > Set up Codex so every model call goes through Nexus Gateway on your organization's key, metered and recorded. > **Status: unclaimed.** A recorded run, codex-2026-10-27-1 on 2026-10-27, Codex 0.165.0 and nexus 0.14.0+69e1c09, reached a first call in 2m 50s, but no claims register backs this page yet, so it makes no claim about the tool. ## Read this first - This is the Gateway route. Every call goes through Nexus Gateway on your organization's OpenAI key: reserved, metered, checked against your organization's policy and attributed to you. Nexus credit never pays for it. Your own ChatGPT plan is not used. - Plain `nexus codex`, with no route flag, runs on your own ChatGPT plan instead, unless you saved another route. Every command below names `--api`. - Every call reserves the most it could cost before it is sent. Codex names no output limit, so a call reserves the model's own. On a large model one call can reserve more than a small monthly limit has left, and Gateway refuses it with `402` before it runs. Name a smaller model with `-m`, or ask an owner or admin about your limit. - Codex refuses to start outside a git repository. Run it from inside one, or add `--skip-git-repo-check` at the end of the command. ## Set up and run 1. Install the nexus CLI. It needs Node.js 22.6 or later and curl. If the installer says its folder is not on your PATH, add the line it prints to your shell's profile, then open a new terminal. ```sh curl -fsSL https://api.nexus.inc/install.sh | bash ``` 2. Install Codex. Nexus never installs it for you. If `codex` is not found afterwards, add npm's global folder, `$(npm prefix -g)/bin`, to your PATH. ```sh npm install -g @openai/codex ``` 3. Sign in to Nexus and approve the code in Nexus UI. The code expires after ten minutes. ```sh nexus auth login ``` 4. **Owner or admin.** If `nexus keys list` shows no OpenAI key, add the organization's key, once. Without a key, Gateway refuses the call with `403`. ```sh nexus keys add openai ``` 5. Run one prompt through Gateway, on a small model so even a $1 monthly limit covers the call. It runs from any folder. ```sh nexus codex --api exec -m gpt-6-luna --skip-git-repo-check "Reply with the single word pong" ``` ## Check it worked The call shows in your spend under `agents › codex`, and the session in Nexus UI. ```sh nexus spend ``` ## What Nexus changes for the run For each run with `--api`, Nexus points Codex at your Gateway's `/v1/openai/v1` with your Nexus sign-in as `NEXUS_API_KEY`, and changes no file. It removes `OPENAI_API_KEY` from Codex's environment, so its calls can only go through Nexus. ## How it is tested - One prompt through Gateway by the steps above, recorded in `nexus spend` | Run | Date | Codex | nexus | First call | Steps skipped | Result | | --- | --- | --- | --- | --- | --- | --- | | codex-2026-10-26-1 | 2026-10-26 | 0.164.0 | 0.12.0+7d18f42 | 1m 02s | `install_cli`, `nexus_login`, `provider_key` | pass | | codex-2026-10-27-1 | 2026-10-27 | 0.165.0 | 0.14.0+69e1c09 | 2m 50s | `provider_key` | pass | Each run is a record in `eng/factory/kit/recipes/runs/`, with its steps' times, the call and what got in the way. --- # MCP server > Give Claude Code, Codex or any MCP agent your spend, budgets, usage, models and teams as tools under your own sign-in, and let an admin manage the organization through them. `nexus mcp` is a local [Model Context Protocol](https://modelcontextprotocol.io) server. An agent starts it and uses Nexus through it as tools. Every tool is one operation of the [API](/docs/api), sent with your CLI sign-in, so the agent sees and does exactly what you may. Most tools read. Owners and admins also get tools that change the organization, and the agent asks you before each change. ## Set up 1. Install the CLI and [sign in](/docs/authentication) with `nexus auth login`. The server uses that sign-in. 2. Add the server to your agent, once: ```sh claude mcp add nexus -- nexus mcp # Claude Code codex mcp add nexus -- nexus mcp # Codex ``` Any other agent takes the same command in its MCP settings: `nexus` with the argument `mcp`, over stdio. 3. Ask the agent something the tools answer, such as "How much of my budget is left this month?". The server signs in as you, in the organization you last chose with `nexus org switch`. To use another organization, switch the CLI first, then restart the agent. ## The tools Each tool has the name, arguments and answer of its API operation, and the same [permission](/docs/concepts/permissions). A tool whose operation takes a JSON request body takes it as the argument `body`. | Tool | What it reads | API | | --- | --- | --- | | `currentTenant` | Your organization, your role and your permissions | [`GET /v1/tenants/me`](/docs/api/core#current-tenant) | | `spend` | Budget, spend and reservations by product, with recent calls | [`GET /v1/spend`](/docs/api/core#spend) | | `listBudgets` | Monthly spend limits: yours, or everyone's for owners and admins | [`GET /v1/budgets`](/docs/api/budgets#list-budgets) | | `getPersonBudget` | One person's limit this month (`me` for yours) | [`GET /v1/people/{userId}/budget`](/docs/api/budgets#get-person-budget) | | `getTeamBudget` | A team's cap, as you may see it | [`GET /v1/teams/{slug}/budget`](/docs/api/teams#get-team-budget) | | `usage` | Usage over a date range, grouped by team, person, model, provider, product or day | [`GET /v1/analytics/usage`](/docs/api/analytics#usage) | | `getAgentAdoption` | Who used coding agents through Nexus, day by day | [`GET /v1/analytics/agents`](/docs/api/analytics#get-agent-adoption) | | `getChatUsage` | Chat sessions in numbers, never their content | [`GET /v1/analytics/chat`](/docs/api/analytics#get-chat-usage) | | `listModels` | The models you may use, with context windows and prices | [`GET /v1/models`](/docs/api/models#list-models) | | `listTeams` | The organization's teams, as a list or a tree | [`GET /v1/teams`](/docs/api/teams#list-teams) | | `getTeam` | A team, its members and its child teams | [`GET /v1/teams/{slug}`](/docs/api/teams#get-team) | | `listAgentSessions` | Coding-agent sessions, newest first | [`GET /v1/agents/sessions`](/docs/api/agents#list-agent-sessions) | | `getAgentSession` | One coding-agent session | [`GET /v1/agents/sessions/{id}`](/docs/api/agents#get-agent-session) | | `modules` | The products and capabilities your Gateway registers | [`GET /v1/modules`](/docs/api/core#modules) | ### Ask your agent The `ask` tool asks your own Nexus agent a question and returns its answer, the model that ran and its cost. It is the one tool that is not an API operation. It answers on a model your policy allows, `nexus/auto` unless the agent names one. `ask` never makes a change. It runs no tool, so it cannot write or confirm a write. When a change is needed, the answer says so, and you confirm the change yourself in Slack or Nexus UI. Gateway records each call from the surface `mcp`. ### Review before a pull request `nexus mcp` also has `review_local`, which needs the machine the server runs on. It reviews the change in your working tree against its merge base with the remote default branch. It uses the repository's own review rules and spends your model budget. It posts nothing, and answers the findings and whether one would fail the check. It reads only folders inside the one `nexus mcp` runs in. It is not marked read-only, so the agent asks you before each call. A run can take several minutes. ### Connectors These tools reach outside systems such as GitHub or Jira through Nexus. Call `describeConnector` first. It lists each operation with its `effect` and the schema of its `body`. Its `usable` field says whether you may use the connector. `readConnector` and `writeConnector` run only connectors your organization made available to you. `readConnector` runs only operations that read, so you may approve it once. `writeConnector` runs a change, and the agent asks you before each call. People cannot make changes through connectors yet, so it refuses them for now. A `readConnector` answer longer than 50,000 characters is cut there, with a note that starts with `answer_cut`. Ask the agent for a page, a limit or a filter where the operation takes one. Each connector answer starts with a `connector_data` note: the text comes from an outside system, so the agent treats it as data, not instructions. | Tool | What it does | API | | --- | --- | --- | | `describeConnector` | One connector's operations, what each changes, and its arguments | [`GET /v1/connectors/{name}`](/docs/api/connectors#describe-connector) | | `readConnector` | Run one operation that only reads | [`POST /v1/connectors/{name}/{operation}/read`](/docs/api/connectors#read-connector) | | `writeConnector` | Run one operation that changes something | [`POST /v1/connectors/{name}/{operation}`](/docs/api/connectors#write-connector) | ### Your notifications Everyone can read their own inbox and clear an item from it. `doneNotification` is a change, so the agent asks you before each call. | Tool | What it does | API | | --- | --- | --- | | `listNotifications` | Your inbox: items not yet done, newest first | [`GET /v1/notifications`](/docs/api/core#list-notifications) | | `doneNotification` | Mark one of your items done, so it leaves the inbox | [`POST /v1/notifications/{id}/done`](/docs/api/core#done-notification) | ### Pages These tools let an agent publish a [page](/docs/guides/artifacts) it wrote, read it back, read the design system it uses and run Check on it. The page is private to your organization's Gateway until you share it, and there is no tool to share a page. `createPage` and `writePageVersion` are changes, so the agent asks you before each call. The rest only read. Nexus for desktop gives them to its Code sessions, which may have no `nexus` command to run `nexus pages publish`. | Tool | What it does | API | | --- | --- | --- | | `createPage` | Publish a new page from HTML or Markdown | [`POST /v1/pages`](/docs/api/pages#create-page) | | `writePageVersion` | Write the next version of one of your pages | [`POST /v1/pages/{id}/versions`](/docs/api/pages#write-page-version) | | `listPages` | Your pages, most recently written first | [`GET /v1/pages`](/docs/api/pages#list-pages) | | `getPage` | One page and its versions: titles and sizes, not content | [`GET /v1/pages/{id}`](/docs/api/pages#get-page) | | `getPageSource` | A version's source as text, to edit and write back (`latest` is the newest) | [`GET /v1/pages/{id}/versions/{version}/source`](/docs/api/pages#get-page-source) | | `listPageComments` | The comments on a page | [`GET /v1/pages/{id}/comments`](/docs/api/pages#list-page-comments) | | `checkPage` | Run Check on a design: colours, sizes and spacing off its tokens, and low contrast | [`POST /v1/pages/{id}/check`](/docs/api/pages#check-page) | | `listDesignSystems` | The organization's design systems, the built-in `@nexus/brand` first | [`GET /v1/design-systems`](/docs/api/design-systems#list-design-systems) | | `getDesignSystem` | One design system: its tokens, notes and components | [`GET /v1/design-systems/{id}`](/docs/api/design-systems#get-design-system) | ### For owners and admins These tools read the whole organization. Most answer owners and admins only, and the billing tools answer the owner only. Anyone else gets Gateway's refusal, or only their own part, as the API answers them. | Tool | What it reads | API | | --- | --- | --- | | `listOrgs` | Your organizations and your role in each | [`GET /v1/orgs`](/docs/api/organizations#list-orgs) | | `getOrgSettings` | The organization's settings, such as how long chats are kept | [`GET /v1/orgs/settings`](/docs/api/organizations#get-org-settings) | | `listOrgDomains` | The organization's verified email domains | [`GET /v1/orgs/domains`](/docs/api/organizations#list-org-domains) | | `listMembers` | Members and their roles, with each person's spend | [`GET /v1/orgs/members`](/docs/api/organizations#list-members) | | `listPendingTeamMembers` | People added to a team by an email that has not joined yet | [`GET /v1/teams/pending`](/docs/api/teams#list-pending-team-members) | | `listAuditEvents` | Who changed what, newest first | [`GET /v1/audit`](/docs/api/audit#list-audit-events) | | `listSpendCalls` | The organization's model calls, newest first, with filters | [`GET /v1/spend/calls`](/docs/api/core#list-spend-calls) | | `getSpendCall` | One model call: what was reserved and charged, or why it was refused | [`GET /v1/spend/calls/{id}`](/docs/api/core#get-spend-call) | | `getOrganizationPolicy` | The organization's model policy | [`GET /v1/policies/organization`](/docs/api/models#get-organization-policy) | | `getTeamPolicy` | A team's model policy and what it inherits | [`GET /v1/policies/teams/{slug}`](/docs/api/models#get-team-policy) | | `getAgentPolicy` | A coding agent's model policy | [`GET /v1/policies/agents/{agent}`](/docs/api/models#get-agent-policy) | | `listOperatorControls` | The pauses, limits and overrides in force | [`GET /v1/policies/controls`](/docs/api/models#list-operator-controls) | | `listWriteGrants` | Which module may write through which connector operation | [`GET /v1/policies/grants`](/docs/api/models#list-write-grants) | | `listProviderKeys` | The organization's own provider keys, last four characters only | [`GET /v1/keys/providers`](/docs/api/core#list-provider-keys) | | `getProviderKey` | One provider key and its versions, never its value | [`GET /v1/keys/providers/{provider}`](/docs/api/core#get-provider-key) | | `listTokens` | Live tokens: yours, or everyone's with `all` | [`GET /v1/auth/tokens`](/docs/api/auth#list-tokens) | | `getBilling` | The payment method and Stripe customer (the owner only) | [`GET /v1/billing`](/docs/api/organizations#get-billing) | | `listBillingStatements` | The stored monthly statements (the owner only) | [`GET /v1/billing/statements`](/docs/api/organizations#list-billing-statements) | | `getBillingStatement` | A month's bill (the owner only) | [`GET /v1/billing/statement`](/docs/api/organizations#get-billing-statement) | | `connectors` | The connectors Gateway offers and their operations | [`GET /v1/connectors`](/docs/api/connectors#connectors) | | `listRepositories` | GitHub installations and linked repositories | [`GET /v1/github/repositories`](/docs/api/github#list-repositories) | | `githubApp` | Whether the GitHub App is set up, and its install link | [`GET /v1/github/app`](/docs/api/github#github-app) | ### Changes, for owners and admins These tools change the organization. Each one is the API call itself, so Gateway checks your permission and records the change in the [audit log](/docs/api/audit#list-audit-events). No change tool is marked read-only, so Claude Code and Codex ask you before each call. Keep that prompt on for these tools. The API's own guards still apply. `inviteMembers` needs `expect`, the count you confirmed, to invite more than one person. `importTeams` applies only the `plan` that its dry run returned. | Tool | What it changes | API | | --- | --- | --- | | `inviteMembers` | Invite people by email, as members or admins | [`POST /v1/orgs/invitations`](/docs/api/organizations#invite-members) | | `setMemberRole` | Make a member an admin, or an admin a member | [`POST /v1/orgs/members/{userId}/role`](/docs/api/organizations#set-member-role) | | `removeMember` | Remove a member and revoke their tokens | [`DELETE /v1/orgs/members/{userId}`](/docs/api/organizations#remove-member) | | `transferOwnership` | Make another member the owner (the owner only) | [`POST /v1/orgs/owner`](/docs/api/organizations#transfer-ownership) | | `setOrgSettings` | The organization's settings, such as how long chats are kept | [`PUT /v1/orgs/settings`](/docs/api/organizations#set-org-settings) | | `addOrgDomain` | Add a verified email domain | [`POST /v1/orgs/domains`](/docs/api/organizations#add-org-domain) | | `removeOrgDomain` | Remove a verified email domain | [`DELETE /v1/orgs/domains/{id}`](/docs/api/organizations#remove-org-domain) | | `setBudget` | The organization's budget | [`POST /v1/orgs/budget`](/docs/api/organizations#set-budget) | | `createTeam` | Create a team, optionally under a parent | [`POST /v1/teams`](/docs/api/teams#create-team) | | `updateTeam` | Rename, relabel or move a team | [`PATCH /v1/teams/{slug}`](/docs/api/teams#update-team) | | `deleteTeam` | Delete a team | [`DELETE /v1/teams/{slug}`](/docs/api/teams#delete-team) | | `addTeamMember` | Add someone to a team, by user id or email | [`POST /v1/teams/{slug}/members`](/docs/api/teams#add-team-member) | | `removeTeamMember` | Take someone off a team | [`DELETE /v1/teams/{slug}/members/{userId}`](/docs/api/teams#remove-team-member) | | `importTeams` | Load teams from a file, after a dry run | [`POST /v1/teams/import`](/docs/api/teams#import-teams) | | `cancelPendingTeamMembers` | Cancel pending team members | [`DELETE /v1/teams/pending`](/docs/api/teams#cancel-pending-team-members) | | `setDefaultTeam` | A person's default team | [`PUT /v1/people/{userId}/default-team`](/docs/api/teams#set-default-team) | | `setTeamBudget` | A team's cap per day, week or month | [`PUT /v1/teams/{slug}/budget`](/docs/api/teams#set-team-budget) | | `setPersonBudget` | One person's monthly limit | [`PUT /v1/people/{userId}/budget`](/docs/api/budgets#set-person-budget) | | `setPersonDefaultBudget` | Everyone's default monthly limit | [`PUT /v1/budgets/person-default`](/docs/api/budgets#set-person-default-budget) | | `setOrganizationPolicy` | The organization's model policy | [`PUT /v1/policies/organization`](/docs/api/models#set-organization-policy) | | `setTeamPolicy` | A team's model policy | [`PUT /v1/policies/teams/{slug}`](/docs/api/models#set-team-policy) | | `setAgentPolicy` | A coding agent's model policy | [`PUT /v1/policies/agents/{agent}`](/docs/api/models#set-agent-policy) | | `setOperatorControl` | Pause, limit or override models for a subject | [`POST /v1/policies/controls`](/docs/api/models#set-operator-control) | | `clearOperatorControl` | End an operator control | [`DELETE /v1/policies/controls/{id}`](/docs/api/models#clear-operator-control) | | `setWriteGrants` | The connector writes a module may make | [`PUT /v1/policies/grants/{product}/{capability}`](/docs/api/models#set-write-grants) | | `testPolicy` | Check whether a person may use a model, and by which rule (changes nothing) | [`POST /v1/policies/test`](/docs/api/models#test-policy) | | `enableProviderKey` | Turn a disabled provider key back on | [`POST /v1/keys/providers/{provider}/enable`](/docs/api/core#enable-provider-key) | | `disableProviderKey` | Stop calls from using a provider key | [`POST /v1/keys/providers/{provider}/disable`](/docs/api/core#disable-provider-key) | | `removeProviderKey` | Remove a provider key | [`POST /v1/keys/providers/{provider}/remove`](/docs/api/core#remove-provider-key) | | `revokeToken` | Revoke a token: yours, or anyone's | [`DELETE /v1/auth/tokens/{id}`](/docs/api/auth#revoke-token) | | `revokeScopedKey` | Revoke a module's scoped key before it expires | [`POST /v1/auth/scoped-keys/revoke`](/docs/api/auth#revoke-scoped-key) | | `unlinkInstallation` | Unlink a GitHub installation | [`DELETE /v1/github/installations/{id}`](/docs/api/github#unlink-installation) | Chats and artifacts are not tools, and no tool reads a page, so a prompt an agent reads cannot ask it to pass them on. When Nexus refuses a call, the agent gets the refusal as a tool error with Gateway's status, code and message, as the API sends it. Adding or replacing a provider key and creating an API key are not tools, because the secret would stay in the agent's transcript. Use `nexus keys add` or `nexus keys replace` for a provider key, and Nexus UI for an API key. ## Not yet Approvals that Nexus enforces on an agent's change, and a remote server that signs in through your browser, are planned. --- # The GitHub App > Connect your repositories to Nexus so agents can read them and post reviews, with a short-lived token scoped to your organization. The **Nexus GitHub App** links your repositories to your organization, so agents can read them as they work and post reviews back as pull request comments. ## Connect your repositories Owners and admins connect repositories through the App: 1. In Nexus UI, open **Settings › Repositories** and choose **Connect repositories on GitHub**. 2. On GitHub, install the App on your GitHub organization or account and pick the repositories. The App asks to read contents and metadata. It also asks to write pull requests, checks and issues, which Nexus uses to post reviews. It receives push, pull request and comment events. 3. GitHub sends you back to Nexus. Gateway checks the installation with GitHub, then links it and its repositories to your organization. ## What happens afterwards - **Changes on GitHub follow.** Adding or removing repositories in the App's settings on GitHub updates the links. - **Private stays private.** Nexus reads a private repository with a short-lived token for that installation only, and only for your organization. - **Unlink at any time.** Removing the installation on GitHub, or unlinking it under **Settings › Repositories**, drops the repositories from your organization. --- # Aider through Nexus Gateway > Point Aider at Nexus Gateway with a Nexus API key, so its model calls are metered and recorded on your organization's key. > **Status: unclaimed.** A recorded run, aider-2026-10-28-1 on 2026-10-28, Aider 0.86.2 and nexus 0.14.0+69e1c09, reached a first call in 5m 47s, but no claims register backs this page yet, so it makes no claim about the tool. ## Read this first - Nexus has no launcher for Aider. You set two variables in your terminal, and Aider sends its calls to Gateway's OpenAI compatible API, `/v1/chat/completions`, with a Nexus API key: reserved, metered, checked against your organization's policy and attributed to you. - Gateway cannot tell Aider's calls from any other call on that key. `nexus spend` lists them under Nexus Gateway, direct API calls (`core`), not under `agents`, and no agent session groups them. - These calls run on a provider key your person, team or organization stored. Nexus credit never pays for them: without a key, Gateway refuses the call with `403`. - Aider writes the model as `openai/` followed by Gateway's model id, so `openai/gpt-6-luna` becomes `openai/openai/gpt-6-luna`. `nexus models` lists the ids you may use. A call that names no output limit reserves the model's own, so name a small model. - The API key works until you revoke it in Nexus UI, and anyone holding it spends as you. Keep it out of files and shell history. ## Set up and run 1. Install the nexus CLI. It needs Node.js 22.6 or later and curl. If the installer says its folder is not on your PATH, add the line it prints to your shell's profile, then open a new terminal. ```sh curl -fsSL https://api.nexus.inc/install.sh | bash ``` 2. Sign in to Nexus and approve the code in Nexus UI. The code expires after ten minutes. ```sh nexus auth login ``` 3. In Nexus UI, open Settings, then Keys, and create a key named `aider`. It is shown once: copy it. 4. Install Aider with its own installer. Nexus never installs it for you. If `aider` is not found afterwards, open a new terminal. ```sh curl -LsSf https://aider.chat/install.sh | sh ``` 5. **Owner or admin.** If `nexus keys list` shows no OpenAI key, add the organization's key, once. ```sh nexus keys add openai ``` 6. Point Aider at Gateway for this terminal only. After the second line, paste the API key and press Enter: nothing shows, and the key stays out of your shell history. ```sh export OPENAI_API_BASE=https://api.nexus.inc/v1 read -rs OPENAI_API_KEY && export OPENAI_API_KEY ``` 7. Run one prompt through Gateway on a small model. It runs from any folder. ```sh aider --model openai/openai/gpt-6-luna --no-git --yes-always --message "Reply with the single word pong" ``` ## Check it worked The call shows in your spend under Nexus Gateway, direct API calls, and first in its recent calls. ```sh nexus spend ``` ## What Nexus changes for the run Nexus changes nothing on your computer. You set `OPENAI_API_BASE` to your Gateway's `/v1` and `OPENAI_API_KEY` to your Nexus API key, in one terminal only, and Aider sends its calls there. To go back, close that terminal or run `unset OPENAI_API_BASE OPENAI_API_KEY`, and revoke the key in Nexus UI when you no longer use it. ## How it is tested - One prompt through Gateway's `/v1/chat/completions` by the steps above, recorded in `nexus spend` under direct API calls | Run | Date | Aider | nexus | First call | Steps skipped | Result | | --- | --- | --- | --- | --- | --- | --- | | aider-2026-10-28-1 | 2026-10-28 | 0.86.2 | 0.14.0+69e1c09 | 5m 47s | `provider_key` | pass | Each run is a record in `eng/factory/kit/recipes/runs/`, with its steps' times, the call and what got in the way. --- # Cline through Nexus Gateway > Run Cline's command line through Nexus Gateway on a folder of its own and a Nexus API key, so its model calls are metered and recorded on your organization's key. > **Status: unclaimed.** A recorded run, cline-2026-10-28-1 on 2026-10-28, Cline 3.0.74 and nexus 0.14.0+69e1c09, reached a first call in 3m 17s, but no claims register backs this page yet, so it makes no claim about the tool. ## Read this first - Nexus has no launcher for Cline. It writes a folder of its own, and Cline's command line, run on that folder, sends its calls to Gateway's OpenAI compatible API, `/v1/chat/completions`, with a Nexus API key: reserved, metered, checked against your organization's policy and attributed to you. Your own Cline settings in `~/.cline` are not read or changed. - Run it from a terminal, as the page does. When its input is not a terminal (a pipe or a file), Cline adds that input to the prompt and sends it to the model. - Gateway cannot tell Cline's calls from any other call on that key. `nexus spend` lists them under Nexus Gateway, direct API calls (`core`), not under `agents`, and no agent session groups them. - These calls run on a provider key your person, team or organization stored. Nexus credit never pays for them: without a key, Gateway refuses the call with `403`. - Run it as the page does, without `-y`. With `-y`, Cline keeps sending calls until the model calls its finish tool, and a short answer never does: it spends until you stop it. - If Cline cannot read the folder's file, it falls back to OpenAI's own API and sends the key there, which refuses it. Write the file again with the step below. - Cline's editor extensions are not covered: pointed at a new folder, the VS Code extension copies the keys it already stores into it, so this page does not use them. - The API key works until you revoke it in Nexus UI, and anyone holding it spends as you. Keep it out of files and shell history. ## Set up and run 1. Install the nexus CLI. It needs Node.js 22.6 or later and curl. If the installer says its folder is not on your PATH, add the line it prints to your shell's profile, then open a new terminal. ```sh curl -fsSL https://api.nexus.inc/install.sh | bash ``` 2. Sign in to Nexus and approve the code in Nexus UI. The code expires after ten minutes. ```sh nexus auth login ``` 3. In Nexus UI, open Settings, then Keys, and create a key named `cline`. It is shown once: copy it. 4. Install Cline's command line. Nexus never installs it for you. If `cline` is not found afterwards, add npm's global folder, `$(npm prefix -g)/bin`, to your PATH. ```sh npm i -g cline ``` 5. **Owner or admin.** If `nexus keys list` shows no OpenAI key, add the organization's key, once. ```sh nexus keys add openai ``` 6. Write Nexus's folder for Cline. Its one file holds your Gateway's URL and the model, not the key. If the folder is already there, it is moved aside first, and nothing is written if that fails. ```sh { [ ! -e ~/.cline-nexus ] || mv ~/.cline-nexus ~/.cline-nexus.nexus-backup-$(date -u +%Y%m%dT%H%M%SZ); } && mkdir -p ~/.cline-nexus/data/settings && cat > ~/.cline-nexus/data/settings/providers.json <<'EOF' { "version": 1, "lastUsedProvider": "openai-compatible", "modes": {}, "providers": { "openai-compatible": { "settings": { "provider": "openai-compatible", "baseUrl": "https://api.nexus.inc/v1", "model": "openai/gpt-6-luna" }, "updatedAt": "2026-10-28T00:00:00.000Z", "tokenSource": "manual" } } } EOF ``` 7. Give this terminal the key. After you run the line, paste the API key and press Enter: nothing shows, and the key stays out of your shell history. ```sh read -rs NEXUS_API_KEY && export NEXUS_API_KEY ``` 8. Run one prompt through Gateway on the folder's small model. Cline gets the folder and the key for this command only. It runs from any folder. ```sh CLINE_DIR=~/.cline-nexus OPENAI_API_KEY="$NEXUS_API_KEY" cline --data-dir ~/.cline-nexus/data -P openai-compatible "Reply with the single word pong" ``` ## Check it worked The call shows in your spend under Nexus Gateway, direct API calls, and first in its recent calls. ```sh nexus spend ``` ## What Nexus changes for the run Nexus writes one folder of its own, `~/.cline-nexus`, and changes no file of yours: Cline runs on that folder only when you pass it, and keeps its state for those runs there. Its `data/settings/providers.json` holds your Gateway's URL and the model, never the key: the run step hands it to Cline from `NEXUS_API_KEY`, for that command only. If the folder was already there, step 6 first moves it to `~/.cline-nexus.nexus-backup-` and the time. To go back, delete the folder, or move that copy back in its place, and revoke the key in Nexus UI when you no longer use it. On a computer without the folder, the write is this diff: ```diff --- /dev/null +++ ~/.cline-nexus/data/settings/providers.json @@ -0,0 +1,16 @@ +{ + "version": 1, + "lastUsedProvider": "openai-compatible", + "modes": {}, + "providers": { + "openai-compatible": { + "settings": { + "provider": "openai-compatible", + "baseUrl": "https://api.nexus.inc/v1", + "model": "openai/gpt-6-luna" + }, + "updatedAt": "2026-10-28T00:00:00.000Z", + "tokenSource": "manual" + } + } +} ``` ## How it is tested - One prompt through Gateway's `/v1/chat/completions` by Cline's command line and the steps above, recorded in `nexus spend` under direct API calls | Run | Date | Cline | nexus | First call | Steps skipped | Result | | --- | --- | --- | --- | --- | --- | --- | | cline-2026-10-28-1 | 2026-10-28 | 3.0.74 | 0.14.0+69e1c09 | 3m 17s | `provider_key` | pass | Each run is a record in `eng/factory/kit/recipes/runs/`, with its steps' times, the call and what got in the way. --- # Continue through Nexus Gateway > Point Continue at Nexus Gateway with a file of its own and a Nexus API key, so its model calls are metered and recorded on your organization's key. > **Status: unclaimed.** A recorded run, continue-2026-10-28-1 on 2026-10-28, Continue 1.5.47 and nexus 0.14.0+69e1c09, reached a first call in 2m 59s, but no claims register backs this page yet, so it makes no claim about the tool. ## Read this first - Nexus has no launcher for Continue. It writes one model file of its own, and Continue sends that model's calls to Gateway's OpenAI compatible API, `/v1/chat/completions`, with a Nexus API key: reserved, metered, checked against your organization's policy and attributed to you. - Gateway cannot tell Continue's calls from any other call on that key. `nexus spend` lists them under Nexus Gateway, direct API calls (`core`), not under `agents`, and no agent session groups them. - These calls run on a provider key your person, team or organization stored. Nexus credit never pays for them: without a key, Gateway refuses the call with `403`. - The run below uses Continue's command line, `cn`, which reads the file when you pass it. Continue's editor extension reads the same folder on its own, but it reads `NEXUS_API_KEY` from its own environment or from `~/.continue/.env`, and no run has shown it yet. - The API key works until you revoke it in Nexus UI, and anyone holding it spends as you. Keep it out of files and shell history. ## Set up and run 1. Install the nexus CLI. It needs Node.js 22.6 or later and curl. If the installer says its folder is not on your PATH, add the line it prints to your shell's profile, then open a new terminal. ```sh curl -fsSL https://api.nexus.inc/install.sh | bash ``` 2. Sign in to Nexus and approve the code in Nexus UI. The code expires after ten minutes. ```sh nexus auth login ``` 3. In Nexus UI, open Settings, then Keys, and create a key named `continue`. It is shown once: copy it. 4. Install Continue's command line. Nexus never installs it for you. If `cn` is not found afterwards, add npm's global folder, `$(npm prefix -g)/bin`, to your PATH. ```sh npm i -g @continuedev/cli ``` 5. **Owner or admin.** If `nexus keys list` shows no OpenAI key, add the organization's key, once. ```sh nexus keys add openai ``` 6. Write Nexus's model file. It holds your Gateway's URL and the name of the variable with the key, not the key. If the file is already there and differs, the last line keeps a copy first, and stops if it cannot. ```sh mkdir -p ~/.continue/models && cat > ~/.continue/models/nexus.yaml.nexus-new <<'EOF' name: Nexus Gateway version: 1.0.0 schema: v1 models: - name: Nexus Gateway gpt-6-luna provider: openai model: openai/gpt-6-luna apiBase: https://api.nexus.inc/v1 apiKey: ${{ secrets.NEXUS_API_KEY }} roles: - chat - edit - apply EOF { [ ! -e ~/.continue/models/nexus.yaml ] || cmp -s ~/.continue/models/nexus.yaml ~/.continue/models/nexus.yaml.nexus-new || cp ~/.continue/models/nexus.yaml ~/.continue/models/nexus.yaml.nexus-backup-$(date -u +%Y%m%dT%H%M%SZ); } && mv ~/.continue/models/nexus.yaml.nexus-new ~/.continue/models/nexus.yaml ``` 7. Give this terminal the key. After you run the line, paste the API key and press Enter: nothing shows, and the key stays out of your shell history. ```sh read -rs NEXUS_API_KEY && export NEXUS_API_KEY ``` 8. Run one prompt through Gateway on the file's small model. It runs from any folder. ```sh cn --config ~/.continue/models/nexus.yaml -p "Reply with the single word pong" ``` ## Check it worked The call shows in your spend under Nexus Gateway, direct API calls, and first in its recent calls. ```sh nexus spend ``` ## What Nexus changes for the run Nexus writes one file of its own, `~/.continue/models/nexus.yaml`, and changes no file of yours: Continue reads it beside your own settings, or alone when you pass it. The file holds your Gateway's URL and names `NEXUS_API_KEY`, never the key itself. If the file was already there and differs, step 6 copies it first to `~/.continue/models/nexus.yaml.nexus-backup-` and the time, and writes nothing if it cannot. To go back, delete the file, or move that copy back over it, and revoke the key in Nexus UI when you no longer use it. On a computer without the file, the write is this diff: ```diff --- /dev/null +++ ~/.continue/models/nexus.yaml @@ -0,0 +1,13 @@ +name: Nexus Gateway +version: 1.0.0 +schema: v1 +models: + - name: Nexus Gateway gpt-6-luna + provider: openai + model: openai/gpt-6-luna + apiBase: https://api.nexus.inc/v1 + apiKey: ${{ secrets.NEXUS_API_KEY }} + roles: + - chat + - edit + - apply ``` ## How it is tested - One prompt through Gateway's `/v1/chat/completions` by Continue's command line and the steps above, recorded in `nexus spend` under direct API calls | Run | Date | Continue | nexus | First call | Steps skipped | Result | | --- | --- | --- | --- | --- | --- | --- | | continue-2026-10-28-1 | 2026-10-28 | 1.5.47 | 0.14.0+69e1c09 | 2m 59s | `provider_key` | pass | Each run is a record in `eng/factory/kit/recipes/runs/`, with its steps' times, the call and what got in the way. --- # Search > Press ⌘K (Ctrl+K) anywhere in Nexus UI to find your chats, people, teams and models, or to jump to any page or action. Press **⌘K** on a Mac, **Ctrl+K** elsewhere, or the search icon at the top of the sidebar, and type. The same search is in the CLI (`nexus search`) and the API ([`GET /v1/search`](/docs/api/core#search)). ## What it finds | Group | What matches | Who sees it | | --- | --- | --- | | Actions | New session, Invite member, Create team, Set spend limit, Add provider key, Create API key, Link a repository, Set model policy, Toggle sidebar, Switch account | The ones your role may do | | Go to | Every page of Nexus UI, and each product | The ones your role may open | | Settings | Every setting, by name | The ones your role may open | | Sessions | Your own sessions, by title and by what was said in them | Only you: nobody else's chats, owners and admins included | | Artifacts | Chats shared with you, or by you | Their audience; a revoked one only its author | | People | Members by name, email, role and team; people added to a team who have not joined yet | Everyone; not-joined people for owners and admins | | Teams | By name, slug and full path (`Engineering / Platform`) | Everyone | | Models | The models you may use (and coming-soon ones), and your organization's model policies | Everyone | Docs and the audit log are not searched. Results appear at once from what the page already knows (your recent sessions, teams, members and models), then Gateway's full answer replaces them a moment after you stop typing. A match inside a chat message shows that part of the message, highlighted; opening it scrolls the session to the message. ## Narrowing and keys | Type | To | | --- | --- | | `>` | Actions only | | `@` | People and teams only | | `/` | Pages and settings only | | ↑ ↓ | Move | | Enter | Open | | Tab, Shift+Tab | Next or previous group | | Esc | Close | Words match as prefixes, in any order: `depl fly` finds "How do we deploy to Fly?". With nothing typed, the palette shows a few pages, your latest sessions and a few actions. ## From the CLI and the API ```sh nexus search "deploy checklist" # every group nexus search ada --type people # one type (or several: --type chats,teams) nexus search fly --type chats --json # groups, scores, match ranges and Nexus UI links ``` `GET /v1/search?q=…&types=…&limit=…` answers the groups best first, each result with its `title`, `subtitle`, a highlighted `snippet` where it matched outside the title, its Nexus UI `url` and a `score` from 0 to 1. Match ranges are offsets in UTF-16 code units, the way JavaScript slices strings. --- # Organizations and roles > An organization holds your people, keys, budget, teams and usage; each person has one role in it. An **organization** is where everything in Nexus lives: its members, its provider keys, its budget and spend, its teams, its linked repositories and its audit log. Nothing is shared between organizations, and a person can belong to several, signing in to one at a time. Every person also has a **personal organization**. They are its owner and its only member. It takes no invitations and no other members. To work with others, create a company organization. ## Roles Each member has exactly one role in an organization. | Role | Can | | --- | --- | | Owner | Everything an admin can, plus transferring ownership, billing (the card, credits and invoices), setting the default spend limit per person and allowing admins to set each person's limit. There is exactly one owner. | | Admin | Manage members (invite, change roles, remove, recover), teams, repositories, provider keys, service accounts, the budget and model policies; see everyone's spend and tokens; set each person's spend limit, except an owner's, when an owner allows it | | Member | Use the products and coding agents; see their own spend, sessions and tokens, and their teams' | A **team lead** is a member who leads at least one team. In the teams they lead and the teams under them, a lead reads and exports the audit events and narrows the model policy. A lead also pauses or limits model traffic there, and decides skill promotion requests. The full list of what each role may do is the [permissions matrix](/docs/concepts/permissions). ## Members ```sh nexus members # everyone, by role nexus members remove ada@example.com nexus members removed # who can still be recovered, and until when nexus members recover usr_123 ``` Owners and admins change a member's role with [`POST /v1/orgs/members/{userId}/role`](/docs/api/organizations#set-member-role) and remove a member with [`DELETE /v1/orgs/members/{userId}`](/docs/api/organizations#remove-member). Removing someone revokes their tokens and keys at once. An owner or admin can recover them for 30 days: their role, teams, default team and spend limit come back, but their tokens and keys do not. The owner's role changes only by [transferring ownership](/docs/api/organizations#transfer-ownership), so the owner must transfer it before they can be removed. A person can delete their own account with `nexus auth delete-account`, from a sign-in and not an API key. This removes them from every organization and closes their personal organization. It is refused while they own a company organization. ## Inviting people Invitations are always explicit: adding someone to a team by email, or importing a file of teams, never sends an email by itself. ```sh nexus members invite new-hire@example.com # one email nexus members invite --pending --dry-run # who would be invited: everyone placed in a team who hasn't joined nexus members invite --pending --yes # send them; more than one email needs --yes ``` The API is [`POST /v1/orgs/invitations`](/docs/api/organizations#invite-members). To send more than one invitation it needs `expect`, the number you confirmed; if the number to send has changed since, it answers `409` `count_changed` and sends nothing. `dryRun: true` reports who would be invited. When an invited person signs in and joins, every team they were placed in by email becomes a membership, and their home team becomes their default. ## Budget Each organization has a budget in US dollars, a cap per UTC day, ISO week or calendar month. Every model call reserves its maximum cost first, and a call that doesn't fit in what is left is refused, so the budget is never overspent (see [the ledger](/docs/concepts/ledger)). Owners and admins set it with `nexus budget set org 2000/month` or [`POST /v1/orgs/budget`](/docs/api/organizations#set-budget). A monthly [spend limit per person](/docs/concepts/spend-limits) is built: owners set the default and each person's limit, and admins an owner allows set each person's limit. A team can have its own cap too, which counts the team and every team under it (`nexus budget set team/platform 500/month`). --- # Teams > Teams nest to describe your organization; levels are your own labels; a file loads the whole tree. Teams sit between the organization and the person. Use them to see who spends what, at every level of your organization. ## Teams nest A team can have a **parent** team, so you can describe your whole structure: for example a department, the teams in it, and the squads in those. Up to 10 levels deep, and never a cycle. ```sh nexus team create engineering --level department nexus team create platform --parent engineering --level team --name "Platform" nexus team move platform --parent engineering # or --root for the top level nexus team tree --depth 2 # levels, leads and headcount ``` A team has a slug (unique in your organization, up to 127 characters), a name and an optional description. Moving a team moves everything under it, and its spend stays attributed to it. Deleting a team that has child teams needs `--cascade` (API: `?cascade=1`), which deletes the whole subtree; spend always keeps the team it was attributed to. ## Levels are yours A team's **level** is a free-text label your organization chooses, such as `department`, `team` or `squad` (1 to 32 lower-case letters, digits or dashes). Nexus gives levels no meaning; they help you read the tree. ## Leads, members and home teams Owners and admins add people to teams as `member` or `lead`. A person can be in several teams and has at most one **default team** per organization, their **home team**: the first team they join becomes it, and they can choose another among their teams. ```sh nexus team add platform ada@example.com --lead nexus team use platform # your own default team ``` **Pending members.** Adding an email that isn't in the organization yet stores a pending membership (`202`, `pending: true`), optionally with `--home`. When that person joins, the pending entry becomes a membership. Nothing is emailed: invite them with `nexus members invite --pending` ([Organizations and roles](/docs/concepts/organizations-and-roles#inviting-people)). ## Import your structure from a file Owners and admins load teams, leads and members from a YAML or JSON file, in one transaction. ```yaml units: - slug: engineering name: Engineering level: department leads: - email: lead@example.com - slug: platform level: team parent: engineering # absent or null: a top-level team members: - email: dev@example.com home: true # their default team - email: new-hire@example.com # not in the organization yet: pending ``` Teams are matched by slug: missing ones are created, existing ones moved, renamed and relabelled to match. The same file twice changes nothing the second time. **Review first, then apply exactly what you reviewed.** A dry run changes nothing and returns the diff it would apply and a **plan**, a hash of that diff. Applying with that plan succeeds only if the result is still exactly the plan; if anything changed in between, Gateway answers `409` `plan_changed` and applies nothing. ```sh nexus team import teams.yaml --dry-run # the diff, and a plan nexus team import teams.yaml --plan 3f9c0a1b2c3d4e5f ``` `--prune` (API: `prune: true`) also removes the memberships, pending entries and teams the file doesn't list (never spend); applying it needs `--plan` or `--yes`. `--invite` invites the file's people who haven't joined, after the import. The API is [`POST /v1/teams/import`](/docs/api/teams#import-teams). ## Who can do what | Who | Can | | --- | --- | | Owners and admins | Create, rename, move and delete teams; add and remove members; import; set anyone's default team; set team caps | | Team leads | In the teams they lead and those under them: narrow the model policy, pause or limit model traffic, read the audit events | | Everyone | See the organization's teams and members; set their own default team among their teams | ## Model policies and budgets Each team can have its own [model policy](/docs/concepts/models-and-policies): it narrows what the organization and the teams above it allow, and a deny anywhere on the path wins. Each team can also have a spend cap per day, week or month. A cap counts the team and every team under it. A call must fit in every cap on the path from the top team down to its own team, else it is refused with `402`. A moved team keeps its past spend under its old parent. ```sh nexus budget set team/platform 500/month nexus budget show team/platform ``` A member of the team sees only what is left for them, never the cap of a team above theirs. Each person can also have a monthly [spend limit](/docs/concepts/spend-limits). --- # Models and policies > One catalog of models, and allow and deny lists per organization, team and coding agent; a deny always wins. Every model in Nexus has one name, and every model call is checked against your organization's policies before it reaches a provider. Owners and admins decide which models people may use; everyone can see what they may use and test a rule before relying on it. ## The catalog Each model is named one way: `provider/model`, such as `anthropic/claude-opus-5.5` or `openai/gpt-5.3-codex`. Nexus reads every other spelling of the same model (the provider's own, like `claude-opus-5-5`, dots or dashes, a dated snapshot) as that one name, so a rule written once matches every way a client may ask. A model is either: - **Supported**: Nexus calls its provider directly, prices and meters it. Today: Anthropic's Claude models, OpenAI's GPT-6 and GPT-5.3-Codex, and open-weight models that Baseten hosts, such as `zai/glm-5.3` and `openai/gpt-oss-120b`. Each runs on the APIs its provider serves it on. - **Coming soon**: listed to show what is planned, and not callable yet. ```sh nexus models # the models you may use nexus models --all # the whole catalog: supported and coming soon, prices, and whether you may use each ``` The API is [`GET /v1/models`](/docs/api/models#list-models), an OpenAI-compatible list of the models you may use; `?status=all` gives the whole catalog with each model's status, price and whether it is allowed for you. Nexus UI's **Models** page shows the same. ## Rules: allow and deny A policy rule has an **allow** list and a **deny** list of patterns, and optional defaults: ```yaml allow: - anthropic/* # a provider deny: - anthropic/claude-fable-* # a family defaults: chat: anthropic/claude-sonnet-5.5 claude: anthropic/claude-opus-5.5 ``` A pattern is an exact model (any spelling), a provider (`anthropic/*`), a family (`openai/gpt-6-*`) or `*`. - **No allow list means every supported model** is allowed. - **A deny always wins**, at any level, over any allow. Only an [override](#pause-limit-and-override) allows a denied model. - A rule may name a model that is coming soon: it is accepted with a note and takes effect once the model is supported. ## Levels intersect Rules apply at several levels, widest first: 1. the **organization**; 2. each **team** on the path from the top of your team tree down to the team the call is attributed to; 3. the **coding agent** (`claude` for Claude Code, `codex` for Codex), for their calls. Every allow list on the way must match, and any deny on the way refuses. So a lower level can only narrow what the levels above allow: a team that allows more than its organization gains nothing. Rules are per organization, team and agent; there are no rules for individual people. ```sh nexus policy set org --deny "anthropic/claude-fable-*" nexus policy set team/platform --allow "anthropic/*" --default anthropic/claude-haiku-5.5 nexus policy set agent/claude --from rule.yaml nexus policy show team/platform # its rule, what it inherits, and what it allows ``` `--allow all` and `--deny none` clear a list; `--clear` removes a level's rule. The API is [`GET` and `PUT /v1/policies/organization`](/docs/api/models#set-organization-policy), [`/v1/policies/teams/{slug}`](/docs/api/models#set-team-policy) and [`/v1/policies/agents/{agent}`](/docs/api/models#set-agent-policy); a `PUT` replaces the level's rule, and an empty rule removes it. Owners and admins set policies. A team lead sets the policy of a team they lead, or one under it, only to narrow it (else `403` `policy_widens`). Everyone reads them. Every change is in the [audit log](/docs/concepts/audit-log) as `policy.changed`, with the rule before and after. ## `nexus/auto` and `nexus/default` Ask for `nexus/auto` in a chat call, and Auto Router picks the model. It sorts the request as light, standard or heavy, and sends it to the lowest-priced model for that class that your organization allows. The `x-nexus-router` header names the Auto version that picked. See the [Auto Router changelog](/auto-router/changelog). If Auto cannot pick, and for Claude Code and Codex, `nexus/auto` runs the same model as `nexus/default`: the default named by the most specific level for that API (chat, Claude Code or Codex), else Nexus's own default. Neither ever runs a refused model: if the default is denied, the first allowed supported model runs, and the answer says so. Every answer names the model that ran: the `model` field of the response, and the `x-nexus-model` header. ```sh nexus chat "Summarize our refund policy in three bullets" # nexus/auto nexus chat "hello" --model anthropic/claude-haiku-5.5 --team platform nexus claude --model auto # Claude Code on the model Nexus resolves ``` ## Pause, limit and override An **operator control** acts on the organization, a team, a person or a key until it expires. A **pause** refuses every model call. A **limit** narrows to the models it lists. An **override** allows the models it lists over the rules, but never over a pause or a limit. ```sh nexus policy pause person/usr_123 --reason "runaway script" --expires 12h nexus policy limit team/platform --models anthropic/claude-haiku-5.5 --reason "cost review" --expires 30d nexus policy controls # the controls in force that apply to you nexus policy clear ``` Owners and admins set every control. A team lead pauses or limits a team they lead, and the people and keys in it, with `--team`. Only owners and admins override. Every change is in the audit log as `policy.control_set` or `policy.control_cleared`. The API is `/v1/policies/controls`. ## Test a rule The policy test makes the same decision as a real call, without making one, and says which rule decided: ```sh nexus policy test --agent claude --model claude-haiku-5-5 nexus policy test --as ada@example.com --team platform --model openai/gpt-6-astra ``` It exits `1` when the model would be refused. The answer lists the models allowed in that situation, and warns when a rule would break a coding agent: Claude Code also calls a small Haiku model in the background, and a rule that denies it refuses those calls like any other. Testing as someone else needs owner or admin. The API is [`POST /v1/policies/test`](/docs/api/models#test-policy). ## When a model is refused A refused call never reaches the provider and costs nothing. It is answered in the provider's own error format, so SDKs and coding agents show it the way they show the provider's errors, and the message names the level and the rule: | Status | Code | When | | --- | --- | --- | | `403` | `model_not_allowed` | A policy refuses the model | | `403` | `operator_paused` | An operator control pauses the caller's model calls | | `404` | `model_not_found` | The catalog has no such model | | `400` | `model_not_supported` | The model is coming soon, or not served on that API | On chat completions and the OpenAI pass-through: ```json { "error": { "message": "model anthropic/claude-fable-5.1 is not allowed: it matches \"anthropic/claude-fable-*\" on the deny list of the organization's policy", "type": "permission_error", "code": "model_not_allowed", "param": "model" } } ``` On the Anthropic pass-through, the same message in Anthropic's shape: `{"type": "error", "error": {"type": "permission_error", "message": "…"}}`. A refusal appears in your spend's list of calls as refused, with no cost. ## Coming Rules on individual API keys and service accounts are coming. Until then, an operator control can pause or limit one key. --- # Attribution > Every model call is attributed to a person, a team, a product and, for coding agents, a session. Every model call through Nexus carries who made it and what it was for, so spend can be read by person, team, model or product. | Recorded | From | | --- | --- | | Person | The token that made the call, or the person who started the product run | | Team | The team named on the call, else the person's default team, else none ("Unassigned") | | Product and capability | The product that made the call (for example `robustness › review`), `chat` for chats, `agents › claude` or `agents › codex` for coding agents, or `core` for direct API calls. A cloud machine's running time is `cloud › compute` | | Session | For `nexus claude` and `nexus codex`, the session the call belongs to | ## Choosing the team The team is, in order: 1. the one the caller names: the `x-nexus-team` header, or a `team` field in the request. The caller must be in that team (else `403` `not_in_team`); an unknown team is `404`. 2. else the caller's default team; 3. else none, shown as "Unassigned". From the CLI, `--team ` or `NEXUS_TEAM` names the team for product runs and coding-agent sessions: ```sh NEXUS_TEAM=platform nexus claude ``` Each spend record keeps the team's id and its slug at the time, so a renamed or deleted team's history still reads. ## Reading it back ```sh nexus spend # budget and spend by product and capability nexus analytics --by team --days 7 # usage by team, person, model, product or day nexus analytics --by team --depth 1 # each top-level team with everything under it nexus analytics --by team --under engineering ``` By team, spend rolls up the tree: each group counts its own spend and that of every team under it, and spend on a parent team itself appears as its own "(direct)" row. The API is [`GET /v1/analytics/usage`](/docs/api/analytics#usage). Owners and admins see the whole organization. Everyone else sees their own calls and those of the teams they are in and every team under those; grouped by person, other people in those teams appear as one "Others in your teams" row. --- # The ledger > Every model call reserves its maximum cost first and settles on what it actually used, so a budget is never overspent. Nexus Gateway keeps one ledger per organization. Every model call, whether made by a product, a coding agent or your own code, goes through it in two steps. ## Reserve, then settle 1. **Reserve.** Before the call reaches a provider, Gateway reserves its maximum possible cost: the request's size counted as input tokens, plus the most output it may produce (`max_tokens`). If the reservation doesn't fit in what is left of the organization's budget, a cap on the call's team, the person's [spend limit](/docs/concepts/spend-limits) or a product's cap, the call is refused with `402` and nothing is sent to the provider. 2. **Settle.** When the provider answers, Gateway charges what the call actually used, as the provider reported it, and releases the rest of the reservation. A call is never charged more than it reserved. A provider error charges the usage the provider reported for it, else nothing. So the budget can't be overspent, even with many calls running at once: each one holds its maximum until it settles. ## What it means for you - **Reservations are generous.** A call that may produce a lot of output reserves a lot, even if it ends up short. Your budget must cover the largest call you make, or that call is refused. - **`nexus spend` shows both.** *Spent* is what settled; *reserved* is held by calls still running; *remaining* is the budget minus both. A member sees only what is left for them, and when it resets, never the organization's budget, spent or reserved. - **Streams settle too.** For a streamed call, Gateway settles on the usage the provider reports at the end of the stream; if a stream is cut short, it settles on its input and an estimate of the output streamed so far. - **A settled call is never charged twice.** With an [idempotency key](/docs/concepts/idempotency), a model call that settled is not run again. A retry after a failure runs again, and each attempt is charged for the tokens it used. - **An unpaid invoice stops the calls Nexus pays for.** Past its grace period, such a call is refused with `402` and code [`payment_past_due`](/docs/api/errors#codes) before it reserves. Calls on your own provider keys keep running. An owner pays the invoice, and the other calls run again. - **Who pays depends on the key.** A call on your own provider key costs you only what the provider bills you. A call on Nexus's own provider accounts costs the provider's price plus 8%. The free start pays first, for cheaper models only. Then your credits pay, then your card if an owner turned on paying after the fact. When none of them can pay, the call is refused with `402` and a code such as `credit_exhausted` or `usage_limit_reached`. A call settles on what the provider reported: its cost, or its token counts at the provider's list prices. --- # Spend limits > A monthly spend limit per person, a default for everyone and overrides for some. Owners set both, and admins an owner allows set each person's limit. Checked on every call before it reaches a provider. Your organization's budget caps what everyone spends together. A **spend limit** caps what one person spends in a calendar month, so a single runaway agent session or script can't use up the budget for everyone else. ## How a limit is set An owner sets two things, both at the organization: - **A default per person.** Everyone without a limit of their own can spend this much a month. With no default, people have no limit of their own; only the organization's budget applies. - **A limit for one person.** Above or below the default, for one person. It wins over the default for them; remove it and the default applies again. ```sh nexus budgets default 50 # $50 a month for everyone without a limit of their own nexus budgets set ada@acme.example 200 # Ada: $200 a month nexus budgets set ada@acme.example default # Ada: back to the default nexus budgets default none # no default: no person limits ``` Every change is in the [audit log](/docs/concepts/audit-log), with the value before and after (`budget.person_default_changed`, `budget.person_limit_changed`). When a person is removed, their own limit closes with them. Recovering them inside 30 days brings it back. This includes a removal by an admin whom no owner has allowed to set limits. ## Who can set a limit An owner sets the default per person and each person's limit. An owner can also allow a named admin to set each person's limit. Team leads and members never set limits: they get `403` with code `role_required`. Only an owner sets the default per person, and only an owner sets an owner's limit. An allowed admin who tries gets `403` with code `role_required`. An admin whom no owner has allowed gets `403` with code `limit_grant_required`. ### Allow an admin An owner allows an admin one person at a time. The admin can then set each person's limit, except an owner's. The default per person stays with owners. ```sh nexus budgets managers # every owner, then the admins an owner has allowed nexus budgets managers add dee@acme.example # allow an admin nexus budgets managers remove dee@acme.example # stop them ``` The API is `PUT /v1/budgets/limit-managers/{userId}` to allow an admin and `DELETE` on the same path to stop them. Only an owner can call either one. Both answer `{ "userId": "…", "limitManager": true }`, with `false` after a `DELETE`. - An owner does not need to be allowed: an owner can always set limits. - Only an admin can be allowed. For anyone else the answer is `409` with code `not_an_admin`. - Allowing an admin who is already allowed, or stopping one who is not, changes nothing and writes no audit event. The allowance lasts only while the person is an admin. It ends when they become a member, when ownership is transferred to them, and when they leave the organization. When an owner transfers ownership, the previous owner becomes an admin with no allowance. A person who becomes an admin again starts without it, so an owner must allow them again. The limits they set before stay in place. Allowing and stopping are in the [audit log](/docs/concepts/audit-log) as `budget.limit_manager_granted` and `budget.limit_manager_revoked`. The event names the admin, and shows `limitManager` before and after. An allowance that ends with a role change, a transfer or a removal writes no `budget.limit_manager_revoked` event. The event for that role change, transfer or removal is the record. ## How it's checked A limit counts everything the person spends in the calendar month, in UTC: every model call they make, their `nexus claude` and `nexus codex` sessions, the products they run and their chats, through whichever team the spend goes to. It resets on the 1st at 00:00 UTC. The check happens when a call [reserves](/docs/concepts/ledger) its maximum cost, together with the organization's budget and the caps on the call's team: the person's spend this month, plus their calls still running, plus this call's maximum, must fit in their limit. If it doesn't, the call is refused with `402` and code `budget_exceeded` before anything is sent to a provider, in the error shape of the API you called (OpenAI's for `/v1/chat/completions` and `nexus codex`, Anthropic's for `nexus claude`). The error names the level and the limit: ```json { "error": { "message": "person limit: this call may cost up to $0.004096, and $0.00 of your $1.00 monthly limit is left (the organization's default per person); it resets on 2026-11-01 (UTC)", "type": "billing_error", "code": "budget_exceeded", "nexus": { "level": "person", "limitUsd": 1, "limitUsdDecimal": "1.000000", "source": "default", "period": "2026-10", "spentUsd": 1, "spentUsdDecimal": "1.000000", "reservedUsd": 0, "reservedUsdDecimal": "0.000000", "requestedUsd": 0.004096, "requestedUsdDecimal": "0.004096", "resetsAt": "2026-11-01T00:00:00.000Z" } } } ``` Each amount comes twice: as a number, which is deprecated, and as its exact decimal string (`requestedUsdDecimal`). Read the decimal string. A refused call costs nothing and is recorded as an **overspend prevented**: `nexus spend` and the Spend page show it among the calls, and `nexus budgets` counts them per person. Lowering a limit below what a person has already spent stops their next call, never one already running. ## Where to see it - **Nexus UI → Spend → Spend limits**: the default per person on one line, then a table of everyone with three columns: name, spend limit and spend this month. What calls still running hold shows under the spend as "in flight". A person at their limit has a warning mark. Owners edit the default and each person's limit there. Admins an owner allowed edit each person's limit, except an owner's. - **`nexus budgets`**: everyone's limit, spend, what is left and the calls a limit refused; `nexus budgets show me` for your own month; `nexus budgets managers` for every owner and the admins an owner has allowed. - **The API**: [`GET /v1/budgets`](/docs/api/budgets), `PUT /v1/budgets/person-default`, `GET`/`PUT /v1/people/{userId}/budget` and `PUT`/`DELETE /v1/budgets/limit-managers/{userId}`. Send a limit as a decimal string in `monthlyUsdDecimal`, with at most 6 decimals. Send `null` to clear it. ```json { "monthlyUsdDecimal": "50.00" } ``` A JSON number in `monthlyUsd` still works, but it is deprecated. `GET /v1/budgets` also says what the caller may do. `canManage` is true for a caller who may set a person's limit: an owner, or an admin an owner allowed. `canGrant` is true for an owner, who alone sets the default per person and allows admins. Each person in the answer has `limitManager`, which is true for an allowed admin. ### The table - **Search** by name or email. - **Filter** by where the limit comes from: own limit, default limit or no limit. - **At limit.** When someone is at their limit, a chip counts them ("2 at limit"). Press it to show only those people. - **Sort** by name, spend limit or spend. Without a sort, the person who spent the most this month is first. - **Edit in place.** Click a limit to change it, then save. "Use default" removes a person's own limit. The default per person has an Edit button for an owner, and "Clear" removes it. - **Select the amount.** The editor opens with the amount selected. Type to replace it, or press Backspace to clear it. Enter saves, and Escape closes the editor. - **Who can change limits.** An owner sees a switch for each admin above the table. Turn it on to allow the admin to set limits, as `nexus budgets managers add` does, and off to stop them. An allowed admin sees a line that says so. Only a person who may change a limit sees its edit control. An admin an owner allowed sees none on an owner's row, and none for the default per person. An admin whom no owner has allowed sees the table without any. Members see only their own limit and spend, and `nexus spend` gives them only what is left for them. Teams have their own caps: see [Teams](/docs/concepts/teams#model-policies-and-budgets). --- # Idempotency keys > Retry any write or model call safely; Nexus applies it once. Every write (`POST`, `PUT`, `PATCH`, `DELETE`) and every model call accepts an `Idempotency-Key` header. Send the same key again and Nexus answers with the first result instead of running the request twice. ```sh curl -X POST "$NEXUS_URL/v1/teams" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: 6f1c2a9e-1d4b-4e0a-9f53-0c8b7d2e4a11" \ -H "Content-Type: application/json" \ -d '{"slug": "platform"}' ``` A key is 1 to 255 printable ASCII characters, typically a UUID. It belongs to your organization and the credential that sent it, and is kept for **24 hours**. | Case | Answer | | --- | --- | | First request | Runs; its answer is kept | | Same key and same request, within 24 hours | The kept answer, with `Idempotent-Replayed: true`; nothing runs | | Same key, different method, path or body | `422` `idempotency_key_reused` | | Same key while the first request is still running | `409` `idempotency_in_progress`: retry in a moment | | Same key for a streamed model call that has finished | `409` `idempotency_stream_replay`: a stream is neither replayed nor run again. A stream whose call failed (cut, provider error) gives its key back, so the retry runs | | The first answer was a `5xx` or `429` | Not kept: a retry with the key runs again | | The first answer was too large to keep (over 2 MB) | `409` `idempotency_response_not_stored`: it never runs again | | The first request was cut off before it answered (Gateway's `504` `timeout` or `module_timeout`, or the connection closed) | `409` `idempotency_interrupted` for 24 hours: it may have run in part, so it never runs again. Check the state it changes, then use a new key. A retry in the first moments may still get `409` `idempotency_in_progress` | ## A settled call is never charged twice A model call with a key that succeeds runs once, and its success is charged once. The [ledger](/docs/concepts/ledger) checks this on its own as well: it refuses a second reservation under a key that has one open (`409` `idempotency_in_progress`) or a settled charge in the last 24 hours (`409` `idempotency_already_charged`). A retry after a `5xx` or `429` answer runs again: the key is released, and the failed attempt is not a settled charge. Each attempt is charged for the tokens it used, and a failure that used none charges nothing. A finished stream is never run again. ## The CLI does it for you The `nexus` CLI sends a fresh key with every command that changes something, and retries with the same key when the connection drops after sending or Gateway answers `502`, `503`, `504` or `409` `idempotency_in_progress`. Your own code can do the same with `createCoreClient({ idempotency: true })` from `@nexus/kit`. --- # The audit log > Every change in your organization, who made it, through which credential and from where, kept for good. Every change in an organization is an **audit event**: who made it (the person and the credential they used), from where (API, CLI, MCP, Nexus UI, a chat agent, a webhook or the system), what it did (a stable action such as `team.moved`), to what, and the record before and after. The actor can also be a service account, an agent link or a Nexus operator under an [operator grant](/docs/concepts/permissions). - **Written with the change.** An event is stored in the same transaction as the change it records: both happen or neither does. A refused change leaves no event. - **Append-only, kept indefinitely.** Events are never edited or deleted. A person who deletes their account stays in the log by user id, with no email. - **No secrets.** Tokens, keys and passwords are redacted before an event is stored; keys appear by id, prefix or last four characters only. No IP address is stored. - **Changes, not usage.** Model calls, agent sessions and product runs are in the ledger and their reports, not in the audit log. A few uses are audited too, such as a connector call, an operator's request and an admin's read of a synced session. ## Actions The main actions, by area. Chats, artifacts, pages, skills, routines and agents have their own actions too. | Area | Actions | | --- | --- | | Organization | `org.created`, `org.settings_changed`, `org.recovery_key_changed`, `org.budget_changed`, `org.owner_transferred`, `org.relinked`, `domain.added`, `domain.removed` | | Budgets | `budget.person_default_changed`, `budget.person_limit_changed`, `budget.team_changed`, `budget.product_changed`, `budget.limit_manager_granted`, `budget.limit_manager_revoked` | | Members | `member.joined`, `member.role_changed`, `member.removed`, `member.recovered`, `member.default_team_changed`, `account.deleted`, `invitation.sent`, `invitation.revoked` | | Keys and sign-in | `key.created`, `key.revoked`, `provider_key.added`, `provider_key.replaced`, `provider_key.disabled`, `provider_key.enabled`, `provider_key.removed`, `provider_key.rejected`, `vault.master_changed`, `auth.device_approved`, `auth.device_denied`, `auth.token_issued`, `auth.token_revoked` | | Service accounts, agents and operators | `service_account.created`, `service_account.key_created`, `service_account.key_rotated`, `service_account.key_revoked`, `service_account.revoked`, `agent.linked`, `agent.unlinked`, `operator_grant.issued`, `operator_grant.revoked`, `operator.request` | | Policy | `policy.changed`, `policy.control_set`, `policy.control_cleared`, `connector_grant.granted`, `connector_grant.revoked`, `connector_availability.changed`, `chat_write_setting.changed`, `review_event_setting.changed` | | Teams | `team.created`, `team.updated`, `team.moved`, `team.deleted`, `team.member_added`, `team.member_role_changed`, `team.member_removed`, `team.pending_added`, `team.pending_cancelled`, `team.import_applied` | | GitHub and connectors | `github.installation_linked`, `github.installation_unlinked`, `github.installation_removed`, `github.repositories_changed`, `connector_credential.added`, `connector_credential.replaced`, `connector_credential.revoked`, `connector.read`, `connector.write_attempt`, `connector.write` | | Billing | `credit.purchased`, `credit.auto_topup_changed`, `subsidy.granted`, `subsidy.used`, `subsidy.expired`, `billing.payment_method_changed`, `billing.invoice_paid`, `billing.invoice_failed`, `billing.usage_charged`, `billing.usage_charge_failed` | ## Who sees what | Who | Sees | | --- | --- | | Owners and admins | Every event of the organization | | Team leads | The events of the teams they lead and every team under them, plus their own actions | | Everyone else | The events where they are the actor | ## Reading it ```sh nexus audit # the last 7 days you may see nexus audit --since 24h --action 'team.*' # one area nexus audit --actor ada@example.com --team engineering --json nexus audit --csv > audit.csv # every matching event (owners, admins and team leads) ``` [`GET /v1/audit`](/docs/api/audit#list-audit-events) answers a page of events, newest first, with `nextCursor` for the next one. Filter with `since` and `until` (ISO times, or `30m`, `24h`, `7d`), `action` (one, a comma-separated list, or a prefix such as `team.*`), `actor`, `target` and `team`. [`GET /v1/audit/export.csv`](/docs/api/audit#export-audit-events) streams every matching event as CSV; cells that a spreadsheet would run as a formula are escaped. Nexus UI shows the same under **Audit**. --- # Permissions > One matrix of every action by role, checked before every request. Every endpoint of the Nexus API names the one permission it needs, and Gateway checks it before the request runs. A denied request is `403` `role_required`, and the message says who may. The API reference shows each endpoint's permission, and [`GET /v1/tenants/me`](/docs/api/core#current-tenant) lists the permissions you have. Some checks depend on the data and stay with the request: revoking someone else's token needs `keys.manage_all`, setting someone else's default team needs `teams.manage`, and only the owner transfers ownership. An admin sets a person's [spend limit](/docs/concepts/spend-limits) only when an owner has allowed it. Only an owner sets the default per person, and only an owner sets an owner's limit. A **lead** is a member who leads at least one team. A **service account** is a caller for CI and scripts. Its keys hold the public actions only, until a Policy Engine statement admits them to more. A **sandbox** is a sandbox session's reference, and holds the public actions only. A **module key** is the scoped key Nexus gives a product to call models and connectors. An **agent link** is no column. Its token holds what the person who linked it granted, cut down to that person's role now. A **Nexus operator** is no column either. An operator reaches your organization only under an operator grant, which names a reason, a list of actions and an expiry. It may do only the actions the grant names that an admin may do. Each request writes `operator.request` in your [audit log](/docs/concepts/audit-log) before it runs. Owners and admins read the grants with `GET /v1/operator-grants` and revoke one with `DELETE /v1/operator-grants/{id}`. | Action | Owner | Admin | Lead | Member | Service account | Sandbox | Module key | Signed out | Covers | | --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | --- | | `public` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | Public: sign up, the API description, the device login, signed webhooks | | `ui.session` | – | – | – | – | – | – | – | – | Start a Nexus UI session (Nexus UI's server only, with its shared secret) | | `authenticated` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | – | Any valid credential: who it is, and nothing else (GET /v1/auth/whoami); an agent link and an operator hold it whatever their grant, and no grant names it | | `org.read` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Read the organization: who you are, its modules, provider keys (masked), linked repositories, the subscription, agent policy (deprecated alias) | | `org.create` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Create a company organization: you become its owner | | `org.settings` | ✓ | ✓ | – | – | – | – | – | – | Change the organization's settings: its name, slug and logo, how long chat messages are kept | | `org.transfer` | ✓ | – | – | – | – | – | – | – | Transfer ownership of the organization | | `org.delete` | ✓ | – | – | – | – | – | – | – | Delete the organization (no endpoint yet) | | `org.billing` | ✓ | – | – | – | – | – | – | – | Billing: the card on file, the monthly invoices, and the subscription's payer and billing contact | | `members.read` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | List the organization's members (spend only for owners, admins and yourself) | | `members.manage` | ✓ | ✓ | – | – | – | – | – | – | Change a member's role, remove a member | | `members.invite` | ✓ | ✓ | – | – | – | – | – | – | Invite people by email | | `keys.manage_own` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Create, list and revoke your own API keys and tokens; sign out | | `account.delete` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Delete your own account from a sign-in, not an API key: your sign-in, your personal organization and your place in every organization (not while you own a company organization) | | `keys.manage_all` | ✓ | ✓ | – | – | – | – | – | – | List and revoke anyone's API keys and tokens | | `service_accounts.manage` | ✓ | ✓ | – | – | – | – | – | – | Make, list and revoke the organization's service accounts; issue, rotate and revoke their keys | | `agent_links.manage_own` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Link an agent that acts for you; list and unlink your own agent links (anyone's: owners and admins) | | `provider_keys.manage` | ✓ | ✓ | – | – | – | – | – | – | Add, replace, disable, enable and remove the organization's provider keys (BYOK) | | `budgets.manage` | ✓ | ✓ | – | – | – | – | – | – | Set the organization's budget and each team's cap; set the default per person as an owner, and each person's limit as an owner or as an admin an owner allowed (budgets.delegate) | | `budgets.delegate` | ✓ | – | – | – | – | – | – | – | Allow an admin to set person spend limits, or stop them | | `policy.read` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Read the model policies (organization, teams, coding agents) and test them for yourself | | `policy.manage` | ✓ | ✓ | – | – | – | – | – | – | Set the organization's and the coding agents' model policies; test them for anyone | | `policy.manage_team` | ✓ | ✓ | ✓ | – | – | – | – | – | Set a team's model policy, and pause or limit its model traffic (team leads: their own teams and those under them; a policy only to narrow it, a control never an override) | | `repositories.manage` | ✓ | ✓ | – | – | – | – | – | – | Link and unlink repositories through the Nexus GitHub App | | `chat_apps.manage` | ✓ | ✓ | – | – | – | – | – | – | Bind a chat workspace (Slack) to the organization through the app's install, confirm it, list the bindings and unbind them | | `chat_apps.manage_team` | ✓ | ✓ | ✓ | – | – | – | – | – | Bind a chat channel (Slack) to a team, list the channel bindings, read a channel's effective settings and unbind it (team leads: the teams they lead and those under them) | | `chat_apps.runtime` | – | – | – | – | – | – | – | – | Read a chat workspace's binding and bot token; report its revocation; keep the agents service's own sealed state (/v1/agents/state; the agents service only) | | `teams.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Read teams; choose your own default team | | `teams.manage` | ✓ | ✓ | – | – | – | – | – | – | Create, change, move and delete teams; add and remove members; import | | `spend.read_own` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Spend, analytics, agent sessions and spend limits: your own and your teams' (the organization's for owners and admins) | | `spend.read_all` | ✓ | ✓ | – | – | – | – | – | – | The whole organization's spend, analytics and agent sessions | | `spend.export` | ✓ | ✓ | – | – | – | – | – | – | Export the organization's spend calls, usage and agent sessions as CSV or JSON Lines, and the directory file that maps ids to names | | `products.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Run modules and read their reports; open and end agent sessions | | `routines.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Your own routines, such as a morning brief: create, read, pause, resume and delete them (/v1/routines; owners and admins also read, pause and delete others'); an agent link holds it only on its person's opt-in | | `wiki.run` | ✓ | – | – | – | – | – | – | – | Start a Nexus Wiki run (owners only until budgets exist; also the Wiki's run verb) | | `review.configure` | ✓ | – | – | – | – | – | – | – | Connect a repository to Nexus Review, change its review config, and watch it (owners only, as Nexus Review's connect and watch verbs) | | `agents.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | The agent gateway: Anthropic and OpenAI pass-through for nexus claude and nexus codex | | `agents.memory` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Your agent's memory: rows your agent seals and keeps for you, which only you and your own agent links read, write and delete (/v1/agents/memory); an agent link holds it only on its person's opt-in | | `agents.profiles` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Read your agents' profiles: your own personal agent and your organization's company agents (GET /v1/agents/profiles); an agent link holds it only on its person's opt-in | | `agents.profiles_manage` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Change agent profiles: your own personal agent, and as an owner or admin your organization's company agents (/v1/agents/profiles); no agent link holds it | | `projects.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Projects: list and read the projects you are in, create one, and as a project admin rename or archive it and change its repositories, members and secrets (/v1/projects; owners and admins are admins of every project); set your own secrets (/v1/secrets/me; values are write-only); read a project's setup and, as a project admin, save a new version (/v1/projects/{id}/setup); no agent link holds it | | `projects.org_secrets` | ✓ | ✓ | – | – | – | – | – | – | The organization's project secrets: list their names, set and delete them (/v1/secrets/org; values are write-only); no agent link holds it | | `models.use` | ✓ | ✓ | ✓ | ✓ | – | – | ✓ | – | Model calls through /v1/chat/completions, and the models you may use (GET /v1/models) | | `chat.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Chat sessions: your own, private to you (Nexus UI's home, nexus chat, Ask your code) | | `chat.ask` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Ask your code alone: a question to the organization's Nexus Wiki in an ask-mode session of your own (POST /v1/chat/ask) and no other chat route; an agent link holds it only on its person's opt-in | | `chat.web` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Web search alone: a text question answered with the organization's web search and no other tool, in a chat session of your own (POST /v1/chat/web) and no other chat route; an agent link holds it only on its person's opt-in | | `artifacts.share` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Share your own chat sessions as artifacts (snapshots) with the organization, chosen teams or chosen people in it, or outside it (named people by email, or anyone with the link) as its settings allow; see and change who has them; revoke them (owners and admins: any of the organization's) | | `artifacts.read` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Artifacts shared with you (from other organizations too, by your verified email): list, read, download as Markdown, ask for access, and continue one in a new private chat when its author allows | | `artifacts.manage_external` | ✓ | ✓ | – | – | – | – | – | – | Everything the organization shared outside it: list it with open counts, requests and reports, and revoke in bulk | | `artifacts.manage_all` | ✓ | ✓ | – | – | – | – | – | – | Revoke any of the organization's artifacts and change who has them (their authors: their own, with artifacts.share) | | `skills.promote` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Ask to promote your own skill to a team you are in or to the organization; list your own promotion requests and withdraw a held one | | `skills.approve_team` | ✓ | ✓ | ✓ | – | – | – | – | – | Approve or refuse a promotion request to a team, and withdraw an approved version (team leads: their own teams and those under them; never your own request) | | `skills.approve_org` | ✓ | ✓ | – | – | – | – | – | – | Approve or refuse a promotion request to the organization, and withdraw an approved version (never your own request) | | `sessions.control` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Send and receive encrypted requests for your own computers and Code sessions from your trusted devices | | `synced_sessions.manage_policy` | ✓ | ✓ | – | – | – | – | – | – | Change the organization's content policy for synced sessions, and register or replace its recovery key's public half | | `synced_sessions.audit` | ✓ | ✓ | – | – | – | – | – | – | Read every member's synced sessions in the organization, each read audited, the copies locked for its recovery key, and which members lock for it (GET /v1/threads?scope=org, GET /v1/threads/{threadId}/org-keys, GET /v1/orgs/recovery-key/coverage) | | `connectors.use` | ✓ | ✓ | ✓ | ✓ | – | – | ✓ | – | Connector reads and module writes with a standing Policy grant | | `connections.manage_own` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Connect, list and disconnect your own accounts at a connector's vendor (the organization's: owners and admins) | | `audit.read_own` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Audit events where you are the actor | | `audit.read_team` | ✓ | ✓ | ✓ | – | – | – | – | – | Audit events of the teams you lead and the teams under them | | `audit.read_all` | ✓ | ✓ | – | – | – | – | – | – | Every audit event of the organization | | `audit.export` | ✓ | ✓ | ✓ | – | – | – | – | – | Export audit events as CSV (within what you can read) | | `operator_grants.issue` | ✓ | ✓ | – | – | – | – | – | – | Ask for an operator grant on a customer's organization, with a reason, a list of actions and an expiry (a person with a platform role only) | | `operator_grants.read` | ✓ | ✓ | – | – | – | – | – | – | Read the operator grants on the organization (who holds each one, why, what it allows, when it ends) and revoke them | | `auth.device_approve` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Approve a `nexus auth login` code (in Nexus UI, or on Gateway's own `/device` page without it) | | `approvals.decide` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Confirm or deny, as yourself in Nexus, a connector write a chat agent asked for, and turn your own agents' writes on or off; an agent link never holds it | | `search.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Search what your role may read: your own chats, artifacts shared with or by you, people, teams, models and model policies (GET /v1/search) | | `notifications.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | The notification inbox: your own items, marked read or done, and the catalogue of kinds (GET /v1/notifications), and a question to the owners about a billing block (POST /v1/notifications/ask-owner) | | `growth.read` | ✓ | ✓ | – | – | – | – | – | – | Read the organization's activation and first values, and its members' paths to first value as counts per step (GET /v1/growth/activation, GET /v1/growth/paths) | | `diagnostics.report` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Send the app's own error and crash reports, which hold no content, to the Gateway's log (POST /v1/diagnostics/reports), its activity heartbeat (POST /v1/diagnostics/heartbeat) and the errors it caught, with no content (POST /v1/diagnostics/errors) and the artifact frames that failed to load (POST /v1/diagnostics/frame-failures) | | `feedback.send` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Send feedback, and the crash reports you chose to send, to Nexus's team in Slack (POST /v1/diagnostics/feedback) | | `referrals.read` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Your referral code and the people you referred (GET /v1/referrals) | | `cloud.machines.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Your own cloud machines on Nexus's provider account: create, wake, sleep, delete and connect to them; their compute is charged as cloud compute (/v1/cloud/machines) | | `cloud.sandboxes.use` | – | – | – | – | – | – | ✓ | – | Throwaway cloud sandboxes on Nexus's provider account for a module's untrusted commands: create, read, run commands in, upload to and delete them; Nexus Review's module key only; their compute is charged as cloud compute (/v1/cloud/sandboxes) | | `cloud.runs.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Start and read your own fix runs: Gateway fixes a GitHub issue in a throwaway cloud sandbox on Nexus's provider account and opens the pull request through your agents' writes; only an agent link starts one; the sandbox is charged as cloud compute (/v1/cloud/runs) | | `sessions.read` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Read your own cloud sessions and their history (the /v1/sessions routes, when they ship); an agent link holds it only on its person's opt-in | | `sessions.start` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Start cloud sessions as you, billed to you; an agent link that holds it also holds your cloud machines (cloud.machines.use), and only on its person's opt-in | | `sessions.steer` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Send messages to and stop your own cloud sessions (the /v1/sessions routes, when they ship); an agent link holds it only on its person's opt-in | | `apps.use` | ✓ | ✓ | ✓ | ✓ | – | – | – | – | Your own apps on Nexus's Vercel team: deploy a folder, read, delete and claim them to your own Vercel account; owners and admins reach every app of the organization (/v1/apps, NEXUS_APPS_ENABLED) | | `accounts.mark` | ✓ | ✓ | – | – | – | – | – | – | Mark an organization or a person as Nexus's own: staff, test or demo (a person with a platform role only) | | `desktop.revoke` | ✓ | ✓ | – | – | – | – | – | – | Read and change the desktop app versions this Gateway refuses with 426 desktop_revoked, for every organization (a person with a platform role only) | | `staff.read` | ✓ | ✓ | – | – | – | – | – | – | Read every person's and organization's metadata and usage across organizations, audited (a person with a platform role who is one of Nexus's own people only) | | `staff.invites` | ✓ | ✓ | – | – | – | – | – | – | Make, list and revoke campaign codes for invite-only sign-up, audited (a person with a platform role who is one of Nexus's own people only) | This table is generated from the API's own description, which a test keeps equal to the code. --- # API overview > One API for everything in Nexus, the same one the CLI and Nexus UI use. Everything you can do in Nexus UI or the CLI goes through the Nexus API: organizations, keys, teams, spend, the audit log, model calls and every product. This reference is generated from the API's own OpenAPI description at each build, so it lists exactly the endpoints that exist. ## Base URL The API lives under `/v1` on your Nexus Gateway, for example `https://api.nexus.inc/v1`. The examples use two shell variables: ```sh export NEXUS_URL=https://api.nexus.inc export NEXUS_API_KEY=nx_… # an API key: Nexus UI → Settings → Keys ``` Your Gateway also serves the full description, with every registered product's operations merged in, at [`GET /v1/openapi.json`](/docs/api/core#openapi). ## Authentication Send a personal token as `Authorization: Bearer `. See [Authentication](/docs/authentication) for the kinds of tokens and how to get one. Each endpoint below shows the permission it needs and who has it; the full matrix is on [Permissions](/docs/concepts/permissions). ## Requests and responses - Request and response bodies are JSON, except where an endpoint says otherwise (an audit export is CSV; the agent gateway streams server-sent events). - Every answer carries an `x-request-id`; the audit log records it with each change. - Every write and model call accepts an `Idempotency-Key`, so a retry is applied once. See [Idempotency keys](/docs/concepts/idempotency). - Name the team a call is attributed to with the `x-nexus-team` header. See [Attribution](/docs/concepts/attribution). - Errors are `{ "error": { "message", "type", "code" } }`. See [Errors](/docs/api/errors). - Requests are rate-limited per key per minute (`429`). ## Examples Each endpoint has a curl example and, where the typed client has the call, a TypeScript example using `@nexus/kit`, the client the CLI and Nexus UI use. `@nexus/kit` is not published to npm yet: coming. **Try it** on an endpoint opens it in Nexus UI's API Explorer, which sends the request with your key and shows the answer. > The API is at version `0.45.0`. MVP: not a stable contract yet. Changes appear here on the day they ship. --- # Errors > Every error has an HTTP status, a type, often a stable code, and a message that says what to do. Errors from the Nexus API share one shape: ```json { "error": { "message": "there is already a team platform in this organization", "type": "invalid_request_error", "code": "slug_taken" } } ``` - `message` is written for people: it names what is wrong and, where it can, what to do next. - `type` is the broad class, by status. - `code` is stable: match on it in code, never on the message. Every `4xx` carries one, and a `5xx` only when it names a cause. The agent gateway (`/v1/anthropic/…`, `/v1/openai/…`) answers errors in the provider's own error format instead, so Claude Code, Codex and the providers' SDKs understand them. So are model refusals on chat completions; see [Models and policies](/docs/concepts/models-and-policies#when-a-model-is-refused). ## By status | Status | Type | Meaning | | --- | --- | --- | | `400` | `invalid_request_error` | A field is missing or not valid; the message names it | | `401` | `authentication_error` | No token, or a token Gateway does not accept: sign in again | | `402` | `billing_error` | The call's maximum cost is more than the budget, the free start, the credits or the usage limit left, or a payment did not go through; see the code | | `403` | `permission_error` | Your role or your key may not do this | | `404` | `not_found` | Nothing matches in your organization | | `405` | `invalid_request_error` | The method is not allowed on this path | | `409` | `invalid_request_error` | The request conflicts with the current state; see the code | | `413` | `invalid_request_error` | The request body is too large | | `422` | `invalid_request_error` | An idempotency key was reused for a different request | | `426` | `invalid_request_error` | The `nexus` CLI is older than this Gateway supports (`cli_too_old`): run `nexus update` | | `429` | `rate_limit_error` | Too many requests from this key in a minute: wait and retry | | `500` | `server_error` | Something unexpected failed on Gateway; the cause is in its logs, not in the answer | | `501` | `not_implemented` | Not built yet (`not_ported`) | | `502` | `api_error`, `module_unavailable`, `connector_error` | A provider, product or outside service behind Gateway did not answer | | `503` | `not_configured`, `server_error` | Not configured on this Gateway, or the database is busy (`database_busy`): retry | | `504` | `api_error` | The request passed Gateway's deadline (`timeout`), or a product's module did not answer in time (`module_timeout`) | ## Codes | Code | Status | What to do | | --- | --- | --- | | `role_required` | `403` | Ask an owner or admin; the message says which roles may | | `not_in_team` | `403` | Name a team you belong to, or ask to be added | | `model_not_allowed` | `403` | Use a model your policies allow: `nexus models`; `nexus policy test` names the rule | | `model_not_found` | `404` | Check the name: `nexus models --all` lists the catalog | | `model_not_supported` | `400` | The model is coming soon, or not served on this API | | `cli_too_old` | `426` | Run `nexus update` | | `module_key` | `403` | A product's scoped key can only call models and connectors | | `module_unavailable` | `502` | The product's module failed or could not be reached; the message names it. Retry later | | `module_timeout` | `504` | The product's module did not answer within 28 s and may have started the work. Check its state before you retry. With the same `Idempotency-Key`, a retry gets `idempotency_interrupted` | | `nexus_ui_only` | `403` | Do this in Nexus UI | | `unknown_team` | `404` | Check the slug: `nexus team list` | | `budget_exceeded` | `402` | Check `nexus spend`; an owner or admin can raise the budget | | `limit_grant_required` | `403` | You may not set person spend limits. Ask an owner to set the limit, or to allow you to: `nexus budgets managers add` | | `payment_past_due` | `402` | An invoice is unpaid past its grace period, so Nexus does not pay for the call: ask an owner to pay the month the message names, or use your own provider key | | `subsidy_exhausted` | `402` | The free start is used up, or pays only for cheaper models. Set up billing (`nexus billing`), pick a cheaper model, or add your own provider key | | `credit_exhausted` | `402` | The Nexus credits are used up: buy more with `nexus billing credits buy`, or add your own provider key | | `usage_limit_reached` | `402` | What is left of this month's usage limit does not cover the call's cost at most (`details.requestedUsd` and `details.remainingUsd`): an owner raises the limit, or buys credits, in `nexus billing` | | `payment_failed` | `402` | The last card charge failed: an owner replaces the card with `nexus billing card add`. When the bank wants the cardholder to confirm it (3-D Secure), an owner approves that same charge with `nexus billing confirm` | | `charge_processing` | `402` | A charge for usage is still going through, such as a bank debit, and the card pays for no more calls until it is paid (`details.chargeUsd`, `details.unpaidUsd`, `details.capUsd`). Credits and your own provider keys still pay | | `provider_key_required` | `403` | Your organization has no key for this provider: an owner or admin adds one with `nexus keys add` | | `subscriptions_disabled` | `403` | Your organization turned off agents on personal plans: run the agent through Gateway (`--api`). Antigravity does not run until an owner or admin allows personal plans again: `nexus org settings set agentSubscriptions true` | | `route_unsupported` | `400` | The agent runs only on your own plan, so `--api` is not available. Run it on your plan: `nexus agy --subscription` for Antigravity | | `slug_taken` | `409` | Choose another slug | | `team_cycle`, `too_deep` | `409` | A team can't be under itself, or more than 10 levels deep | | `has_children` | `409` | Delete with `cascade=1`, or move the child teams first | | `plan_changed` | `409` | Run the import's dry run again and review the new plan | | `confirmation_required` | `400` | Send `expect` with the number of invitations you confirmed | | `count_changed` | `409` | The number of invitations changed; review it again | | `not_a_clerk_org` | `409` | This organization has no sign-in through Nexus UI, so there is no one to invite to it | | `owner_role` | `409` | Transfer ownership first | | `not_an_admin` | `409` | Only an admin can be allowed to set person spend limits: check the person's role with `nexus members` | | `code_used` | `409` | Start `nexus auth login` again | | `installation_taken` | `409` | That GitHub installation is linked to another organization | | `api_key_limit` | `409` | You hold 100 live API keys in this organization: revoke one first | | `idempotency_in_progress` | `409` | The first request with this key is still running: retry in a moment | | `idempotency_interrupted` | `409` | The first request with this key was cut off and may have run in part: check the state, then use a new key | | `idempotency_key_reused` | `422` | Use a new key for a different request | | `idempotency_stream_replay` | `409` | A finished streamed call is not replayed: use a new key | | `idempotency_already_charged` | `409` | That call was already charged: use a new key to run it again | | `invalid_idempotency_key` | `400` | Keys are 1 to 255 printable ASCII characters | | `invalid_cursor` | `400` | Start the listing again without `cursor` | | `database_busy` | `503` | Nothing was written: retry | ## In the CLI The CLI prints an error as one line and the fix, and exits non-zero: `1` for a failure, `2` for a usage error. With `--json`, it prints `{"error": {"message", "hint"}}` on stderr. `NEXUS_DEBUG=1` adds the stack trace. --- # Gateway > Organizations, keys, models, spend and the module registry. ## Create tenant `POST /v1/tenants` Sign up: create a tenant, its first user and an API key (shown once). The person's personal organization is made too (`personal` in the answer); `personal: true` without a name makes only the personal organization and returns its key. Permission: `public` (Anyone, signed in or not). ### Request body (application/json, required) - `name` (string) [max length 80] - `email` (string) - `personal` (boolean): Make only your personal organization (no name needed) ### Responses - `201` Created (application/json, CreateTenantResponse) - `tenant` (object) - `id` (string) - `name` (string) - `budgetUsd` (number) - `kind` ("company" | "personal"): A company organization, or a person's own personal organization (one per person, one member) - `slug` (string): A personal organization's slug - `user` (object) - `id` (string) - `email` (string) - `apiKey` (string) - `personal` (OrgSummary): Your personal organization, made with the company organization - `id` (string, required) - `name` (string, required) - `slug` (string) - `clerkOrgId` (string): Its sign-in provider organization's id: Nexus UI's URL segment when it has no slug - `kind` ("company" | "personal", required): A company organization, or a person's own personal organization (one per person, one member) - `role` ("owner" | "admin" | "member") - `current` (boolean): The organization this request is in - `imageUrl` (string): Its logo, as the tenant's imageUrl (https://img.clerk.com/…); unset when it has none. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/tenants" \ -H "Content-Type: application/json" \ -d '{ "name": "Platform", "email": "ada@example.com", "personal": false }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.createTenant("Acme"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Ftenants) ## Current tenant `GET /v1/tenants/me` The calling token's organization (id, name, slug), the person and their role and permissions. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, CurrentTenantResponse) - `tenant` (object, required) - `id` (string, required) - `name` (string, required) - `createdAt` (string (date-time), required) - `slug` (string) - `kind` ("company" | "personal"): A company organization, or a person's own personal organization (one per person, one member) - `imageUrl` (string): The organization's logo, as Clerk serves it (https://img.clerk.com/…); unset when it has none. - `mark` ("staff" | "test" | "demo"): Set only when it is Nexus's own; unset for a customer's. - `user` (object): The person calling, when the key is a person's - `id` (string, required) - `email` (string) - `name` (string) - `mark` ("staff" | "test" | "demo"): Set only when it is Nexus's own; unset for a customer's. - `teams` (array of object): Your teams in this organization - `id` (string) - `slug` (string) - `name` (string) - `role` ("lead" | "member"): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `team` (object): Your default team - `id` (string) - `slug` (string) - `name` (string) - `features` (GatewayFeatures): The products this Gateway has on. Unset reads as all off. - `wiki` (boolean, required): Nexus Wiki is on. Off, its routes and Ask your code answer 404 wiki_off, and clients hide them. - `apps` (boolean): Nexus Apps (`NEXUS_APPS_ENABLED`): `nexus apps` and /v1/apps. An older Gateway leaves it out: off. - `agentSessionAudit` (boolean): Coding agent sessions write agent_session.started and agent_session.ended audit events (`NEXUS_AUDIT_AGENT_SESSIONS`). An older Gateway leaves it out: off. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/tenants/me" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.me(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Ftenants%2Fme) ## List provider keys `GET /v1/keys/providers` List the tenant's own provider keys (last four characters only). Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, object) - `providers` (array of ProviderKey): The organization's own keys. - `provider` (string) - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own. - `scopeId` (string): The team's or the person's id. - `last4` (string) - `createdAt` (string (date-time)) - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it. - `checkedAt` (string (date-time)) - `lastUsedOn` (string (date)): The UTC day a call last used the key. - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`. - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement. - `last4` (string, required) - `addedAt` (string (date-time), required) - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys. - `scopedKeys` (array of ProviderKey): The keys the organization's teams and people hold. An owner or admin reads every one; anyone else reads the teams' keys and their own. Absent when there is none. A call takes the caller's own key, then its team's, then each parent team's, then the organization's: the first one that is not disabled. - `provider` (string) - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own. - `scopeId` (string): The team's or the person's id. - `last4` (string) - `createdAt` (string (date-time)) - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it. - `checkedAt` (string (date-time)) - `lastUsedOn` (string (date)): The UTC day a call last used the key. - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`. - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement. - `last4` (string, required) - `addedAt` (string (date-time), required) - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/keys/providers" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.listProviderKeys(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fkeys%2Fproviders) ## Add provider key `POST /v1/keys/providers` Store a provider key (BYOK), encrypted at rest. Used for this tenant's calls only. Permission: `provider_keys.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `provider` ("anthropic" | "openai", required) - `key` (string, required) - `team` (string): A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key. - `user` (string): A person's key: `me` or a member's id. Name a team or a user, not both: both are a 400, and one the organization lacks is a 404. ### Responses - `201` Created (application/json, ProviderKey) - `provider` (string) - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own. - `scopeId` (string): The team's or the person's id. - `last4` (string) - `createdAt` (string (date-time)) - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it. - `checkedAt` (string (date-time)) - `lastUsedOn` (string (date)): The UTC day a call last used the key. - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`. - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement. - `last4` (string, required) - `addedAt` (string (date-time), required) - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys. - `400` Not valid: a provider not in the list (`provider_retired` for a retired one), a key not 8 to 512 characters once surrounding whitespace is trimmed, or both `team` and `user`. `provider_key_invalid_character`: the trimmed key holds a character outside visible ASCII, such as a space, a line break, a terminal's paste marker or an invisible mark, so it is never sent or stored. A NUL is refused before that as `nul_in_string`. `provider_key_rejected`: the provider refused the key when it was checked, and nothing is stored. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not valid: a provider not in the list (`provider_retired` for a retired one), a key not 8 to 512 characters once surrounding whitespace is trimmed, or both `team` and `user`. `provider_key_invalid_character`: the trimmed key holds a character outside visible ASCII, such as a space, a line break, a terminal's paste marker or an invisible mark, so it is never sent or stored. A NUL is refused before that as `nul_in_string`. `provider_key_rejected`: the provider refused the key when it was checked, and nothing is stored. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/keys/providers" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "provider": "anthropic", "key": "" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.addProviderKey("anthropic", process.env.ANTHROPIC_API_KEY ?? ""); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fkeys%2Fproviders) ## Get provider key `GET /v1/keys/providers/{provider}` One provider key, in any state, with its versions: who added each, when, and its last four characters, never the value. 404 `provider_key_not_found` when none was ever stored. Permission: `org.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `provider` | path | string | yes | The key's provider (`anthropic`, `openai`) | | `team` | query | string | no | A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key. | | `user` | query | string | no | A person's key: `me` or a member's id. Another person's key is an owner's or admin's to read: anyone else gets a 403. | ### Responses - `200` OK (application/json, ProviderKey) - `provider` (string) - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own. - `scopeId` (string): The team's or the person's id. - `last4` (string) - `createdAt` (string (date-time)) - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it. - `checkedAt` (string (date-time)) - `lastUsedOn` (string (date)): The UTC day a call last used the key. - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`. - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement. - `last4` (string, required) - `addedAt` (string (date-time), required) - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | `provider_key_not_found` | 404 `provider_key_not_found` when none was ever stored | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/keys/providers/anthropic" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fkeys%2Fproviders%2F%7Bprovider%7D) ## Replace provider key `POST /v1/keys/providers/{provider}/replace` Replace the stored provider key with `key`, checked against its provider first, as its next version. A disabled key stays disabled. 404 `provider_key_not_found` when none is stored, before the key is sent anywhere; 400 `provider_key_invalid_character` when the trimmed key holds a character outside visible ASCII, and nothing is sent; 400 `provider_key_rejected` when the provider refuses it, and the stored key stays. With `dryRun: true`, the key is checked and nothing is stored. Audited as `provider_key.replaced`. Permission: `provider_keys.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `provider` | path | string | yes | The key's provider (`anthropic`, `openai`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `key` (string, required) - `dryRun` (boolean): Check and change nothing. [default false] - `team` (string): A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key. - `user` (string): A person's key: `me` or a member's id. Name a team or a user, not both: both are a 400, and one the organization lacks is a 404. ### Responses - `200` OK (application/json, ProviderKeyChange) - `dryRun` (boolean, required) - `changed` (boolean, required): False when the key was already in the state asked for, so nothing was written. - `providerKey` (ProviderKey, required): The key after the change, or as it would be after a dry run. - `provider` (string) - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own. - `scopeId` (string): The team's or the person's id. - `last4` (string) - `createdAt` (string (date-time)) - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it. - `checkedAt` (string (date-time)) - `lastUsedOn` (string (date)): The UTC day a call last used the key. - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`. - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement. - `last4` (string, required) - `addedAt` (string (date-time), required) - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | `provider_key_invalid_character` | 404 `provider_key_not_found` when none is stored, before the key is sent anywhere; 400 `provider_key_invalid_character` when the trimmed key holds a character outside visible ASCII, and nothing is sent; 400 `provider_key_rejected` when the provider refuses it, and the stored key stays | | 400 | `provider_key_rejected` | 404 `provider_key_not_found` when none is stored, before the key is sent anywhere; 400 `provider_key_invalid_character` when the trimmed key holds a character outside visible ASCII, and nothing is sent; 400 `provider_key_rejected` when the provider refuses it, and the stored key stays | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | `provider_key_not_found` | 404 `provider_key_not_found` when none is stored, before the key is sent anywhere; 400 `provider_key_invalid_character` when the trimmed key holds a character outside visible ASCII, and nothing is sent; 400 `provider_key_rejected` when the provider refuses it, and the stored key stays | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/keys/providers/anthropic/replace" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "key": "" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fkeys%2Fproviders%2F%7Bprovider%7D%2Freplace) ## Disable provider key `POST /v1/keys/providers/{provider}/disable` Disable the stored provider key: it stays sealed, and no call opens it until it is enabled. Disabling a disabled key answers `changed: false`. 404 `provider_key_not_found` when none is stored. With `dryRun: true`, nothing changes. Audited as `provider_key.disabled`. Permission: `provider_keys.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `provider` | path | string | yes | The key's provider (`anthropic`, `openai`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json) - `dryRun` (boolean): Check and change nothing. [default false] - `team` (string): A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key. - `user` (string): A person's key: `me` or a member's id. Name a team or a user, not both: both are a 400, and one the organization lacks is a 404. ### Responses - `200` OK (application/json, ProviderKeyChange) - `dryRun` (boolean, required) - `changed` (boolean, required): False when the key was already in the state asked for, so nothing was written. - `providerKey` (ProviderKey, required): The key after the change, or as it would be after a dry run. - `provider` (string) - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own. - `scopeId` (string): The team's or the person's id. - `last4` (string) - `createdAt` (string (date-time)) - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it. - `checkedAt` (string (date-time)) - `lastUsedOn` (string (date)): The UTC day a call last used the key. - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`. - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement. - `last4` (string, required) - `addedAt` (string (date-time), required) - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | `provider_key_not_found` | 404 `provider_key_not_found` when none is stored | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/keys/providers/anthropic/disable" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "dryRun": false, "team": "platform", "user": "" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fkeys%2Fproviders%2F%7Bprovider%7D%2Fdisable) ## Enable provider key `POST /v1/keys/providers/{provider}/enable` Enable a disabled provider key, or check a rejected one again, after checking it against its provider: its state is what the provider answers. 400 `provider_key_rejected` when the provider still refuses it, and it stays as it was. 400 `provider_key_invalid_character` when the stored key holds a character outside visible ASCII: it is not sent, and only a replacement mends it. Enabling a key that is neither disabled nor rejected answers `changed: false`. 409 `provider_key_changed` when the key was replaced while it was checked. With `dryRun: true`, the key is checked and nothing changes. Audited as `provider_key.enabled`. Permission: `provider_keys.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `provider` | path | string | yes | The key's provider (`anthropic`, `openai`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json) - `dryRun` (boolean): Check and change nothing. [default false] - `team` (string): A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key. - `user` (string): A person's key: `me` or a member's id. Name a team or a user, not both: both are a 400, and one the organization lacks is a 404. ### Responses - `200` OK (application/json, ProviderKeyChange) - `dryRun` (boolean, required) - `changed` (boolean, required): False when the key was already in the state asked for, so nothing was written. - `providerKey` (ProviderKey, required): The key after the change, or as it would be after a dry run. - `provider` (string) - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own. - `scopeId` (string): The team's or the person's id. - `last4` (string) - `createdAt` (string (date-time)) - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it. - `checkedAt` (string (date-time)) - `lastUsedOn` (string (date)): The UTC day a call last used the key. - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`. - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement. - `last4` (string, required) - `addedAt` (string (date-time), required) - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | `provider_key_rejected` | 400 `provider_key_rejected` when the provider still refuses it, and it stays as it was | | 400 | `provider_key_invalid_character` | 400 `provider_key_invalid_character` when the stored key holds a character outside visible ASCII: it is not sent, and only a replacement mends it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 409 | `provider_key_changed` | 409 `provider_key_changed` when the key was replaced while it was checked | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/keys/providers/anthropic/enable" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "dryRun": false, "team": "platform", "user": "" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fkeys%2Fproviders%2F%7Bprovider%7D%2Fenable) ## Remove provider key `POST /v1/keys/providers/{provider}/remove` Remove the stored provider key: its sealed value is deleted, its state is `removed`, and its versions stay. 404 `provider_key_not_found` when none is stored. With `dryRun: true`, nothing changes. Audited as `provider_key.removed`. Permission: `provider_keys.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `provider` | path | string | yes | The key's provider (`anthropic`, `openai`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json) - `dryRun` (boolean): Check and change nothing. [default false] - `team` (string): A team's key: the team's slug or id. Leave out `team` and `user` for the organization's own key. - `user` (string): A person's key: `me` or a member's id. Name a team or a user, not both: both are a 400, and one the organization lacks is a 404. ### Responses - `200` OK (application/json, ProviderKeyChange) - `dryRun` (boolean, required) - `changed` (boolean, required): False when the key was already in the state asked for, so nothing was written. - `providerKey` (ProviderKey, required): The key after the change, or as it would be after a dry run. - `provider` (string) - `scope` ("team" | "user"): Who holds the key: a team or a person. Absent for the organization's own. - `scopeId` (string): The team's or the person's id. - `last4` (string) - `createdAt` (string (date-time)) - `state` ("valid" | "rejected" | "unreachable" | "disabled" | "removed"): What the provider answered when the key was checked on add: a model listing, which costs nothing. Absent for a key stored before the check. An add the provider rejects answers 400 `provider_key_rejected` and stores nothing. `disabled` and `removed` are an admin's: no call opens such a key. The list marks a disabled key `unused` and leaves a removed one out. `rejected` on a stored key: its provider refused it on a call with HTTP 401; `enableProviderKey` checks it again, and a replacement clears it. - `checkedAt` (string (date-time)) - `lastUsedOn` (string (date)): The UTC day a call last used the key. - `versions` (array of ProviderKeyVersion): Each key stored for the provider, oldest first, at most 50; only on `getProviderKey`. - `version` (integer, required): 1 for the first key stored for the provider, then one more for each replacement. - `last4` (string, required) - `addedAt` (string (date-time), required) - `addedBy` (string): The user who added it; absent for Core's own work and for a key stored before Nexus recorded who added keys. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | `provider_key_not_found` | 404 `provider_key_not_found` when none is stored | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/keys/providers/anthropic/remove" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "dryRun": false, "team": "platform", "user": "" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fkeys%2Fproviders%2F%7Bprovider%7D%2Fremove) ## Chat completion `POST /v1/chat/completions` OpenAI-compatible chat completion. Policy check, then the call's maximum cost is reserved against the budget, the provider is called, and the reservation settles on reported usage (also on errors). Model `nexus/auto` lets Gateway choose. `model` is a catalog id (any spelling), `nexus/auto` or `nexus/default` (the effective default within policy); the answer's `model` and `x-nexus-model` header say which model ran. An answer the auto router picked also names the router version in `x-nexus-router` and in `nexus.router`. A refused model: 403 `model_not_allowed` (policy, naming the level and rule), 404 `model_not_found`, 400 `model_not_supported` (coming soon); never sent upstream or reserved, recorded as a refused call. Who pays: the organization's own key; Nexus's own key for Nexus's own organizations; Nexus credit only for a module run's scoped key (a Nexus feature, such as a Wiki or Review run). Any other caller with no key of its own gets 403 `provider_key_required`, never Nexus credit. Tools (OpenAI's `tools`, `tool_choice`, `parallel_tool_calls`, an assistant's `tool_calls` and `tool` messages) work for Anthropic and OpenAI models alike, translated by Gateway. `stream: true` answers as server-sent events in OpenAI's `chat.completion.chunk` shape (the role, then text and tool-call pieces, a chunk with `finish_reason`, a last chunk with no choices and the `usage` and `nexus` cost, then `data: [DONE]`; a failure after the stream started is a `data: {"error": …}` event), so agent tools that speak Chat Completions (opencode's `@ai-sdk/openai-compatible` and the like) use `/v1` as their provider. A stream is checked, reserved and refused exactly as a call that does not stream, and settles however it ends: on the reported usage, or on what streamed when the provider fails or the caller goes away. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-team` | header | string | no | The team (slug) this call's spend goes to; you must be in it. Default: your default team. | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `model` (string, required) - `messages` (array of ChatMessage, required) - `role` ("system" | "developer" | "user" | "assistant" | "tool", required): `developer` is taken as `system`. Answers are always `assistant`. - `content` (string | array of object | null): The text, or OpenAI's content parts: `{type: "text", text}` (joined) and, in a person's message, `{type: "image_url", image_url: {url}}` with a `data:` URL (Gateway fetches no URLs). An assistant turn that only calls tools may leave it out or send null. Answers carry a string. - `tool_calls` (array of ToolCall): The tools an assistant turn called (in an answer: when `finish_reason` is `tool_calls`). - `id` (string, required) - `type` ("function", required) - `function` (object, required) - `name` (string, required) - `arguments` (string, required): A JSON object, as a string. - `tool_call_id` (string): A `tool` message: the call it answers. - `max_tokens` (integer): At most the lower of the deployment's cap (`NEXUS_MAX_TOKENS`) and the model's `max_output_tokens`; above it is a 400 `output_over_limit` before anything is reserved, with `error.nexus.limit`. A call skips a host whose output limit is below it; when no host it may use takes it, the same 400 names the largest limit of those hosts. A call also skips a host that does not read the call's images (400 `model_no_image_input` when no host does) and a host that does not take its `reasoning_effort` (400 `reasoning_effort_not_offered`). A host whose own context window may be too small for the prompt and `max_tokens` is tried after the hosts that surely hold them. Absent: the model's chat default, within that cap. [min 1] - `temperature` (number) - `stream` (boolean): Answer as server-sent events (`ChatCompletionChunk`). Absent or null: no stream. A value that is not a boolean is a 400 (`stream must be true or false`). - `stream_options` (object): Accepted for compatibility; a stream always ends with its usage chunk. - `include_usage` (boolean) - `tools` (array of object): Functions the model may call, in OpenAI's shape; translated for Anthropic models. - `type` ("function", required) - `function` (object, required) - `name` (string, required) - `description` (string) - `parameters` (object): A JSON Schema; `{"type": "object"}` when left out. - `tool_choice` ("auto" | "none" | "required" | object): `auto` (the default), `none`, `required`, or one function by name (it must be in `tools`). `required` or a function on a model that does not take a forced choice is 400 `tool_choice_not_offered`, before anything is reserved. - `parallel_tool_calls` (boolean): `false`: at most one tool call per answer. - `reasoning_effort` (string): One of the model's `reasoning.efforts` (GET /v1/models). Absent: the provider's default. An effort the model does not offer is a 400 `reasoning_effort_not_offered` before anything is reserved; `error.nexus.offered` lists the model's efforts. - `response_format` (object): OpenAI's `response_format`, sent on as written when the model offers its `type` (`text`, `json_object` or `json_schema`). A type the model does not offer is a 400 `response_format_not_offered` before anything is reserved; `error.nexus.offered` lists the model's types. - `type` (string, required) ### Responses - `200` OK: the answer, or with `stream: true` its server-sent events (application/json, ChatCompletionResponse) - `id` (string) - `object` ("chat.completion") - `created` (integer) - `model` (string) - `choices` (array of object) - `index` (integer) - `message` (ChatMessage) - `role` ("system" | "developer" | "user" | "assistant" | "tool", required): `developer` is taken as `system`. Answers are always `assistant`. - `content` (string | array of object | null): The text, or OpenAI's content parts: `{type: "text", text}` (joined) and, in a person's message, `{type: "image_url", image_url: {url}}` with a `data:` URL (Gateway fetches no URLs). An assistant turn that only calls tools may leave it out or send null. Answers carry a string. - `tool_calls` (array of ToolCall): The tools an assistant turn called (in an answer: when `finish_reason` is `tool_calls`). - `id` (string, required) - `type` ("function", required) - `function` (object, required) - `name` (string, required) - `arguments` (string, required): A JSON object, as a string. - `tool_call_id` (string): A `tool` message: the call it answers. - `finish_reason` (string): Stop, length, or refusal when the provider declined to answer; its words are in nexus.refusal. - `usage` (object) - `prompt_tokens` (integer) - `completion_tokens` (integer) - `total_tokens` (integer) - `nexus` (object): What the call cost and who it was attributed to. - `cost_usd` (number) - `product` (string) - `capability` (string) - `provider` (string) - `funded_by` ("own_key" | "nexus_key" | "nexus_subsidy" | "nexus_credit" | "nexus_invoiced"): Who paid the provider. own_key: the organization's own key; nexus_key: Nexus's own key, for Nexus's own organizations; nexus_subsidy: a Nexus subsidy; nexus_credit: the organization's prepaid Nexus credits, charged the cost plus Nexus's rate; nexus_invoiced: an organization under contract, billed the cost plus Nexus's rate on its month's invoice. Unset on the mock provider - `refusal` (string): The provider's words when it declined to answer (a safety refusal); set exactly when finish_reason is "refusal". Billed as the provider billed it. - `router` (object): The auto router's pick, on an answer it routed or a chat session held. The answer also carries the header x-nexus-router with the version. Unset on every other answer. The pick's cost estimates stay on the spend record. - `version` (string, required): The router version that acted, e.g. auto-v0.0.1. - `class` ("light" | "standard" | "heavy"): The request's class. Unset on a held pick. - `reason` ("cheapest" | "below_floor" | "catalog_order"): Why the version chose its model. Unset on a held pick. - `held` (boolean, required): The chat session held its model, with no router run. - `default_model` (string): The model nexus/auto resolves to for the caller with no router. - `effort` (string): The reasoning effort the call ran at: the request's own reasoning_effort, else the one the router version picked. Unset when the call ran at the model's default. - `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `402` The call's maximum cost is more than the budget left (`budget_exceeded`; `subsidy_exhausted` for the Nexus subsidy, or `credit_exhausted` for the organization's prepaid credits), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. (application/json, Error & object) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `error` (object) - `nexus` (BudgetRefusal): The details (`error.nexus`) of a 402 `budget_exceeded` or `subsidy_exhausted`. Each money figure comes as its number (deprecated) and its exact decimal twin (`requestedUsd`, `requestedUsdDecimal`). A refusal below the person level names only what is left and what was asked, never a limit above the caller. `credit_exhausted` sends `remainingUsd` and `requestedUsd` as decimal strings already, without twins. - `level` ("organization" | "team" | "person" | "product"): The level whose limit refused the call (`budget_exceeded`) - `period` (string): The period the refusal counted in: `2026-10`, `2026-W44` or `2026-10-21` - `resetsAt` (string (date-time)): When the period ends (UTC) - `source` ("override" | "default"): Person level only: whether the limit was set for them or is the organization's default per person - `limitUsd` (number): Person level only: their monthly limit. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `spentUsd` (number): Person level only: what they spent this month. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number): Person level only: what their calls in flight hold. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `remainingUsd` (number): Every level, and `subsidy_exhausted`: what is left, never below 0. Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `requestedUsd` (number): What the call may cost at most, the amount it asked to hold. Deprecated: read `requestedUsdDecimal`, the exact decimal string (root rule 9). - `requestedUsdDecimal` (string): `requestedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `requestedUsd`. - `notified` (boolean): `budget_exceeded`: true once Gateway has told the refused person and the organization's owners and admins - `fundedBy` (string): `subsidy_exhausted`: who funds the subsidy (`nexus`) - `next` (array of string): `subsidy_exhausted`: what the caller can do next (`billing`, `own_key`) - `403` The caller may not do this: for example, the role does not have the permission (`role_required`), or the team named is not the caller's (`not_in_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Nothing matches. A path parameter outside its pattern is a 404 "no such endpoint", before the credential is checked. A team named that does not exist is `unknown_team`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `408` The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `413` The request body is over the operation's limit (`request_too_large`): 1,000,000 bytes, unless the operation says otherwise. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `422` The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `426` The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The provider failed the call. `upstream_auth`: it refused the provider key the call ran on (its 401), never your Nexus API key. `upstream_forbidden`: it refused this model for that key (its 403); the key may still serve other models. `upstream_billing`: the provider account behind that key is out of credit (its 402), never your Nexus budget. The message says whose key it was: your organization's own, Nexus's, or the Nexus credit's. Any other provider 5xx is a 502 with no code. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The provider's or the Gateway's own; every one may be retried. The provider's: it has no capacity now (its 529, or the 503 OpenAI documents as its overload), `upstream_overloaded`; retry after its `retry-after` when it sent one, or try another model. The Gateway's: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); it stopped before the call's first event (`gateway_stopping`, send the call again: it reaches a running Gateway); or its database is busy (`database_busy`: nothing was committed, retry shortly). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 400 | `model_not_supported` | 403 `model_not_allowed` (policy, naming the level and rule), 404 `model_not_found`, 400 `model_not_supported` (coming soon); never sent upstream or reserved, recorded as a refused call | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The call's maximum cost is more than the budget left (`budget_exceeded`; `subsidy_exhausted` for the Nexus subsidy, or `credit_exhausted` for the organization's prepaid credits), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | 403 `model_not_allowed` (policy, naming the level and rule), 404 `model_not_found`, 400 `model_not_supported` (coming soon); never sent upstream or reserved, recorded as a refused call | | 403 | `provider_key_required` | Any other caller with no key of its own gets 403 `provider_key_required`, never Nexus credit | | 404 | | Nothing matches. A path parameter outside its pattern is a 404 "no such endpoint", before the credential is checked. A team named that does not exist is `unknown_team`. | | 404 | `model_not_found` | 403 `model_not_allowed` (policy, naming the level and rule), 404 `model_not_found`, 400 `model_not_supported` (coming soon); never sent upstream or reserved, recorded as a refused call | | 408 | | The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). | | 409 | | The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 413 | | The request body is over the operation's limit (`request_too_large`): 1,000,000 bytes, unless the operation says otherwise. | | 422 | | The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 426 | | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | The provider failed the call. `upstream_auth`: it refused the provider key the call ran on (its 401), never your Nexus API key. `upstream_forbidden`: it refused this model for that key (its 403); the key may still serve other models. `upstream_billing`: the provider account behind that key is out of credit (its 402), never your Nexus budget. The message says whose key it was: your organization's own, Nexus's, or the Nexus credit's. Any other provider 5xx is a 502 with no code. | | 503 | | The provider's or the Gateway's own; every one may be retried. The provider's: it has no capacity now (its 529, or the 503 OpenAI documents as its overload), `upstream_overloaded`; retry after its `retry-after` when it sent one, or try another model. The Gateway's: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); it stopped before the call's first event (`gateway_stopping`, send the call again: it reaches a running Gateway); or its database is busy (`database_busy`: nothing was committed, retry shortly). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/chat/completions" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "model": "nexus/auto", "messages": [ { "role": "user", "content": "Hello" } ] }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.chatCompletion({ model: "nexus/auto", messages: [{ role: "user", content: "Hello" }] }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fcompletions) ## Spend `GET /v1/spend` Budget, spend and reservations, by product and capability, with recent calls. Owners and admins (`spend.read_all`) get the organization's figures. Everyone else gets their own calls and, in place of the organization's budget, spent and reserved, only what is left for them (`remainingUsd`): the least room of the organization, the caps on the team their call is charged to (`x-nexus-team`, else their default team) and their monthly limit, the figure the next 402 gives, with the `period` and `resetsAt` of the cap that binds it. Permission: `spend.read_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-team` | header | string | no | Members: the team (slug) the left-for-you figure is for, as for a call; you must be in it. Default: your default team. Owners and admins get the organization's figures whatever it says. | ### Responses - `200` OK (application/json, Spend) - `budgetUsd` (number): The organization's budget, a cap per budgetPeriod. Owners and admins only: a member gets none of budgetUsd, spentUsd, reservedUsd, budgetPeriod and periodSpentUsd. Deprecated: read `budgetUsdDecimal`, the exact decimal string (root rule 9). - `budgetUsdDecimal` (string): `budgetUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `budgetUsd`. - `spentUsd` (number): The organization's spend since it began. Owners and admins only. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number): Held by the organization's calls in flight. Owners and admins only. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `budgetPeriod` ("day" | "week" | "month"): Owners and admins only: the budget's period - `periodSpentUsd` (number): Owners and admins only: the spend of calls reserved in the budget's current period, what the budget counts. Deprecated: read `periodSpentUsdDecimal`, the exact decimal string (root rule 9). - `periodSpentUsdDecimal` (string): `periodSpentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `periodSpentUsd`. - `remainingUsd` (number): Owners and admins: what the organization's budget has left this period. Everyone else: what is left for them, the least room of the organization, their team's caps and their monthly limit, as the next 402 says it. Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `period` (string): Not owners and admins: the period of the cap that binds remainingUsd (`2026-10-17`, `2026-W43` or `2026-10`). For the organization's budget, its current period - `resetsAt` (string): When the binding cap's period ends and remainingUsd comes back; for owners and admins, when the budget's period ends - `scope` ("org" | "own"): `org`: the whole organization's calls (owners and admins); `own`: only the caller's - `byProduct` (array of object) - `product` (string) - `capability` (string) - `costUsd` (number): Deprecated: read `costUsdDecimal`, the exact decimal string (root rule 9). - `costUsdDecimal` (string): `costUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `costUsd`. - `calls` (integer) - `recent` (array of object): Recent calls. fundedBy says who paid the provider (own_key, nexus_key for Nexus's own organizations, nexus_subsidy, nexus_credit for the organization's prepaid credits, or nexus_invoiced for a contract's invoice); unset on refusals, typed decisions and calls from before it was recorded. A call a Nexus subsidy paid also has fundingOrg, the organization whose stored key paid it. A call Nexus paid the provider for (nexus_key or nexus_subsidy) also has markupBps, Nexus's rate on it in basis points (500 is 5%), as it was when the call settled; costUsd stays the provider's cost. A call a Nexus subsidy paid also has subsidyMarkupBps, the rate the subsidy was charged at: the subsidy spent costUsd plus that rate. It is unset on older calls, which spent costUsd alone. An Anthropic call also has inferenceGeo (us or global), where the provider said it ran; unset on other providers and on calls from before it was recorded. Each call also names the caller's key, never its secret: keyId (a token id `key_…`; a module's scoped key id `scoped://smk_…`, which POST /v1/auth/scoped-keys/revoke takes; an agent's link id `agl_…`, so a call of the agent differs from the person's own; `ui`; or a system caller's name) and keyKind (the audit log's actor kind: `api_key`, `cli`, `ui`, `module`, `service`, `sandbox`, `operator`, `agent` or `system`). Both are unset on calls from before they were recorded: an unknown key Each call's `costUsd`, and its `overspendPrevented.limitUsd` and `overUsd`, also come as exact decimal strings: `costUsdDecimal`, `limitUsdDecimal` and `overUsdDecimal`. The numbers are deprecated. - `subsidizedUsd` (number): Organizations with a Nexus subsidy: what calls the subsidy paid cost the subsidy, each at its provider cost plus Nexus's rate (in your scope: a member gets what it paid for their own calls). Deprecated: read `subsidizedUsdDecimal`, the exact decimal string (root rule 9). - `subsidizedUsdDecimal` (string): `subsidizedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `subsidizedUsd`. - `subsidy` (object): Owners and admins only: the organization's Nexus subsidy (a personal organization's starting credit), funded by Nexus, never the organization's own money. A member's answer has none of it - `grantedUsd` (number): Deprecated: read `grantedUsdDecimal`, the exact decimal string (root rule 9). - `grantedUsdDecimal` (string): `grantedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `grantedUsd`. - `spentUsd` (number): What settled calls cost the subsidy: each call's provider cost plus Nexus's rate, as for credits. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number): Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `remainingUsd` (number): Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `expiredUsd` (number): What was left of the free start when it expired, 30 days after its grant (pricing v2.0). Absent before. Deprecated: read `expiredUsdDecimal`, the exact decimal string (root rule 9). - `expiredUsdDecimal` (string): `expiredUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `expiredUsd`. - `fundedBy` ("nexus") - `usableForModelCalls` (boolean): Whether this Gateway pays a Nexus feature's model calls (chat sessions, module runs; never raw model access) of an organization with no key of its own from the subsidy (NEXUS_CREDIT_PROVIDER, and NEXUS_SUBSIDY_ORG's stored keys or a subsidy environment key) - `subsidiesPaid` (object): The funding organization (NEXUS_SUBSIDY_ORG), owners and admins: what its stored provider keys paid for other organizations' subsidized calls. Never part of its own spend, budget or limits - `usd` (number): Deprecated: read `usdDecimal`, the exact decimal string (root rule 9). - `usdDecimal` (string): `usd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `usd`. - `calls` (integer) - `organizations` (integer) - `credits` (object): Owners and admins: the organization's prepaid Nexus credits, its own money, never expiring, once it bought some. A Nexus feature's call spends them after the subsidy, at its provider cost plus `markupBps`. Decimal dollar strings. - `purchasedUsd` (string, required): Bought, over all time. - `spentUsd` (string, required): What settled calls cost the credits: each call's provider cost plus `markupBps`. - `reservedUsd` (string, required): Held by calls in progress. - `remainingUsd` (string, required): Bought, less spent, held and reversed. Below zero after a refund or a lost dispute took back credit that was already spent: then Nexus pays for no call (the free start, credits or the card after the fact) until a purchase pays it back. - `reversedUsd` (string): What refunds, lost disputes and operators took back, and what an open dispute holds of its purchase until it closes. A refund that fails gives its credit back. Only while something is taken back. - `markupBps` (integer, required): Nexus's rate in basis points (500 is 5%). - `payAfterTheFact` (boolean): Owners and admins (pricing v2.0): the organization pays after the fact, so calls the free start and the credits cannot pay still run on its card. - `nexusPays` (object): Every member: whether Nexus can pay for the organization's next model call, and why not. It reads the payers in the ledger's order: a contract, the free start, other Nexus grants, the credits, then the card when it pays after the fact; an unpaid invoice past its grace stops all of them. It answers for a small call to a model the free start pays for, so a pricier model or a larger call can still be refused. Absent where Nexus pays for no model calls on this Gateway. - `pays` (boolean, required) - `payer` ("contract" | "free_start" | "subsidy" | "credits" | "card" | null, required): Who pays the next call; null when `pays` is false - `reason` ("free_start_used_up" | "free_start_expired" | "credits_out" | "usage_limit_reached" | "charge_failed" | "card_needs_confirming" | "card_disputed" | "past_due" | "billing_off" | "charge_processing" | null, required): Why Nexus cannot pay; null when `pays` is true. `billing_off`: nothing was set up to pay (no free start, no credits, and the card does not pay after the fact). `card_disputed`: a payment on the card was disputed, and only another card pays. `past_due` comes first, also under a contract. A balance under a cent does not count as paying. - `changesAt` (string (date-time) | null, required): The next time this changes by itself: the free start's deadline while it pays, or the next month while the usage limit is reached; else null - `limitUsedPercent` (integer | null): While the card pays: how much of this UTC month's usage limit it paid, in whole percent, rounded down. Null while another payer pays, or nobody, and always null for a caller who sees only their own spend: only billing managers see it. Absent from an older Gateway. [min 0; max 100] - `403` A member who names a team they are not in with `x-nexus-team` (`not_in_team`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` A member names, with `x-nexus-team`, a team that does not exist in the organization (`unknown_team`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `period` | The least room of the organization, the caps on the team their call is charged to (`x-nexus-team`, else their default team) and their monthly limit, the figure the next 402 gives, with the `period` and `resetsAt` of the cap that binds it | | 403 | `role_required` | Your role does not have this permission | | 404 | | A member names, with `x-nexus-team`, a team that does not exist in the organization (`unknown_team`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/spend" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.spend(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fspend) ## List spend calls `GET /v1/spend/calls` One page of the organization's model calls, newest first, with the filters below (owners and admins). People and teams by id only. A bad filter or a range over 366 days is a 400. One request reads at most 10,000 calls, so a narrow filter can answer a short page, even an empty one, with a `nextCursor` that resumes the scan. Permission: `spend.read_all` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `from` | query | string (date) | no | The first UTC day, YYYY-MM-DD; default 29 days before `to` | | `to` | query | string (date) | no | The last UTC day, YYYY-MM-DD, included; default today. A range covers at most 366 days | | `team` | query | string | no | A team slug or id: that team and every team under it; `unassigned` for calls with no team | | `person` | query | string | no | A person's user id | | `model` | query | string | no | A model, as the rows name it; `-` for the calls with none (released calls), as Analytics groups them | | `provider` | query | string | no | A provider, as the rows name it; `-` for the calls with none (refused and released calls), as Analytics groups them | | `product` | query | string | no | A product (`agents`) or a product and capability (`intelligence/wiki`): Analytics' group key | | `status` | query | string | no | A comma-separated set of `settled`, `failed`, `refused` and `released`; default all four | | `session` | query | string | no | An agent session id or a chat session id: the calls attributed to it | | `limit` | query | integer | no | Calls per page, 1 to 500 (default 50) | | `cursor` | query | string | no | `nextCursor` from the previous page. It is bound to the organization, the caller and the query: anywhere else it is a 400 `invalid_cursor` | ### Responses - `200` OK (application/json, SpendCallPage) - `from` (string (date), required): The first UTC day the page covers. - `to` (string (date), required): The last UTC day the page covers, included. - `calls` (array of SpendCall, required) - `id` (string, required): The call's record id. - `at` (string (date-time), required): When the ledger recorded the call. - `status` ("settled" | "failed" | "refused" | "released", required): `settled`, `failed`, `refused` (Nexus Gateway refused it, and no money moved) or `released` (its reservation closed without a settle, by a job's cleanup or the ledger's age sweep). - `model` (string | null, required): The model the call asked for; null for a released call, whose model the ledger did not record. - `provider` (string | null, required): The provider that served it; null for a refused or released call, which no provider served. - `product` (string, required): The product it is metered to: `core` for direct API calls, `agents`, `chat` or a module. - `capability` (string | null, required): The module's capability, such as `wiki`. - `userId` (string | null, required): The person who made the call. - `teamId` (string | null, required): The team the call was attributed to; null for none (`unassigned`). - `agentSessionId` (string | null, required): The coding-agent session the call belongs to. - `chatSessionId` (string | null, required): The chat session the call belongs to (metadata only, never its content). - `inputTokens` (integer | null, required): Prompt tokens, as the ledger charged them; null for a released call, whose tokens nobody reported. - `outputTokens` (integer | null, required): Completion tokens, as the ledger charged them; null for a released call. - `costUsd` (string, required): What the call was charged. [pattern ^-?[0-9]+\.[0-9]{6}$] - `reservedUsd` (string | null, required): What Nexus Gateway held for the call before it ran. [pattern ^-?[0-9]+\.[0-9]{6}$] - `reason` (string | null, required): The ledger's note on the call, with any secret redacted: why it was refused, failed or released, or what it charged past its hold. - `overspendLevel` ("organization" | "team" | "person" | "product" | null, required): The spend limit that refused the call. - `overspendLimitUsd` (string | null, required): The person's limit, when a person's limit refused the call. Null for a team's cap and the organization's budget: the ledger does not keep their limit on the call. [pattern ^-?[0-9]+\.[0-9]{6}$] - `overspendAmountUsd` (string | null, required): What the refused call asked to hold. [pattern ^-?[0-9]+\.[0-9]{6}$] - `overspendOverUsd` (string | null, required): How far over the limit it would have gone. [pattern ^-?[0-9]+\.[0-9]{6}$] - `overspendPeriod` (string | null, required): The limit's period (`2026-10`, `2026-W43` or `2026-10-23`). - `fundedBy` (string | null, required): `nexus_subsidy` for a call a Nexus subsidy paid, `nexus_credit` for one the organization's prepaid credits paid; null for the organization's own. - `nextCursor` (string | null, required): Pass as `cursor` for the next, older page; null on the last page. - `400` A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, a `limit` outside 1 to 500 or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Only owners and admins list the organization's calls (`role_required`): a member without `spend.read_all` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, a `limit` outside 1 to 500 or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/spend/calls" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.spendCalls({ from: "2026-10-01", status: "failed,refused" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fspend%2Fcalls) ## Get spend call `GET /v1/spend/calls/{id}` One of the organization's model calls, as its row in the files: what was reserved, what was charged and why it was refused (owners and admins). Another organization's call reads as missing: 404 `unknown_call`. Permission: `spend.read_all` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The call's record id | ### Responses - `200` OK (application/json, SpendCall) - `id` (string, required): The call's record id. - `at` (string (date-time), required): When the ledger recorded the call. - `status` ("settled" | "failed" | "refused" | "released", required): `settled`, `failed`, `refused` (Nexus Gateway refused it, and no money moved) or `released` (its reservation closed without a settle, by a job's cleanup or the ledger's age sweep). - `model` (string | null, required): The model the call asked for; null for a released call, whose model the ledger did not record. - `provider` (string | null, required): The provider that served it; null for a refused or released call, which no provider served. - `product` (string, required): The product it is metered to: `core` for direct API calls, `agents`, `chat` or a module. - `capability` (string | null, required): The module's capability, such as `wiki`. - `userId` (string | null, required): The person who made the call. - `teamId` (string | null, required): The team the call was attributed to; null for none (`unassigned`). - `agentSessionId` (string | null, required): The coding-agent session the call belongs to. - `chatSessionId` (string | null, required): The chat session the call belongs to (metadata only, never its content). - `inputTokens` (integer | null, required): Prompt tokens, as the ledger charged them; null for a released call, whose tokens nobody reported. - `outputTokens` (integer | null, required): Completion tokens, as the ledger charged them; null for a released call. - `costUsd` (string, required): What the call was charged. [pattern ^-?[0-9]+\.[0-9]{6}$] - `reservedUsd` (string | null, required): What Nexus Gateway held for the call before it ran. [pattern ^-?[0-9]+\.[0-9]{6}$] - `reason` (string | null, required): The ledger's note on the call, with any secret redacted: why it was refused, failed or released, or what it charged past its hold. - `overspendLevel` ("organization" | "team" | "person" | "product" | null, required): The spend limit that refused the call. - `overspendLimitUsd` (string | null, required): The person's limit, when a person's limit refused the call. Null for a team's cap and the organization's budget: the ledger does not keep their limit on the call. [pattern ^-?[0-9]+\.[0-9]{6}$] - `overspendAmountUsd` (string | null, required): What the refused call asked to hold. [pattern ^-?[0-9]+\.[0-9]{6}$] - `overspendOverUsd` (string | null, required): How far over the limit it would have gone. [pattern ^-?[0-9]+\.[0-9]{6}$] - `overspendPeriod` (string | null, required): The limit's period (`2026-10`, `2026-W43` or `2026-10-23`). - `fundedBy` (string | null, required): `nexus_subsidy` for a call a Nexus subsidy paid, `nexus_credit` for one the organization's prepaid credits paid; null for the organization's own. - `403` Only owners and admins read the organization's calls (`role_required`): a member without `spend.read_all` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No call with this id in the caller's organization (`unknown_call`); another organization's call reads as missing (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No call with this id in the caller's organization (`unknown_call`); another organization's call reads as missing | | 404 | `unknown_call` | 404 `unknown_call` | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/spend/calls/" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.spendCall(""); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fspend%2Fcalls%2F%7Bid%7D) ## Export spend calls CSV `GET /v1/spend/calls/export.csv` Every model call of the organization that matches the filters, newest first, as CSV (owners and admins): the rows `listSpendCalls` pages through, with its filters. A series of files reads the calls written up to the newest one when its first file started. At most 100,000 rows a file: past that the file stops, and its manifest says `complete: false` and gives `nextCursor`. Each export is an audit event (`observability.exported`) with the file's manifest, never its rows. An organization runs at most 60 exports an hour: the 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's). A bad filter is a 400 before any row. Permission: `spend.export` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `from` | query | string (date) | no | The first UTC day, YYYY-MM-DD; default 29 days before `to` | | `to` | query | string (date) | no | The last UTC day, YYYY-MM-DD, included; default today. A range covers at most 366 days | | `team` | query | string | no | A team slug or id: that team and every team under it; `unassigned` for calls with no team | | `person` | query | string | no | A person's user id | | `model` | query | string | no | A model, as the rows name it; `-` for the calls with none (released calls), as Analytics groups them | | `provider` | query | string | no | A provider, as the rows name it; `-` for the calls with none (refused and released calls), as Analytics groups them | | `product` | query | string | no | A product (`agents`) or a product and capability (`intelligence/wiki`): Analytics' group key | | `status` | query | string | no | A comma-separated set of `settled`, `failed`, `refused` and `released`; default all four | | `session` | query | string | no | An agent session id or a chat session id: the calls attributed to it | | `cursor` | query | string | no | A cut file's `manifest.nextCursor`: the next file of the same query. A manifest's `watermark` also works: it starts the same series again. It is bound to the organization, the caller and the query: anywhere else it is a 400 `invalid_cursor` | ### Responses - `200` CSV with a header row: one column per field of `SpendCall`, in its order. (text/csv, string) - `400` A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Only owners and admins export the organization's calls (`role_required`): a member without `spend.export` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `export_rate_limited` | The 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/spend/calls/export.csv" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.spendCallsExport("csv", { from: "2026-10-01" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fspend%2Fcalls%2Fexport.csv) ## Export spend calls JSON Lines `GET /v1/spend/calls/export.jsonl` Every model call of the organization that matches the filters, newest first, as JSON Lines (owners and admins): the rows `listSpendCalls` pages through, with its filters. A series of files reads the calls written up to the newest one when its first file started. At most 100,000 rows a file: past that the file stops, and its manifest says `complete: false` and gives `nextCursor`. Each export is an audit event (`observability.exported`) with the file's manifest, never its rows. An organization runs at most 60 exports an hour: the 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's). A bad filter is a 400 before any row. Permission: `spend.export` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `from` | query | string (date) | no | The first UTC day, YYYY-MM-DD; default 29 days before `to` | | `to` | query | string (date) | no | The last UTC day, YYYY-MM-DD, included; default today. A range covers at most 366 days | | `team` | query | string | no | A team slug or id: that team and every team under it; `unassigned` for calls with no team | | `person` | query | string | no | A person's user id | | `model` | query | string | no | A model, as the rows name it; `-` for the calls with none (released calls), as Analytics groups them | | `provider` | query | string | no | A provider, as the rows name it; `-` for the calls with none (refused and released calls), as Analytics groups them | | `product` | query | string | no | A product (`agents`) or a product and capability (`intelligence/wiki`): Analytics' group key | | `status` | query | string | no | A comma-separated set of `settled`, `failed`, `refused` and `released`; default all four | | `session` | query | string | no | An agent session id or a chat session id: the calls attributed to it | | `cursor` | query | string | no | A cut file's `manifest.nextCursor`: the next file of the same query. A manifest's `watermark` also works: it starts the same series again. It is bound to the organization, the caller and the query: anywhere else it is a 400 `invalid_cursor` | ### Responses - `200` JSON Lines: one `SpendCall` per line, then one line `{"manifest": ExportManifest}`. (application/jsonl, string) - `400` A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Only owners and admins export the organization's calls (`role_required`): a member without `spend.export` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A filter Nexus cannot read: a date not YYYY-MM-DD, `from` after `to` or a range past 366 days, or an unknown `status` (`invalid_request`), a team that does not exist (`unknown_team`), or a cursor issued for another caller or query (`invalid_cursor`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `export_rate_limited` | The 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/spend/calls/export.jsonl" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.spendCallsExport("jsonl", { from: "2026-10-01" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fspend%2Fcalls%2Fexport.jsonl) ## Modules `GET /v1/modules` Manifests of the registered capability modules. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, object) - `modules` (array of ModuleManifest) - `product` (object) - `slug` (string) - `name` (string) - `capability` (object) - `slug` (string) - `name` (string) - `description` (string) - `verbs` (array of "connect" | "run" | "report" | "apply" | "watch") - `inputs` (array of object) - `panel` (object) - `kind` (string) - `operations` (object) - `unavailable` (array of object) - `url` (string) - `error` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/modules" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.modules(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fmodules) ## Openapi `GET /v1/openapi.json` This document, merged with every registered module's operations. Permission: `public` (Anyone, signed in or not). ### Responses - `200` OpenAPI 3.1 document ### Errors | Status | Code | When | | --- | --- | --- | ### Example ```sh curl "$NEXUS_URL/v1/openapi.json" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.openapi(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fopenapi.json) ## Healthz `GET /healthz` Liveness: the process answers. It reads no database, and it stays 200 while Gateway drains. Permission: `public` (Anyone, signed in or not). ### Responses - `200` The process is alive. (application/json, object) - `status` ("ok", required) - `implementation` ("rust", required): The gateway that answered. - `version` (string, required): The Factory release this binary is (`info.version` of this document). - `edition` ("licensed" | "open", required): The build: `licensed`, or `open` for the open gateway (no licensed code; those routes answer 501 `licensed`). - `provider` ("live" | "mock", required): `NEXUS_PROVIDER`: `live` calls the providers; `mock` answers every chat and module model call with canned text. - `agentProvider` ("live" | "mock", required): `NEXUS_AGENT_PROVIDER`: the same for the agent gateway's pass-through. - `catalogFingerprint` (string | null, required): The SHA-256 of the catalog file this process loaded (`NEXUS_CATALOG_FILE`), in hex, as `sha256sum` prints it; null when no file is set. Processes with the same value run the same catalog. - `simSeed` (string): Local simulations only: the installed `NEXUS_SIM_SEED`, as a string. Absent everywhere else. ### Errors | Status | Code | When | | --- | --- | --- | ### Example ```sh curl "$NEXUS_URL/healthz" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fhealthz) ## Readyz `GET /readyz` Readiness: whether to send this process traffic (`ready`, `degraded`, `draining` or `unavailable`). Permission: `public` (Anyone, signed in or not). ### Responses - `200` Send traffic: `ready`, or `degraded` with its reasons. (application/json, object | object) - `503` Send no traffic: Gateway is stopping (`draining`), or the database ping failed (`database`) or did not answer in time (`database_timeout`). (application/json, object | object) ### Errors | Status | Code | When | | --- | --- | --- | | 503 | | Send no traffic: Gateway is stopping (`draining`), or the database ping failed (`database`) or did not answer in time (`database_timeout`). | ### Example ```sh curl "$NEXUS_URL/readyz" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Freadyz) ## Cli version `GET /cli/version` The `nexus` CLI this Gateway serves: its version, SHA-256, download URL and the oldest CLI Gateway talks to. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `target` | query | string | no | A platform, `-`: lowercase letters and digits, 16 at most each. | ### Responses - `200` The build to install. `target` is present only when the request named one. (application/json, object) - `version` (string, required) - `sha256` (string, required) [pattern ^[0-9a-f]{64}$] - `url` (string (uri), required): Where to download it, on this Gateway's public URL. - `minimum` (string, required): `NEXUS_CLI_MINIMUM`: an older CLI gets 426 `cli_too_old` on `/v1`. - `target` (string): The platform asked for. - `404` `cli_target_unavailable`: this Gateway publishes no native build for `target`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `405` Not GET or HEAD. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cli_bundle_unavailable` (`server_error`): no `target`, and no CLI bundle is built on this Gateway. Also `overloaded` or `draining`, as every route outside the health checks. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 404 | | `cli_target_unavailable`: this Gateway publishes no native build for `target`. | | 405 | | Not GET or HEAD. | | 503 | | `cli_bundle_unavailable` (`server_error`): no `target`, and no CLI bundle is built on this Gateway. Also `overloaded` or `draining`, as every route outside the health checks. | ### Example ```sh curl "$NEXUS_URL/cli/version" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fcli%2Fversion) ## Stripe webhook `POST /v1/stripe/webhook` Stripe's webhook, signed by Stripe with STRIPE_WEBHOOK_SECRET (the Stripe-Signature header, t=,v1=; refused more than five minutes from now). Gateway keeps the verified event's identity once in an inbox and nothing else: a repeated delivery changes nothing, and an event whose livemode differs from the key's is kept as ignored. After it answers, Gateway reads the event's object again from Stripe and updates the organization's card on file (`GET /v1/billing`). A signed event Gateway cannot keep (a thin event, no id) is a 200 with `stored: false`, so Stripe does not retry it. An event that stopped (`unmatched`, or failed on its last try) runs again when Stripe sends it again, with all its tries. 400 for a body that is not JSON; 401 `invalid_signature` for a bad or old signature; 413 over 1 MB; 503 `not_configured` until STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are both set and well formed. The 503's message says only that Stripe is not configured; Gateway logs the reason at start. Permission: `public` (Anyone, signed in or not). ### Responses - `200` OK (application/json, object) - `ok` (boolean, required) - `event` (string | null, required): The event's type. Null when the signed event has no string `type` (or the body is not a JSON object); Stripe's own events always have one. - `stored` (boolean, required): True when this delivery added a row to process. False for a repeat that changes nothing. False too for a resend of a stopped (`dead`) or `unmatched` event: no row is added, but the event runs again from its first try. False for an event whose livemode differs from the key's: it is kept as `ignored` and never processed. - `400` Not JSON (`invalid_request_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` The signature is bad or too old (`invalid_signature`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `413` Over 1 MB (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | Not JSON (`invalid_request_error`) | | 401 | `invalid_signature` | 400 for a body that is not JSON; 401 `invalid_signature` for a bad or old signature; 413 over 1 MB; 503 `not_configured` until STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are both set and well formed | | 413 | | Over 1 MB | | 503 | | Stripe is not configured (`not_configured`) | | 503 | `not_configured` | 400 for a body that is not JSON; 401 `invalid_signature` for a bad or old signature; 413 over 1 MB; 503 `not_configured` until STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are both set and well formed | ### Example ```sh curl -X POST "$NEXUS_URL/v1/stripe/webhook" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fstripe%2Fwebhook) ## Search `GET /v1/search` Search what you may read, grouped by type and ranked: your own chat sessions (titles and message text), artifacts shared with or by you, people, teams, models and model policies. Permission: `search.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `q` | query | string | yes | What to search for, 1 to 200 characters. Words match as prefixes (`depl` finds deploy) | | `types` | query | string | no | Comma-separated: chats, artifacts, people, teams, models (default: all you may read). `actions` and `pages` are accepted and ignored: the palette answers them itself | | `limit` | query | integer | no | Results per group, 1 to 20 (default 5) | ### Responses - `200` OK (application/json, SearchResponse) - `query` (string, required) - `types` (array of string, required): The types searched: those asked for that your role may read - `groups` (array of SearchGroup, required): Groups with results, best first - `type` (string, required) - `label` (string, required) - `results` (array of SearchResult, required) - `type` ("chats" | "artifacts" | "people" | "teams" | "models", required) - `entity` ("session" | "artifact" | "member" | "invitation" | "team" | "model" | "policy", required) - `id` (string, required) - `title` (string, required) - `titleMatches` (array of array of integer, required): Ranges of `title` that matched (UTF-16) - `subtitle` (string) - `snippet` (SearchSnippet) - `text` (string, required): An excerpt; `…` where cut - `matches` (array of array of integer, required): [start, end) ranges of `text` that matched, in UTF-16 code units - `url` (string, required): Nexus UI's page for it, under the organization's slug: /app//sessions/ (a chat message match ends in #m-) - `score` (number, required) [min 0; max 1] - `messageId` (string): Chats: the message that matched - `more` (boolean, required): More matched than `limit` - `tookMs` (number, required): The server's time for the search - `400` A query parameter is not valid (`invalid_search`): `q` empty or over 200 characters, an unknown type in `types`, or `limit` not 1 to 20. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `search.use` (`role_required`: a service account, a sandbox, or an agent not granted it), or the caller is not a person, such as a module key (`person_required`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A query parameter is not valid (`invalid_search`): `q` empty or over 200 characters, an unknown type in `types`, or `limit` not 1 to 20. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/search?q=%3Cq%3E" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fsearch) ## Decisions `POST /v1/decisions` Typed decisions: a batch of requests to a decision model (TypeSafe's Jev), each a `state` and its `questions`, answered with typed judgments and probabilities, never text. Metered as one model call: one model policy decision on the `decisions` surface, one reservation of the batch's maximum cost, one settlement on the summed reported input tokens, one spend record. Only decision models serve it, and `nexus/auto` does not resolve here. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-team` | header | string | no | The team (slug) this batch's spend goes to; you must be in it. Default: your default team. | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `model` (string, required): A decision model: `typesafe/jev` - `requests` (array of object, required) [at most 100 items] - `state` (string | object | array of any, required): What the questions are about: a string, an object or an array - `questions` (object, required): `{ : { type, instructions, criteria } }`, passed through: `choice` (criteria: 1 to 255 options), `score` (an ordered list of 1 to 10 levels), `noul` (a yes/no probability; criteria optional) - `team` (string): The team (slug), as `x-nexus-team` ### Responses - `200` OK (application/json, DecisionsResponse) - `model` (string, required): The canonical model that answered - `results` (array of object | object, required): One per request, in order - `nexus` (object, required) - `cost_usd` (number, required): What the batch cost the organization - `input_tokens` (integer, required): The input tokens charged, summed - `notes` (array of string): What the caller should know about the answer; absent when there is none. When the batch's settlement failed, a note says the charge is not confirmed: cost_usd is then the Gateway's computed charge, not a ledger record. - `402` The organization has nothing to pay the batch with (`subsidy_exhausted`, the shape a model call returns), the batch's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. (application/json, Error & object) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `error` (object) - `nexus` (BudgetRefusal): The details (`error.nexus`) of a 402 `budget_exceeded` or `subsidy_exhausted`. Each money figure comes as its number (deprecated) and its exact decimal twin (`requestedUsd`, `requestedUsdDecimal`). A refusal below the person level names only what is left and what was asked, never a limit above the caller. `credit_exhausted` sends `remainingUsd` and `requestedUsd` as decimal strings already, without twins. - `level` ("organization" | "team" | "person" | "product"): The level whose limit refused the call (`budget_exceeded`) - `period` (string): The period the refusal counted in: `2026-10`, `2026-W44` or `2026-10-21` - `resetsAt` (string (date-time)): When the period ends (UTC) - `source` ("override" | "default"): Person level only: whether the limit was set for them or is the organization's default per person - `limitUsd` (number): Person level only: their monthly limit. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `spentUsd` (number): Person level only: what they spent this month. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number): Person level only: what their calls in flight hold. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `remainingUsd` (number): Every level, and `subsidy_exhausted`: what is left, never below 0. Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `requestedUsd` (number): What the call may cost at most, the amount it asked to hold. Deprecated: read `requestedUsdDecimal`, the exact decimal string (root rule 9). - `requestedUsdDecimal` (string): `requestedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `requestedUsd`. - `notified` (boolean): `budget_exceeded`: true once Gateway has told the refused person and the organization's owners and admins - `fundedBy` (string): `subsidy_exhausted`: who funds the subsidy (`nexus`) - `next` (array of string): `subsidy_exhausted`: what the caller can do next (`billing`, `own_key`) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The organization has nothing to pay the batch with (`subsidy_exhausted`, the shape a model call returns), the batch's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. | | 403 | `role_required` | Your role does not have this permission | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/decisions" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "model": "", "requests": [ { "state": "…", "questions": {} } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdecisions) ## List notifications `GET /v1/notifications` Your inbox in this organization: items not yet done, newest first, 50 a page. Permission: `notifications.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `cursor` | query | string | no | A `nextCursor` this list returned | | `unread` | query | boolean | no | Only items not yet read | | `group` | query | "my_sessions" \| "usage_and_billing" \| "requests_and_approvals" \| "automations_and_integrations" \| "account_and_security" | no | Only this group's kinds | ### Responses - `200` OK (application/json, NotificationPage) - `items` (array of NotificationItem, required) - `id` (string, required): `ntf_…` - `kind` (string, required): The kind's stable name, as GET /v1/notifications/kinds lists it - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required) - `subjectText` (string, required): The kind's fixed text - `title` (string): A month report's summary, from its figures only: the month and the total. Absent for other kinds - `detail` (string): A month report's second line, from its figures only: the calls. Absent for other kinds - `subject` (NotificationSubject, required) - `type` ("organization" | "team" | "user" | "artifact", required) - `id` (string, required) - `sources` (array of NotificationSource, required) [at most 20 items] - `count` (integer, required): The events this item collapses; it can pass the 20 sources kept [min 1] - `readAt` (string (date-time)) - `doneAt` (string (date-time)) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `nextCursor` (string): Pass as `cursor` for the next page; absent on the last - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/notifications" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fnotifications) ## Read notification `POST /v1/notifications/{id}/read` Mark your item read. Not yours, or the audience rule no longer gives it to you: 404. Permission: `notifications.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The item's id (`ntf_…`) | ### Responses - `200` OK (application/json, NotificationItem) - `id` (string, required): `ntf_…` - `kind` (string, required): The kind's stable name, as GET /v1/notifications/kinds lists it - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required) - `subjectText` (string, required): The kind's fixed text - `title` (string): A month report's summary, from its figures only: the month and the total. Absent for other kinds - `detail` (string): A month report's second line, from its figures only: the calls. Absent for other kinds - `subject` (NotificationSubject, required) - `type` ("organization" | "team" | "user" | "artifact", required) - `id` (string, required) - `sources` (array of NotificationSource, required) [at most 20 items] - `count` (integer, required): The events this item collapses; it can pass the 20 sources kept [min 1] - `readAt` (string (date-time)) - `doneAt` (string (date-time)) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/notifications//read" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fnotifications%2F%7Bid%7D%2Fread) ## Done notification `POST /v1/notifications/{id}/done` Mark your item done (and read): it leaves the list. Not yours, or the audience rule no longer gives it to you: 404. Permission: `notifications.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The item's id (`ntf_…`) | ### Responses - `200` OK (application/json, NotificationItem) - `id` (string, required): `ntf_…` - `kind` (string, required): The kind's stable name, as GET /v1/notifications/kinds lists it - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required) - `subjectText` (string, required): The kind's fixed text - `title` (string): A month report's summary, from its figures only: the month and the total. Absent for other kinds - `detail` (string): A month report's second line, from its figures only: the calls. Absent for other kinds - `subject` (NotificationSubject, required) - `type` ("organization" | "team" | "user" | "artifact", required) - `id` (string, required) - `sources` (array of NotificationSource, required) [at most 20 items] - `count` (integer, required): The events this item collapses; it can pass the 20 sources kept [min 1] - `readAt` (string (date-time)) - `doneAt` (string (date-time)) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/notifications//done" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fnotifications%2F%7Bid%7D%2Fdone) ## List notification kinds `GET /v1/notifications/kinds` The notification catalogue: each kind's name, group, fixed text, whether it is required, and its default channels. Permission: `notifications.use` (Every member). ### Responses - `200` OK (application/json, NotificationKinds) - `kinds` (array of NotificationKind, required) - `name` (string, required) - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required) - `subjectText` (string, required) - `required` (boolean, required): A required kind can move between channels but never be muted - `defaults` (array of "inbox" | "email" | "push", required) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/notifications/kinds" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fnotifications%2Fkinds) ## Get growth activation `GET /v1/growth/activation` When your organization first reached each value, computed on read (Growth Capabilities): activation through Gateway (the first agent session), through Nexus Wiki (the first Wiki run on a repository the organization links now; a repository unlinked since no longer counts), and the first settled model call, each with its minutes after sign-up. `exact` is false when older records were pruned or not listed, so the true first may be earlier. The Wiki row reads the Wiki module; when it is missing (`wiki_not_configured`) or fails (`wiki_unavailable`), that row carries `error` and the answer stays 200. Nothing here writes, and no person is named. Permission: `growth.read` (Owner, Admin). ### Responses - `200` OK (application/json, GrowthActivation) - `tenantId` (string, required) - `mark` ("staff" | "test" | "demo" | null, required): The organization's mark; null for a customer's. A figure that leaves the organization counts a marked one apart - `tenantZero` (boolean, required): Whether the organization is marked staff: Nexus's own, where C1 is measured. A figure that leaves it counts it apart - `signedUpAt` (string (date-time), required): The organization's creation: every `minutesAfterSignup` counts from it - `activated` (FirstValue, required): Activated by either definition: the earlier of `gateway` and `wiki`. Exact only when both are; carries the Wiki's `error`, since an unknown Wiki run may be the earlier - `at` (string (date-time) | null, required): When the organization first reached it; null when it has not, or when `error` says it could not be read - `minutesAfterSignup` (integer | null, required): Whole minutes from `signedUpAt` to `at`; 0 for a value recorded before the sign-up - `exact` (boolean, required): False when older records were pruned or not listed, so the true first may be earlier than `at` - `error` (string | null, required): `wiki_not_configured` or `wiki_unavailable`: why the value could not be read; the rest of the answer stands - `gateway` (FirstValue, required): Activated: Gateway. The first agent session through nexus claude or nexus codex - `at` (string (date-time) | null, required): When the organization first reached it; null when it has not, or when `error` says it could not be read - `minutesAfterSignup` (integer | null, required): Whole minutes from `signedUpAt` to `at`; 0 for a value recorded before the sign-up - `exact` (boolean, required): False when older records were pruned or not listed, so the true first may be earlier than `at` - `error` (string | null, required): `wiki_not_configured` or `wiki_unavailable`: why the value could not be read; the rest of the answer stands - `wiki` (FirstValue, required): Activated: Wiki. The first Nexus Wiki run - `at` (string (date-time) | null, required): When the organization first reached it; null when it has not, or when `error` says it could not be read - `minutesAfterSignup` (integer | null, required): Whole minutes from `signedUpAt` to `at`; 0 for a value recorded before the sign-up - `exact` (boolean, required): False when older records were pruned or not listed, so the true first may be earlier than `at` - `error` (string | null, required): `wiki_not_configured` or `wiki_unavailable`: why the value could not be read; the rest of the answer stands - `firstSettledCall` (FirstValue, required): The first model call that settled; refused and failed calls do not count - `at` (string (date-time) | null, required): When the organization first reached it; null when it has not, or when `error` says it could not be read - `minutesAfterSignup` (integer | null, required): Whole minutes from `signedUpAt` to `at`; 0 for a value recorded before the sign-up - `exact` (boolean, required): False when older records were pruned or not listed, so the true first may be earlier than `at` - `error` (string | null, required): `wiki_not_configured` or `wiki_unavailable`: why the value could not be read; the rest of the answer stands - `403` Not an owner or admin (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/growth/activation" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fgrowth%2Factivation) ## Get growth member paths `GET /v1/growth/paths` How far your organization's members got on the path to first value, computed on read (Growth Capabilities): per step (joined, signed in on the CLI, first key, first agent session, first settled call), how many reached it, how many stopped just before it, and how long they waited from each member's previous step reached (shown from five waits, so no one person's wait shows). `stall` is the step the most members stopped just before. Counts only: no person is named. `exact` is false when older records were pruned or not read. Permission: `growth.read` (Owner, Admin). ### Responses - `200` OK (application/json, GrowthMemberPaths) - `tenantId` (string, required) - `mark` ("staff" | "test" | "demo" | null, required): The organization's mark, as in GrowthActivation - `tenantZero` (boolean, required): Whether the organization is marked staff, as in GrowthActivation - `members` (integer, required): The organization's members now with no mark; a removed member is not counted - `markedMembers` (integer, required): Its members marked staff, test or demo; no step counts them. At an organization marked staff, staff stay in members - `steps` (array of PathStep, required): Every step, over the members with no mark, in order - `step` ("joined" | "cli_signed_in" | "first_key" | "first_agent_session" | "first_settled_call", required) - `reached` (integer, required): Members who reached it - `waiting` (integer, required): Members whose furthest step is the one before it: they stopped there - `waitMinutes` (WaitMinutes | null, required): Whole minutes from each member's previous step reached to this one, never below 0; null for joined, and below five waits, so no one person's wait shows - `exact` (boolean, required): False when older records were pruned or not read, so a member may have reached it earlier, or at all - `stall` ("joined" | "cli_signed_in" | "first_key" | "first_agent_session" | "first_settled_call" | null, required): The step the most members stopped just before (the earlier one on a tie); null when no one stopped short - `403` Not an owner or admin (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/growth/paths" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fgrowth%2Fpaths) ## List referrals `GET /v1/referrals` Your referral code and the people whose sign-up carried it, oldest first, each with when they joined and their email masked. The code is made on the first read: ten random characters of lowercase base 32, with no name in it, and it never changes after. A code made earlier from your name gets a random one on its next read, and the old code still works. It is a person's, whichever organization you call from. The people always page: the first 100 without `limit` or `cursor`. Permission: `referrals.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `limit` | query | integer | no | People per page, 1 to 500 (default 100). | | `cursor` | query | string | no | NextCursor from the previous page. A cursor whose person left the list answers 400 `invalid_cursor`. | ### Responses - `200` OK (application/json, ReferralList) - `code` (string, required): Your referral code: ten random characters of lowercase base 32, made on the first read. A code made earlier from your name gets one on its next read, and the old code still works. - `referred` (array of ReferredPerson, required) - `joinedAt` (string (date-time), required): When their sign-up was recorded. - `email` (string | null, required): Their email with all but its first character before the `@` hidden (`a***@example.com`). `null` when they erased their account (`erased`), or when their sign-in carried no email Nexus could keep. - `erased` (boolean): Whether the person erased their account. A person with no email who is not erased is still live: a reward needs their email. Absent on older Gateways, which a client reads from a `null` email. - `rewarded` (boolean | null): Whether this referral earned the caller a reward. Absent or null when unavailable. No payment date is disclosed. - `reward` ("pending" | "rewarded" | "not_rewarded"): This referral's reward. `pending`: none yet, and one may come; a payment is never disclosed while a reward can still come. `rewarded`: your personal organization got it. `not_rewarded`: final, it never will (its reward was voided, you reached the lifetime limit, or you have no personal organization). Absent on older Gateways. - `nextCursor` (string): The next page's cursor, while more people follow. - `invitesLeft` (integer): While sign-up is invite-only: how many more people your code admits, as an operator approved. Only the people who joined through your code after the approval use one. Absent while sign-up is open, and for a staff member's code with no approval, which admits anyone. [min 0] - `invitesAllowed` (integer): While sign-up is invite-only: how many people an operator approved your code to admit in all, used or not. `0`: not approved. With `invitesLeft` `0` and this above `0`, you used every invitation. Absent while sign-up is open, for a staff member's code with no approval, and on older Gateways. [min 0] - `enabled` (boolean, required): False while the personal referral program is stopped. Existing referrals remain readable. - `rewardProgress` (ReferralRewardProgress): Lifetime referral rewards for the person's personal organization, across all pages, including credit already spent or expired, against its limit. Absent for a staff member, whose account has no limit, and on older Gateways. - `granted` (integer, required): How many referral rewards this account has received. [min 0] - `limit` (integer, required): The maximum number of rewarded referrals per account, currently 10. [min 1] - `rewardsGranted` (integer): How many referral rewards your personal organization got in all, across all pages, including credit already spent or expired, limit or not. Absent on older Gateways. [min 0] - `rewardUsdDecimal` (string): What one rewarded referral gives your personal organization, in US dollars with six decimals (`"1.000000"`). `"0.000000"` while no reward is set. Absent on older Gateways. - `rewardsActive` (boolean): Whether your referrals earn rewards now: the program is on, a reward and a program cap are set, the cap has room for one more reward, and you are below your lifetime limit (`rewardProgress`) or are staff, who have none. False: no referral of yours earns credit now. Absent on older Gateways, which a client reads as false. - `400` A bad `limit` or `cursor` (`invalid_request_error`, `invalid_cursor`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: a module, a service account, an agent or an operator (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 100 | `limit` | The first 100 without `limit` or `cursor` | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A bad `limit` or `cursor` (`invalid_request_error`, `invalid_cursor`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/referrals" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Freferrals) ## Send diagnostic reports `POST /v1/diagnostics/reports` Send the app's own error and crash reports to the observability store. Each report becomes one `nexus::client_report` line in the Gateway's log, which reaches Cloud Logging with the Gateway's other lines; the Gateway keeps no copy. A report names what failed and where, never content: its fields are a closed set, each one bounded, and its free text (`name`, `message`) is logged redacted, with quoted text, URL paths and queries, emails and anything shaped like a key or token taken out. A stack frame is logged only as a code location (`at (::)` or ` +0x`), with every key or token shape taken out; any other frame is logged as `[redacted]`. Permission: `diagnostics.report` (Every member). ### Request body (application/json, required) - `reports` (array of DiagnosticReport, required) [at most 20 items] - `kind` ("error" | "crash", required): `error`: an error in the app's JavaScript; `crash`: a native crash (the OS's, or a desktop panic) seen at the next start - `fatal` (boolean, required): Whether it ended the app - `name` (string, required): The error's name (`TypeError`), or the crash's exception and signal [min length 1; max length 120] - `message` (string): The error's message, already redacted by the app; may be empty [max length 500] - `stack` (array of string): The top frames: a function and its place in the bundle, or a binary and its offset [at most 64 items] - `occurredAt` (string (date-time), required): When it happened - `appVersion` (string, required): The app's version [min length 1; max length 40] - `appBuild` (string | null): The store build number, when the app knows it [min length 1; max length 40] - `platform` ("ios" | "android" | "macos" | "windows" | "linux" | "web", required) - `osVersion` (string, required): The OS version the report came from [min length 1; max length 40] ### Responses - `202` Logged (application/json, DiagnosticReportsAccepted) - `accepted` (integer, required): How many reports went to the log - `400` A report breaks the contract (`invalid_report`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not one of the organization's people: a service account, a module or a sandbox (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A report breaks the contract (`invalid_report`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/diagnostics/reports" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "reports": [ { "kind": "error", "fatal": false, "name": "Platform", "occurredAt": "2026-10-01T00:00:00Z", "appVersion": "", "platform": "ios", "osVersion": "" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdiagnostics%2Freports) ## Send activity heartbeat `POST /v1/diagnostics/heartbeat` Report one active minute of the caller on an app: the app's window has focus and the person acted in the last minute. The Gateway keeps active minutes per UTC day, organization, person, surface, app, app version and OS, and the last minute per app. Labels come from fixed lists and versions are bounded: no content, path or address is kept. Permission: `diagnostics.report` (Every member). ### Request body (application/json, required) - `surface` ("code" | "chat" | "wiki" | "review" | "pages" | "other", required): What the person looks at: Code (or an agent session), Chat, Wiki, Review, Pages (with Slides and Design), or any other screen - `app` ("desktop" | "desktop-gpui" | "web" | "cli" | "mobile", required): The app that reports - `appVersion` (string, required): The app's version, such as 0.31.0+abc1234 [pattern ^[0-9A-Za-z.+-]{1,32}$] - `os` ("macos" | "windows" | "linux" | "ios" | "android" | "other", required): The OS family - `osVersion` (string): The OS release, such as 15.1 [pattern ^[0-9A-Za-z._-]{1,32}$] - `browser` ("chrome" | "safari" | "firefox" | "edge" | "other"): The web app's browser; the web app only - `browserVersion` (string): The browser's major version; the web app only [pattern ^[0-9]{1,4}$] ### Responses - `200` Checked; `recorded` says whether a minute counted (application/json, HeartbeatRecorded) - `recorded` (boolean, required): Whether the heartbeat counted a minute: false when collection is off, or when the person's minute on this app was already counted - `400` A value outside its list or pattern (`invalid_heartbeat`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: a service account, a module, an agent link or an operator (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A value outside its list or pattern (`invalid_heartbeat`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/diagnostics/heartbeat" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "surface": "code", "app": "desktop", "appVersion": "", "os": "macos" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdiagnostics%2Fheartbeat) ## Send client errors `POST /v1/diagnostics/errors` Report errors the caller's app caught, with no content: the app, its version and OS, a kind from a fixed list, and a component and a code the app names from its own code. Never a message, a stack, a path or a URL: the pattern refuses spaces, '/', ':' and '@', and the app must not put content in a name. The Gateway counts them per UTC day, organization, person, app, version, OS, kind, component and code, and keeps each person's last 50 per organization. Permission: `diagnostics.report` (Every member). ### Request body (application/json, required) - `errors` (array of ClientError, required) [at most 20 items] - `app` ("desktop" | "desktop-gpui" | "web" | "cli" | "mobile", required): The app that reports - `appVersion` (string, required): The app's version, such as 0.31.0+abc1234 [pattern ^[0-9A-Za-z.+-]{1,32}$] - `os` ("macos" | "windows" | "linux" | "ios" | "android" | "other", required): The OS family - `osVersion` (string): The OS release, such as 15.1 [pattern ^[0-9A-Za-z._-]{1,32}$] - `kind` ("crash" | "render" | "network" | "sign_in" | "update" | "agent" | "storage" | "other", required): Crash: a panic or native crash; render: a UI error boundary; network: a request from the app failed; sign_in; update: the updater; agent: a local agent did not start or ended badly; storage: local files or the keychain; other - `component` (string, required): The app's own name for where it failed, such as diff_view: never text from the error [pattern ^[a-z0-9_.-]{1,64}$] - `code` (string, required): The app's own error code, such as panic or callback_timeout: never text from the error [pattern ^[a-z0-9_.-]{1,64}$] - `fatal` (boolean): Whether it ended the app or the window; false when absent - `occurredAt` (string (date-time)): When it happened (RFC 3339); the Gateway's now when absent or out of bounds ### Responses - `200` Checked; `recorded` says how many were stored (application/json, ClientErrorsRecorded) - `recorded` (integer, required): How many errors were stored: 0 when collection is off - `400` A value outside its list or pattern (`invalid_client_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: a service account, a module, an agent link or an operator (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A value outside its list or pattern (`invalid_client_error`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/diagnostics/errors" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "errors": [ { "app": "desktop", "appVersion": "", "os": "macos", "kind": "crash", "component": "", "code": "" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdiagnostics%2Ferrors) ## Send frame failures `POST /v1/diagnostics/frame-failures` Report artifact frames that failed to load, with no content: the surface, how it failed, the app and browser versions, and the frame's host, the artifact's id and the HTTP status when the app knows them. Never a URL, a path, a share token or free text: each field is a fixed list or a pattern. The Gateway counts each failure in `nexus_gateway_artifact_frame_failures_total`, which holds no identity, and stores nothing. With `NEXUS_COLLECT_FRAME_FAILURES=true` it also writes one `nexus::artifact_frame_failure` log line per failure; off, the default, it logs nothing and `accepted` is 0. Permission: `diagnostics.report` (Every member). ### Request body (application/json, required) - `failures` (array of FrameFailure, required) [at most 10 items] - `surface` ("api" | "share_link" | "subdomain", required) - `kind` ("error" | "timeout" | "blocked" | "csp" | "http", required) - `app` ("web" | "desktop-gpui", required) - `appVersion` (string, required) [pattern ^[0-9A-Za-z.+-]{1,32}$] - `browser` ("chrome" | "safari" | "firefox" | "edge" | "webkit" | "other") - `browserVersion` (string) [pattern ^[0-9]{1,4}$] - `artifactId` (string) [pattern ^[A-Za-z0-9_-]{1,64}$] - `host` (string): The frame's host name: the sandbox subdomain [pattern ^[a-z0-9.-]{1,253}$] - `status` (integer) [min 100; max 599] - `occurredAt` (string (date-time)) [max length 40] ### Responses - `202` Logged; `accepted` says how many (application/json, FrameFailuresAccepted) - `accepted` (integer, required): How many failures were logged: 0 while `NEXUS_COLLECT_FRAME_FAILURES` is off - `400` A value outside its list or pattern (`invalid_frame_failure`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: a service account, a module, an agent link or an operator (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A value outside its list or pattern (`invalid_frame_failure`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/diagnostics/frame-failures" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "failures": [ { "surface": "api", "kind": "error", "app": "web", "appVersion": "" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdiagnostics%2Fframe-failures) ## Send public frame failures `POST /v1/public/frame-failures` Report artifact frames that failed to load from the public share-link viewer: the same body as the signed-in route. No credential; limited per address, one count per request, on the public artifact reads' limit. With logging on, the line carries `org` "public" and no person. Permission: `public` (Anyone, signed in or not). ### Request body (application/json, required) - `failures` (array of FrameFailure, required) [at most 10 items] - `surface` ("api" | "share_link" | "subdomain", required) - `kind` ("error" | "timeout" | "blocked" | "csp" | "http", required) - `app` ("web" | "desktop-gpui", required) - `appVersion` (string, required) [pattern ^[0-9A-Za-z.+-]{1,32}$] - `browser` ("chrome" | "safari" | "firefox" | "edge" | "webkit" | "other") - `browserVersion` (string) [pattern ^[0-9]{1,4}$] - `artifactId` (string) [pattern ^[A-Za-z0-9_-]{1,64}$] - `host` (string): The frame's host name: the sandbox subdomain [pattern ^[a-z0-9.-]{1,253}$] - `status` (integer) [min 100; max 599] - `occurredAt` (string (date-time)) [max length 40] ### Responses - `202` Logged; `accepted` says how many (application/json, FrameFailuresAccepted) - `accepted` (integer, required): How many failures were logged: 0 while `NEXUS_COLLECT_FRAME_FAILURES` is off - `400` A value outside its list or pattern (`invalid_frame_failure`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A value outside its list or pattern (`invalid_frame_failure`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/public/frame-failures" \ -H "Content-Type: application/json" \ -d '{ "failures": [ { "surface": "api", "kind": "error", "app": "web", "appVersion": "" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpublic%2Fframe-failures) ## Send daily active `POST /v1/public/daily-active` Report that this install of the open-source desktop app was used today: a random install ID, the day, the app version and release channel, the OS, its major and minor version, the CPU type, and how the app reached models. No credential: the app sends it at most once a day, only while its person has "Send usage data" on. Never a prompt, code, path, name or account. With `NEXUS_COLLECT_DAILY_ACTIVE=true` the Gateway keeps one row per UTC day and install ID for 90 days, then only counts with no install ID; off, the default, it keeps nothing and `accepted` is false. The client's address is never kept with the event. Permission: `public` (Anyone, signed in or not). ### Request body (application/json, required) - `install_id` (string, required): A random UUID v4 the app made when its person turned usage data on, in lower case. No account links to it [pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$] - `day` (string (date), required): The UTC day the app was used, from a week ago to tomorrow - `app_version` (string, required) [pattern ^[0-9A-Za-z.+-]{1,32}$] - `channel` ("stable" | "beta" | "internal" | "other", required) - `os` ("macos" | "linux" | "windows", required) - `os_version` (string): Major and minor only. Absent when the system names none [pattern ^[0-9]{1,4}(\.[0-9]{1,4})?$] - `arch` ("arm64" | "x86_64", required) - `modes` (array of "own_subscription" | "own_key" | "own_model" | "cloud"): How the app reached models that day. `cloud`: signed in to Nexus Cloud [at most 4 items] ### Responses - `202` Checked; `accepted` says whether it was kept (application/json, DailyActiveAccepted) - `accepted` (boolean, required): Whether the day was kept: false while `NEXUS_COLLECT_DAILY_ACTIVE` is off - `400` A value outside its list or pattern, or a day outside the last week (`invalid_daily_active`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A value outside its list or pattern, or a day outside the last week (`invalid_daily_active`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/public/daily-active" \ -H "Content-Type: application/json" \ -d '{ "install_id": "", "day": "2026-10-01", "app_version": "", "channel": "stable", "os": "macos", "arch": "arm64" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpublic%2Fdaily-active) ## Send feedback `POST /v1/diagnostics/feedback` Send feedback, a crash report the person chose to send, or a report on a model's answer (App Review 1.2), to Nexus's team. The Gateway posts one message to the feedback channel in Slack (`NEXUS_FEEDBACK_SLACK_WEBHOOK_URL`) and keeps no copy. The message names the person (name and email) and the organization, so the team can answer, with the app, its version, the OS and the screen. What the person wrote is shown as plain text, so it cannot mention a channel or a person, hide a link, or pass for the Gateway's own lines; names are code spans, and Slack previews no link. A crash shows its redacted name and message and its top frames, as `POST /v1/diagnostics/reports` logs them, and is logged as one `nexus::client_report` line too. A reported answer shows its reason and model, then the answer as plain text, as the app showed it. Permission: `feedback.send` (Every member). ### Request body (application/json, required) - `category` ("bug" | "idea" | "other" | "crash" | "report" | "triage", required): What it is. `crash` carries `crash`, and only it does; `report` carries `answer`, and only it does; `triage` is a report that `nexus triage`'s agent wrote, sent only by Nexus's own people to the triage channel (`NEXUS_TRIAGE_SLACK_WEBHOOK_URL`) - `message` (string): What the person wrote: 1 to 4000 characters (12000 with `triage`), or empty with a crash or a report. Slack shows it as plain text [max length 12000] - `screen` (string | null): The screen the person was on, as its route's shape (`/acme/sessions/:id`): letters, digits and / _ . ~ - :, never a query [min length 1; max length 120; pattern ^/[A-Za-z0-9/_.~:-]*$] - `appVersion` (string, required): The app's version [min length 1; max length 40] - `appBuild` (string | null): The build, when the app knows it [min length 1; max length 40] - `platform` ("ios" | "android" | "macos" | "windows" | "linux" | "web", required) - `osVersion` (string, required): The OS's version, or the browser's [min length 1; max length 40] - `crash` (DiagnosticReport | null): The crash the app saw at this start, which the person chose to send; logged as a diagnostic report too - `answer` (ReportedAnswer | null): With the category `report`: the model's answer the person reported, as the app showed it ### Responses - `200` Posted to the channel (application/json, FeedbackSent) - `sent` (true, required) - `400` Feedback that breaks the contract (`invalid_feedback`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not one of the organization's people: a service account, a module or a sandbox (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Slack did not take the message (`upstream_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No feedback channel on this Gateway (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Feedback that breaks the contract (`invalid_feedback`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | Slack did not take the message (`upstream_error`) | | 503 | | No feedback channel on this Gateway (`not_configured`) | ### Example ```sh curl -X POST "$NEXUS_URL/v1/diagnostics/feedback" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "category": "bug", "appVersion": "", "platform": "ios", "osVersion": "" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdiagnostics%2Ffeedback) ## Get notification settings `GET /v1/notifications/settings` Your notification settings in this organization: one row per group and channel. Permission: `notifications.use` (Every member). ### Responses - `200` OK (application/json, NotificationSettings) - `settings` (array of NotificationSetting, required) - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required) - `channel` ("inbox" | "email" | "push", required) - `setting` ("on" | "off", required): Your choice, else the default - `default` ("on" | "off", required): On when one of the group's kinds uses the channel before anyone chooses - `locked` (boolean, required): The inbox: always on, no setting changes it - `required` (boolean, required): The group holds a required kind, which off does not mute - `available` (boolean, required): The channel can reach the person on this Gateway. Always true: push reaches a desktop app, which collects its deliveries, even where Web Push has no keys. Kept for older clients - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/notifications/settings" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fnotifications%2Fsettings) ## Set notification settings `PUT /v1/notifications/settings` Change one or more of your notification settings. Answers with every setting. Permission: `notifications.use` (Every member). ### Request body (application/json, required) - `settings` (array of object, required) [at most 20 items] - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required) - `channel` ("email" | "push", required) - `setting` ("on" | "off", required) ### Responses - `200` OK (application/json, NotificationSettings) - `settings` (array of NotificationSetting, required) - `group` ("my_sessions" | "usage_and_billing" | "requests_and_approvals" | "automations_and_integrations" | "account_and_security", required) - `channel` ("inbox" | "email" | "push", required) - `setting` ("on" | "off", required): Your choice, else the default - `default` ("on" | "off", required): On when one of the group's kinds uses the channel before anyone chooses - `locked` (boolean, required): The inbox: always on, no setting changes it - `required` (boolean, required): The group holds a required kind, which off does not mute - `available` (boolean, required): The channel can reach the person on this Gateway. Always true: push reaches a desktop app, which collects its deliveries, even where Web Push has no keys. Kept for older clients - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/notifications/settings" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "settings": [ { "group": "my_sessions", "channel": "email", "setting": "on" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fnotifications%2Fsettings) ## Get notification push key `GET /v1/notifications/push-key` The public key a browser subscribes to Web Push with. Permission: `notifications.use` (Every member). ### Responses - `200` OK (application/json, NotificationPushKey) - `publicKey` (string, required): The application server's secp256r1 public key (VAPID), uncompressed, base64url without padding: the browser's applicationServerKey - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Web Push is not configured on this Gateway (`not_configured`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Web Push is not configured on this Gateway (`not_configured`). | ### Example ```sh curl "$NEXUS_URL/v1/notifications/push-key" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fnotifications%2Fpush-key) ## List notification devices `GET /v1/notifications/devices` Your devices that take push in this organization. No answer holds a token. Permission: `notifications.use` (Every member). ### Responses - `200` OK (application/json, NotificationDevices) - `devices` (array of NotificationDevice, required) - `id` (string, required) - `platform` ("web" | "desktop" | "ios" | "android", required) - `createdAt` (string (date-time), required) - `lastSeenAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `revokedReason` ("signed_out" | "lost" | "left" | "rejected" | "replaced") - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/notifications/devices" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fnotifications%2Fdevices) ## Register notification device `POST /v1/notifications/devices` Register this device for push, or refresh it. Registering the same token again answers the same device. Permission: `notifications.use` (Every member). ### Request body (application/json, required) - `platform` ("web" | "desktop" | "ios" | "android", required) - `token` (string, required): The push service's token: for `web`, the browser's push subscription JSON (`endpoint` on a known push service, `keys.p256dh`, `keys.auth`), checked at registration; an APNs or FCM token otherwise. Sealed, never answered back. [min length 1; max length 4096] ### Responses - `200` OK (application/json, NotificationDevice) - `id` (string, required) - `platform` ("web" | "desktop" | "ios" | "android", required) - `createdAt` (string (date-time), required) - `lastSeenAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `revokedReason` ("signed_out" | "lost" | "left" | "rejected" | "replaced") - `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` You hold 20 live devices in this organization (`device_limit`). Remove one first. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | You hold 20 live devices in this organization (`device_limit`). Remove one first. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/notifications/devices" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "platform": "web", "token": "" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fnotifications%2Fdevices) ## Revoke notification device `DELETE /v1/notifications/devices/{id}` Stop push to one of your devices. Not yours, revoked already or unknown: 404. Permission: `notifications.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The device's id (`ndv_…`) | | `reason` | query | "lost" \| "signed_out" | no | Why the device stops: `lost` when omitted | ### Responses - `200` OK (application/json, NotificationDevice) - `id` (string, required) - `platform` ("web" | "desktop" | "ios" | "android", required) - `createdAt` (string (date-time), required) - `lastSeenAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `revokedReason` ("signed_out" | "lost" | "left" | "rejected" | "replaced") - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/notifications/devices/" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fnotifications%2Fdevices%2F%7Bid%7D) ## Collect notification deliveries `POST /v1/notifications/devices/{id}/collect` Collect a desktop device's notifications, once each. Not yours, revoked or unknown: 404. Permission: `notifications.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The device's id (`ndv_…`) | ### Responses - `200` OK (application/json, CollectedNotifications) - `items` (array of CollectedNotification, required) - `kind` (string, required): The kind's name - `eventId` (string, required): The inbox item's key - `title` (string, required): The kind's fixed subject, or a month report's summary from its figures only: no text a tenant wrote - `body` (string): A month report's second line, from its figures only. Absent for other kinds - `path` (string, required): The path the notice opens. It names no organization; a month report opens Usage on its month - `deliveryId` (string, required): The delivery's id (`ndl_…`) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/notifications/devices//collect" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fnotifications%2Fdevices%2F%7Bid%7D%2Fcollect) ## Create voice speech `POST /v1/chat/voice-speech` A piece of a voice-mode answer, said by ElevenLabs: the app plays the `audio/mpeg` it answers, and Nexus's own key stays on the Gateway. Permission: `chat.use` (Every member). ### Request body (application/json, required) - `text` (string, required): The text to say: 1 to 500 characters, not only spaces. [min length 1; max length 500] ### Responses - `200` The speech, as MP3. (audio/mpeg, string (binary)) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/chat/voice-speech" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "text": "" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fvoice-speech) ## Create voice token `POST /v1/chat/voice-token` A short-lived token for dictation: the app's microphone button streams audio to AssemblyAI's speech to text with it, and Nexus's own key stays on the Gateway. Permission: `chat.use` (Every member). ### Responses - `200` OK (application/json, VoiceToken) - `token` (string, required): The streaming token. It opens one session. - `url` (string, required): The WebSocket to open, token included. - `sampleRate` (integer, required): The sample rate the audio must have: 16000. - `expiresInSeconds` (integer, required): Seconds from now until the token can no longer open a session. - `maxSessionSeconds` (integer, required): The longest one session may run, in seconds. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/chat/voice-token" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fvoice-token) ## Ask owners `POST /v1/notifications/ask-owner` Ask the organization's owners about a billing block: a reached usage limit, used-up credits or free start, a failed charge, an unpaid invoice, or the plan. Permission: `notifications.use` (Every member). ### Request body (application/json, required) - `block` ("usage_limit" | "credits_out" | "free_start_used" | "payment_failed" | "past_due" | "billing", required): What stops you: a reached usage limit, used-up credits, a used-up free start, a failed charge, an unpaid invoice, or `billing` for a question about the plan and its usage ### Responses - `200` OK (application/json, AskOwnersResponse) - `status` ("sent" | "already_asked", required): `sent`: each owner gets an inbox item and an email now. `already_asked`: you asked about this block today (UTC), so nobody is told again. - `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/notifications/ask-owner" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "block": "usage_limit" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fnotifications%2Fask-owner) --- # Chat sessions > Chat sessions, Nexus UI's home and `nexus chat`. Two modes: Chat, with any model you may use, and Ask your code, grounded in your organization's Nexus Wiki. Sessions are private to their author; messages are kept for the organization's retention window (90 days by default, GET/PUT /v1/orgs/settings). ## List chat sessions `GET /v1/chat/sessions` Your own chat sessions, most recently active first, a page at a time. Private: nobody else's are listed, for owners and admins too. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `limit` | query | integer | no | | | `cursor` | query | string | no | NextCursor of the previous page | | `q` | query | string | no | Words in the title or the messages | | `archived` | query | "exclude" \| "include" \| "only" | no | | ### Responses - `200` OK (application/json, object) - `sessions` (array of ChatSession, required) - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app//artifacts/ - `viewerUrl` (string): The fast viewer: /a/ - `publicUrl` (string): Kind public: /a/ - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `nextCursor` (string) - `400` A query parameter is not valid: `limit` is not 1 to the page maximum, `cursor` is not one this API returned, or `archived` is not exclude, include or only. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `chat.use` (`role_required`: a service account, a sandbox, or an agent not granted it), or the caller is not a person, such as a module key (`person_required`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A query parameter is not valid: `limit` is not 1 to the page maximum, `cursor` is not one this API returned, or `archived` is not exclude, include or only. | | 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/chat/sessions" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fchat%2Fsessions) ## Create chat session `POST /v1/chat/sessions` Start a chat session. It is yours alone; its spend goes to you, the team (named, else your default) and the product chat. Audited as chat.session_created (never the title). Permission: `chat.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) - `title` (string): Default: the first question [max length 120] - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string): Nexus/auto (default), nexus/default or a catalog id; whether you may use it is decided on each message - `team` (string): A team slug you are in - `webSearch` (boolean): Whether the model may search the web in this chat. It takes effect only while the organization's webSearch.engine is on [default false] ### Responses - `201` Created (application/json, ChatSession) - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app//artifacts/ - `viewerUrl` (string): The fast viewer: /a/ - `publicUrl` (string): Kind public: /a/ - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `400` The body is not valid: `title` over 120 characters, `mode` not chat or ask, a `model` that is not a string, `webSearch` not a boolean, `team` not a slug, or a bad `Idempotency-Key`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `chat.use` (`role_required`: a service account, a sandbox, or an agent not granted it), the caller is not a person (`person_required`), or the team named is not the caller's (`not_in_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` The team named does not exist in this organization (`unknown_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The `Idempotency-Key`'s first request still runs (`idempotency_in_progress`) or was interrupted (`idempotency_interrupted`). The request does not run again. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `422` The `Idempotency-Key` was used for a different request (`idempotency_key_reused`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not valid: `title` over 120 characters, `mode` not chat or ask, a `model` that is not a string, `webSearch` not a boolean, `team` not a slug, or a bad `Idempotency-Key`. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | The team named does not exist in this organization (`unknown_team`). | | 409 | | The `Idempotency-Key`'s first request still runs (`idempotency_in_progress`) or was interrupted (`idempotency_interrupted`). The request does not run again. | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | | The `Idempotency-Key` was used for a different request (`idempotency_key_reused`). | | 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/chat/sessions" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "title": "", "mode": "chat", "model": "<model>", "team": "platform", "webSearch": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fsessions) ## Get chat session `GET /v1/chat/sessions/{id}` One of your sessions with its messages, oldest first. Anyone else's session is 404. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`chs_…`) | ### Responses - `200` OK (application/json, ChatSessionDetail) - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `messages` (array of ChatSessionMessage, required) - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `404` No such session among yours (`chat_session_not_found`): someone else's session answers the same. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session among yours (`chat_session_not_found`): someone else's session answers the same. | | 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/chat/sessions/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fchat%2Fsessions%2F%7Bid%7D) ## Update chat session `PATCH /v1/chat/sessions/{id}` Rename, archive or restore a session, or change the model, mode, web search switch or team its next messages use. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`chs_…`) | | `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) - `title` (string) [max length 120] - `archived` (boolean) - `model` (string) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `team` (string | null) - `webSearch` (boolean): Whether the model may search the web in this chat. It takes effect only while the organization's webSearch.engine is on ### Responses - `200` OK (application/json, ChatSession) - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `404` No such session among yours (`chat_session_not_found`): someone else's session answers the same. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session among yours (`chat_session_not_found`): someone else's session answers the same. | | 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/chat/sessions/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "title": "<title>", "archived": false, "model": "<model>", "mode": "chat", "team": "platform", "webSearch": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Fchat%2Fsessions%2F%7Bid%7D) ## Delete chat session `DELETE /v1/chat/sessions/{id}` Delete a session and its messages. Audited as chat.session_deleted (never the content). Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`chs_…`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `deleted` (boolean) - `id` (string) - `messages` (integer) - `404` No such session among yours (`chat_session_not_found`): someone else's session answers the same. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session among yours (`chat_session_not_found`): someone else's session answers the same. | | 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/chat/sessions/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fchat%2Fsessions%2F%7Bid%7D) ## Send chat message `POST /v1/chat/sessions/{id}/messages` Send a message; the answer streams as server-sent events (OpenAI chat.completion.chunk; `stream: false` answers with JSON). The call takes the same path as /v1/chat/completions: the model policy decision (nexus/auto by default), the ledger's reserve and settle, attribution to you, your team and chat. Ask your code ranks your organization's Nexus Wiki sections (BM25) and cites them. A refusal is stored in the session and answered before any stream: 403 model_not_allowed (naming the level and rule), 402 budget_exceeded or payment_past_due; error.nexus names the session and the stored message. With an Idempotency-Key a message runs at most once; a finished stream is not replayed (409 idempotency_stream_replay). With `images` a question carries up to 8 images, PNG, JPEG, GIF or WebP by their bytes, at most 5 MB each and 20 MB in all; `content` may then be empty. They go to the model with the question (and with the next ones while they are among the last two questions that had any) and are stored beside it: the message lists them in `attachments`, and getChatAttachment returns their bytes. 400 invalid_image, 413 image_too_large, 400 model_no_image_input for a model that does not read images. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`chs_…`) | | `x-nexus-team` | header | string | no | The team (slug) this message's spend goes to; you must be in it. Default: the session's team. | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `content` (string, required): The question; may be empty when `images` or `files` has at least one [max length 32000] - `images` (array of ChatImageInput): Images that go with the question. [at most 8 items] - `data` (string, required): The image as base64, or a `data:image/…;base64,…` URL - `name` (string): Its file name, shown with it [max length 200] - `files` (array of ChatFileInput): Data files that go with the question: the model reads a text file's text, and a page written in this chat keeps a copy. With the images, at most 20 MB. [at most 8 items] - `data` (string, required): Standard base64, or a data: URL - `name` (string, required): With its extension. The name a page reads it by [max length 200] - `model` (string): For this message and the next ones - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `team` (string) - `stream` (boolean) [default true] ### Responses - `200` The answer: an event stream, or with stream false the stored question and answer (text/event-stream, ChatStreamChunk) - `id` (string) - `object` ("chat.completion.chunk") - `created` (integer) - `model` (string | null): The model that runs - `choices` (array of object) - `index` (integer) - `delta` (object) - `role` (string) - `content` (string) - `finish_reason` (string | null) - `usage` (object) - `prompt_tokens` (integer) - `completion_tokens` (integer) - `total_tokens` (integer) - `nexus` (object) - `session` (ChatSession): A chat session, private to its author unless shared as an artifact. - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `question` (ChatSessionMessage) - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `message` (ChatSessionMessage) - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requested` (string) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `no_wiki` (boolean) - `tool` (object): A chat tool currently executing - `name` ("write_page" | "load_skill" | "describe_connector" | "read_connector" | "web_search", required) - `status` ("running", required) - `skill` (ChatSkillBlock): A skill load_skill has just read - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connector` (ChatConnectorBlock): A connector read read_connector is about to run - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `cost_usd` (number) - `402` The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). The refusal is stored in the session. A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. (application/json, Error & object) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `error` (object) - `nexus` (BudgetRefusal): The details (`error.nexus`) of a 402 `budget_exceeded` or `subsidy_exhausted`. Each money figure comes as its number (deprecated) and its exact decimal twin (`requestedUsd`, `requestedUsdDecimal`). A refusal below the person level names only what is left and what was asked, never a limit above the caller. `credit_exhausted` sends `remainingUsd` and `requestedUsd` as decimal strings already, without twins. - `level` ("organization" | "team" | "person" | "product"): The level whose limit refused the call (`budget_exceeded`) - `period` (string): The period the refusal counted in: `2026-10`, `2026-W44` or `2026-10-21` - `resetsAt` (string (date-time)): When the period ends (UTC) - `source` ("override" | "default"): Person level only: whether the limit was set for them or is the organization's default per person - `limitUsd` (number): Person level only: their monthly limit. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `spentUsd` (number): Person level only: what they spent this month. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number): Person level only: what their calls in flight hold. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `remainingUsd` (number): Every level, and `subsidy_exhausted`: what is left, never below 0. Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `requestedUsd` (number): What the call may cost at most, the amount it asked to hold. Deprecated: read `requestedUsdDecimal`, the exact decimal string (root rule 9). - `requestedUsdDecimal` (string): `requestedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `requestedUsd`. - `notified` (boolean): `budget_exceeded`: true once Gateway has told the refused person and the organization's owners and admins - `fundedBy` (string): `subsidy_exhausted`: who funds the subsidy (`nexus`) - `next` (array of string): `subsidy_exhausted`: what the caller can do next (`billing`, `own_key`) - `404` No such session among yours (`chat_session_not_found`): someone else's session answers the same. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). The refusal is stored in the session. A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session among yours (`chat_session_not_found`): someone else's session answers the same. | | 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/chat/sessions/<id>/messages" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "content": "<content>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fsessions%2F%7Bid%7D%2Fmessages) ## Ask code `POST /v1/chat/ask` Ask your code alone: a question to your organization's Nexus Wiki, answered and cited as sendChatMessage answers in ask mode. Without `session` it starts an ask-mode session of yours; with one it continues it. It needs `chat.ask`, not `chat.use`, so an agent link that holds it reaches no other chat route. An agent link holds `chat.ask` only when its sign-in asked for it, and it asks as its person: it reads the Wiki pages the person reads and nothing more. An agent link continues only a session it started; any other session is a 404 chat_session_not_found, as someone else's is. Text only: no images, no team, no page or skill tools. Permission: `chat.ask` (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) - `content` (string, required): The question [min length 1; max length 32000] - `session` (string): The ask-mode session to continue (`chs_…`). An agent link continues only a session it started. Omit it to start one. [pattern ^[A-Za-z0-9_-]+$] - `model` (string): For this question and the next ones in the session - `stream` (boolean) [default true] ### Responses - `200` The answer: an event stream, or with stream false the stored question and answer (text/event-stream, ChatStreamChunk) - `id` (string) - `object` ("chat.completion.chunk") - `created` (integer) - `model` (string | null): The model that runs - `choices` (array of object) - `index` (integer) - `delta` (object) - `role` (string) - `content` (string) - `finish_reason` (string | null) - `usage` (object) - `prompt_tokens` (integer) - `completion_tokens` (integer) - `total_tokens` (integer) - `nexus` (object) - `session` (ChatSession): A chat session, private to its author unless shared as an artifact. - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `question` (ChatSessionMessage) - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `message` (ChatSessionMessage) - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requested` (string) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `no_wiki` (boolean) - `tool` (object): A chat tool currently executing - `name` ("write_page" | "load_skill" | "describe_connector" | "read_connector" | "web_search", required) - `status` ("running", required) - `skill` (ChatSkillBlock): A skill load_skill has just read - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connector` (ChatConnectorBlock): A connector read read_connector is about to run - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `cost_usd` (number) - `402` The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). The refusal is stored in the session. A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. (application/json, Error & object) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `error` (object) - `nexus` (BudgetRefusal): The details (`error.nexus`) of a 402 `budget_exceeded` or `subsidy_exhausted`. Each money figure comes as its number (deprecated) and its exact decimal twin (`requestedUsd`, `requestedUsdDecimal`). A refusal below the person level names only what is left and what was asked, never a limit above the caller. `credit_exhausted` sends `remainingUsd` and `requestedUsd` as decimal strings already, without twins. - `level` ("organization" | "team" | "person" | "product"): The level whose limit refused the call (`budget_exceeded`) - `period` (string): The period the refusal counted in: `2026-10`, `2026-W44` or `2026-10-21` - `resetsAt` (string (date-time)): When the period ends (UTC) - `source` ("override" | "default"): Person level only: whether the limit was set for them or is the organization's default per person - `limitUsd` (number): Person level only: their monthly limit. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `spentUsd` (number): Person level only: what they spent this month. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number): Person level only: what their calls in flight hold. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `remainingUsd` (number): Every level, and `subsidy_exhausted`: what is left, never below 0. Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `requestedUsd` (number): What the call may cost at most, the amount it asked to hold. Deprecated: read `requestedUsdDecimal`, the exact decimal string (root rule 9). - `requestedUsdDecimal` (string): `requestedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `requestedUsd`. - `notified` (boolean): `budget_exceeded`: true once Gateway has told the refused person and the organization's owners and admins - `fundedBy` (string): `subsidy_exhausted`: who funds the subsidy (`nexus`) - `next` (array of string): `subsidy_exhausted`: what the caller can do next (`billing`, `own_key`) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). The refusal is stored in the session. A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. The details are a BudgetRefusal: each money figure with its exact decimal twin. | | 403 | `role_required` | Your role does not have this permission | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/chat/ask" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "content": "<content>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fask) ## Ask web `POST /v1/chat/web` Web search alone: a text question answered with your organization's web search, as sendChatMessage answers in a chat with webSearch on. Without `session` it starts a chat session of yours with webSearch on; with one it continues it. The turn offers the web_search tool and no other: no page, skill or connector tool. The organization's webSearch.* settings apply, maxPerTurn included. While search is off it is a 403 web_search_off, and while webSearch.requireZdr or a domain rule is set a 403 web_search_unenforced; both name the setting in error.nexus.setting, and no session is made. It needs `chat.web`, not `chat.use`, so an agent link that holds it reaches no other chat route. An agent link holds `chat.web` only when its sign-in asked for it, and it searches as its person, on its person's budget. An agent link continues only a session it started; any other session is a 404 chat_session_not_found, as someone else's is. Text only: no images and no team. When no model the policy allows can search, the answer comes without a search and `sources` is absent. Permission: `chat.web` (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) - `content` (string, required): The question [min length 1; max length 32000] - `session` (string): The web session to continue (`chs_…`): a chat session with webSearch on. An agent link continues only a session it started. Omit it to start one. [pattern ^[A-Za-z0-9_-]+$] - `model` (string): For this question and the next ones in the session - `stream` (boolean) [default true] ### Responses - `200` The answer: an event stream, or with stream false the stored question and answer, with the answer's sources (text/event-stream, ChatStreamChunk) - `id` (string) - `object` ("chat.completion.chunk") - `created` (integer) - `model` (string | null): The model that runs - `choices` (array of object) - `index` (integer) - `delta` (object) - `role` (string) - `content` (string) - `finish_reason` (string | null) - `usage` (object) - `prompt_tokens` (integer) - `completion_tokens` (integer) - `total_tokens` (integer) - `nexus` (object) - `session` (ChatSession): A chat session, private to its author unless shared as an artifact. - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `question` (ChatSessionMessage) - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `message` (ChatSessionMessage) - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requested` (string) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `no_wiki` (boolean) - `tool` (object): A chat tool currently executing - `name` ("write_page" | "load_skill" | "describe_connector" | "read_connector" | "web_search", required) - `status` ("running", required) - `skill` (ChatSkillBlock): A skill load_skill has just read - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connector` (ChatConnectorBlock): A connector read read_connector is about to run - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `cost_usd` (number) - `402` The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). The refusal is stored in the session. A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). The refusal is stored in the session. A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. | | 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/chat/web" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "content": "<content>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fweb) ## Get chat attachment `GET /v1/chat/sessions/{id}/attachments/{attachmentId}` An image attached to a question in one of your sessions, with its bytes as base64 (`data:<mediaType>;base64,<data>` shows it). Someone else's session, or an image not in it, is a 404 (chat_session_not_found, chat_attachment_not_found). Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`chs_…`) | | `attachmentId` | path | string | yes | The image's id (`cha_…`), from the message's `attachments` | ### Responses - `200` The image (application/json, ChatAttachment) - `id` (string, required) - `sessionId` (string, required) - `messageId` (string, required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required) - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `data` (string, required): Standard base64 - `createdAt` (string (date-time), required) - `404` No such session among yours (`chat_session_not_found`), or no such image in it (`chat_attachment_not_found`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session among yours (`chat_session_not_found`), or no such image in it (`chat_attachment_not_found`). | | 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/chat/sessions/<id>/attachments/<attachmentId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fchat%2Fsessions%2F%7Bid%7D%2Fattachments%2F%7BattachmentId%7D) ## Rewind chat session `POST /v1/chat/sessions/{id}/rewind` Rewind before one active user message. Original messages remain saved. Running replies return 409. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`chs_…`) | ### Request body (application/json, required) - `messageId` (string, required) [min length 1] ### Responses - `200` OK (application/json, ChatSessionDetail) - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `messages` (array of ChatSessionMessage, required) - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `404` No such session among yours (`chat_session_not_found`): someone else's session answers the same. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` An answer is still running (`chat_session_busy`), or the message is no longer part of the conversation (`chat_message_inactive`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session among yours (`chat_session_not_found`): someone else's session answers the same. | | 409 | | An answer is still running (`chat_session_busy`), or the message is no longer part of the conversation (`chat_message_inactive`). | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/chat/sessions/<id>/rewind" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "messageId": "<messageId>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fsessions%2F%7Bid%7D%2Frewind) ## Suggest chat message `POST /v1/chat/sessions/{id}/suggest` Suggest the message the person is most likely to send next. The call reads the session's cached prompt; nothing is stored. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`chs_…`) | ### Responses - `200` OK. `suggestion` is null when the model offers none. It is also null, and no model is called, when the session's last message is not a complete answer or the organization turned `chatSuggestions` off. (application/json, ChatSuggestion) - `suggestion` (string | null, required): The suggested message, one line of at most 120 characters. - `model` (string | null, required): The model that wrote it; null when no model was called. - `costUsd` (number, required): What the call cost. The session's `costUsd` does not count it; the ledger does. - `404` No such session among yours (`chat_session_not_found`): someone else's session answers the same. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session among yours (`chat_session_not_found`): someone else's session answers the same. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/chat/sessions/<id>/suggest" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fsessions%2F%7Bid%7D%2Fsuggest) ## Get guest chat `GET /v1/guest/chat` Guest chat for a signed-out visitor: whether this guest may send a round now, its rounds, and the model that answers. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `X-Nexus-Guest` | header | string (uuid) | yes | The browser's guest id: a random UUID it keeps (in localStorage). Its rounds count under it. | ### Responses - `200` OK (application/json, GuestChatStatus) - `enabled` (boolean, required): Whether a round from this guest id and address is within the rounds, the output tokens and the address's rounds now - `rounds_used` (integer, required): The rounds this guest id has used [min 0] - `rounds_limit` (integer, required): The rounds a guest id gets [min 0] - `model` (string, required): The display name of the model that answers every guest round, such as `DeepSeek V4 Flash 0731` - `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 | | --- | --- | --- | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | ### Example ```sh curl "$NEXUS_URL/v1/guest/chat" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fguest%2Fchat) ## Send guest chat message `POST /v1/guest/chat/messages` One guest chat round: the answer streams as server-sent events, as sendChatMessage streams it, on the guest model, billed to the guest organization. Nothing of the chat is stored. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `X-Nexus-Guest` | header | string (uuid) | yes | The browser's guest id: a random UUID it keeps (in localStorage). Its rounds count under it. | ### Request body (application/json, required) - `messages` (array of GuestChatMessage, required): The conversation, oldest first; the last one the guest's (`user`). 32,000 characters in all at most. [at most 20 items] - `role` ("user" | "assistant", required) - `content` (string, required) [min length 1] - `turnstile` (string, required): The Cloudflare Turnstile widget's token [min length 1; max length 2048] ### Responses - `200` The answer, as an event stream (text/event-stream, ChatStreamChunk) - `id` (string) - `object` ("chat.completion.chunk") - `created` (integer) - `model` (string | null): The model that runs - `choices` (array of object) - `index` (integer) - `delta` (object) - `role` (string) - `content` (string) - `finish_reason` (string | null) - `usage` (object) - `prompt_tokens` (integer) - `completion_tokens` (integer) - `total_tokens` (integer) - `nexus` (object) - `session` (ChatSession): A chat session, private to its author unless shared as an artifact. - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `question` (ChatSessionMessage) - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `message` (ChatSessionMessage) - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requested` (string) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `no_wiki` (boolean) - `tool` (object): A chat tool currently executing - `name` ("write_page" | "load_skill" | "describe_connector" | "read_connector" | "web_search", required) - `status` ("running", required) - `skill` (ChatSkillBlock): A skill load_skill has just read - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connector` (ChatConnectorBlock): A connector read read_connector is about to run - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `cost_usd` (number) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/guest/chat/messages" \ -H "Content-Type: application/json" \ -d '{ "messages": [ { "role": "user", "content": "<content>" } ], "turnstile": "<turnstile>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fguest%2Fchat%2Fmessages) --- <!-- /docs/api/artifacts --> # Artifacts > Nexus Artifacts: a chat session shared as an immutable snapshot (its messages, sources, the model of each answer, mode, title, author and cost). Inside the organization: the whole organization, chosen teams or chosen people. Outside it, as the organization's settings allow (`artifacts.external*`: on, with public links, by default): named people by email, who open it signed in with that verified email (a forwarded link opens for nobody else, who can ask for access), or anyone with an unguessable link, never indexed, optionally expiring. Readers outside see the author's name and the organization's name, never the cost, the author's email or team names, and Ask your code's sources only when the organization allows it and the author included them. Sharing again makes a new version; each version survives the chat being edited or deleted, is revocable at once, and is kept for the organization's chat retention from the moment it was shared. Owners and admins see everything shared outside, with open counts, and revoke in bulk. Every artifact and chat downloads as Markdown. ## Share chat session `POST /v1/chat/sessions/{id}/share` Share one of your sessions as an artifact: a snapshot for the organization, chosen teams or chosen people, or outside it (named people by email, or anyone with the link) as its settings allow. Sharing again makes a new version. Audited as artifact.shared. Permission: `artifacts.share` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`chs_…`) | | `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) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string): Team slugs or ids (audience teams) - `people` (array of string): Kind people: members' emails or ids; kind external: the emails of people outside the organization (checked against artifacts.external.domains) - `allowContinue` (boolean) [default false] - `includeCode` (boolean): Kinds external and public: keep Ask your code's sources (refused, 403 external_code_not_allowed, unless artifacts.external.code is on) - `expiresIn` (string | number): Kind public: 30d, 12h or a number of days (within artifacts.external.expiry) - `expiresAt` (string (date-time)): Kind public: when the link stops opening ### Responses - `201` Shared (application/json, Artifact) - `id` (string, required): Art_…; one per version - `version` (integer, required): 1 for a session's first share, then 2, 3… [min 1] - `sessionId` (string, required): The session it was shared from (which may have changed or been deleted since) - `title` (string, required) - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The session's model when shared: nexus/auto or a pinned model - `models` (array of string, required): The models that answered, in order of first use - `author` (ArtifactAuthor, required): Readers outside the organization get the name only - `email` (string) - `name` (string) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required): Readers may continue it in a new private chat of their own - `status` ("active" | "revoked", required): Only its author sees a revoked artifact - `mine` (boolean, required): You shared it - `latest` (boolean): No newer active version you can read - `messageCount` (integer, required) - `costUsd` (number): What the shared answers cost; absent for readers outside the organization - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external, and for every reader outside), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL, else a path - `path` (string, required): /app/<org>/artifacts/<id> - `markdownUrl` (string, required): GET /v1/artifacts/{id}.md - `createdAt` (string (date-time), required): When it was shared - `sessionCreatedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `viewerUrl` (string): The fast viewer outside the app shell: <origin>/a/<id> (read through a public link: that link) - `publicUrl` (string): Kind public, for its author and the organization's owners and admins (and whoever holds it): <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `external` (boolean): Shared outside the organization (kind external or public) - `includeCode` (boolean): Outside the organization: whether Ask your code's sources are in the snapshot - `organization` (string): The organization's name, shown to every reader - `kind` ("page" | "session"): Page for a shared page (no messages; open it with GET /v1/artifacts/{id}/frame); session for a shared coding-agent session (its messages derived from its timeline, `session` on ArtifactDetail); absent for a chat - `pageId` (string): A shared page: the page - `pageFormat` ("html" | "md" | "jsx" | "sheet" | "board") - `pageVersion` (integer): A shared page: the version it pins; absent: the latest - `pageRole` ("view" | "edit"): A shared page: edit when its readers in the organization may edit the page; absent for a chat - `404` No such session among yours (`chat_session_not_found`): someone else's session answers the same. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session among yours (`chat_session_not_found`): someone else's session answers the same. | | 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/chat/sessions/<id>/share" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "audience": "org" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fchat%2Fsessions%2F%7Bid%7D%2Fshare) ## Unshare chat session `DELETE /v1/chat/sessions/{id}/share` Make one of your sessions private again ("Only you"): every active version of its artifact is revoked at once, and Nexus UI's cached pages go with them. Nothing shared is a no-op. Audited as artifact.revoked per version. Permission: `artifacts.share` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`chs_…`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `sessionId` (string, required) - `visibility` ("private", required) - `revoked` (array of object, required): The versions revoked now, oldest first; empty when nothing was shared. - `id` (string, required) - `version` (integer, required) - `404` No such session among yours (`chat_session_not_found`): someone else's session answers the same. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session among yours (`chat_session_not_found`): someone else's session answers the same. | | 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/chat/sessions/<id>/share" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fchat%2Fsessions%2F%7Bid%7D%2Fshare) ## Export chat session `GET /v1/chat/sessions/{id}/export.md` One of your sessions as Markdown: YAML front matter, the conversation, sources as links, the cost per answer and in total. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`chs_…`) | ### Responses - `200` Markdown with YAML front matter (text/markdown, string) - `404` No such session among yours (`chat_session_not_found`): someone else's session answers the same. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session among yours (`chat_session_not_found`): someone else's session answers the same. | | 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/chat/sessions/<id>/export.md" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fchat%2Fsessions%2F%7Bid%7D%2Fexport.md) ## List artifacts `GET /v1/artifacts` Artifacts shared with you and by you, newest first; shared_with_me includes what other organizations shared with your verified email. Nexus UI's server may call it for a person with no organization. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `order` | query | "recent" \| "name" \| "kind" \| "created" | no | The order for this list. Keep the same filter and order when sending its cursor. | | `scope` | query | "all" \| "shared_with_me" \| "shared_by_me" | no | | | `status` | query | "active" \| "revoked" \| "all" | no | Active, revoked or all (default: all you may read: every active artifact shared with or by you, and your own revoked ones, marked revoked; nobody else sees a revoked artifact) | | `session` | query | string | no | Only the versions shared from this session of yours | | `q` | query | string | no | Words in the title | | `limit` | query | integer | no | | | `cursor` | query | string | no | NextCursor of the previous page | ### Responses - `200` OK (application/json, ArtifactPage) - `artifacts` (array of Artifact, required) - `id` (string, required): Art_…; one per version - `version` (integer, required): 1 for a session's first share, then 2, 3… [min 1] - `sessionId` (string, required): The session it was shared from (which may have changed or been deleted since) - `title` (string, required) - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The session's model when shared: nexus/auto or a pinned model - `models` (array of string, required): The models that answered, in order of first use - `author` (ArtifactAuthor, required): Readers outside the organization get the name only - `email` (string) - `name` (string) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required): Readers may continue it in a new private chat of their own - `status` ("active" | "revoked", required): Only its author sees a revoked artifact - `mine` (boolean, required): You shared it - `latest` (boolean): No newer active version you can read - `messageCount` (integer, required) - `costUsd` (number): What the shared answers cost; absent for readers outside the organization - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external, and for every reader outside), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL, else a path - `path` (string, required): /app/<org>/artifacts/<id> - `markdownUrl` (string, required): GET /v1/artifacts/{id}.md - `createdAt` (string (date-time), required): When it was shared - `sessionCreatedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `viewerUrl` (string): The fast viewer outside the app shell: <origin>/a/<id> (read through a public link: that link) - `publicUrl` (string): Kind public, for its author and the organization's owners and admins (and whoever holds it): <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `external` (boolean): Shared outside the organization (kind external or public) - `includeCode` (boolean): Outside the organization: whether Ask your code's sources are in the snapshot - `organization` (string): The organization's name, shown to every reader - `kind` ("page" | "session"): Page for a shared page (no messages; open it with GET /v1/artifacts/{id}/frame); session for a shared coding-agent session (its messages derived from its timeline, `session` on ArtifactDetail); absent for a chat - `pageId` (string): A shared page: the page - `pageFormat` ("html" | "md" | "jsx" | "sheet" | "board") - `pageVersion` (integer): A shared page: the version it pins; absent: the latest - `pageRole` ("view" | "edit"): A shared page: edit when its readers in the organization may edit the page; absent for a chat - `nextCursor` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/artifacts" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fartifacts) ## Share agent session `POST /v1/artifacts/sessions` Share a coding-agent session (a Code session in Nexus for desktop, or a nexus claude session) as an artifact, from a snapshot your app builds: with the same audiences as a chat, as the organization's settings allow. Sharing the same session again makes a new version. Readers cannot continue it. Thinking stays out unless included. Common key and token formats are hidden, and home folders become ~; images are not checked. Audited as artifact.shared. Permission: `artifacts.share` (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) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string): Team slugs or ids (audience teams) - `people` (array of string): Kind people: members' emails or ids; kind external: the emails of people outside the organization (checked against artifacts.external.domains) - `expiresIn` (string | number): Kind public: 30d, 12h or a number of days (within artifacts.external.expiry) - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `replace` (boolean): Revoke the session's earlier active versions in the same step, so it has exactly this audience - `follow` (boolean): Keep updated: later snapshots sent with update replace this share's content in place, so its link stays the same - `update` (boolean): Write this snapshot over the session's Keep updated share in place: same link, readers and expiry, no new version, no email. The audience fields are ignored; includeThinking must match the share (else 400). 200; no such share is 404 artifact_not_found. Audited as artifact.updated - `includeThinking` (boolean): Keep the agent's thinking; left out by default - `session` (object, required): The snapshot your app built from its own log. The checked timeline is at most 4 MB - `source` ("desktop" | "claude-code", required) - `id` (string, required): Your app's id for the session: the same id shares its next version [min length 1; max length 200] - `title` (string): Cut to 200 characters. Absent: the first prompt's first line - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string) [max length 200] - `costUsd` (number) [min 0] - `startedAt` (integer) [min 0] - `events` (array of SessionEvent, required) [at most 20000 items] - `kind` ("user" | "text" | "thinking" | "tool" | "toolResult" | "approval" | "approvalResolved" | "usage" | "turnStart" | "turnEnd" | "task" | "notice" | "error", required) - `at` (integer): When it happened, in milliseconds [min 0] - `id` (string) [max length 200] - `text` (string) - `parent` (string | null): The sub-agent's tool call that made it; absent or null: the session's own agent [max length 200] - `name` (string) [max length 200] - `input` (any): A tool's input, as the agent sent it - `output` (string): A tool's result: at most 64 KiB, the desktop timeline's cap [max length 65536] - `isError` (boolean) - `truncated` (boolean) - `images` (array of string): Ids of the request's images - `requestId` (string) [max length 200] - `toolUseId` (string) [max length 200] - `tool` (string) [max length 200] - `description` (string) - `decision` ("allow" | "allowSession" | "deny" | "expired") - `message` (string) - `model` (string) [max length 200] - `inputTokens` (integer) [min 0] - `outputTokens` (integer) [min 0] - `cacheReadTokens` (integer) [min 0] - `cacheWriteTokens` (integer) [min 0] - `costUsd` (number) [min 0] - `turnId` (string) [max length 200] - `status` (string): TurnEnd: completed, interrupted or error; task: running, completed, failed or stopped - `durationMs` (integer) [min 0] - `error` (string) - `taskId` (string) [max length 200] - `agentType` (string) [max length 200] - `detail` (string) - `images` (array of object): The images the events name, at most 20 MB in all; PNG, JPEG, GIF or WebP, at most 5 MB each [at most 32 items] - `id` (string, required) [pattern ^[A-Za-z0-9_-]{1,64}$] - `data` (string, required): Base64, or a data: URL - `name` (string) ### Responses - `200` Updated in place (update) (application/json, Artifact) - `id` (string, required): Art_…; one per version - `version` (integer, required): 1 for a session's first share, then 2, 3… [min 1] - `sessionId` (string, required): The session it was shared from (which may have changed or been deleted since) - `title` (string, required) - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The session's model when shared: nexus/auto or a pinned model - `models` (array of string, required): The models that answered, in order of first use - `author` (ArtifactAuthor, required): Readers outside the organization get the name only - `email` (string) - `name` (string) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required): Readers may continue it in a new private chat of their own - `status` ("active" | "revoked", required): Only its author sees a revoked artifact - `mine` (boolean, required): You shared it - `latest` (boolean): No newer active version you can read - `messageCount` (integer, required) - `costUsd` (number): What the shared answers cost; absent for readers outside the organization - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external, and for every reader outside), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL, else a path - `path` (string, required): /app/<org>/artifacts/<id> - `markdownUrl` (string, required): GET /v1/artifacts/{id}.md - `createdAt` (string (date-time), required): When it was shared - `sessionCreatedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `viewerUrl` (string): The fast viewer outside the app shell: <origin>/a/<id> (read through a public link: that link) - `publicUrl` (string): Kind public, for its author and the organization's owners and admins (and whoever holds it): <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `external` (boolean): Shared outside the organization (kind external or public) - `includeCode` (boolean): Outside the organization: whether Ask your code's sources are in the snapshot - `organization` (string): The organization's name, shown to every reader - `kind` ("page" | "session"): Page for a shared page (no messages; open it with GET /v1/artifacts/{id}/frame); session for a shared coding-agent session (its messages derived from its timeline, `session` on ArtifactDetail); absent for a chat - `pageId` (string): A shared page: the page - `pageFormat` ("html" | "md" | "jsx" | "sheet" | "board") - `pageVersion` (integer): A shared page: the version it pins; absent: the latest - `pageRole` ("view" | "edit"): A shared page: edit when its readers in the organization may edit the page; absent for a chat - `201` Shared (application/json, Artifact) - `id` (string, required): Art_…; one per version - `version` (integer, required): 1 for a session's first share, then 2, 3… [min 1] - `sessionId` (string, required): The session it was shared from (which may have changed or been deleted since) - `title` (string, required) - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The session's model when shared: nexus/auto or a pinned model - `models` (array of string, required): The models that answered, in order of first use - `author` (ArtifactAuthor, required): Readers outside the organization get the name only - `email` (string) - `name` (string) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required): Readers may continue it in a new private chat of their own - `status` ("active" | "revoked", required): Only its author sees a revoked artifact - `mine` (boolean, required): You shared it - `latest` (boolean): No newer active version you can read - `messageCount` (integer, required) - `costUsd` (number): What the shared answers cost; absent for readers outside the organization - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external, and for every reader outside), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL, else a path - `path` (string, required): /app/<org>/artifacts/<id> - `markdownUrl` (string, required): GET /v1/artifacts/{id}.md - `createdAt` (string (date-time), required): When it was shared - `sessionCreatedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `viewerUrl` (string): The fast viewer outside the app shell: <origin>/a/<id> (read through a public link: that link) - `publicUrl` (string): Kind public, for its author and the organization's owners and admins (and whoever holds it): <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `external` (boolean): Shared outside the organization (kind external or public) - `includeCode` (boolean): Outside the organization: whether Ask your code's sources are in the snapshot - `organization` (string): The organization's name, shown to every reader - `kind` ("page" | "session"): Page for a shared page (no messages; open it with GET /v1/artifacts/{id}/frame); session for a shared coding-agent session (its messages derived from its timeline, `session` on ArtifactDetail); absent for a chat - `pageId` (string): A shared page: the page - `pageFormat` ("html" | "md" | "jsx" | "sheet" | "board") - `pageVersion` (integer): A shared page: the version it pins; absent: the latest - `pageRole` ("view" | "edit"): A shared page: edit when its readers in the organization may edit the page; absent for a chat - `413` The timeline is over 4 MB, or the images over their limits (session_too_large, image_too_large) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 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 | | 413 | | The timeline is over 4 MB, or the images over their limits (session_too_large, image_too_large) | | 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/artifacts/sessions" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "audience": "org", "session": { "source": "desktop", "id": "<id>", "events": [ { "kind": "user" } ] } }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fartifacts%2Fsessions) ## Unshare agent session `DELETE /v1/artifacts/sessions/{id}` Stop sharing one of your coding sessions: every active version of its artifact is revoked at once, as a chat's unshare. Your own session with nothing active left changes nothing. A key you never shared under is 404 artifact_not_found. Each version is audited as artifact.revoked. Permission: `artifacts.share` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's key (`cds_…`): the `sessionId` its share answered | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `sessionId` (string, required) - `visibility` ("private", required) - `revoked` (array of object, required): The versions revoked now, oldest first; empty when nothing was shared. - `id` (string, required) - `version` (integer, required) - `404` You shared no coding session under this key (artifact_not_found) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | You shared no coding session under this key (artifact_not_found) | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/artifacts/sessions/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fartifacts%2Fsessions%2F%7Bid%7D) ## Get artifact `GET /v1/artifacts/{id}` An artifact shared with you (or by you), with its messages: as members see it, or (outside the organization) the external variant. Outside its audience: 404; a signed-in person with a verified email outside an external artifact's audience: 403 artifact_access_required (they may ask). A named outsider's open is counted. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The artifact's id (`art_…`) | ### Responses - `200` OK (application/json, ArtifactDetail) - `id` (string, required): Art_…; one per version - `version` (integer, required): 1 for a session's first share, then 2, 3… [min 1] - `sessionId` (string, required): The session it was shared from (which may have changed or been deleted since) - `title` (string, required) - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The session's model when shared: nexus/auto or a pinned model - `models` (array of string, required): The models that answered, in order of first use - `author` (ArtifactAuthor, required): Readers outside the organization get the name only - `email` (string) - `name` (string) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required): Readers may continue it in a new private chat of their own - `status` ("active" | "revoked", required): Only its author sees a revoked artifact - `mine` (boolean, required): You shared it - `latest` (boolean): No newer active version you can read - `messageCount` (integer, required) - `costUsd` (number): What the shared answers cost; absent for readers outside the organization - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external, and for every reader outside), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL, else a path - `path` (string, required): /app/<org>/artifacts/<id> - `markdownUrl` (string, required): GET /v1/artifacts/{id}.md - `createdAt` (string (date-time), required): When it was shared - `sessionCreatedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `viewerUrl` (string): The fast viewer outside the app shell: <origin>/a/<id> (read through a public link: that link) - `publicUrl` (string): Kind public, for its author and the organization's owners and admins (and whoever holds it): <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `external` (boolean): Shared outside the organization (kind external or public) - `includeCode` (boolean): Outside the organization: whether Ask your code's sources are in the snapshot - `organization` (string): The organization's name, shown to every reader - `kind` ("page" | "session"): Page for a shared page (no messages; open it with GET /v1/artifacts/{id}/frame); session for a shared coding-agent session (its messages derived from its timeline, `session` on ArtifactDetail); absent for a chat - `pageId` (string): A shared page: the page - `pageFormat` ("html" | "md" | "jsx" | "sheet" | "board") - `pageVersion` (integer): A shared page: the version it pins; absent: the latest - `pageRole` ("view" | "edit"): A shared page: edit when its readers in the organization may edit the page; absent for a chat - `messages` (array of ChatSessionMessage, required): The snapshot, oldest first; citations from repositories you cannot see are left out - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `hiddenSources` (integer, required): Citations left out: from repositories the reader cannot see, or (outside the organization) Ask your code's sources not included - `versions` (array of ArtifactLink): Every version of the session's artifact you can read, newest first - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `variant` ("member" | "external"): Member: as the organization's members see it; external: no cost, author email or team names, and no code sources unless included - `session` (SessionSnapshot): A shared coding-agent session (kind session): its timeline as the sharer's app showed it. Outside the organization: no cost and no usage events - `format` (integer, required): 1 - `source` ("desktop" | "claude-code", required): Desktop: a Code session in Nexus for desktop; claude-code: a nexus claude session's Claude Code transcript - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string) - `costUsd` (number): The agent's own estimate. Hidden from readers outside the organization - `startedAt` (integer): When the session started, in milliseconds - `thinking` (boolean, required): Whether the sharer included the agent's thinking - `events` (array of SessionEvent, required) - `kind` ("user" | "text" | "thinking" | "tool" | "toolResult" | "approval" | "approvalResolved" | "usage" | "turnStart" | "turnEnd" | "task" | "notice" | "error", required) - `at` (integer): When it happened, in milliseconds [min 0] - `id` (string) [max length 200] - `text` (string) - `parent` (string | null): The sub-agent's tool call that made it; absent or null: the session's own agent [max length 200] - `name` (string) [max length 200] - `input` (any): A tool's input, as the agent sent it - `output` (string): A tool's result: at most 64 KiB, the desktop timeline's cap [max length 65536] - `isError` (boolean) - `truncated` (boolean) - `images` (array of string): Ids of the request's images - `requestId` (string) [max length 200] - `toolUseId` (string) [max length 200] - `tool` (string) [max length 200] - `description` (string) - `decision` ("allow" | "allowSession" | "deny" | "expired") - `message` (string) - `model` (string) [max length 200] - `inputTokens` (integer) [min 0] - `outputTokens` (integer) [min 0] - `cacheReadTokens` (integer) [min 0] - `cacheWriteTokens` (integer) [min 0] - `costUsd` (number) [min 0] - `turnId` (string) [max length 200] - `status` (string): TurnEnd: completed, interrupted or error; task: running, completed, failed or stopped - `durationMs` (integer) [min 0] - `error` (string) - `taskId` (string) [max length 200] - `agentType` (string) [max length 200] - `detail` (string) - `images` (array of object, required): The images the events name; read each with getArtifactAttachment - `id` (string, required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp", required) - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/artifacts/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fartifacts%2F%7Bid%7D) ## Revoke artifact `DELETE /v1/artifacts/{id}` Revoke an artifact at once: its author, or an owner or admin of its organization. Nexus UI's cached page goes with it (the signed hook). Audited as artifact.revoked. Permission: `artifacts.share` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The artifact's id (`art_…`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `revoked` (boolean, required) - `id` (string, required) - `version` (integer, 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/artifacts/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fartifacts%2F%7Bid%7D) ## Export artifact `GET /v1/artifacts/{id}.md` An artifact as Markdown: YAML front matter, a link back to it, the conversation, sources as links, the cost per answer and in total. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The artifact's id (`art_…`) | ### Responses - `200` Markdown with YAML front matter (text/markdown, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/artifacts/<id>.md" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fartifacts%2F%7Bid%7D.md) ## Continue artifact `POST /v1/artifacts/{id}/continue` Continue an artifact (its id, or a public link's token) in a new private session of your own, in one of your organizations and at its expense (when its author allows, and from outside when artifacts.external.continue is on). Shared inside one of your organizations: in that organization (another `org`: 403 stays_in_organization). From outside the sharer's organization: in `org` when given (one of yours, else 404 not_a_member), else in the sharer's organization when you belong to it, else in your personal organization, made then if you have none. Someone Nexus does not know yet: 409 organization_required. Audited as artifact.continued in the organization the copy is made in. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The artifact's id (`art_…`) | | `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) - `title` (string) [max length 120] - `team` (string) - `org` (string): Where the copy goes: one of your organizations (a slug, an id, or `personal`). Default: see the summary. ### Responses - `201` Created (application/json, ContinuedChatSession) - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `org` (OrgSummary, required) - `id` (string, required) - `name` (string, required) - `slug` (string) - `clerkOrgId` (string): Its sign-in provider organization's id: Nexus UI's URL segment when it has no slug - `kind` ("company" | "personal", required): A company organization, or a person's own personal organization (one per person, one member) - `role` ("owner" | "admin" | "member") - `current` (boolean): The organization this request is in - `imageUrl` (string): Its logo, as the tenant's imageUrl (https://img.clerk.com/…); unset when it has none. - `orgCreated` (boolean, required): Whether that organization was made now: your personal organization, which you did not have yet. - `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 POST "$NEXUS_URL/v1/artifacts/<id>/continue" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "title": "<title>", "team": "platform", "org": "<org>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fartifacts%2F%7Bid%7D%2Fcontinue) ## List external artifacts `GET /v1/artifacts/external` Everything the organization shared outside it, newest first, with open counts, readers, requests and reports (owners and admins). Permission: `artifacts.manage_external` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `audience` | query | "external" \| "public" | no | | | `author` | query | string | no | An author's email or user id | | `team` | query | string | no | A team (slug or id) and the teams under it: the team of the session it was shared from | | `status` | query | "active" \| "revoked" \| "all" | no | | | `q` | query | string | no | Words in the title | | `limit` | query | integer | no | | | `cursor` | query | string | no | | ### Responses - `200` OK (application/json, ExternalArtifactPage) - `artifacts` (array of ExternalArtifact, required) - `id` (string, required): Art_…; one per version - `version` (integer, required): 1 for a session's first share, then 2, 3… [min 1] - `sessionId` (string, required): The session it was shared from (which may have changed or been deleted since) - `title` (string, required) - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The session's model when shared: nexus/auto or a pinned model - `models` (array of string, required): The models that answered, in order of first use - `author` (ArtifactAuthor, required): Readers outside the organization get the name only - `email` (string) - `name` (string) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required): Readers may continue it in a new private chat of their own - `status` ("active" | "revoked", required): Only its author sees a revoked artifact - `mine` (boolean, required): You shared it - `latest` (boolean): No newer active version you can read - `messageCount` (integer, required) - `costUsd` (number): What the shared answers cost; absent for readers outside the organization - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external, and for every reader outside), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL, else a path - `path` (string, required): /app/<org>/artifacts/<id> - `markdownUrl` (string, required): GET /v1/artifacts/{id}.md - `createdAt` (string (date-time), required): When it was shared - `sessionCreatedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `viewerUrl` (string): The fast viewer outside the app shell: <origin>/a/<id> (read through a public link: that link) - `publicUrl` (string): Kind public, for its author and the organization's owners and admins (and whoever holds it): <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `external` (boolean): Shared outside the organization (kind external or public) - `includeCode` (boolean): Outside the organization: whether Ask your code's sources are in the snapshot - `organization` (string): The organization's name, shown to every reader - `kind` ("page" | "session"): Page for a shared page (no messages; open it with GET /v1/artifacts/{id}/frame); session for a shared coding-agent session (its messages derived from its timeline, `session` on ArtifactDetail); absent for a chat - `pageId` (string): A shared page: the page - `pageFormat` ("html" | "md" | "jsx" | "sheet" | "board") - `pageVersion` (integer): A shared page: the version it pins; absent: the latest - `pageRole` ("view" | "edit"): A shared page: edit when its readers in the organization may edit the page; absent for a chat - `opens` (integer, required) - `readers` (integer, required): Named outsiders with access - `requests` (integer, required): Requests for access waiting for an answer - `reports` (integer, required) - `team` (string): The team of the session it was shared from - `nextCursor` (string) - `totals` (object, required) - `active` (integer, required) - `named` (integer, required) - `public` (integer, 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 | | 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/artifacts/external" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fartifacts%2Fexternal) ## Revoke artifacts `POST /v1/artifacts/revoke` Revoke several of the organization's artifacts at once (at most 100; owners and admins). Each is audited as artifact.revoked. Permission: `artifacts.manage_external` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `ids` (array of string, required) [at most 100 items] ### Responses - `200` OK (application/json, object) - `revoked` (array of object, required) - `id` (string, required) - `version` (integer, required) - `skipped` (array of object, required) - `id` (string, required) - `reason` ("not_found" | "already_revoked", 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/artifacts/revoke" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "ids": [ "<id>" ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fartifacts%2Frevoke) ## Get artifact access `GET /v1/artifacts/{id}/access` Who has an artifact shared outside, who asked for access, opens and reports: its author, owners and admins. Permission: `artifacts.share` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The artifact's id (`art_…`) | ### Responses - `200` OK (application/json, ArtifactAccess) - `id` (string, required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `status` ("active" | "revoked", required) - `people` (array of ArtifactAccessPerson, required) - `email` (string, required) - `status` ("granted" | "requested" | "denied" | "removed", required) - `opens` (integer, required) - `lastOpenedAt` (string (date-time)) - `requestedAt` (string (date-time)) - `grantedAt` (string (date-time)) - `message` (string): What the person asking wrote - `opens` (integer, required) - `lastOpenedAt` (string (date-time)) - `reports` (integer, required) - `expiresAt` (string (date-time)) - `publicUrl` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/artifacts/<id>/access" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fartifacts%2F%7Bid%7D%2Faccess) ## Change artifact access `POST /v1/artifacts/{id}/access` Grant (approve a request, or add someone), deny a request, or remove someone's access to an artifact shared with named people outside: its author, owners and admins. Audited as artifact.access_changed (counts and domains). Permission: `artifacts.share` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The artifact's id (`art_…`) | | `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) - `grant` (array of string) - `deny` (array of string) - `remove` (array of string) ### Responses - `200` OK (application/json, ArtifactAccess) - `id` (string, required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `status` ("active" | "revoked", required) - `people` (array of ArtifactAccessPerson, required) - `email` (string, required) - `status` ("granted" | "requested" | "denied" | "removed", required) - `opens` (integer, required) - `lastOpenedAt` (string (date-time)) - `requestedAt` (string (date-time)) - `grantedAt` (string (date-time)) - `message` (string): What the person asking wrote - `opens` (integer, required) - `lastOpenedAt` (string (date-time)) - `reports` (integer, required) - `expiresAt` (string (date-time)) - `publicUrl` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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 POST "$NEXUS_URL/v1/artifacts/<id>/access" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "grant": [ "<grant>" ], "deny": [ "<deny>" ], "remove": [ "<remove>" ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fartifacts%2F%7Bid%7D%2Faccess) ## Request artifact access `POST /v1/artifacts/{id}/access-requests` Ask an artifact's author for access (someone outside its audience, signed in with a verified email). Nexus UI's server may call it for a person with no organization. Audited as artifact.access_requested (the domain). Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The artifact's id (`art_…`) | | `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) - `message` (string) [max length 500] ### Responses - `200` Already answered (application/json, object) - `status` ("granted" | "requested" | "denied", required) - `requested` (boolean, required) - `202` Requested (application/json, object) - `status` ("requested", required) - `requested` (boolean, 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 POST "$NEXUS_URL/v1/artifacts/<id>/access-requests" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "message": "<message>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fartifacts%2F%7Bid%7D%2Faccess-requests) ## Get artifact attachment `GET /v1/artifacts/{id}/attachments/{attachmentId}` An image attached to one of an artifact's questions, with its bytes as base64 (`data:<mediaType>;base64,<data>` shows it), to everyone who may read the artifact (getArtifact's rules: its audience inside the organization, named people outside it by verified email; its author always). The snapshot keeps its own copy, so it outlives the session. Not one of its images: 404 artifact_attachment_not_found. Reading it is not counted as an open. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The artifact's id (`art_…`) | | `attachmentId` | path | string | yes | The image's id (`cha_…`), from the message's `attachments` | ### Responses - `200` The image (application/json, ArtifactAttachment) - `id` (string, required): The image's id as the artifact's messages list it - `artifactId` (string, required) - `messageId` (string, required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp", required) - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `data` (string, required): Standard base64 - `createdAt` (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/artifacts/<id>/attachments/<attachmentId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fartifacts%2F%7Bid%7D%2Fattachments%2F%7BattachmentId%7D) ## Get public artifact `GET /v1/public/artifacts/{token}` A public artifact through its link, as anyone holding it reads it (the external variant). No credential; never indexed (X-Robots-Tag). Revoked, expired or unknown: 404. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `token` | path | string | yes | A public link's token (the last part of `/a/<token>`) | ### Responses - `200` OK (application/json, ArtifactDetail) - `id` (string, required): Art_…; one per version - `version` (integer, required): 1 for a session's first share, then 2, 3… [min 1] - `sessionId` (string, required): The session it was shared from (which may have changed or been deleted since) - `title` (string, required) - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The session's model when shared: nexus/auto or a pinned model - `models` (array of string, required): The models that answered, in order of first use - `author` (ArtifactAuthor, required): Readers outside the organization get the name only - `email` (string) - `name` (string) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required): Readers may continue it in a new private chat of their own - `status` ("active" | "revoked", required): Only its author sees a revoked artifact - `mine` (boolean, required): You shared it - `latest` (boolean): No newer active version you can read - `messageCount` (integer, required) - `costUsd` (number): What the shared answers cost; absent for readers outside the organization - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external, and for every reader outside), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL, else a path - `path` (string, required): /app/<org>/artifacts/<id> - `markdownUrl` (string, required): GET /v1/artifacts/{id}.md - `createdAt` (string (date-time), required): When it was shared - `sessionCreatedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `viewerUrl` (string): The fast viewer outside the app shell: <origin>/a/<id> (read through a public link: that link) - `publicUrl` (string): Kind public, for its author and the organization's owners and admins (and whoever holds it): <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `external` (boolean): Shared outside the organization (kind external or public) - `includeCode` (boolean): Outside the organization: whether Ask your code's sources are in the snapshot - `organization` (string): The organization's name, shown to every reader - `kind` ("page" | "session"): Page for a shared page (no messages; open it with GET /v1/artifacts/{id}/frame); session for a shared coding-agent session (its messages derived from its timeline, `session` on ArtifactDetail); absent for a chat - `pageId` (string): A shared page: the page - `pageFormat` ("html" | "md" | "jsx" | "sheet" | "board") - `pageVersion` (integer): A shared page: the version it pins; absent: the latest - `pageRole` ("view" | "edit"): A shared page: edit when its readers in the organization may edit the page; absent for a chat - `messages` (array of ChatSessionMessage, required): The snapshot, oldest first; citations from repositories you cannot see are left out - `id` (string, required) - `sessionId` (string, required) - `role` ("user" | "assistant", required) - `content` (string, required): Markdown (a question with images may have none) - `status` ("complete" | "failed" | "refused", required): Refused: the policy or budget refused the call (error says why); failed: it broke mid-way (content is what arrived) - `mode` ("chat" | "ask"): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `requestedModel` (string) - `model` (string): The model that ran - `costUsd` (number) - `usage` (object) - `promptTokens` (integer) - `completionTokens` (integer) - `citations` (array of ChatCitation) - `n` (integer, required): The number the answer cites it by - `repo` (string, required): Owner/name - `page` (string, required) - `slug` (string, required) - `section` (string) - `path` (string, required): <slug>#<anchor> in the repository's wiki - `files` (array of string): Repository files the section names - `runId` (string, required): The Nexus Wiki run that wrote the page - `error` (object) - `code` (string) - `message` (string) - `status` (integer) - `notified` (boolean): A budget refusal told the organization's owners and admins (licensed build). Absent otherwise. - `remainingUsdDecimal` (string): A budget refusal's `remainingUsdDecimal`: what was left of that level's budget, as an exact decimal. Absent when the 402 had none. - `requestedUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `requestedUsd`: the most the call may cost with Nexus's rate, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `remainingUsd` (string): A usage-limit refusal's (`usage_limit_reached`) `remainingUsd`: what this month's usage limit had left, as an exact decimal. Absent for any other refusal, or when the 402 had none. - `details` (object): A 402's details, as the live error's `error.nexus` had them, cut to an allow-list: short codes, ways forward, `notified` and decimal dollar amounts. Absent for any other status, when none was kept, and on an answer stored before it. - `reason` (string): Why the refusal happened, such as `authentication_required` or `disputed` for `payment_failed`. - `level` (string): A budget refusal's level. - `freeStart` (string): `cheaper_models_only` when the free start pays for cheaper models only. - `next` (array of string): The ways forward, such as `billing` and `own_key`; at most 4. - `notified` (boolean): The organization's owners and admins were told. - `owedUsd` (string) - `unpaidUsd` (string) - `remainingUsd` (string) - `remainingUsdDecimal` (string) - `requestedUsd` (string) - `limitUsd` (string) - `chargeUsd` (string) - `capUsd` (string) - `createdAt` (string (date-time), required) - `attachments` (array of ChatAttachmentRef): The images attached to a question - `id` (string, required) - `type` ("image" | "file", required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp" | "text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required): An image's from the bytes, not as it was named; a data file's from its extension, checked against the bytes - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `page` (ChatPageBlock): A page this answer created or revised through write_page - `pageId` (string, required) - `version` (integer, required) [min 1] - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `skills` (array of ChatSkillBlock): The skills this answer loaded through load_skill, in the order it loaded them. The file stays in the skills store - `skillId` (string, required): Skl_… For a library skill, the library skill's id, which getSkill and getSkillVersion also take - `name` (string, required): The name the version had when it was served - `version` (integer, required): The version served: a personal skill's latest, or a library skill's latest approved version that nobody withdrew [min 1] - `scope` ("personal" | "team" | "org"): Where the skill came from: your own skills, a team's library, or the organization's. Left out on an answer stored before skills had a scope: read it as personal - `teamId` (string): The team (team_…), for scope team. Map it to the team's name with listTeams - `connectors` (array of ChatConnectorBlock): The connector reads this answer ran through read_connector, in order. What they returned is never kept. In a shared artifact, a reader sees only the reads of connectors they may use - `connector` (string, required) - `operation` (string, required) - `input` (object, required) - `account` (object): The connection the read ran with: whose it is and the account's name. Absent while the read streams, and on reads kept before it was recorded - `scope` ("org" | "team" | "user", required) - `name` (string, required) - `sources` (array of ChatWebSource): The web pages this answer's searches gave the model, one per URL, in the order they were found. Only the session's author reads them; a shared artifact keeps none - `title` (string, required) - `url` (string, required) - `date` (string): The page's date as the engine gave it, cut as the model read it - `query` (string, required): The first query in the turn that found this page - `rewound` (boolean): Retained for the author, but excluded from future model context after a conversation rewind. - `hiddenSources` (integer, required): Citations left out: from repositories the reader cannot see, or (outside the organization) Ask your code's sources not included - `versions` (array of ArtifactLink): Every version of the session's artifact you can read, newest first - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `variant` ("member" | "external"): Member: as the organization's members see it; external: no cost, author email or team names, and no code sources unless included - `session` (SessionSnapshot): A shared coding-agent session (kind session): its timeline as the sharer's app showed it. Outside the organization: no cost and no usage events - `format` (integer, required): 1 - `source` ("desktop" | "claude-code", required): Desktop: a Code session in Nexus for desktop; claude-code: a nexus claude session's Claude Code transcript - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string) - `costUsd` (number): The agent's own estimate. Hidden from readers outside the organization - `startedAt` (integer): When the session started, in milliseconds - `thinking` (boolean, required): Whether the sharer included the agent's thinking - `events` (array of SessionEvent, required) - `kind` ("user" | "text" | "thinking" | "tool" | "toolResult" | "approval" | "approvalResolved" | "usage" | "turnStart" | "turnEnd" | "task" | "notice" | "error", required) - `at` (integer): When it happened, in milliseconds [min 0] - `id` (string) [max length 200] - `text` (string) - `parent` (string | null): The sub-agent's tool call that made it; absent or null: the session's own agent [max length 200] - `name` (string) [max length 200] - `input` (any): A tool's input, as the agent sent it - `output` (string): A tool's result: at most 64 KiB, the desktop timeline's cap [max length 65536] - `isError` (boolean) - `truncated` (boolean) - `images` (array of string): Ids of the request's images - `requestId` (string) [max length 200] - `toolUseId` (string) [max length 200] - `tool` (string) [max length 200] - `description` (string) - `decision` ("allow" | "allowSession" | "deny" | "expired") - `message` (string) - `model` (string) [max length 200] - `inputTokens` (integer) [min 0] - `outputTokens` (integer) [min 0] - `cacheReadTokens` (integer) [min 0] - `cacheWriteTokens` (integer) [min 0] - `costUsd` (number) [min 0] - `turnId` (string) [max length 200] - `status` (string): TurnEnd: completed, interrupted or error; task: running, completed, failed or stopped - `durationMs` (integer) [min 0] - `error` (string) - `taskId` (string) [max length 200] - `agentType` (string) [max length 200] - `detail` (string) - `images` (array of object, required): The images the events name; read each with getArtifactAttachment - `id` (string, required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp", required) - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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). | ### Example ```sh curl "$NEXUS_URL/v1/public/artifacts/<token>" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpublic%2Fartifacts%2F%7Btoken%7D) ## Export public artifact `GET /v1/public/artifacts/{token}.md` A public artifact through its link, as Markdown (no cost, no author email). No credential. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `token` | path | string | yes | The token followed by .md | ### Responses - `200` Markdown with YAML front matter (text/markdown, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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). | ### Example ```sh curl "$NEXUS_URL/v1/public/artifacts/<token>.md" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpublic%2Fartifacts%2F%7Btoken%7D.md) ## Get public artifact attachment `GET /v1/public/artifacts/{token}/attachments/{attachmentId}` An image of a public artifact through its link, with its bytes as base64. No credential; never indexed (X-Robots-Tag). Revoked, expired or unknown link: 404 artifact_not_found; not one of its images: 404 artifact_attachment_not_found. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `token` | path | string | yes | A public link's token (the last part of `/a/<token>`) | | `attachmentId` | path | string | yes | The image's id (`cha_…`), from the message's `attachments` | ### Responses - `200` The image (application/json, ArtifactAttachment) - `id` (string, required): The image's id as the artifact's messages list it - `artifactId` (string, required) - `messageId` (string, required) - `mediaType` ("image/png" | "image/jpeg" | "image/gif" | "image/webp", required) - `bytes` (integer, required) - `width` (integer) - `height` (integer) - `name` (string) - `data` (string, required): Standard base64 - `createdAt` (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 | | --- | --- | --- | | 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). | ### Example ```sh curl "$NEXUS_URL/v1/public/artifacts/<token>/attachments/<attachmentId>" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpublic%2Fartifacts%2F%7Btoken%7D%2Fattachments%2F%7BattachmentId%7D) ## Count public artifact open `POST /v1/public/artifacts/{token}/opened` Count one open of a public link's page (its beacon: the page itself is cached). A count, never who. No credential; limited per address. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `token` | path | string | yes | A public link's token (the last part of `/a/<token>`) | ### Responses - `204` Counted - `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 | | --- | --- | --- | | 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). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/public/artifacts/<token>/opened" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpublic%2Fartifacts%2F%7Btoken%7D%2Fopened) ## Report public artifact `POST /v1/public/artifacts/{token}/report` Report a public artifact ("Report" on its page) for Trust and Safety: recorded and audited in its organization as artifact.reported, and members with artifacts.manage_external get a requests.artifact_reported notification. No credential; limited per address. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `token` | path | string | yes | A public link's token (the last part of `/a/<token>`) | ### Request body (application/json, required) - `reason` ("spam" | "phishing" | "malware" | "illegal" | "other", required) - `details` (string) [max length 1000] ### Responses - `202` Reported (application/json, object) - `reported` (boolean, required) - `id` (string, 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 | | 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). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/public/artifacts/<token>/report" \ -H "Content-Type: application/json" \ -d '{ "reason": "spam" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpublic%2Fartifacts%2F%7Btoken%7D%2Freport) ## Frame artifact `GET /v1/artifacts/{id}/frame` A shared page's frame URL on the sandbox origin, valid five minutes, to anyone who may read the artifact. An unpinned page share's frame shows the page's live state, unsaved edits included; a pinned share's frame shows its version. Frame it with sandbox="allow-scripts" only. 404 artifact_not_found for a shared chat id; 404 artifact_revoked once revoked; 403 pages_off; 503 pages_viewer_unconfigured. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `siteVersion` | query | integer | no | Request signed routes for this exact authorized saved Site version. | | `id` | path | string | yes | The artifact's id (`art_…`) | ### Responses - `200` OK (application/json, PageFrame) - `siteRoutes` (array of SiteFrameRoute): The root and signed additional routes of the authorized saved Site version. - `path` (string, required) - `title` (string, required) - `url` (string, required) - `url` (string (uri), required): The signed URL on the sandbox origin; frame it with sandbox="allow-scripts" only - `expiresAt` (string (date-time), required): When the URL stops opening; mint another to reload - `pageId` (string, required) - `version` (integer, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `title` (string, 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 "$NEXUS_URL/v1/artifacts/<id>/frame" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fartifacts%2F%7Bid%7D%2Fframe) ## Stream artifact events `GET /v1/artifacts/{id}/events` A shared page's live events, as server-sent events, by the share's id: for readers without the page's own stream (the /a/ viewer, the phone app). Anyone who may frame the share reads it, and it counts no open. A query event (PageQueryEvent) says one of the page's queries has a new result (Nexus Data). Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The artifact's id (`art_…`) | ### Responses - `200` The event stream (text/event-stream, PageVersionEvent) - `pageId` (string, required) - `version` (integer, required) - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `contentSha256` (string): SHA-256 of the content, lowercase hex: a shared draft tells its own saves from other writes by it. Gateway sends it; a client treats an event without it as a write from elsewhere. - `404` A shared chat id, missing share, or inaccessible share (`artifact_not_found`). Revoked shares may return `artifact_revoked`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` A pinned share: it shows one version, so it has nothing to follow (`page_share_pinned`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Too many live readers on this Gateway copy (`page_events_full`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | A shared chat id, missing share, or inaccessible share (`artifact_not_found`). Revoked shares may return `artifact_revoked`. | | 409 | | A pinned share: it shows one version, so it has nothing to follow (`page_share_pinned`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Too many live readers on this Gateway copy (`page_events_full`) | ### Example ```sh curl "$NEXUS_URL/v1/artifacts/<id>/events" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fartifacts%2F%7Bid%7D%2Fevents) ## Frame public artifact `GET /v1/public/artifacts/{token}/frame` A public page link's frame URL, valid five minutes. An unpinned link's frame shows the page's live state, unsaved edits included; a pinned link's frame shows its version. No credential; rate limited per address. Revoked, expired, unknown, or its organization turned pages or public page links off: 404. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `siteVersion` | query | integer | no | Request signed routes for this exact authorized saved Site version. | | `token` | path | string | yes | A public link's token (the last part of `/a/<token>`) | ### Responses - `200` OK (application/json, PageFrame) - `siteRoutes` (array of SiteFrameRoute): The root and signed additional routes of the authorized saved Site version. - `path` (string, required) - `title` (string, required) - `url` (string, required) - `url` (string (uri), required): The signed URL on the sandbox origin; frame it with sandbox="allow-scripts" only - `expiresAt` (string (date-time), required): When the URL stops opening; mint another to reload - `pageId` (string, required) - `version` (integer, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `title` (string, 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 | | 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). | ### Example ```sh curl "$NEXUS_URL/v1/public/artifacts/<token>/frame" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpublic%2Fartifacts%2F%7Btoken%7D%2Fframe) ## Stream public artifact events `GET /v1/public/artifacts/{token}/events` A public page link's live events, as server-sent events. No credential. Each stream open counts against the address's public reads, and an address holds at most 32 open on each Gateway copy. A query event (PageQueryEvent) says one of the page's queries has a new result (Nexus Data). Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `token` | path | string | yes | A public link's token (the last part of `/a/<token>`) | ### Responses - `200` The event stream (text/event-stream, PageVersionEvent) - `pageId` (string, required) - `version` (integer, required) - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `contentSha256` (string): SHA-256 of the content, lowercase hex: a shared draft tells its own saves from other writes by it. Gateway sends it; a client treats an event without it as a write from elsewhere. - `404` No link opens here (`artifact_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` A pinned link: it shows one version, so it has nothing to follow (`page_share_pinned`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the address's public reads a minute, or 32 streams open from it (`page_events_per_address`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Too many live readers on this Gateway copy (`page_events_full`) (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 | | --- | --- | --- | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No link opens here (`artifact_not_found`) | | 409 | | A pinned link: it shows one version, so it has nothing to follow (`page_share_pinned`) | | 429 | | Over the address's public reads a minute, or 32 streams open from it (`page_events_per_address`) | | 503 | | Too many live readers on this Gateway copy (`page_events_full`) | ### Example ```sh curl "$NEXUS_URL/v1/public/artifacts/<token>/events" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpublic%2Fartifacts%2F%7Btoken%7D%2Fevents) --- <!-- /docs/api/auth --> # Authentication > `nexus auth login` (a device code approved in Nexus UI), personal tokens and API keys. ## Start device login `POST /v1/auth/device` Start `nexus auth login`: a device code for the CLI and a user code to approve in Nexus UI (ten minutes, single use). No key needed. Permission: `public` (Anyone, signed in or not). ### Request body (application/json, required) - `client` (string): E.g. nexus CLI on <host>. Control characters are dropped. Without agent and scope, each character outside ASCII is stored as ?. A label that starts with an agent's reserved label (Nexus Slack) needs that agent and a scope, else a 400 reserved_client. - `agent` (string): With scope: the agent the sign-in is for (slack). Its approval issues an agent link (nxo_…), never a personal token. [pattern ^[a-z0-9][a-z0-9-]{0,39}$] - `scope` (string): With agent: the matrix actions the agent link holds, space-separated (models.use, spend.read_own, connectors.use, chat.ask, chat.web, agents.memory). Any other is a 400 invalid_scope. - `client_id` (string): With NEXUS_OAUTH_CLIENT_TIERS=on: the OAuth client that signs in (nxc_cli). Without one, nxc_unregistered. An unknown or revoked client is a 400 invalid_client. ### Responses - `200` OK (application/json, object) - `device_code` (string) - `user_code` (string) - `verification_uri` (string) - `verification_uri_complete` (string) - `expires_in` (integer) - `interval` (integer) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/auth/device" \ -H "Content-Type: application/json" \ -d '{ "client": "my script" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.startDeviceLogin("my script"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fauth%2Fdevice) ## Poll device login `POST /v1/auth/token` Poll for the device login's token, no faster than `interval`. 400 with code authorization_pending, slow_down (with a new interval), expired_token or access_denied until approved; then a personal token, once, or for a sign-in that asked for a scope, an agent link that holds only that scope. With `grant_type` `authorization_code` (Rust only), the phone's sign-in exchanges the code `authorizeApp` sent to its redirect URI, with its PKCE verifier, for a personal token, once; 400 `invalid_grant` for an unknown, used, expired or mismatched code, which a failed try also uses up. Permission: `public` (Anyone, signed in or not). ### Request body (application/json, required) - `device_code` (string): The device login's code (`grant_type` `urn:ietf:params:oauth:grant-type:device_code`, or none). - `grant_type` ("urn:ietf:params:oauth:grant-type:device_code" | "authorization_code") - `code` (string): With `authorization_code`: the code sent to the app's redirect URI. - `code_verifier` (string): With `authorization_code`: the PKCE verifier whose S256 challenge `authorizeApp` was given (RFC 7636). - `redirect_uri` (string): With `authorization_code`: the redirect URI the code was sent to. ### Responses - `200` OK (application/json, object) - `access_token` (string) - `token_type` (string) - `expires_at` (string) - `tenant` (object) - `user` (object) - `role` ("owner" | "admin" | "member") - `scope` (string): The matrix actions an agent link holds, space-separated; only for a sign-in that asked for a scope. - `ui_url` (string): Nexus UI's address (`NEXUS_UI_URL`), when Gateway knows it: where a client's links into Nexus UI go. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | `invalid_grant` | With `grant_type` `authorization_code` (Rust only), the phone's sign-in exchanges the code `authorizeApp` sent to its redirect URI, with its PKCE verifier, for a personal token, once; 400 `invalid_grant` for an unknown, used, expired or mismatched code, which a failed try also uses up | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/auth/token" \ -H "Content-Type: application/json" \ -d '{ "device_code": "<device_code>", "grant_type": "urn:ietf:params:oauth:grant-type:device_code", "code": "<code>", "code_verifier": "<code_verifier>", "redirect_uri": "<redirect_uri>" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.pollDeviceLogin("<device_code>"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fauth%2Ftoken) ## List tokens `GET /v1/auth/tokens` Your live tokens in this organization; `?all=1` for everyone's (owners and admins). Newest first; `limit` and `cursor` page it. Permission: `keys.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `all` | query | "1" | no | `1` for everyone's tokens (owners and admins); default: yours | | `limit` | query | integer | no | Items per page, 1 to 500 (default 100). Without limit or cursor the answer holds the whole list. | | `cursor` | query | string | no | NextCursor from the previous page. A cursor whose item left the list answers 400 `invalid_cursor`. | ### Responses - `200` OK (application/json, object) - `tokens` (array of Token) - `id` (string, required) - `userId` (string, required) - `kind` ("api" | "cli" | "ui", required) - `prefix` (string, required) - `label` (string) - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time)) - `current` (boolean) - `nextCursor` (string): The next page's cursor, while more items follow. Only when limit or cursor was sent. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/auth/tokens" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.tokens(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fauth%2Ftokens) ## Create API key `POST /v1/auth/tokens` Create a personal API key for CI, scripts and the API. The key is in this answer only. A person holds at most 100 live API keys in an organization: the next is refused with 409 `api_key_limit` until one is revoked. Permission: `keys.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `label` (string, required) ### Responses - `201` Created (application/json, Token & object) - `id` (string, required) - `userId` (string, required) - `kind` ("api" | "cli" | "ui", required) - `prefix` (string, required) - `label` (string) - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time)) - `current` (boolean) - `token` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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 | `api_key_limit` | The next is refused with 409 `api_key_limit` until one is revoked | | 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/auth/tokens" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "label": "CI" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.createToken("CI"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fauth%2Ftokens) ## Revoke token `DELETE /v1/auth/tokens/{id}` Revoke a token: your own, or anyone's for owners and admins. Permission: `keys.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `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/auth/tokens/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.revokeToken("<token id>"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fauth%2Ftokens%2F%7Bid%7D) ## Revoke scoped key `POST /v1/auth/scoped-keys/revoke` Revoke a module's scoped key (`nxs_…`) before it expires, without rotating NEXUS_SECRET (owners and admins). A scoped key lives one hour and stops when its person leaves the organization; this stops one key at once. Name it by its key id (`scoped:<product>/<capability>/smk_…`) or by its `smk_…` mint id; 400 `invalid_scoped_key` for anything else. `GET /v1/spend` shows the key id as `keyId` on each model call the key made. The audit log shows it as the actor of the key's connector writes. Gateway keeps no record of the keys it mints, so it accepts any well-formed id. A revoke does not prove that the key was live. Revoking a revoked key answers `already: true` and changes nothing. With `dryRun: true`, nothing changes. Audited as `key.revoked` with target type `scoped_key`. Permission: `keys.manage_all` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `id` (string, required): The key id (scoped:intelligence/wiki/smk_…) or the mint id (smk_…). - `reason` (string): Why, kept in the audit event. - `dryRun` (boolean): Check the id and change nothing. [default false] ### Responses - `200` OK (application/json, ScopedKeyRevoked) - `id` (string, required): The mint id (smk_…). - `keyId` (string): The key id, when the request named it. - `already` (boolean, required): It was revoked before this request. - `dryRun` (boolean, required) - `revokedAt` (string (date-time) | null) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | `invalid_scoped_key` | Name it by its key id (`scoped:<product>/<capability>/smk_…`) or by its `smk_…` mint id; 400 `invalid_scoped_key` for anything else | | 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/auth/scoped-keys/revoke" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "id": "<id>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fauth%2Fscoped-keys%2Frevoke) ## Logout `POST /v1/auth/logout` Revoke the calling token. An agent link may end itself whatever its grant. Permission: `keys.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `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 | | 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/auth/logout" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.logout(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fauth%2Flogout) ## Whoami `GET /v1/auth/whoami` Who the calling credential is, and nothing else: its kind, its organization's id, its person's id, an agent link's grant, and the email only for a person's own credential. Any valid credential may call it (`authenticated`): an agent link and an operator whatever their grant. No organization details, no other member and no role. A person's id is set for a person's own credential, for an agent link (the person it acts for) and for an operator (the operator); a service account, a module key and a sandbox have none. Not audited, as `GET /v1/tenants/me` is not; an operator's request is logged as `operator.request`. Permission: `authenticated` (Every member, module keys). ### Responses - `200` OK (application/json, Whoami) - `kind` ("person" | "agent_link" | "service_account" | "module" | "sandbox" | "operator", required): `person`: a person's own API key, CLI token or Nexus UI session; `agent_link`: an agent link (`nxo_…`); `service_account`: `nxsa_…`; `module`: a module's scoped key; `sandbox`: a sandbox session's reference; `operator`: a Nexus operator under a grant. - `tenantId` (string, required): The organization the credential acts in. - `userId` (string): The person: the caller's own, an agent link's person, or the operator. Absent for a service account, a module key and a sandbox. - `email` (string): The person's email, only for a person's own credential. - `grant` (array of string): An agent link's granted actions (matrix names). Absent for every other kind. - `role` ("owner" | "admin" | "member"): The person's role in the organization: the caller's own, or the role of the person an agent link acts for. Absent for every other kind. - `features` (GatewayFeatures): The products this Gateway has on. Unset reads as all off. - `wiki` (boolean, required): Nexus Wiki is on. Off, its routes and Ask your code answer 404 wiki_off, and clients hide them. - `apps` (boolean): Nexus Apps (`NEXUS_APPS_ENABLED`): `nexus apps` and /v1/apps. An older Gateway leaves it out: off. - `agentSessionAudit` (boolean): Coding agent sessions write agent_session.started and agent_session.ended audit events (`NEXUS_AUDIT_AGENT_SESSIONS`). An older Gateway leaves it out: off. - `401` No credential (`missing_credential`), or one Gateway does not accept: unknown, expired or revoked (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` An operator grant that is unknown, expired, revoked or another person's (`operator_grant_invalid`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/auth/whoami" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fauth%2Fwhoami) ## Lookup device code `GET /v1/auth/device/{code}` A pending `nexus auth login` code, before approval (Nexus UI's server only). Permission: `auth.device_approve` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `code` | path | string | yes | | ### Responses - `200` OK (application/json, object) - `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/auth/device/<code>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fauth%2Fdevice%2F%7Bcode%7D) ## Approve device code `POST /v1/auth/device/approve` Approve or deny a `nexus auth login` code for the signed-in person (Nexus UI's server only). Permission: `auth.device_approve` (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) - `userCode` (string, required) - `approve` (boolean) ### Responses - `200` OK (application/json, object) - `approved` (boolean) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/auth/device/approve" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "userCode": "<userCode>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fauth%2Fdevice%2Fapprove) ## Authorize app `POST /v1/auth/authorize` The phone's sign-in (Nexus UI's server only), after the person's tap, or at once for the app's claimed HTTPS redirect: a code for the signed-in person in the selected organization, bound to the app's PKCE challenge and redirect URI. Nexus UI sends it to that redirect URI; the app exchanges it on `pollDeviceLogin` with `grant_type` `authorization_code` within two minutes. Gateway's `GET /authorize` sends the app's sign-in sheet to Nexus UI's `/app/device/authorize`. Permission: `auth.device_approve` (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) - `client` (string): The app's label, kept on its token: Nexus for iPhone. - `codeChallenge` (string, required): BASE64URL(SHA-256(verifier)), unpadded: 43 characters (RFC 7636). - `codeChallengeMethod` ("S256", required) - `redirectUri` ("https://nexus.inc/app/device/authorize/done" | "xyz.nexus.app:/auth", required): The app's claimed HTTPS redirect (iOS 17.4 and later), or its private-use scheme, the reverse of nexus.xyz (RFC 8252, 7.1 and 7.2). - `clientId` (string): With NEXUS_OAUTH_CLIENT_TIERS=on: the OAuth client that signs in (nxc_mobile). Without one, nxc_unregistered. An unknown or revoked client is a 400 invalid_client. ### Responses - `200` OK (application/json, object) - `code` (string, required): For the app's redirect URI only; single-use. - `expiresIn` (integer, required): Seconds the code lives. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/auth/authorize" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "codeChallenge": "<codeChallenge>", "codeChallengeMethod": "S256", "redirectUri": "https://nexus.inc/app/device/authorize/done" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fauth%2Fauthorize) ## UI session `POST /v1/ui/session` Nexus UI's server: sync the signed-in person and org, and get a short-lived UI token. Authenticated by NEXUS_UI_SECRET, not a token. `personal: true` with only `user` (no `org`) opens the person's personal organization; every sync makes the person's personal organization if they have none. `referral` (a referral code, `GET /v1/referrals`) records who referred a person this sync creates, once; an unknown code, your own code or a person who existed before is ignored, never an error. `signUp` (`method`: google, github or email; `country`: a two-letter code; `utmSource`, `utmMedium`, `utmCampaign`; `referrer`: a host name) says where a person this sync creates came from, and is kept in their personal organization's `org.created` audit event; a value of another shape is dropped, never an error. Two bodies: the provider-neutral one names the person by `user.provider` and `user.subject` and Core's organization by `org.id` or `org.slug` (or `personal: true`); it makes no organization and carries no role, and a person no identity names is made only by a personal sync. The Clerk body (`user.clerkUserId`, `org.clerkOrgId`, `clerkRole`, `creator`) works until the cut-over. A body with fields of both is 400 `mixed_identity_fields`; a provider without a subject, or the reverse, is 400 `incomplete_identity_fields`; an organization the person is not a member of is 403 `not_a_member`. Permission: `ui.session` (Nexus UI's server only). ### Request body (application/json, required) - `user` (object): The signed-in person. - `provider` (string): The provider that signed the person in, such as `google`, `email` or `clerk`. The provider-neutral body only. [max length 64] - `subject` (string): The provider's own id for the person: Google's `sub`, the normalized email for an email code, the hosted provider's user id for `clerk`. The provider-neutral body only. [max length 512] - `email` (string): The person's email. In the provider-neutral body it is kept only with `emailVerified: true`. - `emailVerified` (boolean): Whether the provider verified `email`. The provider-neutral body only. - `name` (string) - `idpOrg` (string): The provider's organization claim, such as Google's `hd`. The provider-neutral body only. - `clerkUserId` (string): The legacy body only; deprecated, removed at the cut-over. - `org` (object): The organization. Leave it out with `personal: true`. - `id` (string): Core's tenant id. The provider-neutral body only. - `slug` (string): Core's slug in the provider-neutral body; the slug the sign-in provider proposes in the legacy body. - `clerkOrgId` (string): The legacy body only; deprecated, removed at the cut-over. - `name` (string): The legacy body only; deprecated, removed at the cut-over. - `imageUrl` (string): The legacy body only; deprecated, removed at the cut-over. - `personal` (boolean): Sync into the person's personal organization. - `clerkRole` (string): The legacy body only; deprecated, removed at the cut-over. - `creator` (object): The legacy body only; deprecated, removed at the cut-over. - `clerkUserId` (string) - `email` (string) - `name` (string) - `token` (boolean): `false`: sync only, with no token. - `referral` (string): A referral code. - `signUp` (object): Where a person this sync creates came from. ### Responses - `200` OK (application/json, object) - `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller may not do this: for example, the role does not have the permission (`role_required`), or the team named is not the caller's (`not_in_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `408` The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `413` The request body is over the operation's limit (`request_too_large`): 1,000,000 bytes, unless the operation says otherwise. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `426` The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Also a first sign-in (`cutover_paused`), only while the operator pauses sign-in for the auth cutover. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `504` The request passed Gateway's deadline, 30 seconds by default (`timeout`). Model calls that may stream are outside it. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 400 | `mixed_identity_fields` | A body with fields of both is 400 `mixed_identity_fields`; a provider without a subject, or the reverse, is 400 `incomplete_identity_fields`; an organization the person is not a member of is 403 `not_a_member` | | 400 | `incomplete_identity_fields` | A body with fields of both is 400 `mixed_identity_fields`; a provider without a subject, or the reverse, is 400 `incomplete_identity_fields`; an organization the person is not a member of is 403 `not_a_member` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `not_a_member` | A body with fields of both is 400 `mixed_identity_fields`; a provider without a subject, or the reverse, is 400 `incomplete_identity_fields`; an organization the person is not a member of is 403 `not_a_member` | | 408 | | The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). | | 413 | | The request body is over the operation's limit (`request_too_large`): 1,000,000 bytes, unless the operation says otherwise. | | 426 | | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Also a first sign-in (`cutover_paused`), only while the operator pauses sign-in for the auth cutover. Retry after `Retry-After` seconds. | | 504 | | The request passed Gateway's deadline, 30 seconds by default (`timeout`). Model calls that may stream are outside it. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/ui/session" \ -H "Content-Type: application/json" \ -d '{ "user": { "provider": "anthropic", "subject": "<subject>", "email": "ada@example.com", "emailVerified": false, "name": "Platform", "idpOrg": "<idpOrg>", "clerkUserId": "<clerkUserId>" }, "org": { "id": "<id>", "slug": "platform", "clerkOrgId": "<clerkOrgId>", "name": "Platform", "imageUrl": "<imageUrl>" }, "personal": false, "clerkRole": "<clerkRole>", "creator": { "clerkUserId": "<clerkUserId>", "email": "ada@example.com", "name": "Platform" }, "token": false, "referral": "<referral>", "signUp": {} }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fui%2Fsession) ## UI send email code `POST /v1/ui/email-code` Nexus UI's server: email a Better Auth sign-in code through Core's sender. Authenticated by NEXUS_UI_SECRET and a `nexus-ui-v2` signature (`x-nexus-ui-signature-version: 2`), required here whatever `NEXUS_UI_SIGNATURE_REQUIRED` says; without one, 401 `ui_signature_required`. A `+tag` alias of another mailbox (Core's `canonical_email` rule; Gmail's dots are no alias) is refused with 400 `email_alias_refused`, and a listed disposable domain with 400 `disposable_email_refused`: no email is sent. At most 5 codes per mailbox in 10 minutes, 10 per client address a minute and 50 per work email domain in 10 minutes: 429 `too_many_codes`. The code is never logged or echoed. 503 `not_configured` without email on Gateway. Permission: `ui.session` (Nexus UI's server only). ### Request body (application/json, required) - `email` (string (email), required) - `code` (string, required) [pattern ^[A-Za-z0-9]{4,12}$] - `type` ("sign-in" | "email-verification" | "forget-password" | "change-email"): Better Auth's kind of code; sign-in when absent. ### Responses - `200` OK (application/json, object) - `sent` (boolean, required) - `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 400 | `email_alias_refused` | A `+tag` alias of another mailbox (Core's `canonical_email` rule; Gmail's dots are no alias) is refused with 400 `email_alias_refused`, and a listed disposable domain with 400 `disposable_email_refused`: no email is sent | | 400 | `disposable_email_refused` | A `+tag` alias of another mailbox (Core's `canonical_email` rule; Gmail's dots are no alias) is refused with 400 `email_alias_refused`, and a listed disposable domain with 400 `disposable_email_refused`: no email is sent | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 401 | `ui_signature_required` | 2`), required here whatever `NEXUS_UI_SIGNATURE_REQUIRED` says; without one, 401 `ui_signature_required` | | 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 | `too_many_codes` | 429 `too_many_codes` | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | | 503 | `not_configured` | 503 `not_configured` without email on Gateway | ### Example ```sh curl -X POST "$NEXUS_URL/v1/ui/email-code" \ -H "Content-Type: application/json" \ -d '{ "email": "ada@example.com", "code": "<code>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fui%2Femail-code) ## UI referral invite `GET /v1/ui/referrals/{code}` Nexus UI's server: who invited a person whose sign-up carries this referral code, so the sign-up page can say so. Authenticated by NEXUS_UI_SECRET, not a token. `inviter.name` is the name of the person whose code it is; `{}` for a campaign's code, or for a person with no name. Only a code that would admit the sign-up and record its referral answers 200; any other is 404 `referral_not_found`: one that cannot be a code, one no one has (or whose person deleted their account), an old code anyone could guess from a name, a person's code while referrals are off, and, while sign-up is invite-only, a code with no invitation left. It never says the person's email or id, and it writes nothing. Permission: `ui.session` (Nexus UI's server only). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `code` | path | string | yes | The referral code the sign-up link carries (`/r/<code>`), read as a sign-up reads it: trimmed and lowercased. | ### Responses - `200` OK (application/json, ReferralInvite) - `inviter` (object): The person whose code it is. Absent for a campaign's code, or for a person with no name. - `name` (string, required): Their name as Nexus has it, trimmed. [min length 1] - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller may not do this: for example, the role does not have the permission (`role_required`), or the team named is not the caller's (`not_in_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` The code would not admit and record a sign-up (`referral_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The code would not admit and record a sign-up (`referral_not_found`) | | 404 | `referral_not_found` | Only a code that would admit the sign-up and record its referral answers 200; any other is 404 `referral_not_found`: one that cannot be a code, one no one has (or whose person deleted their account), an old code anyone could guess from a name, a person's code while referrals are off, and, while sign-up is invite-only, a code with no invitation left | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/ui/referrals/<code>" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fui%2Freferrals%2F%7Bcode%7D) ## Desktop download access `GET /v1/desktop/download-access` Authorize employee desktop downloads Permission: `org.read` (Every member). ### Responses - `200` Verified Nexus employee (application/json, DesktopDownloadAccess) - `allowed` (true, required) - `401` Missing, expired or revoked session - `403` The caller is not a verified Nexus employee - `503` Employee verification is unavailable ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Employee verification is unavailable | ### Example ```sh curl "$NEXUS_URL/v1/desktop/download-access" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdesktop%2Fdownload-access) --- <!-- /docs/api/organizations --> # Organizations > An organization's members and roles (one owner, admins, members), ownership and budget. When the sign-in provider holds the organization, its roles change through Nexus UI, which updates the provider first. ## List orgs `GET /v1/orgs` Your organizations: your personal organization first, then each company organization, with your role in each and which one this request is in. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, OrgList) - `orgs` (array of OrgSummary, required) - `id` (string, required) - `name` (string, required) - `slug` (string) - `clerkOrgId` (string): Its sign-in provider organization's id: Nexus UI's URL segment when it has no slug - `kind` ("company" | "personal", required): A company organization, or a person's own personal organization (one per person, one member) - `role` ("owner" | "admin" | "member") - `current` (boolean): The organization this request is in - `imageUrl` (string): Its logo, as the tenant's imageUrl (https://img.clerk.com/…); unset when it has none. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/orgs" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs) ## Create org `POST /v1/orgs` Create a company organization that Nexus Gateway alone holds, with no sign-in provider organization behind it. You become its owner. Without a slug, the first free one made from the name is used. Only once the Gateway holds organizations; before that, 409 `use_nexus_ui`. Audited as org.created and member.joined. Permission: `org.create` (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): 1 to 120 characters after trimming - `slug` (string): A lowercase DNS label that is not a Nexus UI page (`settings`, `invite`, …) [pattern ^[a-z0-9][a-z0-9-]{0,62}$] ### Responses - `201` Created (application/json, OrgSummary) - `id` (string, required) - `name` (string, required) - `slug` (string) - `clerkOrgId` (string): Its sign-in provider organization's id: Nexus UI's URL segment when it has no slug - `kind` ("company" | "personal", required): A company organization, or a person's own personal organization (one per person, one member) - `role` ("owner" | "admin" | "member") - `current` (boolean): The organization this request is in - `imageUrl` (string): Its logo, as the tenant's imageUrl (https://img.clerk.com/…); unset when it has none. - `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` Another company organization has the slug (`slug_taken`), or the sign-in provider still holds the Gateway's organizations (`use_nexus_ui`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | Another company organization has the slug (`slug_taken`), or the sign-in provider still holds the Gateway's organizations (`use_nexus_ui`) | | 409 | `use_nexus_ui` | Only once the Gateway holds organizations; before that, 409 `use_nexus_ui` | | 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/orgs" \ -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%2Forgs) ## Org waiting counts `GET /v1/orgs/waiting` Read your pending Gateway approvals and waiting cloud sessions by organization. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, OrgWaitingCounts) - `counts` (object, required): Counts keyed by the caller’s current organization memberships. - `checkedAt` (integer, required): Gateway time in milliseconds since the Unix epoch. - `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/orgs/waiting" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fwaiting) ## Switch org `POST /v1/orgs/switch` A new token for another of your organizations (by slug, id, or `personal`), of your credential's kind (`cli` or `ui`; an API key gets a `cli` token that is still an API key to the Gateway), and who you are there. Your current credential stays valid. Permission: `keys.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `org` (string, required): A slug, an id, or personal ### Responses - `200` OK (application/json, SwitchedOrg) - `tenant` (object, required) - `id` (string, required) - `name` (string, required) - `createdAt` (string (date-time), required) - `slug` (string) - `kind` ("company" | "personal"): A company organization, or a person's own personal organization (one per person, one member) - `imageUrl` (string): The organization's logo, as Clerk serves it (https://img.clerk.com/…); unset when it has none. - `mark` ("staff" | "test" | "demo"): Set only when it is Nexus's own; unset for a customer's. - `user` (object): The person calling, when the key is a person's - `id` (string, required) - `email` (string) - `name` (string) - `mark` ("staff" | "test" | "demo"): Set only when it is Nexus's own; unset for a customer's. - `teams` (array of object): Your teams in this organization - `id` (string) - `slug` (string) - `name` (string) - `role` ("lead" | "member"): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `team` (object): Your default team - `id` (string) - `slug` (string) - `name` (string) - `features` (GatewayFeatures): The products this Gateway has on. Unset reads as all off. - `wiki` (boolean, required): Nexus Wiki is on. Off, its routes and Ask your code answer 404 wiki_off, and clients hide them. - `apps` (boolean): Nexus Apps (`NEXUS_APPS_ENABLED`): `nexus apps` and /v1/apps. An older Gateway leaves it out: off. - `agentSessionAudit` (boolean): Coding agent sessions write agent_session.started and agent_session.ended audit events (`NEXUS_AUDIT_AGENT_SESSIONS`). An older Gateway leaves it out: off. - `token` (string, required): Nx_…: shown once - `tokenKind` ("cli" | "ui", required) - `expiresAt` (string (date-time)) - `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/orgs/switch" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "org": "<org>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Fswitch) ## Delete account `POST /v1/auth/account/delete` Delete your own account, from a sign-in made in the last ten minutes (not an API key; a dry run says signInNeeded when yours is older). The sign-in provider deletes your sign-in, the payment provider deletes your personal organization's customer (its plan ends at once), and Gateway takes you out of every organization, closes your personal organization and erases your email and name. Your organizations' spend and audit trail stay, under your user id. Before the customer goes, paying after the fact turns off and one charge tries your personal organization's unpaid usage on the card on file; what it does not collect is written off (unpaidUsageUsd), and its Nexus credits are lost (creditsLostUsd). Refused while you own a company organization: transfer ownership first. A deletion needs confirm: "DELETE", which the person types to confirm. dryRun checks and changes nothing. Permission: `account.delete` (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) - `dryRun` (boolean) - `confirm` ("DELETE"): What the person typed to confirm: DELETE. A deletion without it changes nothing (400 `confirmation_required`); a dry run needs none. ### Responses - `200` OK (application/json, AccountDeleted) - `userId` (string, required) - `dryRun` (boolean, required) - `deleted` (boolean, required): False on a dry run; true once the account is deleted. - `personalOrg` (string): Your personal organization's id, closed with the account; absent when you have none. - `left` (array of object, required): The company organizations you leave. - `id` (string, required) - `name` (string, required) - `planEnded` (boolean, required): Whether your personal organization's plan and cards at the payment provider end with it. - `signInNeeded` (boolean, required): Whether you must sign in again first: only a sign-in from the last ten minutes deletes your account. - `unpaidUsageUsd` (string): Your personal organization's usage that its card has not paid, as a decimal dollar string. On a dry run, what the deletion charges to the card on file first. Once deleted, what that charge did not collect, which Nexus writes off. Absent when nothing is unpaid. - `creditsLostUsd` (string): Your personal organization's Nexus credits that the deletion loses, as a decimal dollar string. Nothing refunds them. Absent when none are left. - `400` The person did not type DELETE to confirm (`confirmation_required`). Nothing changed. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` A sign-in older than ten minutes (`recent_sign_in_required`): sign in again first. An API key, not a sign-in (`sign_in_required`), or a caller that is no person (`person_required`). Nothing changed. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` The account is already deleted (`not_found`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` You own a company organization (`owns_organization`); `nexus.organizations` lists each one's id, name and slug. Or calls your card pays for, or a charge for your usage, are still running (`usage_settling`): paying after the fact is now off; try again in 10 minutes. Nothing else changed. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Clerk did not delete your sign-in (`clerk_unavailable`), or the payment provider did not delete the customer; retry. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` This Gateway has no secret key for the sign-in provider, or no Stripe key while your personal organization has a customer (`not_configured`); nothing changed. Also `cutover_paused`, only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The person did not type DELETE to confirm (`confirmation_required`). Nothing changed. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | The account is already deleted (`not_found`). | | 409 | | You own a company organization (`owns_organization`); `nexus.organizations` lists each one's id, name and slug. Or calls your card pays for, or a charge for your usage, are still running (`usage_settling`): paying after the fact is now off; try again in 10 minutes. Nothing else changed. | | 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 | | 502 | | Clerk did not delete your sign-in (`clerk_unavailable`), or the payment provider did not delete the customer; retry. | | 503 | | This Gateway has no secret key for the sign-in provider, or no Stripe key while your personal organization has a customer (`not_configured`); nothing changed. Also `cutover_paused`, only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/auth/account/delete" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "dryRun": true, "confirm": "DELETE" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fauth%2Faccount%2Fdelete) ## Set org profile `PATCH /v1/orgs/profile` Rename your company organization, change its slug, or remove its logo (owners and admins). A personal organization that holds the slug moves to a free one. An organization the sign-in provider made changes here only once the Gateway holds organizations; before that, 409 `use_nexus_ui`. Audited as org.settings_changed. Permission: `org.settings` (Owner, Admin). ### Request body (application/json, required) - `name` (string): 1 to 120 characters after trimming - `slug` (string): A lowercase DNS label that is not a Nexus UI page [pattern ^[a-z0-9][a-z0-9-]{0,62}$] - `imageUrl` (null): Null removes the logo. A new logo is uploaded with setOrgLogo (POST /v1/orgs/logo) ### Responses - `200` OK (application/json, OrgSummary) - `id` (string, required) - `name` (string, required) - `slug` (string) - `clerkOrgId` (string): Its sign-in provider organization's id: Nexus UI's URL segment when it has no slug - `kind` ("company" | "personal", required): A company organization, or a person's own personal organization (one per person, one member) - `role` ("owner" | "admin" | "member") - `current` (boolean): The organization this request is in - `imageUrl` (string): Its logo, as the tenant's imageUrl (https://img.clerk.com/…); unset when it has none. - `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` Another company organization has the slug (`slug_taken`), a personal organization's name and slug are its person's (`personal_org`), or the sign-in provider still holds this organization (`use_nexus_ui`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | Another company organization has the slug (`slug_taken`), a personal organization's name and slug are its person's (`personal_org`), or the sign-in provider still holds this organization (`use_nexus_ui`) | | 409 | `use_nexus_ui` | An organization the sign-in provider made changes here only once the Gateway holds organizations; before that, 409 `use_nexus_ui` | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X PATCH "$NEXUS_URL/v1/orgs/profile" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Platform", "slug": "platform" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Forgs%2Fprofile) ## Set org logo `POST /v1/orgs/logo` Upload your company organization's logo (owners and admins): the body is the image's bytes, a PNG, JPEG or WebP of 1 MB at most, typed by its first bytes. The Gateway stores it in Nexus's bucket and sets the organization's imageUrl to it. Only once the Gateway holds organizations; before that, 409 `use_nexus_ui`. Audited as org.settings_changed. Permission: `org.settings` (Owner, Admin). ### Request body (image/png, required) string (binary): the provider's own request. ### Responses - `200` OK (application/json, OrgSummary) - `id` (string, required) - `name` (string, required) - `slug` (string) - `clerkOrgId` (string): Its sign-in provider organization's id: Nexus UI's URL segment when it has no slug - `kind` ("company" | "personal", required): A company organization, or a person's own personal organization (one per person, one member) - `role` ("owner" | "admin" | "member") - `current` (boolean): The organization this request is in - `imageUrl` (string): Its logo, as the tenant's imageUrl (https://img.clerk.com/…); unset when it has none. - `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` A personal organization has no logo to change (`personal_org`), or the Gateway does not hold organizations yet (`use_nexus_ui`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `413` The image is over 1 MB (`request_too_large`) (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. - `415` The image is not a PNG, JPEG or WebP by its first bytes (`unsupported_logo_type`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The bucket refused the image (`logo_storage_failed`); nothing changed (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `logo_storage_unconfigured`: the Gateway has no bucket for logos (`NEXUS_ORG_LOGO_BUCKET`). `cutover_paused`: only while the operator pauses sign-in for the auth cutover; retry after `Retry-After` seconds. Nothing changed. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | A personal organization has no logo to change (`personal_org`), or the Gateway does not hold organizations yet (`use_nexus_ui`) | | 409 | `use_nexus_ui` | Only once the Gateway holds organizations; before that, 409 `use_nexus_ui` | | 413 | | The image is over 1 MB (`request_too_large`) | | 415 | | The image is not a PNG, JPEG or WebP by its first bytes (`unsupported_logo_type`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | The bucket refused the image (`logo_storage_failed`); nothing changed | | 503 | | `logo_storage_unconfigured`: the Gateway has no bucket for logos (`NEXUS_ORG_LOGO_BUCKET`). `cutover_paused`: only while the operator pauses sign-in for the auth cutover; retry after `Retry-After` seconds. Nothing changed. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/orgs/logo" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '"<value>"' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Flogo) ## List members `GET /v1/orgs/members` The organization's members and roles; spend per person for owners and admins (and each person's own). `limit` and `cursor` page it. Permission: `members.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `limit` | query | integer | no | Items per page, 1 to 500 (default 100). Without limit or cursor the answer holds the whole list. | | `cursor` | query | string | no | NextCursor from the previous page. A cursor whose item left the list answers 400 `invalid_cursor`. | ### Responses - `200` OK (application/json, object) - `members` (array of Member) - `userId` (string, required) - `email` (string) - `name` (string) - `role` ("owner" | "admin" | "member", required) - `joinedAt` (string (date-time), required) - `spentUsd` (number) - `calls` (integer) - `nextCursor` (string): The next page's cursor, while more items follow. Only when limit or cursor was sent. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/orgs/members" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.members(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fmembers) ## List presence `GET /v1/presence` Every member of the organization and whether they are online (seen in the last two minutes), online ones first (every role: `members.read`; a signed-in member only). `lastSeenAt` is set only while a member is online; a member who turned off showing reads offline to everyone else. You are always online to yourself. `showOnline` is your own setting. Each online member's `activity` says what they are doing, as you may see it. Permission: `members.read` (Every member). ### Responses - `200` OK (application/json, PresenceList) - `members` (array of PresenceMember, required) - `userId` (string, required) - `name` (string | null, required) - `email` (string | null, required) - `role` ("owner" | "admin" | "member", required) - `online` (boolean, required): Seen within the online window. You are always online to yourself. - `lastSeenAt` (string (date-time) | null, required): The last heartbeat, only while it is within the online window. - `activity` (PresenceActivity | null, required): What they are doing, while online; null otherwise. - `onlineWindowSeconds` (integer, required): How long after a heartbeat a member still counts as online. - `showOnline` (boolean, required): Your own setting. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/presence" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpresence) ## Presence heartbeat `POST /v1/presence` Your heartbeat while Nexus UI is open and visible, about every 30 seconds (every role: `members.read`; a signed-in member only, 403 `role_required` otherwise). You count as online for two minutes after it. Gateway stores at most one every 20 seconds, and none while you turned off showing when you are online. It may carry what you are doing (`activity`): `chatting`, a `page` by id, or `idle`. A change of activity is stored at once. Answers your setting. Permission: `members.read` (Every member). ### Request body (application/json) - `activity` (ReportedActivity): What Nexus UI reports with a heartbeat. Coarse on purpose: no chat title, no path, no repository. Gateway keeps a page's id only when you may open the page and reads its title itself. `agents` is taken as `idle`: Gateway counts running agents from agent sessions. - `kind` ("chatting" | "page" | "agents" | "idle", required) - `pageId` (string): Required with `page`. ### Responses - `200` OK (application/json, PresenceSettings) - `showOnline` (boolean, required): Whether others see when you are online. On by default. - `400` Not a known activity (`invalid_activity`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a known activity (`invalid_activity`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/presence" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "activity": { "kind": "chatting" } }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpresence) ## Get presence settings `GET /v1/presence/settings` Whether you show when you are online (every role: `members.read`; a signed-in member only). On unless you turned it off. Permission: `members.read` (Every member). ### Responses - `200` OK (application/json, PresenceSettings) - `showOnline` (boolean, required): Whether others see when you are online. On by default. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/presence/settings" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpresence%2Fsettings) ## Set presence settings `PUT /v1/presence/settings` Choose whether you show when you are online (every role: `members.read`; a signed-in member only). Off, Gateway forgets your last heartbeat and stores none, so you read offline to everyone else at once; you still see yourself online. Permission: `members.read` (Every member). ### Request body (application/json, required) - `showOnline` (boolean, required): Whether others see when you are online. On by default. ### Responses - `200` OK (application/json, PresenceSettings) - `showOnline` (boolean, required): Whether others see when you are online. On by default. - `400` Not `{ "showOnline": bool }` (`invalid_setting`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not `{ "showOnline": bool }` (`invalid_setting`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/presence/settings" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "showOnline": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpresence%2Fsettings) ## Set member role `POST /v1/orgs/members/{userId}/role` Make a member an admin or a member (owners and admins). The owner's role changes only by transfer. Permission: `members.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `userId` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `role` ("admin" | "member", required) ### Responses - `200` OK (application/json, object) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/orgs/members/user_123/role" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "role": "admin" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.setMemberRole("<user id>", "admin"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Fmembers%2F%7BuserId%7D%2Frole) ## Remove member `DELETE /v1/orgs/members/{userId}` Remove a member (owners and admins). The membership is flagged, not deleted, so an owner or admin can recover them for 30 days; their tokens and keys are revoked at once. The owner must transfer ownership first. Permission: `members.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `userId` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `404` No such member (`not_found`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` They are the owner (`owner_role`): transfer ownership first. Or a token removes its own person (`self_removal`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` A token's removal: Clerk did not take them out of its organization (`clerk_unavailable`); nothing changed. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` A token's removal: the organization signs in with the sign-in provider and this Gateway has no secret key for it (`not_configured`); nothing changed. Also `cutover_paused`, only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such member (`not_found`). | | 409 | | They are the owner (`owner_role`): transfer ownership first. Or a token removes its own person (`self_removal`). | | 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 | | 502 | | A token's removal: Clerk did not take them out of its organization (`clerk_unavailable`); nothing changed. | | 503 | | A token's removal: the organization signs in with the sign-in provider and this Gateway has no secret key for it (`not_configured`); nothing changed. Also `cutover_paused`, only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/orgs/members/user_123" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.removeMember("<user id>"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Forgs%2Fmembers%2F%7BuserId%7D) ## List removed members `GET /v1/orgs/members/removed` Removed members (owners and admins), newest removal first, each with the end of its 30-day recovery window. Permission: `members.manage` (Owner, Admin). ### Responses - `200` OK (application/json, RemovedMemberList) - `members` (array of RemovedMember, required) - `userId` (string, required) - `email` (string) - `name` (string) - `role` ("owner" | "admin" | "member", required) - `removedAt` (string (date-time), required) - `removedBy` (string): The user id who removed them; absent when the sign-in provider did. - `recoverableUntil` (string (date-time), required) - `recoverable` (boolean, 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/orgs/members/removed" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fmembers%2Fremoved) ## Recover member `POST /v1/orgs/members/{userId}/recover` Recover a removed member inside the 30-day window (owners and admins): their role, teams, default team and person spend limit come back; their tokens and keys do not. In an org that signs in with Clerk, Gateway adds them back to the Clerk organization. dryRun checks and changes nothing. A 409 removal_final after the window; 503 `not_configured` without CLERK_SECRET_KEY on Gateway, in an org that signs in with Clerk. Permission: `members.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `userId` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json) - `dryRun` (boolean) ### Responses - `200` OK (application/json, MemberRecovered) - `userId` (string, required) - `email` (string) - `role` ("owner" | "admin" | "member", required) - `teams` (array of string, required): The slugs of the teams they come back to. - `dryRun` (boolean, required) - `recovered` (boolean, required) - `404` No such member (`not_found`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` They are a member (`not_removed`), or the 30-day window ended (`removal_final`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Clerk did not add them back to its organization (`clerk_unavailable`); nothing changed. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The organization signs in with the sign-in provider and this Gateway has no secret key for it (`not_configured`); nothing changed. Also `cutover_paused`, only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such member (`not_found`). | | 409 | | They are a member (`not_removed`), or the 30-day window ended (`removal_final`). | | 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 | | 502 | | Clerk did not add them back to its organization (`clerk_unavailable`); nothing changed. | | 503 | | The organization signs in with the sign-in provider and this Gateway has no secret key for it (`not_configured`); nothing changed. Also `cutover_paused`, only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | | 503 | `not_configured` | A 409 removal_final after the window; 503 `not_configured` without CLERK_SECRET_KEY on Gateway, in an org that signs in with Clerk | ### Example ```sh curl -X POST "$NEXUS_URL/v1/orgs/members/user_123/recover" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "dryRun": true }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Fmembers%2F%7BuserId%7D%2Frecover) ## List invitations `GET /v1/orgs/invitations` The organization's pending invitations, oldest first, expired ones included (owners and admins). Only once Core holds organizations (`NEXUS_ORG_OWNER=core`); before that, 409 `use_nexus_ui`. Permission: `members.invite` (Owner, Admin). ### Responses - `200` OK (application/json, object) - `invitations` (array of object, required) - `id` (string, required) - `email` (string, required) - `role` ("member" | "admin", required) - `invitedBy` (string | null): The person who invited them, when a person did. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `sentAt` (string (date-time) | null): The last send. - `expired` (boolean, required): Past expiresAt: its link no longer works; resend it. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (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 | | 409 | `use_nexus_ui` | Only once Core holds organizations (`NEXUS_ORG_OWNER=core`); before that, 409 `use_nexus_ui` | | 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/orgs/invitations" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Finvitations) ## Invite members `POST /v1/orgs/invitations` Invite people to the organization (owners and admins); Clerk emails each invitation. Name `emails`, or `pending: true` for everyone in a team by email who has not joined. Emails already in the organization or already invited are skipped. `dryRun` sends nothing. Sending more than one needs `expect`, the number you confirmed (409 `count_changed` if it differs). 501 without CLERK_SECRET_KEY on Gateway (dry runs still work, checking Gateway only). Once Core holds organizations (`NEXUS_ORG_OWNER=core`), Core writes each invitation and emails its one-time link itself; an expired invitation of the email is sent again. Permission: `members.invite` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `emails` (array of string (email)) [at most 500 items] - `pending` (boolean): Everyone with a pending team membership. - `role` ("member" | "admin") [default "member"] - `dryRun` (boolean) [default false] - `expect` (integer): Required to send more than one invitation: how many you confirmed. ### Responses - `200` OK (application/json, InvitationsResponse) - `dryRun` (boolean, required) - `role` ("member" | "admin", required) - `checkedClerk` (boolean, required): False on a dry run without CLERK_SECRET_KEY: only Gateway's members were checked. - `toSend` (integer, required): Invitations sent, or in a dry run, that would be. - `results` (array of object, required) - `email` (string, required) - `status` ("would_invite" | "sent" | "already_member" | "not_signed_in" | "already_invited" | "removed" | "failed", required) - `invitationId` (string) - `message` (string): The sign-in provider's message when it failed. - `counts` (object, 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. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### 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 | `count_changed` | Sending more than one needs `expect`, the number you confirmed (409 `count_changed` if it differs) | | 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/orgs/invitations" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "pending": true, "dryRun": true }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.invite({ pending: true, dryRun: true }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Finvitations) ## Revoke invitation `DELETE /v1/orgs/invitations/{id}` Revoke a pending invitation (owners and admins), so its link stops working. While the sign-in provider holds organizations the id is the provider's and the provider cancels it; once Core holds them (`NEXUS_ORG_OWNER=core`) the id is Core's. Audited as `invitation.revoked`. Permission: `members.invite` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The invitation's id: the sign-in provider's while it holds organizations, else Core's from `GET /v1/orgs/invitations`. | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `revoked` (boolean, 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. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/orgs/invitations/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Forgs%2Finvitations%2F%7Bid%7D) ## Resend invitation `POST /v1/orgs/invitations/{id}/resend` Email a pending invitation again with a new link and a new expiry, 7 days from now; the old link stops working (owners and admins). At most once per 10 minutes per invitation: 429 `resend_too_soon`. Only once Core holds organizations; before that, 409 `use_nexus_ui`. Audited as `invitation.sent` with `via: resend`. Permission: `members.invite` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The invitation's id, from `GET /v1/orgs/invitations`. | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `email` (string, required) - `status` (string, required) - `invitationId` (string | null) - `message` (string | null) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### 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 | `use_nexus_ui` | Only once Core holds organizations; before that, 409 `use_nexus_ui` | | 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 | `resend_too_soon` | 429 `resend_too_soon` | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/orgs/invitations/<id>/resend" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Finvitations%2F%7Bid%7D%2Fresend) ## List my invitations `GET /v1/orgs/invitations/mine` Your own pending invitations, across organizations, oldest first: those sent to an email one of your sign-ins verified. An unverified email matches none. Expired invitations and organizations you are already in are left out. Accept one with `POST /v1/orgs/invitations/accept` and its `id`. Only once Core holds organizations (`NEXUS_ORG_OWNER=core`); before that, 409 `use_nexus_ui`. A person only (403 `person_required`). Permission: `authenticated` (Every member, module keys). ### Responses - `200` OK (application/json, object) - `invitations` (array of object, required) - `id` (string, required): Accept it with this id. - `email` (string, required): Your email it was sent to. - `orgName` (string, required) - `orgSlug` (string | null) - `role` ("member" | "admin", required) - `invitedBy` (string | null): The inviter's name, else their email; null when no person invited you or that person is gone. - `expiresAt` (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 | | 403 | `person_required` | A person only (403 `person_required`) | | 409 | `use_nexus_ui` | Only once Core holds organizations (`NEXUS_ORG_OWNER=core`); before that, 409 `use_nexus_ui` | | 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/orgs/invitations/mine" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Finvitations%2Fmine) ## Accept invitation `POST /v1/orgs/invitations/accept` Accept an invitation: you join its organization with its role. Name the `token` in its link or the `id` from `GET /v1/orgs/invitations/mine`: exactly one. A body with neither or both is 400 `invalid_request`. For a token, Nexus UI's server must vouch that you verified the invited email (403 `email_mismatch`). For an id, one of your sign-ins must have verified the invited email; any other id is a 404. A used, revoked or replaced link is a 404; an expired invitation is 409 `invitation_expired`. Only once Core holds organizations; before that, 409 `use_nexus_ui`. Audited as `member.joined` with `via: invitation`. Permission: `authenticated` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) object | object: the provider's own request. ### Responses - `200` OK (application/json, OrgSummary) - `id` (string, required) - `name` (string, required) - `slug` (string) - `clerkOrgId` (string): Its sign-in provider organization's id: Nexus UI's URL segment when it has no slug - `kind` ("company" | "personal", required): A company organization, or a person's own personal organization (one per person, one member) - `role` ("owner" | "admin" | "member") - `current` (boolean): The organization this request is in - `imageUrl` (string): Its logo, as the tenant's imageUrl (https://img.clerk.com/…); unset when it has none. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | `invalid_request` | A body with neither or both is 400 `invalid_request` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `email_mismatch` | For a token, Nexus UI's server must vouch that you verified the invited email (403 `email_mismatch`) | | 409 | `invitation_expired` | A used, revoked or replaced link is a 404; an expired invitation is 409 `invitation_expired` | | 409 | `use_nexus_ui` | Only once Core holds organizations; before that, 409 `use_nexus_ui` | | 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/orgs/invitations/accept" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "token": "<token>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Finvitations%2Faccept) ## List org domains `GET /v1/orgs/domains` The organization's verified email domains (owners and admins). While Clerk holds organizations (the default), they are Clerk's, from its Enhanced B2B add-on: people with a verified email on a domain join through Clerk as its `enrollmentMode` says; 409 `not_a_clerk_org` for an organization that does not sign in with Clerk; 503 `not_configured` without CLERK_SECRET_KEY on Gateway. Once Core holds organizations (NEXUS_ORG_OWNER=core), they are the domains a Nexus operator assigned: each one's `id` is the domain, its `enrollmentMode` is `automatic_suggestion`, and a person whose Google sign-in is on it sees the organization in listDomainSuggestions. 409 `personal_org` for a personal organization. Permission: `members.invite` (Owner, Admin). ### Responses - `200` OK (application/json, DomainList) - `domains` (array of OrgDomain, required) - `id` (string, required): The sign-in provider's domain id. - `domain` (string, required) - `enrollmentMode` ("automatic_invitation" | "automatic_suggestion" | "manual_invitation" | "enterprise_sso", required) - `verified` (boolean, required) - `pendingInvitations` (integer, required): Invitations the sign-in provider sent on this domain that nobody accepted yet. - `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 | | 409 | `not_a_clerk_org` | People with a verified email on a domain join through Clerk as its `enrollmentMode` says; 409 `not_a_clerk_org` for an organization that does not sign in with Clerk; 503 `not_configured` without CLERK_SECRET_KEY on Gateway | | 409 | `personal_org` | 409 `personal_org` for a personal 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 | | 503 | `not_configured` | People with a verified email on a domain join through Clerk as its `enrollmentMode` says; 409 `not_a_clerk_org` for an organization that does not sign in with Clerk; 503 `not_configured` without CLERK_SECRET_KEY on Gateway | ### Example ```sh curl "$NEXUS_URL/v1/orgs/domains" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fdomains) ## Add org domain `POST /v1/orgs/domains` Add a verified email domain (owners and admins). While Clerk holds organizations: you must have a verified email on it in Clerk (403 `domain_not_yours`), so an admin cannot add another company's domain and pull its people into their organization; a public mail provider such as gmail.com is refused (400 `public_mail_domain`), and so is a personal organization (409 `personal_org`). Clerk's refusal, such as a domain another organization has, is a 409 `clerk_refused` with Clerk's message. Audited as `domain.added`. Once Core holds organizations (NEXUS_ORG_OWNER=core), a Nexus operator assigns domains after a review, so this is 409 `operator_assigns_domains` (400 `public_mail_domain` for a public mail provider's). Permission: `members.invite` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `domain` (string, required): A host name, as acme.com. - `enrollmentMode` ("automatic_invitation" | "automatic_suggestion" | "manual_invitation"): Automatic_invitation: the sign-in provider invites everyone with a verified email on the domain. automatic_suggestion: the provider suggests the organization and an admin accepts each request. manual_invitation: nobody joins without an invitation. [default "automatic_invitation"] ### Responses - `200` OK (application/json, OrgDomain) - `id` (string, required): The sign-in provider's domain id. - `domain` (string, required) - `enrollmentMode` ("automatic_invitation" | "automatic_suggestion" | "manual_invitation" | "enterprise_sso", required) - `verified` (boolean, required) - `pendingInvitations` (integer, required): Invitations the sign-in provider sent on this domain that nobody accepted yet. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | `public_mail_domain` | You must have a verified email on it in Clerk (403 `domain_not_yours`), so an admin cannot add another company's domain and pull its people into their organization; a public mail provider such as gmail.com is refused (400 `public_mail_domain`), and so is a personal organization (409 `personal_org`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `domain_not_yours` | You must have a verified email on it in Clerk (403 `domain_not_yours`), so an admin cannot add another company's domain and pull its people into their organization; a public mail provider such as gmail.com is refused (400 `public_mail_domain`), and so is a personal organization (409 `personal_org`) | | 409 | `personal_org` | You must have a verified email on it in Clerk (403 `domain_not_yours`), so an admin cannot add another company's domain and pull its people into their organization; a public mail provider such as gmail.com is refused (400 `public_mail_domain`), and so is a personal organization (409 `personal_org`) | | 409 | `clerk_refused` | Clerk's refusal, such as a domain another organization has, is a 409 `clerk_refused` with Clerk's message | | 409 | `operator_assigns_domains` | Once Core holds organizations (NEXUS_ORG_OWNER=core), a Nexus operator assigns domains after a review, so this is 409 `operator_assigns_domains` (400 `public_mail_domain` for a public mail provider's) | | 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/orgs/domains" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "domain": "<domain>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Fdomains) ## Remove org domain `DELETE /v1/orgs/domains/{id}` Remove a verified email domain by its id from listOrgDomains (owners and admins). New people stop joining by it; who already joined stays. Another organization's domain is a 404. Audited as `domain.removed`. Permission: `members.invite` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The domain's id, from listOrgDomains: the sign-in provider's id, or the domain itself once Core holds organizations. | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `removed` (boolean, 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. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/orgs/domains/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Forgs%2Fdomains%2F%7Bid%7D) ## List domain suggestions `GET /v1/orgs/domain-suggestions` The company organizations you may join by domain, with the domain of each. A suggestion needs your own Google sign-in: its `hd` is a domain a Nexus operator assigned to the organization, and Google verified your email on that domain. An email-code sign-in, an unverified email or the email on your account never counts. An organization you belong to, or were removed from, is left out. Only once Core holds organizations (NEXUS_ORG_OWNER=core); before that, 409 `use_nexus_ui`. Permission: `authenticated` (Every member, module keys). ### Responses - `200` OK (application/json, DomainSuggestionList) - `suggestions` (array of DomainSuggestion, required) - `domain` (string, required): The domain, lower-case. - `org` (OrgSummary, required): The organization; no `role` or `current`, since the person is not a member yet. - `id` (string, required) - `name` (string, required) - `slug` (string) - `clerkOrgId` (string): Its sign-in provider organization's id: Nexus UI's URL segment when it has no slug - `kind` ("company" | "personal", required): A company organization, or a person's own personal organization (one per person, one member) - `role` ("owner" | "admin" | "member") - `current` (boolean): The organization this request is in - `imageUrl` (string): Its logo, as the tenant's imageUrl (https://img.clerk.com/…); unset when it has none. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | `use_nexus_ui` | Only once Core holds organizations (NEXUS_ORG_OWNER=core); before that, 409 `use_nexus_ui` | | 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/orgs/domain-suggestions" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fdomain-suggestions) ## Join by domain `POST /v1/orgs/domain-suggestions/join` Join an organization of listDomainSuggestions: you become a member, never an admin. 404 `no_domain_match` when none of your Google sign-ins is on a domain of that organization; the answer does not say whether it exists. 409 `member_removed` while an admin's removal of you can still be undone. A member already keeps their role. Only once Core holds organizations; before that, 409 `use_nexus_ui`. Audited as `member.joined` with `via: domain`. Permission: `authenticated` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `org` (string, required): The organization's id, from listDomainSuggestions. ### Responses - `200` OK (application/json, OrgSummary) - `id` (string, required) - `name` (string, required) - `slug` (string) - `clerkOrgId` (string): Its sign-in provider organization's id: Nexus UI's URL segment when it has no slug - `kind` ("company" | "personal", required): A company organization, or a person's own personal organization (one per person, one member) - `role` ("owner" | "admin" | "member") - `current` (boolean): The organization this request is in - `imageUrl` (string): Its logo, as the tenant's imageUrl (https://img.clerk.com/…); unset when it has none. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### 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 | `no_domain_match` | 404 `no_domain_match` when none of your Google sign-ins is on a domain of that organization; the answer does not say whether it exists | | 409 | `member_removed` | 409 `member_removed` while an admin's removal of you can still be undone | | 409 | `use_nexus_ui` | Only once Core holds organizations; before that, 409 `use_nexus_ui` | | 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/orgs/domain-suggestions/join" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "org": "<org>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Fdomain-suggestions%2Fjoin) ## Transfer ownership `POST /v1/orgs/owner` Transfer ownership to another member (the owner only); the previous owner becomes an admin. Permission: `org.transfer` (Owner). ### 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) - `userId` (string, required) ### Responses - `200` OK (application/json, object) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### 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 | | 503 | | `cutover_paused`: only while the operator pauses sign-in for the auth cutover; nothing changed. Retry after `Retry-After` seconds. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/orgs/owner" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "userId": "user_123" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.transferOwnership("<user id>"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Fowner) ## Set budget `POST /v1/orgs/budget` Set the organization's budget in USD, a cap per UTC day, ISO week or calendar month (owners and admins); never below what the period spent and what is reserved. Permission: `budgets.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `budgetUsd` (number | string): The organization's budget per period in US dollars: a JSON number (deprecated) or a decimal string with at most 6 decimals (`"12.245"`), read exactly. Send `budgetUsdDecimal` instead to send only a string. - `budgetUsdDecimal` (string): The organization's budget per period as a decimal string in US dollars, at most 6 decimals, never below 0; read exactly into micro-dollars, never through a float. With `budgetUsd` too, both must name the same amount (400 `amount_mismatch`). [pattern ^[0-9]+(\.[0-9]{1,6})?$] - `period` ("day" | "week" | "month"): The cap's period. Absent keeps the current one, a month unless set - `dryRun` (boolean): Make the same checks and write nothing; the answer is { dryRun, before, after }, each { budgetUsd, budgetUsdDecimal, period } ### Responses - `200` OK (application/json, object | object) - `400` `budgetUsd` and `budgetUsdDecimal` both missing, `dryRun` not true or false (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one or is below 0 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts (`amount_mismatch`), or a period other than day, week or month (`invalid_period`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Only owners and admins set the organization's budget (`role_required`): a member without `budgets.manage` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The new budget is below what the period has already spent and reserved (`conflict`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `budgetUsd` and `budgetUsdDecimal` both missing, `dryRun` not true or false (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one or is below 0 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts (`amount_mismatch`), or a period other than day, week or month (`invalid_period`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | The new budget is below what the period has already spent and reserved (`conflict`) | | 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/orgs/budget" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.setBudget(100); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Fbudget) ## Export directory CSV `GET /v1/orgs/directory/export.csv` Every person and team of the organization with its name: the one file that maps ids to names, as CSV (owners and admins). The people are its members and the people its calls and kept agent sessions name (former members too), then its teams and the teams those name, each by id. Names are read when the file is asked for. An erased person reads `erased: true` with no name; a person with no record reads with no name, and a deleted team with its id alone. It takes no parameter and has no row limit, range or cursor. The data files name people and teams by id only. Each request is an audit event (`observability.directory_exported`) with the file's manifest, never its rows, and counts toward the 60 exports an hour. Permission: `spend.export` (Owner, Admin). ### Responses - `200` CSV with a header row: one column per field of `DirectoryEntry`, in its order. (text/csv, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/orgs/directory/export.csv" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.directoryExport("csv"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fdirectory%2Fexport.csv) ## Export directory JSON Lines `GET /v1/orgs/directory/export.jsonl` Every person and team of the organization with its name: the one file that maps ids to names, as JSON Lines (owners and admins). The people are its members and the people its calls and kept agent sessions name (former members too), then its teams and the teams those name, each by id. Names are read when the file is asked for. An erased person reads `erased: true` with no name; a person with no record reads with no name, and a deleted team with its id alone. It takes no parameter and has no row limit, range or cursor. The data files name people and teams by id only. Each request is an audit event (`observability.directory_exported`) with the file's manifest, never its rows, and counts toward the 60 exports an hour. Permission: `spend.export` (Owner, Admin). ### Responses - `200` JSON Lines: one `DirectoryEntry` per line, then one line `{"manifest": ExportManifest}`. (application/jsonl, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/orgs/directory/export.jsonl" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.directoryExport("jsonl"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fdirectory%2Fexport.jsonl) ## Clerk webhook `POST /v1/clerk/webhook` Clerk's webhook, signed by Svix with CLERK_WEBHOOK_SECRET (svix-id, svix-timestamp and svix-signature; refused more than five minutes from now). For organizationMembership.created, .updated and .deleted, and user.deleted, Gateway reads the membership or the person from Clerk again and makes its copy match: a member Clerk no longer has loses their membership, teams and tokens (member.removed, via: clerk; the owner loses only the tokens), and a role Clerk changed is mirrored. For organization.updated, Gateway reads the organization from Clerk again and mirrors its name, slug and logo as a sign-in does (org.settings_changed, actor clerk; a logo not on img.clerk.com is dropped); an organization Gateway does not have is ignored. A repeated or late event changes nothing. 401 for a bad signature; 503 `not_configured` without CLERK_WEBHOOK_SECRET or CLERK_SECRET_KEY; 502 when Clerk does not answer, so Svix retries. Permission: `public` (Anyone, signed in or not). ### Responses - `200` OK (application/json, object) - `ok` (boolean, required) - `event` (string, required) - `changed` (integer, required): How many memberships changed. ### Errors | Status | Code | When | | --- | --- | --- | | 503 | `not_configured` | 401 for a bad signature; 503 `not_configured` without CLERK_WEBHOOK_SECRET or CLERK_SECRET_KEY; 502 when Clerk does not answer, so Svix retries | ### Example ```sh curl -X POST "$NEXUS_URL/v1/clerk/webhook" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fclerk%2Fwebhook) ## Get billing `GET /v1/billing` The organization's billing (owner only): the Stripe mode of this Gateway, whether the organization has a Stripe customer yet, its payment method on file (`defaultPaymentMethod`, of any type; `paymentMethod` only when it is a card), how it pays for what Nexus runs (pricing v2.0: `freeStart`, `credits` and `autoTopup`, `afterTheFact`; `plan` where this Gateway sells plans), the numbers a page shows (`pricing`), and `pastDue`. `pastDue` is null, or names the oldest month Stripe could not collect: when it first failed (`since`), its period, and when model calls stop (`blockedFrom`, `since` plus NEXUS_BILLING_GRACE_DAYS, 7 days by default). From `blockedFrom` until an owner pays, every model call is refused with 402 `payment_past_due`. Never Stripe's customer id or the card number. A customer made in the other mode (test or live) is not shown. 503 `not_configured` until STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are both set and well formed (the message says which is wrong). Permission: `org.billing` (Owner). ### Responses - `200` OK (application/json, Billing) - `sharedPaymentTokens` (boolean): True when this Gateway supports delegated Stripe shared payment tokens on credit purchases. Currently enabled only in Stripe test mode; live mode returns false. Check before submitting a token. - `mode` ("test" | "live", required): The mode of Gateway's Stripe key. - `customer` (object | null, required): Null until the first card setup starts. - `state` ("creating" | "ready", required): `creating`: Gateway started the Stripe customer and the first setup has not finished. `ready`: the customer exists. - `paymentMethod` (CardSummary | null, required): The payment method on file when it is a card. Null when there is none, or when it is not a card: read `defaultPaymentMethod` for any type. - `defaultPaymentMethod` (PaymentMethodSummary | null, required): The payment method on file, of any type: the one credits, auto top-ups and charges for usage after the fact are charged to. Null until one is saved. - `credits` (NexusCredits | null): The organization's prepaid Nexus credits; null before it buys any. - `autoTopup` (AutoTopup | null): The organization's auto top-up of Nexus credits; null before an owner sets it. - `planAllowance` (object): The current plan's monthly allowances. Absent when no allowance is available. - `resetAt` (string (date-time), required): Start of the next usage month in UTC. - `ai` (object | null, required): AI allowance in decimal USD, counting settled usage. Null until the allowance is granted. - `includedUsd` (string, required) - `usedUsd` (string, required) - `leftUsd` (string, required) - `cloud` (object | null, required): Cloud allowance in default-size hours. Null when plan cloud metering is unavailable. - `includedHours` (number, required) - `usedHours` (number, required) - `leftHours` (number, required) - `pastDue` (object | null, required): Null while no month of this mode is unpaid after Stripe tried to collect it. Otherwise the oldest such month. - `since` (string (date-time), required): When the month first failed. - `period` (string, required): The unpaid month, YYYY-MM. [pattern ^[0-9]{4}-(0[1-9]|1[0-2])$] - `blockedFrom` (string (date-time) | null, required): `since` plus the grace (NEXUS_BILLING_GRACE_DAYS). From then on model calls are refused with 402 `payment_past_due`. Null when this Gateway has no gate, so nothing is refused. - `invoiceUrl` (string (uri) | null, required): Stripe's page that pays the unpaid month (its hosted invoice). Null when Stripe gave none. - `pricingChange` (object | null): A change to Nexus pricing and the Customer Terms (NEXUS_PRICING_CHANGE), until 30 days past the day it takes effect. Each organization created before that day is told once by `billing.pricing_change`. Null, or absent from an older Gateway, when there is none. - `effectiveOn` (string (date), required): The day the change takes effect, at 00:00 UTC: YYYY-MM-DD. - `plan` (BillingPlan | null): The organization's plan; null on the Free plan - `freeStart` (object | null): The organization's free start (pricing v2.0): what Nexus gave it once, and what is left. Null when it got none. - `grantedUsd` (string, required): What Nexus gave, a decimal dollar string. - `remainingUsd` (string, required): What is left, never below zero. - `expiresAt` (string (date-time) | null): When the free start expires, or expired: 30 days after its grant. Null when the organization's subsidy holds no free start. - `expiredUsd` (string | null): What was left of the free start when it expired, a decimal dollar string. Null before it expires. - `afterTheFact` (AfterTheFact | null): How the organization pays after the fact (pricing v2.0); null before an owner turns it on. - `pricing` (object, required): The numbers a billing page shows, so no client writes a price of its own. Decimal dollar strings. - `markupBps` (integer, required): Nexus's rate on AI it runs past the free start and a plan's allowance, in basis points: 500 is provider price + 5%. App hosting and cloud machines have their own prices. - `minPurchaseUsd` (string, required): The least one credit purchase buys. - `thresholdUsd` (string, required): Paying after the fact, the card is charged each time the unpaid usage reaches this. - `defaultLimitUsd` (string, required): The monthly usage limit a new after-the-fact setting starts at. - `maxLimitUsd` (string, required): The most a usage limit may be now for this organization: $100 in its first week, then $100,000. A higher `limitUsd` answers 400 `invalid_amount`. - `freeStartMaxOutputUsd` (string): The free start pays only for a model whose cheapest host charges at most this per million output tokens. - `minFinalChargeUsd` (string): Minimum final charge when pay after the fact turns off. - `promotionalCreditUsd` (string): Available referral and promotional credit, excluding the welcome free start. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured (`not_configured`): the message says which variable is wrong (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `payment_past_due` | From `blockedFrom` until an owner pays, every model call is refused with 402 `payment_past_due` | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Stripe is not configured (`not_configured`): the message says which variable is wrong | | 503 | `not_configured` | 503 `not_configured` until STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are both set and well formed (the message says which is wrong) | ### Example ```sh curl "$NEXUS_URL/v1/billing" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbilling) ## Get billing statement `GET /v1/billing/statement` The organization's bill for one UTC month (owner only). A month the close stored answers from the stored row, as it closed, and `invoice` shows its Stripe invoice. Any other month is priced now, from the ledger and the prices Gateway has: NEXUS_PRICE_GATEWAY_CALL_MICROS and NEXUS_PRICE_GATEWAY_COST_BPS. Both are 0 until a price is set, so the total reads 0. It counts the calls on the organization's own provider keys. Refused calls and calls a Nexus subsidy paid are left out. Money is a decimal string. The bill is the total in whole cents, rounded down, as a string. `carriedInUsd` is the rest of the newest stored month before this one. `carriedOutUsd` is the part below one cent, and it carries into the next month. A month under 50 cents is not invoiced: all of its total carries. `providerCostUsd` is what the providers charged. They bill it, not Nexus. The stored months are the ones of Gateway's Stripe key mode. Without Stripe nothing is stored, so every month is priced now. The route reads no Stripe, so it answers with Stripe off. 400 for a period that is not YYYY-MM or has not started. Permission: `org.billing` (Owner). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `period` | query | string | no | YYYY-MM from 1970-01 to 9998-12, a UTC month that has started; default the current month | ### Responses - `200` OK (application/json, BillingStatement) - `period` (string, required): The month, as YYYY-MM. [pattern ^[0-9]{4}-(0[1-9]|1[0-2])$] - `lines` (array of BillingStatementLine, required): Every charge. Both lines are always there, with amount 0 until a price is set. - `code` ("gateway.calls" | "gateway.provider_cost" | "gateway.nexus_usage", required): `gateway.calls`: the calls on the organization's own keys. `gateway.provider_cost`: Nexus's fee on what the providers charged for them. `gateway.nexus_usage`: a contract's calls on Nexus-supplied keys, at provider price plus Nexus's rate; only on a month that has some. - `unit` ("call" | "usd", required) - `quantity` (string, required): Unit `call`: a whole number of calls. Unit `usd`: a decimal dollar amount. - `rateUsd` (string): Unit `call` only: the price of one call. [pattern ^[0-9]+\.[0-9]{6}$] - `rateBps` (integer): Unit `usd` only: basis points of `quantity` (100 is 1%). [min 0; max 10000] - `amountUsd` (string, required): `quantity` times the rate, rounded down to a micro-dollar. [pattern ^[0-9]+\.[0-9]{6}$] - `providerCostUsd` (string, required): What the providers charged for the calls on the organization's own keys. The providers bill it, not Nexus. [pattern ^[0-9]+\.[0-9]{6}$] - `carriedInUsd` (string, required): The rest of the month before: the part of its total that no invoice took. [pattern ^[0-9]+\.[0-9]{6}$] - `totalUsd` (string, required): The lines and `carriedInUsd` added. [pattern ^[0-9]+\.[0-9]{6}$] - `amountCents` (string, required): What to charge: `totalUsd` in whole cents, rounded down. A whole number as a string. A month under 50 cents is not invoiced. [pattern ^[0-9]+$] - `carriedOutUsd` (string, required): What moves to the next month: the part of `totalUsd` below one cent. A month under 50 cents is not invoiced, so all of its total moves. [pattern ^[0-9]+\.[0-9]{6}$] - `invoice` (BillingInvoice | null, required): The Stripe invoice of a stored month. Null for a month that is priced now, and for a stored month under 50 cents, which is not invoiced. - `400` Not a month as YYYY-MM, or a month that has not started (`invalid_request_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a month as YYYY-MM, or a month that has not started (`invalid_request_error`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/billing/statement" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbilling%2Fstatement) ## List billing statements `GET /v1/billing/statements` The months the close stored for the organization (owner only), in the mode of Gateway's Stripe key, newest first, at most 24. Each month shows its total, its whole cents, its state and its Stripe invoice page. A `closed` month is under 50 cents: nothing was invoiced and its total carries into the next month. Money is a decimal string. The route reads no Stripe. 503 `not_configured` until STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are both set and well formed (the message says which is wrong). Permission: `org.billing` (Owner). ### Responses - `200` OK (application/json, BillingStatementList) - `statements` (array of BillingStatementSummary, required): The stored months, newest first, at most 24. - `period` (string, required): The month, as YYYY-MM. [pattern ^[0-9]{4}-(0[1-9]|1[0-2])$] - `totalUsd` (string, required): The lines and the rest carried in, added. [pattern ^[0-9]+\.[0-9]{6}$] - `amountCents` (string, required): What the statement priced: `totalUsd` in whole cents, rounded down. A whole number as a string. A `closed` month invoices none of it. [pattern ^[0-9]+$] - `state` ("closed" | "invoicing" | "invoiced" | "paid" | "failed" | "void" | "uncollectible", required): `closed`: under 50 cents, so nothing was invoiced and the total carries into the next month. The other states are the ones of the invoice. - `hostedInvoiceUrl` (string | null, required): Stripe's page for the invoice. Null for a `closed` month, and until Stripe has finalized the invoice. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured (`not_configured`): the message says which variable is wrong (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Stripe is not configured (`not_configured`): the message says which variable is wrong | | 503 | `not_configured` | 503 `not_configured` until STRIPE_SECRET_KEY and STRIPE_WEBHOOK_SECRET are both set and well formed (the message says which is wrong) | ### Example ```sh curl "$NEXUS_URL/v1/billing/statements" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbilling%2Fstatements) ## Start payment method setup `POST /v1/billing/payment-method` Start saving a card for the organization (owner only): a link to a card page hosted by Stripe Checkout. Open `url` in a browser before `expiresAt`. Stripe sends the person back to the organization's billing page in Nexus UI (`<NEXUS_UI_URL>/<org>/billing?checkout=done` or `=cancelled`). Gateway makes the organization's Stripe customer on the first call and reuses it after; each call makes a new link. Takes no body, or `{"embedded": true}`: the same card setup as a form Nexus UI shows inside its billing page. With `STRIPE_PUBLISHABLE_KEY` on Gateway, that answer is `EmbeddedCardSetup` (Stripe.js's `clientSecret` and the `publishableKey`, no `url`), and Stripe sends the page to `?checkout=done` once the card is saved; without it, the hosted link as without the body. 400 when `embedded` is not a boolean. Audited as `billing.customer_created` when the customer is made, and as `billing.customer_deleted` when Stripe no longer has it; neither event names Stripe's customer id. 502 `stripe_error` when Stripe refuses or does not answer (the message names Stripe's type and code). 503 `not_configured` until Stripe is set up, or without NEXUS_UI_URL on Gateway; 503 `billing_setup_in_progress` while a first call for the organization is still running (try again in a moment). Permission: `org.billing` (Owner). ### 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) - `embedded` (boolean): Ask for the card form inside Nexus UI's billing page instead of Stripe's own page. Gateway answers the hosted link when it has no publishable key. ### Responses - `200` OK (application/json, PaymentMethodSetup | EmbeddedCardSetup) - `400` `embedded` is not a boolean (`invalid_request`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Stripe refused the call or did not answer (`stripe_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured, NEXUS_UI_URL is not set (`not_configured`), or a first call for this organization is still running (`billing_setup_in_progress`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `embedded` is not a boolean (`invalid_request`) | | 400 | `embedded` | 400 when `embedded` is not a boolean | | 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 | | 502 | | Stripe refused the call or did not answer (`stripe_error`) | | 502 | `stripe_error` | 502 `stripe_error` when Stripe refuses or does not answer (the message names Stripe's type and code) | | 503 | | Stripe is not configured, NEXUS_UI_URL is not set (`not_configured`), or a first call for this organization is still running (`billing_setup_in_progress`) | | 503 | `not_configured` | 503 `not_configured` until Stripe is set up, or without NEXUS_UI_URL on Gateway; 503 `billing_setup_in_progress` while a first call for the organization is still running (try again in a moment) | | 503 | `billing_setup_in_progress` | 503 `not_configured` until Stripe is set up, or without NEXUS_UI_URL on Gateway; 503 `billing_setup_in_progress` while a first call for the organization is still running (try again in a moment) | ### Example ```sh curl -X POST "$NEXUS_URL/v1/billing/payment-method" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "embedded": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fbilling%2Fpayment-method) ## Confirm payment `POST /v1/billing/confirm-payment` Confirm a payment the bank wants the cardholder to confirm (3-D Secure), owner only. Off session, Stripe refuses such a charge with `authentication_required` and keeps its PaymentIntent; this confirms that same usage charge after the fact again on session; one the bank's page never finished is cancelled at Stripe an hour later. An auto top-up that turned off for the bank's check is fixed by saving the card again (startPaymentMethodSetup). `status` `redirect`: open `url`, the bank's page, which sends the person back to the organization's billing page in Nexus UI (`<NEXUS_UI_URL>/<org>/billing?confirmed=1`). `succeeded` or `processing`: Stripe took it, or a bank debit is on its way. Stripe's notice records the payment as for any charge; nothing is charged twice. Takes no body. 409 `nothing_to_confirm` when no charge waits for the bank's check (save the card again with startPaymentMethodSetup), `charge_running` while a usage charge is being taken. 402 when the card is declined on session. Permission: `org.billing` (Owner). ### 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). | ### Responses - `200` OK (application/json, PaymentConfirmation) - `status` ("redirect" | "succeeded" | "processing", required): `redirect`: open `url`. `succeeded`: Stripe took the payment. `processing`: a bank debit is on its way. - `url` (string (uri) | null, required): The bank's page while it waits for the cardholder; null otherwise - `402` The card was declined on session (`stripe_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` No charge waits for the bank's check (`nothing_to_confirm`), or a usage charge is being taken now (`charge_running`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Stripe refused the call or did not answer (`stripe_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured, or NEXUS_UI_URL is not set (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The card was declined on session (`stripe_error`) | | 403 | `role_required` | Your role does not have this permission | | 409 | | No charge waits for the bank's check (`nothing_to_confirm`), or a usage charge is being taken now (`charge_running`) | | 409 | `nothing_to_confirm` | 409 `nothing_to_confirm` when no charge waits for the bank's check (save the card again with startPaymentMethodSetup), `charge_running` while a usage charge is being taken | | 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 | | 502 | | Stripe refused the call or did not answer (`stripe_error`) | | 503 | | Stripe is not configured, or NEXUS_UI_URL is not set (`not_configured`) | ### Example ```sh curl -X POST "$NEXUS_URL/v1/billing/confirm-payment" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fbilling%2Fconfirm-payment) ## Start billing portal `POST /v1/billing/portal` Open the organization's Stripe customer portal (owner only): a link to a page hosted by Stripe where the owner manages payment methods, sees and pays invoices, sets tax ids and cancels at period end. Plans and seats change through Gateway, not the portal. Open `url` in a browser at once: Stripe's link expires within minutes. Stripe sends the person back to the organization's billing page in Nexus UI (`<NEXUS_UI_URL>/<org>/billing`). Gateway makes the organization's Stripe customer on the first call and reuses it after; each call makes a new link. Takes no body. The Stripe account needs a default portal configuration. 502 `stripe_error` when Stripe refuses or does not answer (the message names Stripe's type and code). 503 `not_configured` until Stripe is set up, or without NEXUS_UI_URL on Gateway; 503 `billing_setup_in_progress` while a first call for the organization is still running (try again in a moment). Permission: `org.billing` (Owner). ### 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). | ### Responses - `200` OK (application/json, BillingPortal) - `url` (string, required): Stripe's customer portal for the organization. Open it at once: it expires within minutes. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Stripe refused the call or did not answer (`stripe_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured, NEXUS_UI_URL is not set (`not_configured`), or a first call for this organization is still running (`billing_setup_in_progress`) (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 | | 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 | | 502 | | Stripe refused the call or did not answer (`stripe_error`) | | 502 | `stripe_error` | 502 `stripe_error` when Stripe refuses or does not answer (the message names Stripe's type and code) | | 503 | | Stripe is not configured, NEXUS_UI_URL is not set (`not_configured`), or a first call for this organization is still running (`billing_setup_in_progress`) | | 503 | `not_configured` | 503 `not_configured` until Stripe is set up, or without NEXUS_UI_URL on Gateway; 503 `billing_setup_in_progress` while a first call for the organization is still running (try again in a moment) | | 503 | `billing_setup_in_progress` | 503 `not_configured` until Stripe is set up, or without NEXUS_UI_URL on Gateway; 503 `billing_setup_in_progress` while a first call for the organization is still running (try again in a moment) | ### Example ```sh curl -X POST "$NEXUS_URL/v1/billing/portal" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fbilling%2Fportal) ## Buy credits `POST /v1/billing/credits` Buy Nexus credits (owner only): the organization's own money, prepaid at face value and never expiring, spent by Nexus features after the free start and a plan's included usage at provider price plus Nexus's rate. Body: `amountUsd`, a decimal string in whole cents, from "10.00" to "10000.00"; a new organization buys at most $100 in its first 7 days, counting the purchases still being paid, such as an open Checkout page until it expires (400 `purchase_limit`). With a payment method on file, Gateway charges it off session: `status: credited` with the credits after, or `processing` for a bank debit still on its way (Stripe's notice credits it). Without one, or when the bank wants the person (3-D Secure) or the card declines, `status: checkout` with a Stripe Checkout `url` to open before `expiresAt`; Stripe sends the person back to `<NEXUS_UI_URL>/<org>/billing?checkout=credits`. A payment credits once, from Stripe's `payment_intent.succeeded`, and only to the organization whose Stripe customer paid. The Idempotency-Key header keys the Stripe call, so a retry never charges twice. Audited as `credit.purchased`. 400 `invalid_amount`; 502 `stripe_error`; 503 `not_configured` until Stripe is set up, or without NEXUS_UI_URL for a hosted purchase. With paymentToken, charge the agent wallet shared payment token directly in Stripe test mode. Live mode returns 503 payment_tokens_not_supported before contacting Stripe. There is no hosted fallback. 400 invalid_payment_token rejects a malformed credential, or one Stripe has deactivated (used, revoked or expired); 402 payment_authentication_required requires the cardholder. The same Idempotency-Key and body replay the first result. Permission: `org.billing` (Owner). ### 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) - `paymentToken` (string): Optional Stripe shared payment token from an agent wallet, scoped to Nexus, USD, the purchase amount and an expiry. Currently accepted only in Stripe test mode. Confirms without a saved card, NEXUS_UI_URL or Checkout. Never accepts card details or merchant API keys. Does not save a card or enable recurring charges. [max length 255; pattern ^spt_[A-Za-z0-9_]+$] - `amountUsd` (string, required): Dollars in whole cents, such as "50.00": from 10.00 to 10000.00. ### Responses - `200` OK (application/json, BuyCredits) - `status` ("credited" | "processing" | "checkout", required): `credited`: charged and credited now; `processing`: Stripe is still taking a bank debit, and its notice credits it; `checkout`: open `url` to pay. - `amountUsd` (string, required): What the purchase buys, in decimal dollars. - `credits` (NexusCredits): The organization's prepaid Nexus credits, its own money, never expiring. A Nexus feature's call spends them after the free start, at its provider cost plus `markupBps`. Decimal dollar strings. - `purchasedUsd` (string, required): Bought, over all time. - `spentUsd` (string, required): What settled calls cost the credits: each call's provider cost plus `markupBps`. - `reservedUsd` (string, required): Held by calls in progress. - `remainingUsd` (string, required): Bought, less spent, held and reversed. Below zero after a refund or a lost dispute took back credit that was already spent: then Nexus pays for no call (the free start, credits or the card after the fact) until a purchase pays it back. - `reversedUsd` (string): What refunds, lost disputes and operators took back, and what an open dispute holds of its purchase until it closes. A refund that fails gives its credit back. Only while something is taken back. - `markupBps` (integer, required): Nexus's rate on AI in basis points (500 is 5%). - `paymentId` (string): Stripe's PaymentIntent, while `processing`. - `url` (string): Stripe Checkout's page, for `checkout`. - `expiresAt` (string (date-time)): When Stripe stops accepting `url`. - `checkoutSessionId` (string): Exact Checkout session to confirm; returned by current Gateways. - `400` An amount outside $25 to $10,000 or not in whole cents (`invalid_amount`), or past a new organization's limit (`purchase_limit`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `402` The delegated payment requires cardholder authentication or was not completed (payment_authentication_required, payment_declined, payment_failed). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Only the owner buys credits (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Stripe refused the call or did not answer (`stripe_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Delegated payment tokens are disabled in live mode (`payment_tokens_not_supported`), Stripe is not configured, NEXUS_UI_URL is not set for a hosted purchase (`not_configured`), or a first call for this organization is still running (`billing_setup_in_progress`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | An amount outside $25 to $10,000 or not in whole cents (`invalid_amount`), or past a new organization's limit (`purchase_limit`) | | 400 | `purchase_limit` | `amountUsd`, a decimal string in whole cents, from "10.00" to "10000.00"; a new organization buys at most $100 in its first 7 days, counting the purchases still being paid, such as an open Checkout page until it expires (400 `purchase_limit`) | | 400 | `invalid_amount` | 400 `invalid_amount`; 502 `stripe_error`; 503 `not_configured` until Stripe is set up, or without NEXUS_UI_URL for a hosted purchase | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The delegated payment requires cardholder authentication or was not completed (payment_authentication_required, payment_declined, payment_failed). | | 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 | | 502 | | Stripe refused the call or did not answer (`stripe_error`) | | 502 | `stripe_error` | 400 `invalid_amount`; 502 `stripe_error`; 503 `not_configured` until Stripe is set up, or without NEXUS_UI_URL for a hosted purchase | | 503 | | Delegated payment tokens are disabled in live mode (`payment_tokens_not_supported`), Stripe is not configured, NEXUS_UI_URL is not set for a hosted purchase (`not_configured`), or a first call for this organization is still running (`billing_setup_in_progress`) | | 503 | `not_configured` | 400 `invalid_amount`; 502 `stripe_error`; 503 `not_configured` until Stripe is set up, or without NEXUS_UI_URL for a hosted purchase | ### Example ```sh curl -X POST "$NEXUS_URL/v1/billing/credits" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "amountUsd": "<amountUsd>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fbilling%2Fcredits) ## Set auto topup `PUT /v1/billing/auto-topup` Turn the organization's auto top-up of Nexus credits on or off (owner only). Body: `enabled`, and `belowUsd` and `addUsd` as decimal strings in whole cents (or the ones set before). On needs the payment method on file (409 `no_payment_method`), and not a card whose payment was disputed (409 `card_disputed`). A closed organization cannot turn it on (409 `organization_closed`). When the credits left fall below `belowUsd`, Gateway's Stripe sweep (`NEXUS_STRIPE_SWEEP_MS`) charges that payment method `addUsd` off session and credits it, one top-up at a time, at most 3 top-ups or $500 a UTC day. A decline, a bank that wants the person, no payment method, a bank debit that fails later (`payment_intent.payment_failed`), a dispute, or a refund that takes the credits below zero turns it off, and `offReason` says why. Off keeps the amounts; turning off what was never set answers `autoTopup: null`. Audited as `credit.auto_topup_changed`. 400 `invalid_amount`; 503 `not_configured` until Stripe is set up. Permission: `org.billing` (Owner). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `enabled` (boolean, required) - `belowUsd` (string): Dollars in whole cents, above 0.00 and at most 10000.00. Needed to turn on the first time. - `addUsd` (string): Dollars in whole cents, from 10.00 to 500.00. Needed to turn on the first time. ### Responses - `200` OK (application/json, SetAutoTopup) - `autoTopup` (AutoTopup | null, required): The setting after; null after turning off what was never set. - `400` `belowUsd` not above $0 or above $10,000, or `addUsd` outside $25 to $500 or not in whole cents (`invalid_amount`); `enabled` missing; or turning on without both amounts (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` Turning on with no payment method on file (`no_payment_method`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `belowUsd` not above $0 or above $10,000, or `addUsd` outside $25 to $500 or not in whole cents (`invalid_amount`); `enabled` missing; or turning on without both amounts | | 400 | `invalid_amount` | 400 `invalid_amount`; 503 `not_configured` until Stripe is set up | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | Turning on with no payment method on file (`no_payment_method`) | | 409 | `no_payment_method` | On needs the payment method on file (409 `no_payment_method`), and not a card whose payment was disputed (409 `card_disputed`) | | 409 | `card_disputed` | On needs the payment method on file (409 `no_payment_method`), and not a card whose payment was disputed (409 `card_disputed`) | | 409 | `organization_closed` | A closed organization cannot turn it on (409 `organization_closed`) | | 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 | | 503 | | Stripe is not configured (`not_configured`) | | 503 | `not_configured` | 400 `invalid_amount`; 503 `not_configured` until Stripe is set up | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/billing/auto-topup" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "enabled": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fbilling%2Fauto-topup) ## Get org settings `GET /v1/orgs/settings` The organization's settings: how many days chat messages are kept (90 by default). Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, OrgSettings) - `hiddenMobilePlaces` (array of "assistant" | "artifacts" | "customize"): Places hidden from members in the mobile drawer. The owner still sees them. - `chatRetentionDays` (integer, required): Days chat messages are kept (90 by default) [min 1; max 3650] - `agentSubscriptions` (boolean): Whether `nexus claude --subscription` may run (true by default) - `growthEvents` (boolean): Whether the Gateway records the organization's growth events in its own store (true by default) - `chatSuggestions` (boolean): Whether chat sessions suggest the person's next message after an answer, a call the organization pays for (true by default) - `defaults` (object, required) - `hiddenMobilePlaces` (array of "assistant" | "artifacts" | "customize") [default []] - `chatRetentionDays` (integer) - `growthEvents` (boolean) - `chatSuggestions` (boolean) - `artifacts.external` ("off" | "named" | "public") - `artifacts.external.code` (boolean) - `artifacts.external.domains` (object) - `allow` (array of string, required) - `deny` (array of string, required) - `artifacts.external.expiry` (object) - `maxDays` (integer | null, required) [min 1; max 3650] - `required` (boolean, required) - `artifacts.external.continue` (boolean) - `artifacts.external.who` ("everyone" | "admins") - `agentSubscriptions` (boolean) - `artifacts.pages` (boolean) - `artifacts.pages.public` (boolean) - `artifacts.pages.queries` (boolean) - `webSearch.engine` ("off" | "borrowed") - `webSearch.model` (string | null) - `webSearch.domains` (object) - `allow` (array of string, required) - `deny` (array of string, required) - `webSearch.maxPerTurn` (integer) - `webSearch.requireZdr` (boolean) - `sessionContent` ("never" | "user" | "user_and_org") - `multiplayerSessions` (boolean) - `cloudHistory` (boolean) - `webSessionViewer` (boolean) - `updatedAt` (string (date-time)) - `artifacts.external` ("off" | "named" | "public"): Sharing artifacts outside the organization: off, named people only, or also public links (default public) - `artifacts.external.code` (boolean): May external snapshots include Ask your code's sources (default false) - `artifacts.external.domains` (object): Email domains named outsiders may (allow, when set) or may not (deny) have; a domain matches itself and its subdomains (default both empty) - `allow` (array of string, required) - `deny` (array of string, required) - `artifacts.external.expiry` (object): The longest a public link may stay open, and whether every public link must expire (default none and false) - `maxDays` (integer | null, required) [min 1; max 3650] - `required` (boolean, required) - `artifacts.external.continue` (boolean): May people outside continue the chat in an organization of their own, at its expense (default true) - `artifacts.external.who` ("everyone" | "admins"): Who may share outside: everyone, or owners and admins (default everyone) - `artifacts.pages` (boolean): Pages: off refuses new pages, versions, shares and every page frame (default true) - `artifacts.pages.public` (boolean): Public links to pages: off refuses new ones and stops existing ones from opening (default false in a company organization, true in a personal one) - `artifacts.pages.queries` (boolean): Page queries (Nexus Data): on lets a page's owner approve read-only queries on a connection, whose results the page's readers see; off refuses saving and running them (default false) - `webSearch.engine` ("off" | "borrowed"): Gates hosted web search in chat and in Code (`nexus claude --api`, `nexus codex --api`): off or borrowed (default borrowed; off means no web search runs) - `webSearch.model` (string | null): The model that runs a chat's search: null for the default (the chat's own model, the cheapest on nexus/auto), cheapest, or a model's catalog id. A pinned model the person may not use, or nobody pays for, gives that person no search, and so does an id this Gateway cannot call, which is shown as stored. Chat only - `webSearch.domains` (object): Domains a search result may (allow, when set) or may not (deny) come from (default both empty). While any is set, no web search runs, in chat or in Code, until the engine applies them - `allow` (array of string, required) - `deny` (array of string, required) - `webSearch.maxPerTurn` (integer): Most searches in one chat turn (default 3). Applies to Gateway-run engines (chat) only [min 1; max 10] - `webSearch.requireZdr` (boolean): Whether only engines with zero data retention may run (default false). While set, no web search runs, in chat or in Code, until the engine applies it - `sessionContent` ("never" | "user" | "user_and_org"): The content policy for synced sessions that runners follow, readable by every member. The default is user in every organization; only a saved user_and_org applies, and it reads as user while the organization has no recovery key (getOrgRecoveryKey) - `multiplayerSessions` (boolean): Whether members read each other's team-visible synced sessions, still end-to-end encrypted. False by default; always false in a personal one - `cloudHistory` (boolean): Whether Gateway stores the organization's cloud session history, so a sleeping cloud session reads on any device. True by default. Off, Gateway stores none. Omitted for an organization that cannot run cloud machines and stores no cloud history - `webSessionViewer` (boolean): Whether Nexus UI in a browser opens the organization's synced sessions. True by default. Off, Nexus UI's credential (its session token or its server's secret) gets 403 web_session_viewer_off for sealed events, key copies and a new device - `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/orgs/settings" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fsettings) ## Set org settings `PUT /v1/orgs/settings` Change the organization's settings (owners and admins). chatRetentionDays: 1 to 3650, or null for the default; a shorter window deletes expired messages at once. Audited as org.settings_changed. Permission: `org.settings` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `hiddenMobilePlaces` (array of "assistant" | "artifacts" | "customize" | null): Places an owner hides from members in the mobile drawer. Only an owner can change this setting. Null makes all places visible. - `chatRetentionDays` (integer | null) [min 1; max 3650] - `agentSubscriptions` (boolean | null): Whether `nexus claude --subscription` may run (people's own Claude logins, outside Gateway's checks); null for the default, true - `growthEvents` (boolean | null): Whether the Gateway records the organization's growth events in its own store; null for the default, true. No safety control depends on it - `chatSuggestions` (boolean | null): Whether chat sessions suggest the person's next message after an answer, a call the organization pays for; null for the default, true - `webSearch.engine` ("off" | "borrowed" | null): Gates hosted web search in chat and in Code (`nexus claude --api`, `nexus codex --api`): off or borrowed; null for the default, borrowed. An unknown engine is a 400 that names the allowed values - `webSearch.model` (string | null): The model that runs a chat's search, whatever the chat's model is: cheapest, or the catalog id of a model that can search (`GET /v1/models` lists it with `web_search_usd`); null or default for the default, the chat's own model (the cheapest on nexus/auto). It is stored as the model's catalog id. Chat only: in Code an agent searches on its own model. Anything else is a 400 that lists the models - `webSearch.domains` (object | null): Domains a search result may (allow, when set) or may not (deny) come from; null for the default, both empty. While any is set, no web search runs, in chat or in Code, until the engine applies them - `allow` (array of string) - `deny` (array of string) - `webSearch.maxPerTurn` (integer | null): Most searches in one chat turn; null for the default, 3. Applies to Gateway-run engines (chat) only [min 1; max 10] - `webSearch.requireZdr` (boolean | null): Whether only engines with zero data retention may run; null for the default, false. While set, no web search runs, in chat or in Code, until the engine applies it - `artifacts.external` ("off" | "named" | "public" | null): Sharing an artifact outside the organization: off, named (named people by verified email) or public (also anyone with an unguessable link); null for the default, public. Another value is a 400 - `artifacts.external.code` (boolean | null): Whether an artifact shared outside the organization may include Ask your code's sources; null for the default, false - `artifacts.external.domains` (object | null): Email domains a named share outside the organization may (allow, when set) or may not (deny) go to; null for the default, both empty - `allow` (array of string) - `deny` (array of string) - `artifacts.external.expiry` (object | null): Limits on how long a public link stays open: maxDays (1-3650, or null for no limit) and whether an expiry is required; null for the default, no limit and not required - `maxDays` (integer | null) [min 1; max 3650] - `required` (boolean) - `artifacts.external.continue` (boolean | null): Whether people outside the organization may continue or remix what it shares; null for the default, true - `artifacts.external.who` ("everyone" | "admins" | null): Who may share outside the organization: everyone or admins; null for the default, everyone - `artifacts.pages` (boolean | null): Pages on or off; null for the default, true - `artifacts.pages.public` (boolean | null): Public links to pages; null for the default (false in a company organization, true in a personal one) - `artifacts.pages.queries` (boolean | null): Page queries (Nexus Data): a page's owner may approve read-only queries on a connection for its readers; null for the default, false - `sessionContent` ("never" | "user" | "user_and_org" | null): What leaves a person's machine when coding sessions sync, end-to-end encrypted: never (only usage numbers), user (only the person's own devices can read it) or user_and_org (also the organization's recovery key); null for the default. Needs synced_sessions.manage_policy. user_and_org answers 409 org_recovery_key_required until the organization registers a recovery key (putOrgRecoveryKey) - `multiplayerSessions` (boolean | null): Whether members read each other's team-visible synced sessions; null for the default, false. A personal organization answers 403 personal_organization - `cloudHistory` (boolean | null): Whether Gateway stores the organization's cloud session history, readable by Nexus's systems and encrypted at rest; null for the default, true. Off, Gateway stores none and deletes what it holds - `webSessionViewer` (boolean | null): Whether Nexus UI in a browser opens the organization's synced sessions; null for the default, true. Needs synced_sessions.manage_policy. Off, Nexus UI's credential gets 403 web_session_viewer_off for sealed events, key copies and a new device; the desktop, the phone and the CLI read as before ### Responses - `200` OK (application/json, OrgSettings) - `hiddenMobilePlaces` (array of "assistant" | "artifacts" | "customize"): Places hidden from members in the mobile drawer. The owner still sees them. - `chatRetentionDays` (integer, required): Days chat messages are kept (90 by default) [min 1; max 3650] - `agentSubscriptions` (boolean): Whether `nexus claude --subscription` may run (true by default) - `growthEvents` (boolean): Whether the Gateway records the organization's growth events in its own store (true by default) - `chatSuggestions` (boolean): Whether chat sessions suggest the person's next message after an answer, a call the organization pays for (true by default) - `defaults` (object, required) - `hiddenMobilePlaces` (array of "assistant" | "artifacts" | "customize") [default []] - `chatRetentionDays` (integer) - `growthEvents` (boolean) - `chatSuggestions` (boolean) - `artifacts.external` ("off" | "named" | "public") - `artifacts.external.code` (boolean) - `artifacts.external.domains` (object) - `allow` (array of string, required) - `deny` (array of string, required) - `artifacts.external.expiry` (object) - `maxDays` (integer | null, required) [min 1; max 3650] - `required` (boolean, required) - `artifacts.external.continue` (boolean) - `artifacts.external.who` ("everyone" | "admins") - `agentSubscriptions` (boolean) - `artifacts.pages` (boolean) - `artifacts.pages.public` (boolean) - `artifacts.pages.queries` (boolean) - `webSearch.engine` ("off" | "borrowed") - `webSearch.model` (string | null) - `webSearch.domains` (object) - `allow` (array of string, required) - `deny` (array of string, required) - `webSearch.maxPerTurn` (integer) - `webSearch.requireZdr` (boolean) - `sessionContent` ("never" | "user" | "user_and_org") - `multiplayerSessions` (boolean) - `cloudHistory` (boolean) - `webSessionViewer` (boolean) - `updatedAt` (string (date-time)) - `artifacts.external` ("off" | "named" | "public"): Sharing artifacts outside the organization: off, named people only, or also public links (default public) - `artifacts.external.code` (boolean): May external snapshots include Ask your code's sources (default false) - `artifacts.external.domains` (object): Email domains named outsiders may (allow, when set) or may not (deny) have; a domain matches itself and its subdomains (default both empty) - `allow` (array of string, required) - `deny` (array of string, required) - `artifacts.external.expiry` (object): The longest a public link may stay open, and whether every public link must expire (default none and false) - `maxDays` (integer | null, required) [min 1; max 3650] - `required` (boolean, required) - `artifacts.external.continue` (boolean): May people outside continue the chat in an organization of their own, at its expense (default true) - `artifacts.external.who` ("everyone" | "admins"): Who may share outside: everyone, or owners and admins (default everyone) - `artifacts.pages` (boolean): Pages: off refuses new pages, versions, shares and every page frame (default true) - `artifacts.pages.public` (boolean): Public links to pages: off refuses new ones and stops existing ones from opening (default false in a company organization, true in a personal one) - `artifacts.pages.queries` (boolean): Page queries (Nexus Data): on lets a page's owner approve read-only queries on a connection, whose results the page's readers see; off refuses saving and running them (default false) - `webSearch.engine` ("off" | "borrowed"): Gates hosted web search in chat and in Code (`nexus claude --api`, `nexus codex --api`): off or borrowed (default borrowed; off means no web search runs) - `webSearch.model` (string | null): The model that runs a chat's search: null for the default (the chat's own model, the cheapest on nexus/auto), cheapest, or a model's catalog id. A pinned model the person may not use, or nobody pays for, gives that person no search, and so does an id this Gateway cannot call, which is shown as stored. Chat only - `webSearch.domains` (object): Domains a search result may (allow, when set) or may not (deny) come from (default both empty). While any is set, no web search runs, in chat or in Code, until the engine applies them - `allow` (array of string, required) - `deny` (array of string, required) - `webSearch.maxPerTurn` (integer): Most searches in one chat turn (default 3). Applies to Gateway-run engines (chat) only [min 1; max 10] - `webSearch.requireZdr` (boolean): Whether only engines with zero data retention may run (default false). While set, no web search runs, in chat or in Code, until the engine applies it - `sessionContent` ("never" | "user" | "user_and_org"): The content policy for synced sessions that runners follow, readable by every member. The default is user in every organization; only a saved user_and_org applies, and it reads as user while the organization has no recovery key (getOrgRecoveryKey) - `multiplayerSessions` (boolean): Whether members read each other's team-visible synced sessions, still end-to-end encrypted. False by default; always false in a personal one - `cloudHistory` (boolean): Whether Gateway stores the organization's cloud session history, so a sleeping cloud session reads on any device. True by default. Off, Gateway stores none. Omitted for an organization that cannot run cloud machines and stores no cloud history - `webSessionViewer` (boolean): Whether Nexus UI in a browser opens the organization's synced sessions. True by default. Off, Nexus UI's credential (its session token or its server's secret) gets 403 web_session_viewer_off for sealed events, key copies and a new device - `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 PUT "$NEXUS_URL/v1/orgs/settings" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "hiddenMobilePlaces": [ "assistant" ], "chatRetentionDays": 1, "agentSubscriptions": false, "growthEvents": false, "chatSuggestions": false, "webSearch.engine": "off", "webSearch.model": "<webSearch.model>", "webSearch.domains": { "allow": [ "<allow>" ], "deny": [ "<deny>" ] }, "webSearch.maxPerTurn": 1, "webSearch.requireZdr": false, "artifacts.external": "off", "artifacts.external.code": false, "artifacts.external.domains": { "allow": [ "<allow>" ], "deny": [ "<deny>" ] }, "artifacts.external.expiry": { "maxDays": 1, "required": false }, "artifacts.external.continue": false, "artifacts.external.who": "everyone", "artifacts.pages": false, "artifacts.pages.public": false, "artifacts.pages.queries": false, "sessionContent": "never", "multiplayerSessions": false, "cloudHistory": false, "webSessionViewer": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Forgs%2Fsettings) ## Get effective settings `GET /v1/orgs/effective-settings` Every control in the control inventory, as far as the caller reaches: owners and admins every control, a team lead the controls of the teams they lead, everyone their own values and those of their teams and the organization. An entry also keeps its own route's permission: a control the caller may not read there (the automatic top-up without `org.billing`) carries the refusal. An entry whose source was not read carries an error, and the answer stays 200. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, EffectiveSettings) - `controls` (array of EffectiveSetting, required) - `key` (string, required): The control's key in the inventory (controls.json). - `capability` (string, required) - `value` (any): The control's value, when its source was read: any JSON value. A model policy control maps each level that stores a rule (`organization:organization`, `team:<slug>`, `agent:<name>`) to the rule it stores. A level without a rule inherits the rule above it, so one level's entry is not, on its own, the rule enforced there. - `error` (string): Set only when the control's value was not read. Tell a read value from an unread one by this field, not by `value`: a read value can be `null`. - `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/orgs/effective-settings" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Feffective-settings) ## Get custody report `GET /v1/orgs/custody` The vault's custody report for the organization (owners and admins): which master key wraps its data keys and who holds that master (Nexus's NEXUS_SECRET, a Cloud KMS key in Nexus's project, or one in the customer's own project, which the customer can revoke); every version of its data key; and every secret or reference the vault holds, with its table, its data key version and its last four characters. It never holds a secret or a data key. Permission: `audit.read_all` (Owner, Admin). ### Responses - `200` OK (application/json, CustodyReport) - `master` (CustodyMaster, required) - `holder` ("nexus_secret" | "nexus_kms" | "customer_kms", required): `nexus_secret`: derived from Nexus's NEXUS_SECRET. `nexus_kms`: a Cloud KMS key in Nexus's project. `customer_kms`: a Cloud KMS key in the customer's own project; the customer can revoke Nexus's access. - `key` (string): The customer's Cloud KMS key's resource name; absent when Nexus holds the master. - `dataKeys` (array of CustodyDataKey, required) - `version` (integer, required) - `master` (CustodyMaster, required) - `holder` ("nexus_secret" | "nexus_kms" | "customer_kms", required): `nexus_secret`: derived from Nexus's NEXUS_SECRET. `nexus_kms`: a Cloud KMS key in Nexus's project. `customer_kms`: a Cloud KMS key in the customer's own project; the customer can revoke Nexus's access. - `key` (string): The customer's Cloud KMS key's resource name; absent when Nexus holds the master. - `createdAt` (string (date-time), required) - `holdings` (array of CustodyHolding, required) - `kind` ("provider_key" | "connector_credential", required) - `name` (string, required): The provider (`anthropic`, or `anthropic:team:team_…` for a team's key), or the connector and its scope (`linear:user:usr_…`). - `table` (string, required): The table that stores it. - `sealedWith` ("data_key" | "nexus_secret" | "reference", required): `data_key`: the organization's data key of version `keyVersion`. `nexus_secret`: a key derived from NEXUS_SECRET, sealed before data keys. `reference`: no secret is held, only a reference to a vendor's short-lived token. - `keyVersion` (integer) - `last4` (string) - `createdAt` (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/orgs/custody" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fcustody) ## Get org subscription `GET /v1/orgs/subscription` The organization's subscription (anyone in it): the plan, the member who pays, the member who receives billing mail, the paid term, the status and the seats (one per human member). An organization nobody changed yet reads as `active` since it was created, with everything else `null` and `updatedAt: null`. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, OrgSubscription) - `plan` (string | null, required): Written by Billing: an entry of Billing Capabilities' plan catalogue; null until one is chosen. - `payerUserId` (string | null, required): The member who pays; null until named. - `billingContactUserId` (string | null, required): The member who receives billing mail; null until named. - `periodStart` (string (date) | null, required): Written by Billing: the first day of the paid term. - `periodEnd` (string (date) | null, required): Written by Billing: the day the paid term ends; null for an open term. - `status` ("active" | "past_due" | "cancelled" | "under_contract", required): Written by Billing alone. It changes what the organization is entitled to, never who is in it. - `statusEffectiveAt` (string (date-time), required): When the status took effect. - `effectiveAt` (string (date-time), required): When the newest change took effect. - `updatedAt` (string (date-time) | null, required): When the subscription was last written; null until its first change. - `seats` (integer, required): One per member that `GET /v1/orgs/members` lists, counted when read. [min 0] - `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/orgs/subscription" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fsubscription) ## Change org subscription `PATCH /v1/orgs/subscription` Name the payer and the billing contact (owners only). A field changes when present and clears when `null`; an absent field stays. Both must be members (400 `not_a_member`). `plan`, `periodStart`, `periodEnd` and `status` are refused (400 `written_by_billing`): Billing writes them from what the organization pays for. `effectiveAt` (default now) is when the change took effect: never in the future and never before the newest change (400 `invalid_effective_at`). `dryRun: true` answers with the result and writes nothing. Audited as `subscription.changed`, with the changed fields before and after and `metadata.effectiveAt`; a body that changes nothing writes nothing. Permission: `org.billing` (Owner). ### 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) - `payerUserId` (string | null): The member who pays: a user id from `GET /v1/orgs/members`. - `billingContactUserId` (string | null): The member who receives billing mail. - `effectiveAt` (string (date-time)): When the change took effect; default now. - `dryRun` (boolean): Check the change and answer with the result; write nothing. [default false] ### Responses - `200` OK (application/json, OrgSubscriptionChange) - `subscription` (OrgSubscription, required) - `plan` (string | null, required): Written by Billing: an entry of Billing Capabilities' plan catalogue; null until one is chosen. - `payerUserId` (string | null, required): The member who pays; null until named. - `billingContactUserId` (string | null, required): The member who receives billing mail; null until named. - `periodStart` (string (date) | null, required): Written by Billing: the first day of the paid term. - `periodEnd` (string (date) | null, required): Written by Billing: the day the paid term ends; null for an open term. - `status` ("active" | "past_due" | "cancelled" | "under_contract", required): Written by Billing alone. It changes what the organization is entitled to, never who is in it. - `statusEffectiveAt` (string (date-time), required): When the status took effect. - `effectiveAt` (string (date-time), required): When the newest change took effect. - `updatedAt` (string (date-time) | null, required): When the subscription was last written; null until its first change. - `seats` (integer, required): One per member that `GET /v1/orgs/members` lists, counted when read. [min 0] - `changed` (array of string, required): The fields that changed, or would change on a dry run; empty when nothing did. - `dryRun` (boolean, required): True when nothing was written. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | `not_a_member` | Both must be members (400 `not_a_member`) | | 400 | `written_by_billing` | `plan`, `periodStart`, `periodEnd` and `status` are refused (400 `written_by_billing`): Billing writes them from what the organization pays for | | 400 | `invalid_effective_at` | Never in the future and never before the newest change (400 `invalid_effective_at`) | | 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 PATCH "$NEXUS_URL/v1/orgs/subscription" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "payerUserId": "<payerUserId>", "billingContactUserId": "<billingContactUserId>", "effectiveAt": "2026-10-01T00:00:00Z", "dryRun": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Forgs%2Fsubscription) ## List plans `GET /v1/billing/plans` The plans this organization can take, priced as Stripe holds them (owner only): one source for Nexus UI, the desktop app, both CLIs and the phone. A per-seat plan is for companies and any other plan for personal organizations, so only the organization's kind is listed (`audience`). Each plan has its name (the Stripe Product's), `perSeat`, `minSeats`, and per interval `amountUsd` (the price, per seat for a per-seat plan) and `includedUsd` (included usage each month, per seat), as decimal strings. Each plan also has its cloud hours a month per seat (`includedHours`), the price of an hour past them (`hourlyUsd`, a decimal string or null) and the machine sizes it allows (`sizes`). A price Stripe could not give has `amountUsd: null` and a machine-readable `error` (`stripe_error`, `stripe_timeout`, `inactive`, `not_usd`, `interval_mismatch`, `no_fixed_amount`). Cheapest a month first. `current` is the plan the organization's subscription holds. Prices are cached for 10 minutes. 502 `stripe_error` when Stripe gave none of the listed prices; 503 `not_configured` without Stripe or NEXUS_PLANS. Permission: `org.billing` (Owner). ### Responses - `200` OK (application/json, PlanCatalogue) - `audience` ("personal" | "company", required) - `plans` (array of CataloguePlan, required) - `plan` (string, required): The plan's key in NEXUS_PLANS, such as `plus`, `pro` or `teams_pro`. - `name` (string, required): The Stripe Product's name; the key when Stripe gave none. - `perSeat` (boolean, required) - `minSeats` (integer, required) - `includedHours` (integer, required): Cloud hours each month, in hours of the default machine size, per seat for a per-seat plan; 0 when NEXUS_PLANS sets none (pricing v3.0). [min 0] - `hourlyUsd` (string | null, required): The price of a default-size hour past the plan's hours, as a decimal string with six places; null when NEXUS_PLANS sets none. [pattern ^[0-9]+\.[0-9]{6}$] - `sizes` (array of "small" | "default" | "large" | "xlarge", required): The machine sizes the plan allows, smallest first; only `default` when NEXUS_PLANS sets none. - `intervals` (array of object, required) - `interval` ("month" | "year", required) - `amountUsd` (string | null, required): The price for the interval, per seat for a per-seat plan; null with `error`. - `includedUsd` (string, required): Included usage each month, per seat for a per-seat plan. - `error` (string | null, required): Why the price is not shown: `stripe_error`, `stripe_timeout`, `inactive`, `not_usd`, `interval_mismatch` or `no_fixed_amount`. - `current` (boolean, required): The organization's subscription holds this plan. - `current` (object | null, required): The plan the organization's subscription holds; null on the Free plan. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Stripe gave none of the listed prices (`stripe_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe or NEXUS_PLANS is not configured (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | Stripe gave none of the listed prices (`stripe_error`) | | 502 | `stripe_error` | 502 `stripe_error` when Stripe gave none of the listed prices; 503 `not_configured` without Stripe or NEXUS_PLANS | | 503 | | Stripe or NEXUS_PLANS is not configured (`not_configured`) | | 503 | `not_configured` | 502 `stripe_error` when Stripe gave none of the listed prices; 503 `not_configured` without Stripe or NEXUS_PLANS | ### Example ```sh curl "$NEXUS_URL/v1/billing/plans" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbilling%2Fplans) ## Change plan `POST /v1/billing/plan/change` Change the organization's plan, interval or seats (owner only). Body: `plan`, `interval`, `seats` for a per-seat plan (one per member, at least its minimum: left out, Gateway counts them), and `dryRun`. A change that costs more a month applies now, and so does monthly to yearly at the same rate a month or more (a yearly price costs its plan's monthly price a month): Stripe prorates it and invoices the difference at once, and the month's included usage grows by the difference at once (live mode, or `NEXUS_PLANS_TEST_GRANTS=on`). A payment that fails changes nothing (402 `payment_failed`). Any other change (a cheaper plan, fewer seats, yearly to monthly, monthly to a yearly plan that costs less a month) applies at the period's end through a Stripe subscription schedule, shows as `pendingChange` on `GET /v1/billing`, and replaces an earlier pending change; `DELETE` cancels it. `dryRun: true` answers `when`, `at` and `amountDueUsd` (what is invoiced now) and changes nothing. The Idempotency-Key header keys the Stripe call. 400 `unknown_plan`, `plan_not_for_org`, `same_plan`; 409 `no_plan` without a paid plan, `plan_ending` while the plan is cancelled (renew it on Stripe's billing page first); 502 `stripe_error`; 503 `not_configured` until Stripe and NEXUS_PLANS are set. Permission: `org.billing` (Owner). ### 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) - `plan` (string, required) - `interval` ("month" | "year", required) - `seats` (integer): For a per-seat plan: from its minimum to 1000 (its minimum when absent). - `dryRun` (boolean): Answer what the change would charge and when, and change nothing. ### Responses - `200` OK (application/json, PlanChange) - `when` ("now" | "period_end", required) - `at` (string, required): When it applies (ISO 8601). - `amountDueUsd` (string | null, required): What is invoiced now, a decimal string: a dry run's preview, or 0 for a change at the period's end; null after a change applied now (Stripe invoiced it). - `dryRun` (boolean, required) - `plan` (BillingPlan | null, required): The plan after the change, or as it is for a dry run. - `400` An unknown plan or interval, seats out of range, a plan for the other kind of organization, or the plan the organization is on (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `402` Stripe could not take the payment for the change (`payment_failed`); nothing changed (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` No paid plan to change (`no_plan`), or the plan is cancelled, for this period or a later one (`plan_ending`, with `cancelAt` on `GET /v1/billing`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Stripe refused the call, did not answer, or gave no prices to compare (`stripe_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe or NEXUS_PLANS is not configured (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | An unknown plan or interval, seats out of range, a plan for the other kind of organization, or the plan the organization is on | | 400 | `unknown_plan` | 400 `unknown_plan`, `plan_not_for_org`, `same_plan`; 409 `no_plan` without a paid plan, `plan_ending` while the plan is cancelled (renew it on Stripe's billing page first); 502 `stripe_error`; 503 `not_configured` until Stripe and NEXUS_PLANS are set | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | Stripe could not take the payment for the change (`payment_failed`); nothing changed | | 402 | `payment_failed` | A payment that fails changes nothing (402 `payment_failed`) | | 403 | `role_required` | Your role does not have this permission | | 409 | | No paid plan to change (`no_plan`), or the plan is cancelled, for this period or a later one (`plan_ending`, with `cancelAt` on `GET /v1/billing`) | | 409 | `no_plan` | 400 `unknown_plan`, `plan_not_for_org`, `same_plan`; 409 `no_plan` without a paid plan, `plan_ending` while the plan is cancelled (renew it on Stripe's billing page first); 502 `stripe_error`; 503 `not_configured` until Stripe and NEXUS_PLANS are set | | 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 | | 502 | | Stripe refused the call, did not answer, or gave no prices to compare (`stripe_error`) | | 502 | `stripe_error` | 400 `unknown_plan`, `plan_not_for_org`, `same_plan`; 409 `no_plan` without a paid plan, `plan_ending` while the plan is cancelled (renew it on Stripe's billing page first); 502 `stripe_error`; 503 `not_configured` until Stripe and NEXUS_PLANS are set | | 503 | | Stripe or NEXUS_PLANS is not configured (`not_configured`) | | 503 | `not_configured` | 400 `unknown_plan`, `plan_not_for_org`, `same_plan`; 409 `no_plan` without a paid plan, `plan_ending` while the plan is cancelled (renew it on Stripe's billing page first); 502 `stripe_error`; 503 `not_configured` until Stripe and NEXUS_PLANS are set | ### Example ```sh curl -X POST "$NEXUS_URL/v1/billing/plan/change" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "plan": "3f9c0a1b2c3d4e5f", "interval": "month" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fbilling%2Fplan%2Fchange) ## Cancel plan change `DELETE /v1/billing/plan/change` Cancel the plan change pending for the period's end (owner only): Stripe releases the schedule and the plan stays as it is. 409 `no_pending_change` without one; 502 `stripe_error`; 503 `not_configured` until Stripe is set up. Permission: `org.billing` (Owner). ### 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). | ### Responses - `200` OK (application/json, object) - `plan` (BillingPlan | null, required) - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` No plan change pending (`no_pending_change`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Stripe refused the call or did not answer (`stripe_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | No plan change pending (`no_pending_change`) | | 409 | `no_pending_change` | 409 `no_pending_change` without one; 502 `stripe_error`; 503 `not_configured` until Stripe is set up | | 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 | | 502 | | Stripe refused the call or did not answer (`stripe_error`) | | 502 | `stripe_error` | 409 `no_pending_change` without one; 502 `stripe_error`; 503 `not_configured` until Stripe is set up | | 503 | | Stripe is not configured (`not_configured`) | | 503 | `not_configured` | 409 `no_pending_change` without one; 502 `stripe_error`; 503 `not_configured` until Stripe is set up | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/billing/plan/change" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fbilling%2Fplan%2Fchange) ## Start plan `POST /v1/billing/plan` Start a plan for the organization (owner only): a link to a Stripe Checkout page that starts the subscription. Stripe sends the person back to `<NEXUS_UI_URL>/<org>/billing?checkout=plan`, or `=plan_cancelled`. The plans are the ones in NEXUS_PLANS (Pro, Max's tiers, Team, Team Premium), billed monthly or yearly; a per-seat plan has one seat per member, at least its minimum (the seats follow the members), so `seats` may be left out and, when given, must be that number. The plan's included usage is granted once a month as a Nexus subsidy and does not roll over. A per-seat plan is for companies and any other plan for personal organizations (`GET /v1/billing/plans` lists an organization's). 400 `unknown_plan` for a plan or interval this Gateway does not sell; 400 `plan_not_for_org` for a plan of the other kind of organization; 409 `plan_active` while the organization has a live subscription: change it with `POST /v1/billing/plan/change`. 502 `stripe_error` when Stripe refuses or does not answer. 503 `not_configured` until Stripe and NEXUS_PLANS are set, or without NEXUS_UI_URL. Permission: `org.billing` (Owner). ### 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) - `plan` (string, required): A plan in NEXUS_PLANS, such as plus, pro, teams_plus or teams_pro - `interval` ("month" | "year", required) - `seats` (integer): Per-seat plans only (Teams Plus, Teams Pro); the plan's minimum when absent [min 1; max 1000] ### Responses - `200` OK (application/json, PaymentMethodSetup) - `url` (string, required): Stripe Checkout's page, where the person enters the card. - `expiresAt` (string (date-time), required): When Stripe stops accepting `url`. - `checkoutSessionId` (string): Exact Checkout session to confirm; returned by current Gateways. - `400` A bad plan, interval or seats (`unknown_plan`, `invalid_request`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` A live subscription already holds the plan (`plan_active`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Stripe refused the call or did not answer (`stripe_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe or NEXUS_PLANS is not configured, or NEXUS_UI_URL is not set (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A bad plan, interval or seats (`unknown_plan`, `invalid_request`) | | 400 | `unknown_plan` | 400 `unknown_plan` for a plan or interval this Gateway does not sell; 400 `plan_not_for_org` for a plan of the other kind of organization; 409 `plan_active` while the organization has a live subscription: change it with `POST /v1/billing/plan/change` | | 400 | `plan_not_for_org` | 400 `unknown_plan` for a plan or interval this Gateway does not sell; 400 `plan_not_for_org` for a plan of the other kind of organization; 409 `plan_active` while the organization has a live subscription: change it with `POST /v1/billing/plan/change` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | A live subscription already holds the plan (`plan_active`) | | 409 | `plan_active` | 400 `unknown_plan` for a plan or interval this Gateway does not sell; 400 `plan_not_for_org` for a plan of the other kind of organization; 409 `plan_active` while the organization has a live subscription: change it with `POST /v1/billing/plan/change` | | 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 | | 502 | | Stripe refused the call or did not answer (`stripe_error`) | | 502 | `stripe_error` | 502 `stripe_error` when Stripe refuses or does not answer | | 503 | | Stripe or NEXUS_PLANS is not configured, or NEXUS_UI_URL is not set (`not_configured`) | | 503 | `not_configured` | 503 `not_configured` until Stripe and NEXUS_PLANS are set, or without NEXUS_UI_URL | ### Example ```sh curl -X POST "$NEXUS_URL/v1/billing/plan" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "plan": "3f9c0a1b2c3d4e5f", "interval": "month" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fbilling%2Fplan) ## Set after the fact `PUT /v1/billing/after-the-fact` Turn paying after the fact on or off, or change its monthly usage limit (owner only; pricing v2.0). Body: `enabled`, and `limitUsd` as a decimal string in whole cents. Turning it on needs the payment method on file (409 `no_payment_method`), and so does turning it on again with no `limitUsd`; a call with `limitUsd` changes the limit of a setting already on without one. A closed organization cannot turn it on (409 `organization_closed`). Calls the free start and the credits cannot pay then go on the card, at provider price plus Nexus's rate, up to the limit in a UTC month (past it, 402 `usage_limit_reached`). Gateway's Stripe sweep charges the card off session each time the unpaid usage reaches `pricing.thresholdUsd` (less carries over, and what is left is charged once it is turned off); a charge that fails stops the calls the card pays (402 `payment_failed`) and tells the owners, until a charge goes through. A disputed payment (`charge.dispute.created`) stops its card the same way (`failed.reason`: `disputed`) until an owner adds another card, and that card never pays again (409 `card_disputed` on turning it on with that card, or on again with no `limitUsd`; a limit change still works). Off stops new calls on the card and still charges what is owed. Off with `limitUsd` keeps the limit, even when it was never on. Audited as `billing.after_the_fact_changed`. 400 `invalid_amount`; 503 `not_configured` until Stripe is set up. Permission: `org.billing` (Owner). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `enabled` (boolean, required) - `limitUsd` (string): The monthly usage limit, dollars in whole cents, from 1.00 to 100000.00 (at most 100.00 in a new organization's first 7 days). A new setting starts at `pricing.defaultLimitUsd`. ### Responses - `200` OK (application/json, SetAfterTheFact) - `afterTheFact` (AfterTheFact | null, required): The setting after; null after turning off what was never on with no `limitUsd`. - `400` `limitUsd` outside $1 to $100,000 ($100 in a new organization's first 7 days) or not in whole cents (`invalid_amount`); `enabled` missing (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` Turning on with no payment method on file (`no_payment_method`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `limitUsd` outside $1 to $100,000 ($100 in a new organization's first 7 days) or not in whole cents (`invalid_amount`); `enabled` missing | | 400 | `invalid_amount` | 400 `invalid_amount`; 503 `not_configured` until Stripe is set up | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `usage_limit_reached` | Calls the free start and the credits cannot pay then go on the card, at provider price plus Nexus's rate, up to the limit in a UTC month (past it, 402 `usage_limit_reached`) | | 402 | `payment_failed` | Gateway's Stripe sweep charges the card off session each time the unpaid usage reaches `pricing.thresholdUsd` (less carries over, and what is left is charged once it is turned off); a charge that fails stops the calls the card pays (402 `payment_failed`) and tells the owners, until a charge goes through | | 403 | `role_required` | Your role does not have this permission | | 409 | | Turning on with no payment method on file (`no_payment_method`) | | 409 | `no_payment_method` | Turning it on needs the payment method on file (409 `no_payment_method`), and so does turning it on again with no `limitUsd`; a call with `limitUsd` changes the limit of a setting already on without one | | 409 | `organization_closed` | A closed organization cannot turn it on (409 `organization_closed`) | | 409 | `card_disputed` | `disputed`) until an owner adds another card, and that card never pays again (409 `card_disputed` on turning it on with that card, or on again with no `limitUsd`; a limit change still works) | | 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 | | 503 | | Stripe is not configured (`not_configured`) | | 503 | `not_configured` | 400 `invalid_amount`; 503 `not_configured` until Stripe is set up | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/billing/after-the-fact" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "enabled": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fbilling%2Fafter-the-fact) ## List receipts `GET /v1/billing/receipts` The organization's receipts (owner only; pricing v2.0), newest first, at most 100: credit purchases (`credits`, `auto_topup`), charges for usage after the fact (`usage`) and invoiced months (`invoice`). Read from Gateway's own records, with no call to Stripe. 503 `not_configured` until Stripe is set up. Permission: `org.billing` (Owner). ### Responses - `200` OK (application/json, ReceiptList) - `receipts` (array of Receipt, required) - `id` (string, required): The payment (`pi_…`), or `month:<YYYY-MM>` for an invoiced month. - `at` (string (date-time), required) - `kind` ("credits" | "auto_topup" | "usage" | "invoice", required) - `description` (string, required): What it paid for, such as `Credits` or `Usage, threshold charge`. - `amountUsd` (string, required) - `status` ("paid" | "open" | "failed" | "void", required) - `url` (string | null, required): Stripe's page of an invoiced month; null for a payment. - `receipt` (boolean, required): Stripe has a receipt page for it: `GET /v1/billing/receipts/{id}` answers its link. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 100 | `credits` | He organization's receipts (owner only; pricing v2.0), newest first, at most 100: credit purchases (`credits`, `auto_topup`), charges for usage after the fact (`usage`) and invoiced months (`invoice`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Stripe is not configured (`not_configured`) | | 503 | `not_configured` | 503 `not_configured` until Stripe is set up | ### Example ```sh curl "$NEXUS_URL/v1/billing/receipts" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbilling%2Freceipts) ## Get receipt `GET /v1/billing/receipts/{paymentId}` Stripe's receipt page of one of the organization's payments (owner only; pricing v2.0): a credit purchase or a charge for usage after the fact, by its `pi_…` id. 404 `not_found` for a payment that is not the organization's; 409 `no_receipt` while Stripe has none; 502 `stripe_error`; 503 `not_configured` until Stripe is set up. Permission: `org.billing` (Owner). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `paymentId` | path | string | yes | The payment's id (`pi_…`); any other id is no receipt (404). | ### Responses - `200` OK (application/json, ReceiptLink) - `url` (string, required): Stripe's receipt page of the payment. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not one of the organization's payments (`not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` Stripe has no receipt for the payment yet (`no_receipt`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not one of the organization's payments (`not_found`) | | 409 | | Stripe has no receipt for the payment yet (`no_receipt`) | | 409 | `no_receipt` | 404 `not_found` for a payment that is not the organization's; 409 `no_receipt` while Stripe has none; 502 `stripe_error`; 503 `not_configured` until Stripe is set up | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | `stripe_error` | 404 `not_found` for a payment that is not the organization's; 409 `no_receipt` while Stripe has none; 502 `stripe_error`; 503 `not_configured` until Stripe is set up | | 503 | | Stripe is not configured (`not_configured`) | | 503 | `not_configured` | 404 `not_found` for a payment that is not the organization's; 409 `no_receipt` while Stripe has none; 502 `stripe_error`; 503 `not_configured` until Stripe is set up | ### Example ```sh curl "$NEXUS_URL/v1/billing/receipts/<paymentId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbilling%2Freceipts%2F%7BpaymentId%7D) ## Billing operation `GET /v1/billing/operations/{operationId}` Confirm one billing operation Permission: `org.billing` (Owner). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `operationId` | path | string | yes | | ### Responses - `200` OK (application/json, BillingOperation) - `kind` ("card" | "credits", required) - `status` ("pending" | "complete" | "expired" | "failed" | "superseded", required): `superseded`: a newer card setup set its card first, so this one ended without setting the default. - `403` Not the owner (`permission_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not one of the organization's payments (`not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Stripe is not configured (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not one of the organization's payments (`not_found`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Stripe is not configured (`not_configured`) | ### Example ```sh curl "$NEXUS_URL/v1/billing/operations/<operationId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbilling%2Foperations%2F%7BoperationId%7D) --- <!-- /docs/api/teams --> # Teams > Teams, the levels between the organization and the person, kept in Gateway (the sign-in provider has no teams). Teams nest: a team may have a parent team (no cycles, at most 10 levels) and a `level`, a free-text label each organization chooses. Someone added by an email not in the organization yet is a pending member until they join it. An organization can load its whole tree from a file (`POST /v1/teams/import`). Owners and admins create, rename and delete teams and manage their members; every member reads them and sets their own default team. Spend is attributed to the team named with `x-nexus-team` (or a `team` field), else the caller's default team. Team caps and person budgets are built: see Budgets. Team model policies are built: see Models. ## List teams `GET /v1/teams` The organization's teams, with member counts, your role in each and your default team (every member). With `tree=1`: the teams nested under their parents, with leads and headcount. The list (not the tree) pages with `limit` and `cursor`. Permission: `teams.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `tree` | query | "1" | no | 1: return `tree` (nested) instead of `teams` | | `depth` | query | integer | no | With tree=1: how many levels to return | | `limit` | query | integer | no | Items per page, 1 to 500 (default 100). Without limit or cursor the answer holds the whole list. | | `cursor` | query | string | no | NextCursor from the previous page. A cursor whose item left the list answers 400 `invalid_cursor`. | ### Responses - `200` OK (application/json, object) - `teams` (array of Team) - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `description` (string) - `createdAt` (string (date-time), required) - `members` (integer, required) - `myRole` ("lead" | "member"): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `isDefault` (boolean) - `parentId` (string): The parent team's id; absent for a top-level team. - `parent` (string): The parent team's slug. - `level` (string): The organization's own label for the team's level (e.g. department). - `depth` (integer, required): 1 for a top-level team. - `pending` (integer, required): People added by email who have not joined the organization yet. - `childCount` (integer, required) - `default` (string | null) - `tree` (array of TeamNode): With tree=1: the top-level teams. - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `description` (string) - `createdAt` (string (date-time), required) - `members` (integer, required) - `myRole` ("lead" | "member"): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `isDefault` (boolean) - `parentId` (string): The parent team's id; absent for a top-level team. - `parent` (string): The parent team's slug. - `level` (string): The organization's own label for the team's level (e.g. department). - `depth` (integer, required): 1 for a top-level team. - `pending` (integer, required): People added by email who have not joined the organization yet. - `leads` (array of object) - `userId` (string) - `email` (string) - `name` (string) - `pending` (boolean) - `headcount` (integer): Distinct people in the team and every team under it, pending ones included. - `children` (array of TeamNode) (same shape as TeamNode) - `nextCursor` (string): The next page's cursor, while more items follow. Only when limit or cursor was sent. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/teams" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.teamTree(2); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fteams) ## Create team `POST /v1/teams` Create a team (owners and admins), optionally under a parent team and with a level label. The slug is unique in the organization and follows the org slug rule (`pending` and `import` are reserved). An organization holds at most 2,000 teams: the next is refused with 409 `team_limit`. Permission: `teams.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `slug` (string, required) - `name` (string) - `description` (string) - `parent` (string | null): The parent team's slug or id; absent or null for a top-level team. - `level` (string): A short label of the organization's choosing: 1 to 32 lower-case letters, digits or dashes. ### Responses - `201` Created (application/json, TeamDetail) - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `description` (string) - `createdAt` (string (date-time), required) - `members` (integer, required) - `myRole` ("lead" | "member"): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `isDefault` (boolean) - `parentId` (string): The parent team's id; absent for a top-level team. - `parent` (string): The parent team's slug. - `level` (string): The organization's own label for the team's level (e.g. department). - `depth` (integer, required): 1 for a top-level team. - `pending` (integer, required): People added by email who have not joined the organization yet. - `childCount` (integer, required) - `memberList` (array of TeamMember) - `userId` (string, required) - `email` (string) - `name` (string) - `role` ("lead" | "member", required): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `isDefault` (boolean, required) - `joinedAt` (string (date-time), required) - `pendingList` (array of PendingMember) - `id` (string, required) - `teamId` (string, required) - `team` (string, required): The team's slug. - `email` (string, required) - `role` ("lead" | "member", required): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `home` (boolean, required): Becomes their default team when they join. - `addedBy` (string) - `createdAt` (string (date-time), required) - `path` (array of TeamLink): The team's ancestors, top level first; the last is its parent. - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `level` (string) - `children` (array of TeamLink & object) - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `level` (string) - `members` (integer) - `pending` (integer) - `childCount` (integer) - `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 | `team_limit` | The next is refused with 409 `team_limit` | | 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/teams" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "slug": "web", "name": "Web", "parent": "engineering", "level": "department" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.createTeam({ slug: "platform", name: "Platform", parent: "engineering", level: "team" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fteams) ## List pending team members `GET /v1/teams/pending` Pending team members: people added by an email not in the organization yet (owners and admins). With `by=person`, one row per email with all their teams and their home team, and whether Gateway can invite them. Permission: `teams.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `team` | query | string | no | Only this team (slug) | | `by` | query | "entry" \| "person" | no | `person`: group by email (`people`); default: one row per pending membership (`pending`) | ### Responses - `200` OK (application/json, object | object) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/teams/pending" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.pendingPeople(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fteams%2Fpending) ## Cancel pending team members `DELETE /v1/teams/pending` Cancel pending team members (owners and admins): one by `id`, or every one for an `email` (optionally in one `team`). Permission: `teams.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | query | string | no | | | `email` | query | string | no | | | `team` | query | string | no | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `cancelled` (array of PendingMember) - `id` (string, required) - `teamId` (string, required) - `team` (string, required): The team's slug. - `email` (string, required) - `role` ("lead" | "member", required): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `home` (boolean, required): Becomes their default team when they join. - `addedBy` (string) - `createdAt` (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 | | 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/teams/pending" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.cancelPendingTeamMembers({ email: "new-hire@example.com" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fteams%2Fpending) ## Import teams `POST /v1/teams/import` Load the organization's teams from a file, in one transaction (owners and admins). Teams are matched by slug: missing ones are created, existing ones moved, renamed and relabelled; leads and members are set by email (pending for emails not in the organization yet) and `home` sets default teams. Idempotent: the same file twice changes nothing the second time. `dryRun` returns the same diff and changes nothing; `prune` also removes what the file does not list (never spend). A dry run returns a `plan` (a hash of the diff): apply with `plan` set to it and Gateway refuses (409 `plan_changed`) if the organization changed since, so exactly the reviewed changes apply. An import that would leave more than 2,000 teams in the organization, and adds any, is refused with 409 `team_limit`. Permission: `teams.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `units` (array of object, required) - `slug` (string, required) - `name` (string) - `level` (string | null) - `parent` (string | null): The parent team's slug; absent or null for a top-level team. - `description` (string | null) - `leads` (array of string (email) | object) - `members` (array of string (email) | object) - `dryRun` (boolean): Report the diff and change nothing. - `prune` (boolean): Also remove memberships and pending entries the file does not list from its teams, and delete teams it does not list (their spend stays). - `plan` (string): A dry run's plan: apply only if the result is still exactly that (else 409 plan_changed). [pattern ^[0-9a-f]{16}$] ### Responses - `200` OK (application/json, TeamImportDiff) - `dryRun` (boolean, required) - `prune` (boolean, required) - `created` (array of string, required) - `moved` (array of object, required) - `slug` (string) - `from` (string) - `to` (string) - `renamed` (array of object, required) - `slug` (string) - `from` (string) - `to` (string) - `relevelled` (array of object, required) - `slug` (string) - `from` (string) - `to` (string) - `membershipsAdded` (array of object, required) - `team` (string) - `email` (string) - `role` (string) - `rolesChanged` (array of object, required) - `team` (string) - `email` (string) - `from` (string) - `to` (string) - `membershipsRemoved` (array of object, required) - `team` (string) - `email` (string) - `role` (string) - `pending` (array of object, required) - `team` (string) - `email` (string) - `role` (string) - `pendingRemoved` (array of object, required) - `team` (string) - `email` (string) - `defaults` (array of object, required) - `email` (string) - `team` (string) - `pending` (boolean) - `deleted` (array of string, required) - `warnings` (array of string, required) - `totals` (object, required) - `teams` (integer) - `memberships` (integer) - `pending` (integer) - `plan` (string, required): A short hash of this diff; pass it back as plan to apply exactly what a dry run showed. - `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 | `plan_changed` | Apply with `plan` set to it and Gateway refuses (409 `plan_changed`) if the organization changed since, so exactly the reviewed changes apply | | 409 | `team_limit` | An import that would leave more than 2,000 teams in the organization, and adds any, is refused with 409 `team_limit` | | 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/teams/import" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "units": [ { "slug": "engineering", "level": "department", "leads": [ { "email": "lead@example.com" } ] }, { "slug": "platform", "parent": "engineering", "level": "team", "members": [ { "email": "dev@example.com", "home": true } ] } ], "dryRun": true }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.importTeams({ units: [{ slug: "platform", parent: "engineering", members: ["ada@example.com"] }], dryRun: true }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fteams%2Fimport) ## Get team `GET /v1/teams/{slug}` A team, its members, pending members, path (ancestors) and child teams (every member). Permission: `teams.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | ### Responses - `200` OK (application/json, TeamDetail) - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `description` (string) - `createdAt` (string (date-time), required) - `members` (integer, required) - `myRole` ("lead" | "member"): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `isDefault` (boolean) - `parentId` (string): The parent team's id; absent for a top-level team. - `parent` (string): The parent team's slug. - `level` (string): The organization's own label for the team's level (e.g. department). - `depth` (integer, required): 1 for a top-level team. - `pending` (integer, required): People added by email who have not joined the organization yet. - `childCount` (integer, required) - `memberList` (array of TeamMember) - `userId` (string, required) - `email` (string) - `name` (string) - `role` ("lead" | "member", required): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `isDefault` (boolean, required) - `joinedAt` (string (date-time), required) - `pendingList` (array of PendingMember) - `id` (string, required) - `teamId` (string, required) - `team` (string, required): The team's slug. - `email` (string, required) - `role` ("lead" | "member", required): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `home` (boolean, required): Becomes their default team when they join. - `addedBy` (string) - `createdAt` (string (date-time), required) - `path` (array of TeamLink): The team's ancestors, top level first; the last is its parent. - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `level` (string) - `children` (array of TeamLink & object) - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `level` (string) - `members` (integer) - `pending` (integer) - `childCount` (integer) - `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/teams/platform" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.team("platform"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fteams%2F%7Bslug%7D) ## Update team `PATCH /v1/teams/{slug}` Change a team (owners and admins): its slug, name, description or level, or move it under another parent (`parent: null` makes it top-level; no cycles, at most 10 levels). Past spend keeps the slug it had; a moved team keeps its history and rollups follow the current tree. Permission: `teams.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `slug` (string) - `name` (string) - `description` (string | null) - `parent` (string | null): The new parent's slug or id, or null for the top level. - `level` (string | null): The level label; null clears it. ### Responses - `200` OK (application/json, TeamDetail) - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `description` (string) - `createdAt` (string (date-time), required) - `members` (integer, required) - `myRole` ("lead" | "member"): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `isDefault` (boolean) - `parentId` (string): The parent team's id; absent for a top-level team. - `parent` (string): The parent team's slug. - `level` (string): The organization's own label for the team's level (e.g. department). - `depth` (integer, required): 1 for a top-level team. - `pending` (integer, required): People added by email who have not joined the organization yet. - `childCount` (integer, required) - `memberList` (array of TeamMember) - `userId` (string, required) - `email` (string) - `name` (string) - `role` ("lead" | "member", required): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `isDefault` (boolean, required) - `joinedAt` (string (date-time), required) - `pendingList` (array of PendingMember) - `id` (string, required) - `teamId` (string, required) - `team` (string, required): The team's slug. - `email` (string, required) - `role` ("lead" | "member", required): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `home` (boolean, required): Becomes their default team when they join. - `addedBy` (string) - `createdAt` (string (date-time), required) - `path` (array of TeamLink): The team's ancestors, top level first; the last is its parent. - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `level` (string) - `children` (array of TeamLink & object) - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `level` (string) - `members` (integer) - `pending` (integer) - `childCount` (integer) - `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/teams/platform" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "parent": "engineering", "level": "team" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.updateTeam("platform", { parent: "engineering", level: "team" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Fteams%2F%7Bslug%7D) ## Delete team `DELETE /v1/teams/{slug}` Delete a team and its memberships (owners and admins). A team with child teams is refused (409 `has_children`) unless `cascade=1`, which deletes the whole subtree. Spend attributed to any of them keeps the team's id and slug. Permission: `teams.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | | `cascade` | query | "1" | no | 1: also delete every team under it | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `deleted` (boolean) - `id` (string) - `slug` (string) - `teams` (array of string): Every team deleted (slugs). - `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 | `has_children` | A team with child teams is refused (409 `has_children`) unless `cascade=1`, which deletes the whole subtree | | 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/teams/platform" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.deleteTeam("platform"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fteams%2F%7Bslug%7D) ## Add team member `POST /v1/teams/{slug}/members` Add someone to a team, by userId or email (owners and admins). An email of someone not in the organization yet is kept as a pending membership (202) until they join it. The first team someone joins becomes their default, unless `home` makes this one it. Permission: `teams.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `userId` (string) - `email` (string) - `role` ("lead" | "member"): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `home` (boolean): Make this their default (home) team; for a pending member, when they join. ### Responses - `201` Created (application/json, object) - `team` (string) - `member` (TeamMember) - `userId` (string, required) - `email` (string) - `name` (string) - `role` ("lead" | "member", required): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `isDefault` (boolean, required) - `joinedAt` (string (date-time), required) - `pending` (false) - `202` Pending: not in the organization yet (application/json, object) - `pending` (true) - `team` (string) - `entry` (PendingMember): Someone added to a team by an email not in the organization yet; they join the team when they join the organization. - `id` (string, required) - `teamId` (string, required) - `team` (string, required): The team's slug. - `email` (string, required) - `role` ("lead" | "member", required): `lead` is reserved for the planned team-lead role and grants nothing extra yet. - `home` (boolean, required): Becomes their default team when they join. - `addedBy` (string) - `createdAt` (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 POST "$NEXUS_URL/v1/teams/platform/members" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "email": "ada@example.com", "role": "member", "home": true }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.addTeamMember("platform", { email: "ada@example.com", role: "member", home: true }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fteams%2F%7Bslug%7D%2Fmembers) ## Remove team member `DELETE /v1/teams/{slug}/members/{userId}` Take someone out of a team (owners and admins). If it was their default, another of their teams becomes it. Permission: `teams.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | | `userId` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `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/teams/platform/members/user_123" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.removeTeamMember("platform", "<user id>"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fteams%2F%7Bslug%7D%2Fmembers%2F%7BuserId%7D) ## Set default team `PUT /v1/people/{userId}/default-team` Set a default team: your own (`me`), among the teams you are in; anyone's for owners and admins. `{"team": null}` clears it. Permission: `teams.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `userId` | path | string | yes | A user id, or `me` | | `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) - `team` (string | null, required) ### Responses - `200` OK (application/json, object) - `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/people/user_123/default-team" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "team": "web" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.setDefaultTeam("platform"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpeople%2F%7BuserId%7D%2Fdefault-team) ## Get team budget `GET /v1/teams/{slug}/budget` A team's cap, as the caller may see it. An owner or admin gets the cap on that team and nothing from the teams above it (`scope: cap`): its limit, period, mode, spent, reserved, what is left and when it resets. A member of the team gets only what is left for them along the team's path, with the period and reset of the cap that binds (`scope: own`); the limit, spent and reserved of a team above theirs are never shown. `budget` is null when no cap applies. 404 `unknown_team`; 403 `not_in_team` for a member who is not in the team. Permission: `teams.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | ### Responses - `200` OK (application/json, TeamBudget) - `team` (object, required) - `slug` (string, required) - `name` (string, required) - `scope` ("cap" | "own", required): `cap`: an owner or admin reads the cap on this team. `own`: a member reads what is left for them. - `budget` (object | null, required): The cap on this team (`cap`), or the cap that binds along the team's path (`own`); null when none applies - `remainingUsd` (number, required): What is left for the period, never below 0. Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `period` ("day" | "week" | "month", required): How often the cap resets - `resetsAt` (string (date-time), required) - `limitUsd` (number): Owners and admins only (`scope: cap`). Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `mode` ("hard_stop"): Owners and admins only - `spentUsd` (number): Owners and admins only: settled this period, in the team and the teams under it. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number): Owners and admins only: held by calls in progress. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `updatedAt` (string (date-time)): Owners and admins only - `canManage` (boolean, required): Whether the caller may set the cap (owners and admins) - `403` A member who is not in the team (`not_in_team`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such team (`unknown_team`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `not_in_team` | 404 `unknown_team`; 403 `not_in_team` for a member who is not in the team | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such team (`unknown_team`) | | 404 | `unknown_team` | 404 `unknown_team`; 403 `not_in_team` for a member who is not in the team | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/teams/platform/budget" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.teamBudget("platform"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fteams%2F%7Bslug%7D%2Fbudget) ## Set team budget `PUT /v1/teams/{slug}/budget` Set a team's cap (owners and admins): an amount in US dollars per day, week or month, counted for the team and every team under it, and a stop mode. `hard_stop` refuses the call; `warn` and `approval` answer 400 `mode_not_available` until they are built. Cutting a cap below what the team used refuses the next call and leaves calls in progress alone. Audited as budget.team_changed, before and after. With `dryRun: true` it checks and answers the same, and changes nothing. The amount is `amountUsd` (a number, deprecated, or a decimal string) or `amountUsdDecimal`, read exactly. 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch`, `invalid_period`, `invalid_mode`; 404 `unknown_team`. Permission: `budgets.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `amountUsd` (number | string): The cap for the period; 0 refuses every call. The cap for the period in US dollars: a JSON number (deprecated) or a decimal string with at most 6 decimals (`"12.245"`), read exactly. Send `amountUsdDecimal` instead to send only a string. [min 0; max 1000000] - `amountUsdDecimal` (string): The cap for the period as a decimal string in US dollars, at most 6 decimals, never below 0; read exactly into micro-dollars, never through a float. With `amountUsd` too, both must name the same amount (400 `amount_mismatch`). [pattern ^[0-9]+(\.[0-9]{1,6})?$] - `period` ("day" | "week" | "month", required): UTC calendar day, ISO week (from Monday) or month - `mode` ("hard_stop" | "warn" | "approval"): Only `hard_stop` is available; the others answer 400 `mode_not_available` [default "hard_stop"] - `warnAtPercent` (number): For mode `warn`, which is not available yet - `dryRun` (boolean): Check the cap and answer what would change; change nothing ### Responses - `200` OK (application/json, TeamBudgetChange) - `dryRun` (boolean, required) - `team` (object, required) - `slug` (string, required) - `name` (string, required) - `before` (object | null, required) - `limitUsd` (number, required): Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `period` ("day" | "week" | "month", required) - `mode` ("hard_stop", required) - `after` (object, required) - `limitUsd` (number, required): Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `period` ("day" | "week" | "month", required) - `mode` ("hard_stop", required) - `400` Not a valid cap (`invalid_amount`, `too_many_decimals`, `amount_mismatch`, `invalid_period`, `invalid_mode`, `mode_not_available`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Only owners and admins set a cap (`role_required`): a member without `budgets.manage` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such team (`unknown_team`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a valid cap (`invalid_amount`, `too_many_decimals`, `amount_mismatch`, `invalid_period`, `invalid_mode`, `mode_not_available`) | | 400 | `mode_not_available` | `hard_stop` refuses the call; `warn` and `approval` answer 400 `mode_not_available` until they are built | | 400 | `invalid_amount` | 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch`, `invalid_period`, `invalid_mode`; 404 `unknown_team` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such team (`unknown_team`) | | 404 | `unknown_team` | 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch`, `invalid_period`, `invalid_mode`; 404 `unknown_team` | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/teams/platform/budget" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fteams%2F%7Bslug%7D%2Fbudget) --- <!-- /docs/api/budgets --> # Spend limits > Spend limits per person and calendar month (UTC), checked with the organization's balance when every call reserves (chat completions, the agent gateway, module runs, chat sessions). The organization sets a default limit per person and overrides per person, both stored at the organization; no default means no person limit. Owners and admins also cap a team per UTC day, week or month (`PUT /v1/teams/{slug}/budget`): the cap is a pool for the team and every team under it. A call that would go over a person limit, a team cap or the organization's budget is refused with 402 `budget_exceeded`, naming the level, and counted as an overspend prevented. The 402 says what is left for the caller; only a person's 402 also names its limit. Person limits reset on the 1st at 00:00 UTC. ## Get person budget `GET /v1/people/{userId}/budget` One person's spend limit this month: their limit and where it comes from (override, default or none), month-to-date spend, what is left and whether they are at it. Yours (`me`) for anyone; anyone's for owners and admins. Permission: `spend.read_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `userId` | path | string | yes | A user id, or `me` | ### Responses - `200` OK (application/json, PersonBudget) - `userId` (string, required) - `email` (string) - `name` (string) - `role` ("owner" | "admin" | "member", required) - `limitManager` (boolean): An admin an owner allowed to set person spend limits - `limitUsd` (number | null, required): Their limit this month; null: no limit of their own. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string | null): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `source` ("override" | "default" | "none", required): Override: set for them; default: the organization's default per person; none: no limit - `overrideUsd` (number | null, required): Their override, when they have one. Deprecated: read `overrideUsdDecimal`, the exact decimal string (root rule 9). - `overrideUsdDecimal` (string | null): `overrideUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `overrideUsd`. - `spentUsd` (number, required): Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number, required): Held by their calls in flight. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `remainingUsd` (number | null, required): Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string | null): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `atLimit` (boolean, required): Spent and reserved reach the limit: their next call is refused - `overspendsPrevented` (integer, required): Calls a spend limit refused this month - `403` A member asking for another person's limit (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No member with this user id in the organization (`not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No member with this user id in the organization (`not_found`) | | 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/people/user_123/budget" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.personBudget(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpeople%2F%7BuserId%7D%2Fbudget) ## Set person budget `PUT /v1/people/{userId}/budget` Set one person's monthly limit in USD, above or below the organization's default (owners, and admins an owner allowed: `grantLimitManager`; an owner's limit: owners only), or null to remove the override so the default applies again. Stored at the organization, naming the person; audited as budget.person_limit_changed, before and after. 403 `limit_grant_required` for an admin without the grant, and `role_required` for an owner's limit set by an allowed admin (both gateways). The amount is `monthlyUsd` (a number, deprecated, or a decimal string) or `monthlyUsdDecimal`, read exactly. 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch`. Permission: `budgets.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `userId` | path | string | yes | A user id, or `me` | | `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) - `monthlyUsd` (number | string | null): This person's monthly limit, in US dollars, at most 1000000: a JSON number (deprecated) or a decimal string with at most 6 decimals (`"12.245"`), read exactly; null removes the override. Send `monthlyUsdDecimal` instead to send only a string. - `monthlyUsdDecimal` (string | null): This person's monthly limit as a decimal string in US dollars, at most 6 decimals, never below 0; read exactly into micro-dollars, never through a float. null removes the override. With `monthlyUsd` too, both must name the same amount (400 `amount_mismatch`). [pattern ^[0-9]+(\.[0-9]{1,6})?$] ### Responses - `200` OK (application/json, PersonBudget) - `userId` (string, required) - `email` (string) - `name` (string) - `role` ("owner" | "admin" | "member", required) - `limitManager` (boolean): An admin an owner allowed to set person spend limits - `limitUsd` (number | null, required): Their limit this month; null: no limit of their own. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string | null): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `source` ("override" | "default" | "none", required): Override: set for them; default: the organization's default per person; none: no limit - `overrideUsd` (number | null, required): Their override, when they have one. Deprecated: read `overrideUsdDecimal`, the exact decimal string (root rule 9). - `overrideUsdDecimal` (string | null): `overrideUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `overrideUsd`. - `spentUsd` (number, required): Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number, required): Held by their calls in flight. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `remainingUsd` (number | null, required): Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string | null): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `atLimit` (boolean, required): Spent and reserved reach the limit: their next call is refused - `overspendsPrevented` (integer, required): Calls a spend limit refused this month - `400` `monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` A member (`role_required`), an admin an owner has not allowed (`limit_grant_required`), or an allowed admin setting an owner's limit (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No member with this user id in the organization (`not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`) | | 400 | `invalid_amount` | 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `limit_grant_required` | 403 `limit_grant_required` for an admin without the grant, and `role_required` for an owner's limit set by an allowed admin (both gateways) | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No member with this user id in the organization (`not_found`) | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/people/user_123/budget" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.setPersonBudget("<user id>", 200); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpeople%2F%7BuserId%7D%2Fbudget) ## List budgets `GET /v1/budgets` Spend limits this month: the organization's default per person and, for owners and admins, every person's limit (override or default), month-to-date spend, what is left, whether they are at their limit and the overspends prevented. Members see only their own row. `canManage`: you may set a person's limit (an owner, or an admin an owner allowed); `canGrant`: you may set the default per person and allow admins to set person limits (owners). Permission: `spend.read_own` (Every member). ### Responses - `200` OK (application/json, Budgets) - `period` (string, required): The calendar month (UTC) - `periodStart` (string (date-time), required) - `resetsAt` (string (date-time), required): The 1st of next month, 00:00 UTC - `personDefault` (object, required) - `monthlyUsd` (number | null, required): Deprecated: read `monthlyUsdDecimal`, the exact decimal string (root rule 9). - `monthlyUsdDecimal` (string | null): `monthlyUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `monthlyUsd`. - `updatedAt` (string (date-time)) - `updatedBy` (string) - `scope` ("org" | "own", required): Org: everyone (owners and admins); own: only you - `people` (array of PersonBudget, required) - `userId` (string, required) - `email` (string) - `name` (string) - `role` ("owner" | "admin" | "member", required) - `limitManager` (boolean): An admin an owner allowed to set person spend limits - `limitUsd` (number | null, required): Their limit this month; null: no limit of their own. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string | null): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `source` ("override" | "default" | "none", required): Override: set for them; default: the organization's default per person; none: no limit - `overrideUsd` (number | null, required): Their override, when they have one. Deprecated: read `overrideUsdDecimal`, the exact decimal string (root rule 9). - `overrideUsdDecimal` (string | null): `overrideUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `overrideUsd`. - `spentUsd` (number, required): Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number, required): Held by their calls in flight. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `remainingUsd` (number | null, required): Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string | null): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `atLimit` (boolean, required): Spent and reserved reach the limit: their next call is refused - `overspendsPrevented` (integer, required): Calls a spend limit refused this month - `canManage` (boolean, required): You may set a person's limit: an owner, or an admin an owner allowed (both gateways) - `canGrant` (boolean): You may set the default per person and allow admins to set person limits: owners - `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/budgets" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.budgets(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbudgets) ## Set person default budget `PUT /v1/budgets/person-default` Set the organization's default monthly limit per person in USD (owners only), or null to clear it: then people without an override have no limit of their own. Audited as budget.person_default_changed, before and after. 403 `role_required` for an admin an owner allowed (only an owner changes the default per person), and `limit_grant_required` for an admin without the grant (both gateways). The amount is `monthlyUsd` (a number, deprecated, or a decimal string) or `monthlyUsdDecimal`, read exactly. 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch`. Permission: `budgets.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `monthlyUsd` (number | string | null): The default monthly limit per person, in US dollars, at most 1000000: a JSON number (deprecated) or a decimal string with at most 6 decimals (`"12.245"`), read exactly; null clears it. Send `monthlyUsdDecimal` instead to send only a string. - `monthlyUsdDecimal` (string | null): The default monthly limit per person as a decimal string in US dollars, at most 6 decimals, never below 0; read exactly into micro-dollars, never through a float. null clears it. With `monthlyUsd` too, both must name the same amount (400 `amount_mismatch`). [pattern ^[0-9]+(\.[0-9]{1,6})?$] ### Responses - `200` OK (application/json, Budgets) - `period` (string, required): The calendar month (UTC) - `periodStart` (string (date-time), required) - `resetsAt` (string (date-time), required): The 1st of next month, 00:00 UTC - `personDefault` (object, required) - `monthlyUsd` (number | null, required): Deprecated: read `monthlyUsdDecimal`, the exact decimal string (root rule 9). - `monthlyUsdDecimal` (string | null): `monthlyUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `monthlyUsd`. - `updatedAt` (string (date-time)) - `updatedBy` (string) - `scope` ("org" | "own", required): Org: everyone (owners and admins); own: only you - `people` (array of PersonBudget, required) - `userId` (string, required) - `email` (string) - `name` (string) - `role` ("owner" | "admin" | "member", required) - `limitManager` (boolean): An admin an owner allowed to set person spend limits - `limitUsd` (number | null, required): Their limit this month; null: no limit of their own. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9). - `limitUsdDecimal` (string | null): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`. - `source` ("override" | "default" | "none", required): Override: set for them; default: the organization's default per person; none: no limit - `overrideUsd` (number | null, required): Their override, when they have one. Deprecated: read `overrideUsdDecimal`, the exact decimal string (root rule 9). - `overrideUsdDecimal` (string | null): `overrideUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `overrideUsd`. - `spentUsd` (number, required): Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. - `reservedUsd` (number, required): Held by their calls in flight. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9). - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`. - `remainingUsd` (number | null, required): Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9). - `remainingUsdDecimal` (string | null): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`. - `atLimit` (boolean, required): Spent and reserved reach the limit: their next call is refused - `overspendsPrevented` (integer, required): Calls a spend limit refused this month - `canManage` (boolean, required): You may set a person's limit: an owner, or an admin an owner allowed (both gateways) - `canGrant` (boolean): You may set the default per person and allow admins to set person limits: owners - `400` `monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` A member (`role_required`), an admin an owner has not allowed (`limit_grant_required`), or an allowed admin (`role_required`: only an owner changes the default per person) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`) | | 400 | `invalid_amount` | 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch` | | 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 PUT "$NEXUS_URL/v1/budgets/person-default" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.setPersonDefaultBudget(50); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fbudgets%2Fperson-default) ## Get product budget `GET /v1/budgets/products/{product}/{capability}` The monthly cap on one module capability, such as Nexus Review's `robustness` / `review` (owners and admins): its limit, the UTC month's spend of every call attributed to it (whoever paid the provider), what open calls hold, what is left and when it resets. Every amount is a decimal string. `cap` is null when the capability has none. 400 `invalid_product`. Permission: `spend.read_all` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `product` | path | string | yes | The module's product, as its calls are attributed (`robustness` for Nexus Review). | | `capability` | path | string | yes | The capability within it (`review`). | ### Responses - `200` OK (application/json, ProductBudget) - `product` (string, required) - `capability` (string, required) - `cap` (object | null, required) - `limitUsd` (string, required): The budget's amount for its period. [pattern ^[0-9]+\.[0-9]{6}$] - `every` ("day" | "week" | "month", required): The budget's period, in UTC: a day, an ISO week from Monday, or a calendar month. - `monthlyUsd` (string, required): The budget's amount whatever its period; read `limitUsd` and `every` instead. [pattern ^[0-9]+\.[0-9]{6}$] - `period` (string, required): The period: `YYYY-MM-DD` for a day, `YYYY-Www` for a week, `YYYY-MM` for a month. - `spentUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$] - `feesUsd` (string, required): The product's own fees this month (`POST /v1/budgets/usage`), part of `spentUsd`. [pattern ^[0-9]+\.[0-9]{6}$] - `reservedUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$] - `remainingUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$] - `resetsAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `canManage` (boolean, required) - `400` Not a product or capability slug (`invalid_product`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Only owners and admins read a product's cap (`role_required`): a member without `spend.read_all` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | Not a product or capability slug (`invalid_product`) | | 400 | `invalid_product` | 400 `invalid_product` | | 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/budgets/products/<product>/<capability>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbudgets%2Fproducts%2F%7Bproduct%7D%2F%7Bcapability%7D) ## Set product budget `PUT /v1/budgets/products/{product}/{capability}` Set or remove the monthly cap on one module capability (owners and admins). `monthlyUsd` is a decimal string in US dollars, or null to remove the cap. The ledger refuses a call that would take the capability's UTC month past it with 402 `budget_exceeded`, `details.level: product`; a cap cut below what the month used refuses the next call and leaves calls in progress alone. Audited as budget.product_changed, before and after. 400 `invalid_amount`, `too_many_decimals`, `invalid_product`. Permission: `budgets.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `product` | path | string | yes | The module's product, as its calls are attributed (`robustness` for Nexus Review). | | `capability` | path | string | yes | The capability within it (`review`). | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `limitUsd` (string | null) [pattern ^[0-9]+(\.[0-9]{1,6})?$] - `every` ("day" | "week" | "month"): Required with `limitUsd`. - `monthlyUsd` (string | null): A monthly budget. Not with `limitUsd`. [pattern ^[0-9]+(\.[0-9]{1,6})?$] ### Responses - `200` OK (application/json, ProductBudgetChange) - `product` (string, required) - `capability` (string, required) - `before` (object, required) - `limitUsd` (string | null, required) [pattern ^[0-9]+\.[0-9]{6}$] - `every` ("day" | "week" | "month" | null, required) - `monthlyUsd` (string | null, required) [pattern ^[0-9]+\.[0-9]{6}$] - `after` (object, required) - `limitUsd` (string | null, required) [pattern ^[0-9]+\.[0-9]{6}$] - `every` ("day" | "week" | "month" | null, required) - `monthlyUsd` (string | null, required) [pattern ^[0-9]+\.[0-9]{6}$] - `400` Not a valid cap (`invalid_amount`), a decimal string with more than 6 decimals (`too_many_decimals`), or not a slug (`invalid_product`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Members: only owners and admins set a cap (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a valid cap (`invalid_amount`), a decimal string with more than 6 decimals (`too_many_decimals`), or not a slug (`invalid_product`) | | 400 | `invalid_amount` | 400 `invalid_amount`, `too_many_decimals`, `invalid_product` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The ledger refuses a call that would take the capability's UTC month past it with 402 `budget_exceeded`, `details.level: product`; a cap cut below what the month used refuses the next call and leaves calls in progress alone | | 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/budgets/products/<product>/<capability>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "limitUsd": "<limitUsd>", "every": "day", "monthlyUsd": "<monthlyUsd>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fbudgets%2Fproducts%2F%7Bproduct%7D%2F%7Bcapability%7D) ## Get product usage `GET /v1/budgets/usage` A module's product cap this UTC month and the price of each unit it records (a module's scoped key only). The product and capability are the key's. `cap` is null without a cap, else as `GET /v1/budgets/products/{product}/{capability}` shows it. Nexus Review reads it before its first model call and pauses a run the cap has no room for. Permission: `models.use` (Every member, module keys). ### Responses - `200` OK (application/json, ProductUsageMonth) - `product` (string, required) - `capability` (string, required) - `cap` (object | null, required): Null without a cap, else as `GET /v1/budgets/products/{product}/{capability}` shows it. - `limitUsd` (string, required): The budget's amount for its period. [pattern ^[0-9]+\.[0-9]{6}$] - `every` ("day" | "week" | "month", required): The budget's period, in UTC: a day, an ISO week from Monday, or a calendar month. - `monthlyUsd` (string, required): The budget's amount whatever its period; read `limitUsd` and `every` instead. [pattern ^[0-9]+\.[0-9]{6}$] - `period` (string, required): The period: `YYYY-MM-DD` for a day, `YYYY-Www` for a week, `YYYY-MM` for a month. - `spentUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$] - `feesUsd` (string, required): The product's own fees this month (`POST /v1/budgets/usage`), part of `spentUsd`. [pattern ^[0-9]+\.[0-9]{6}$] - `reservedUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$] - `remainingUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$] - `resetsAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `unitPricesUsd` (object, required): The price of one of each unit the product records (`review` for Nexus Review). - `403` Not a module's scoped key (`module_key_required`): a use belongs to the module that made it (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `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/budgets/usage" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbudgets%2Fusage) ## Record product usage `POST /v1/budgets/usage` Record one use of the key's product, such as one pull request Nexus Review reviewed (a module's scoped key only). The Gateway prices it (`NEXUS_PRICE_REVIEW_PR_MICROS` for Nexus Review's `review`, 0 by default), and the month's amounts count in the product cap. The row is append-only and keyed by `usageKey`: a repeat with the same unit and quantity answers the stored row with `recorded: false`, and a repeat that differs is a 409. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) - `usageKey` (string, required): One per use: Nexus Review sends `<owner>/<repo>#<pr>`. [pattern ^[A-Za-z0-9._/#@-]{1,200}$] - `unit` (string, required): What was used: `review` for Nexus Review. - `quantity` (integer) [min 1; max 1000; default 1] ### Responses - `200` OK (application/json, ProductUsage) - `id` (string, required) - `product` (string, required) - `capability` (string, required) - `usageKey` (string, required) - `unit` (string, required) - `quantity` (integer, required) - `unitPriceUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$] - `amountUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$] - `at` (string (date-time), required) - `recorded` (boolean, required): False when the usage key was already recorded: this is the stored row. - `400` Not a usage key (`invalid_usage_key`), a unit the product records (`unknown_unit`), a quantity from 1 to 1000 (`invalid_quantity`), or an amount over $1,000 (`amount_too_large`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a module's scoped key (`module_key_required`): a use belongs to the module that made it (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The usage key was already recorded with another unit or quantity (`usage_conflict`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a usage key (`invalid_usage_key`), a unit the product records (`unknown_unit`), a quantity from 1 to 1000 (`invalid_quantity`), or an amount over $1,000 (`amount_too_large`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | The usage key was already recorded with another unit or quantity (`usage_conflict`) | | 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/budgets/usage" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "usageKey": "<usageKey>", "unit": "<unit>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fbudgets%2Fusage) ## Grant limit manager `PUT /v1/budgets/limit-managers/{userId}` Allow an admin to set each person's spend limit, but not an owner's and not the default per person (owners only; owners always can). The grant is on the admin's membership: it ends when they stop being an admin or leave, and does not come back when they return. Granting an admin who has it writes nothing. Audited as budget.limit_manager_granted, `limitManager` before and after, ids only. 409 `not_an_admin` for an owner, a team lead or a member. Permission: `budgets.delegate` (Owner). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `userId` | path | string | yes | A user id, or `me` | | `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, LimitManager) - `userId` (string, required) - `limitManager` (boolean, required) - `403` Not an owner (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such member (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The person is not an admin (`not_an_admin`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such member | | 409 | | The person is not an admin (`not_an_admin`) | | 409 | `not_an_admin` | 409 `not_an_admin` for an owner, a team lead or a member | | 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/budgets/limit-managers/user_123" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.grantLimitManager("<user id>"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fbudgets%2Flimit-managers%2F%7BuserId%7D) ## Revoke limit manager `DELETE /v1/budgets/limit-managers/{userId}` Stop an admin setting person spend limits (owners only). The limits they set stay. Revoking from someone without the grant writes nothing. Audited as budget.limit_manager_revoked, `limitManager` before and after, ids only. Permission: `budgets.delegate` (Owner). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `userId` | path | string | yes | A user id, or `me` | | `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, LimitManager) - `userId` (string, required) - `limitManager` (boolean, required) - `403` Not an owner (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such member (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such member | | 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/budgets/limit-managers/user_123" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.revokeLimitManager("<user id>"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fbudgets%2Flimit-managers%2F%7BuserId%7D) --- <!-- /docs/api/analytics --> # Analytics > Usage over a date range grouped by team, person, model, provider, product, key or day. Owners and admins see the organization; members see their own usage and their teams'. by team, `depth` and `under` roll spend up the tree of teams. ## Usage `GET /v1/analytics/usage` Usage over a date range (UTC days, inclusive; at most 366): totals, groups with their share, and a daily series. Spend with no team is the Unassigned group. Owners and admins see the organization; members their own usage and their teams', with teammates as one row by person. An agent link sees only its person's own calls, as `person=me` does for anyone. with groupBy=team, `depth` and `under` roll spend up the tree: each group includes its teams below; spend on a team that has child teams, above the depth shown, is its own `(direct)` group. Members see rollups only from their own teams down. With groupBy=key, each key shows by its name and prefix, never its token. A revoked key keeps its name and says revoked. A person's Nexus UI sessions are one group. A member sees the keys of their own calls. All other calls in their teams are one Others row. A member's own call with no key is Unassigned. With groupBy=hour, each group is one UTC hour with calls (`YYYY-MM-DDTHH`), in order, under the same scope as by day; the series stays by day. Permission: `spend.read_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `groupBy` | query | "team" \| "person" \| "model" \| "provider" \| "product" \| "key" \| "day" \| "hour" | no | How to group (default team) | | `from` | query | string (date) | no | YYYY-MM-DD; default 29 days before to | | `to` | query | string (date) | no | YYYY-MM-DD; default today | | `team` | query | string | no | Only this team's usage and its child teams' (slug); members: their own teams and the teams under them | | `depth` | query | integer | no | GroupBy=team: roll up to the teams at this depth (1 = top level; with `under`, counted below it) | | `under` | query | string | no | GroupBy=team: roll up to the child teams of this team (slug) | | `person` | query | "me" | no | `me`: only your own calls, under every groupBy, and `scope` is `own`. No other value is accepted (400). | ### Responses - `200` OK (application/json, UsageReport) - `from` (string (date), required) - `to` (string (date), required) - `groupBy` ("team" | "person" | "model" | "provider" | "product" | "key" | "day", required) - `scope` ("org" | "member" | "own", required): `org`: the whole organization (owners and admins); `member`: your own usage and that of your teams and the teams under them; `own`: only your own calls (an agent link, or `person=me`). - `team` (object) - `id` (string) - `slug` (string) - `name` (string) - `totals` (object, required) - `spentUsd` (number): Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string | null): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. `null` for a total, group or day with no call at all (root rule 9's empty day), where `spentUsd` is 0. - `calls` (integer) - `inputTokens` (integer) - `outputTokens` (integer) - `callsByStatus` (object): Calls by status, refused calls included. `calls` counts settled, failed and released calls only. - `settled` (integer, required) - `failed` (integer, required) - `refused` (integer, required) - `released` (integer, required) - `errorRate` (number | null): (failed + refused) / (settled + failed + refused), 0-1. Released calls count in neither part. `null` when there are no such calls. - `overspendPrevented` (object): The refused calls a spend limit stopped in the period, and what they asked to hold (`amountMicros` of the record's `overspendPrevented`, not what they would have cost), in all and by the level whose limit refused them. A refusal at a level other than these four counts nowhere. Zeros, not `null`, when no limit stopped a call. It equals the spend file's rows with an `overspendLevel` over the same days. - `calls` (integer, required) - `amountUsd` (number, required): Deprecated: read `amountUsdDecimal`, the exact decimal string (root rule 9). - `amountUsdDecimal` (string): `amountUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `amountUsd`. - `byLevel` (object, required) - `organization` (object, required) - `calls` (integer, required) - `amountUsd` (number, required): Deprecated: read `amountUsdDecimal`, the exact decimal string (root rule 9). - `amountUsdDecimal` (string): `amountUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `amountUsd`. - `team` (object, required) - `calls` (integer, required) - `amountUsd` (number, required): Deprecated: read `amountUsdDecimal`, the exact decimal string (root rule 9). - `amountUsdDecimal` (string): `amountUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `amountUsd`. - `person` (object, required) - `calls` (integer, required) - `amountUsd` (number, required): Deprecated: read `amountUsdDecimal`, the exact decimal string (root rule 9). - `amountUsdDecimal` (string): `amountUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `amountUsd`. - `product` (object, required): A product's monthly cap. - `calls` (integer, required) - `amountUsd` (number, required): Deprecated: read `amountUsdDecimal`, the exact decimal string (root rule 9). - `amountUsdDecimal` (string): `amountUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `amountUsd`. - `groups` (array of object, required) - `key` (string): Team id, user id, model, provider, product/capability, key id or day; `ui:<user id>` for a person's Nexus UI sessions; `unassigned` for no team (or person, or key); `others` for a member's teammates (or their keys). - `label` (string) - `share` (number) - `slug` (string) - `name` (string): Keys: the key's name, when it has one. - `prefix` (string): Keys: the first characters of the token, to recognise it. Never the token. - `deleted` (boolean): A team deleted since, or a key that no store holds. A key shows its id. - `revoked` (boolean): Keys: the key is revoked. It keeps its name and prefix, and its label ends with `, revoked`. - `spentUsd` (number): Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string | null): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. `null` for a total, group or day with no call at all (root rule 9's empty day), where `spentUsd` is 0. - `calls` (integer) - `inputTokens` (integer) - `outputTokens` (integer) - `callsByStatus` (object): Calls by status, refused calls included. `calls` counts settled, failed and released calls only. - `settled` (integer, required) - `failed` (integer, required) - `refused` (integer, required) - `released` (integer, required) - `errorRate` (number | null): (failed + refused) / (settled + failed + refused), 0-1. Released calls count in neither part. `null` when there are no such calls. - `depth` (integer): Teams: how deep the team sits (1 = top level). - `level` (string) - `hasChildren` (boolean): Rollups: the team has child teams; drill in with `under=<slug>`. - `direct` (boolean): Rollups: spend attributed to the team itself, not to the teams under it (key `<teamId>:direct`). - `product` (string): By team, key `product:<product>/<capability>`: a module's own calls, with no team and no person (a review a GitHub event started). The module's product. - `capability` (string): By team, key `product:<product>/<capability>`: the module's capability. - `series` (array of object, required) - `day` (string (date)) - `groups` (object): Spend per group key that day. Deprecated: read `groupsDecimal`, the same spend as exact decimal strings (root rule 9). - `groupsDecimal` (object): `groups` with each spend as an exact decimal string in US dollars with six decimals, from the micro-dollars. Prefer it to `groups`. - `spentUsd` (number): Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9). - `spentUsdDecimal` (string | null): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`. `null` for a total, group or day with no call at all (root rule 9's empty day), where `spentUsd` is 0. - `calls` (integer) - `inputTokens` (integer) - `outputTokens` (integer) - `callsByStatus` (object): Calls by status, refused calls included. `calls` counts settled, failed and released calls only. - `settled` (integer, required) - `failed` (integer, required) - `refused` (integer, required) - `released` (integer, required) - `errorRate` (number | null): (failed + refused) / (settled + failed + refused), 0-1. Released calls count in neither part. `null` when there are no such calls. - `depth` (integer): Rollups: the depth shown, from the top level. - `under` (object) - `id` (string) - `slug` (string) - `name` (string) - `level` (string) - `path` (array of TeamLink) - `id` (string, required) - `slug` (string, required) - `name` (string, required) - `level` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/analytics/usage" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.usage({ groupBy: "team", from: "2026-10-01", to: "2026-10-16", depth: "1" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fanalytics%2Fusage) ## Export usage CSV `GET /v1/analytics/usage/export.csv` The organization's usage, one row per day, team, person, model, provider and product, as CSV (owners and admins). At most 100,000 rows a file: past that the file stops, and its manifest says `complete: false` and gives `nextCursor`. Each export is an audit event (`observability.exported`) with the file's manifest, never its rows. An organization runs at most 60 exports an hour: the 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's). A bad filter is a 400 before any row. Permission: `spend.export` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `from` | query | string (date) | no | The first UTC day, YYYY-MM-DD; default 29 days before `to` | | `to` | query | string (date) | no | The last UTC day, YYYY-MM-DD, included; default today. A range covers at most 366 days | | `team` | query | string | no | A team slug or id: that team and every team under it; `unassigned` for calls with no team | | `person` | query | string | no | A person's user id | | `model` | query | string | no | A model, as the rows name it; `-` for the calls with none (released calls), as Analytics groups them | | `provider` | query | string | no | A provider, as the rows name it; `-` for the calls with none (refused and released calls), as Analytics groups them | | `product` | query | string | no | A product (`agents`) or a product and capability (`intelligence/wiki`): Analytics' group key | | `cursor` | query | string | no | A cut file's `manifest.nextCursor`: the next file of the same query. A manifest's `watermark` also works: it starts the same series again. It is bound to the organization, the caller and the query: anywhere else it is a 400 `invalid_cursor` | ### Responses - `200` CSV with a header row: one column per field of `UsageRow`, in its order. (text/csv, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `export_rate_limited` | The 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/analytics/usage/export.csv" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.usageExport("csv", { team: "platform" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fanalytics%2Fusage%2Fexport.csv) ## Export usage JSON Lines `GET /v1/analytics/usage/export.jsonl` The organization's usage, one row per day, team, person, model, provider and product, as JSON Lines (owners and admins). At most 100,000 rows a file: past that the file stops, and its manifest says `complete: false` and gives `nextCursor`. Each export is an audit event (`observability.exported`) with the file's manifest, never its rows. An organization runs at most 60 exports an hour: the 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's). A bad filter is a 400 before any row. Permission: `spend.export` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `from` | query | string (date) | no | The first UTC day, YYYY-MM-DD; default 29 days before `to` | | `to` | query | string (date) | no | The last UTC day, YYYY-MM-DD, included; default today. A range covers at most 366 days | | `team` | query | string | no | A team slug or id: that team and every team under it; `unassigned` for calls with no team | | `person` | query | string | no | A person's user id | | `model` | query | string | no | A model, as the rows name it; `-` for the calls with none (released calls), as Analytics groups them | | `provider` | query | string | no | A provider, as the rows name it; `-` for the calls with none (refused and released calls), as Analytics groups them | | `product` | query | string | no | A product (`agents`) or a product and capability (`intelligence/wiki`): Analytics' group key | | `cursor` | query | string | no | A cut file's `manifest.nextCursor`: the next file of the same query. A manifest's `watermark` also works: it starts the same series again. It is bound to the organization, the caller and the query: anywhere else it is a 400 `invalid_cursor` | ### Responses - `200` JSON Lines: one `UsageRow` per line, then one line `{"manifest": ExportManifest}`. (application/jsonl, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `export_rate_limited` | The 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/analytics/usage/export.jsonl" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.usageExport("jsonl", { team: "platform" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fanalytics%2Fusage%2Fexport.jsonl) ## Get agent adoption `GET /v1/analytics/agents` Agent adoption: for each UTC day of a range (inclusive; at most 366), the people whose agent calls (`nexus claude`, `nexus codex`) went through the agent gateway, with their email and how many calls. Refused calls are left out. Each day also lists the people with only `subscription` sessions that day. Each day also counts the active engineers by product: the people with at least one non-refused call that day, and for `agents` the people with only subscription sessions too. Owners and admins see the organization; members only themselves. Permission: `spend.read_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `from` | query | string (date) | no | YYYY-MM-DD; default 29 days before to | | `to` | query | string (date) | no | YYYY-MM-DD; default today | ### Responses - `200` OK (application/json, AgentAdoption) - `from` (string (date), required) - `to` (string (date), required) - `scope` ("org" | "member", required) - `days` (array of object, required): Every day from `from` to `to`, oldest first; a day without agent calls has no people. Each day also counts its active engineers by product: the people with at least one non-refused call that day, and for `agents` the people with only subscription sessions too. A day with no such person has `engineers` 0 and no products. - `day` (string (date), required) - `people` (array of object, required) - `userId` (string, required) - `email` (string | null, required) - `calls` (integer, required) [min 1] - `subscription` (array of object, required): People with `subscription` sessions that day (their own Claude or ChatGPT plan) and no agent call through Gateway. A session counts when it reports its first model call. A person on both routes that day is in `people` only. Gateway keeps these counts for 367 days; days before Gateway counted them have none. - `userId` (string, required) - `email` (string | null, required) - `sessions` (integer, required) [min 1] - `engineers` (integer, required): Distinct active engineers that day over every product: a person with at least one non-refused call, or with a subscription session for agents. [min 0] - `products` (array of object, required): Active engineers by product slug (`core`, `agents`, `chat`), sorted by product, only products with someone. A person counts once per product, so these can add up to more than `engineers`. For `agents` the subscription-only people count too. - `product` (string, required) - `engineers` (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 | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/analytics/agents" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fanalytics%2Fagents) ## Get chat usage `GET /v1/analytics/chat` Chat sessions in numbers, never content or titles: sessions, messages, people and cost by mode and team (and person, for owners and admins). Members see their own. Permission: `spend.read_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `days` | query | integer | no | | ### Responses - `200` OK (application/json, ChatUsage) - `scope` ("org" | "own") - `days` (integer) - `since` (string (date-time)) - `retentionDays` (integer) - `totals` (object & object) - `sessions` (integer) - `messages` (integer) - `costUsd` (number): Deprecated: read `costUsdDecimal`, the exact decimal string (root rule 9). - `costUsdDecimal` (string): `costUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `costUsd`. - `people` (integer) - `byMode` (object) - `chat` (object) - `sessions` (integer) - `messages` (integer) - `costUsd` (number): Deprecated: read `costUsdDecimal`, the exact decimal string (root rule 9). - `costUsdDecimal` (string): `costUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `costUsd`. - `ask` (object) - `sessions` (integer) - `messages` (integer) - `costUsd` (number): Deprecated: read `costUsdDecimal`, the exact decimal string (root rule 9). - `costUsdDecimal` (string): `costUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `costUsd`. - `byTeam` (array of object & object) - `sessions` (integer) - `messages` (integer) - `costUsd` (number): Deprecated: read `costUsdDecimal`, the exact decimal string (root rule 9). - `costUsdDecimal` (string): `costUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `costUsd`. - `team` (string | null) - `byPerson` (array of object & object): Owners and admins - `sessions` (integer) - `messages` (integer) - `costUsd` (number): Deprecated: read `costUsdDecimal`, the exact decimal string (root rule 9). - `costUsdDecimal` (string): `costUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `costUsd`. - `userId` (string) - `email` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/analytics/chat" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fanalytics%2Fchat) --- <!-- /docs/api/audit --> # Audit log > The append-only audit log: who changed what, through which credential, from which surface, before and after. ## List audit events `GET /v1/audit` The audit log, newest first: everything for owners and admins, a lead's teams (and those under them), else your own actions. Permission: `audit.read_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `since` | query | string | no | ISO time, or relative: 30m, 24h, 7d, 2w | | `until` | query | string | no | ISO time, or relative | | `action` | query | string | no | An action, a comma-separated list, or a prefix ending in * (team.*) | | `actor` | query | string | no | The actor's user id or email | | `target` | query | string | no | The target's id or slug | | `team` | query | string | no | A team slug or id: events of that team and every team under it | | `limit` | query | integer | no | Events per page, 1 to 500 (default 50) | | `cursor` | query | string | no | NextCursor from the previous page | ### Responses - `200` OK (application/json, AuditPage) - `scope` ("all" | "team" | "own", required) - `events` (array of AuditEvent, required) - `id` (string, required) - `at` (string (date-time), required) - `actor` (object, required) - `userId` (string) - `email` (string): Filled in when the log is read, from the person's user record: a new event stores the actor by user id alone. Absent for an erased person and for an operator in a customer's log. - `keyId` (string, required): The credential: a token id, `ui` (Nexus UI's server), a module's scoped key (`scoped:<product>/<capability>/smk_…`), a sandbox session's id (`sbs_…`), an agent link (`agl_…`), `github`, `clerk` or `system` - `kind` ("person" | "api_key" | "cli" | "ui" | "module" | "service" | "sandbox" | "operator" | "agent" | "platform" | "system", required) - `erased` (boolean): True when the person was erased: no email is shown for them. - `surface` ("api" | "cli" | "mcp" | "ui" | "chat" | "webhook" | "system", required) - `action` ("org.created" | "org.settings_changed" | "org.recovery_key_changed" | "org.team_key_rotated" | "synced_session.audit_read" | "synced_session.made_private" | "synced_session.made_team_visible" | "cloud_history.break_glass_read" | "devices.recovered" | "org.budget_changed" | "app.cap_changed" | "app.claim_requested" | "app.deleted" | "budget.person_default_changed" | "budget.person_limit_changed" | "budget.team_changed" | "budget.product_changed" | "budget.limit_manager_granted" | "budget.limit_manager_revoked" | "org.owner_transferred" | "org.relinked" | "member.joined" | "member.role_changed" | "member.removed" | "member.recovered" | "account.deleted" | "member.default_team_changed" | "invitation.sent" | "invitation.revoked" | "domain.added" | "domain.removed" | "key.created" | "key.revoked" | "provider_key.added" | "provider_key.replaced" | "provider_key.disabled" | "provider_key.enabled" | "provider_key.removed" | "provider_key.rejected" | "connector_credential.added" | "connector_credential.replaced" | "connector_credential.revoked" | "connector_credential.needs_reconnect" | "vault.master_changed" | "auth.device_approved" | "auth.device_denied" | "auth.token_issued" | "auth.token_revoked" | "policy.changed" | "policy.control_set" | "policy.control_cleared" | "team.created" | "team.updated" | "team.moved" | "team.deleted" | "team.member_added" | "team.member_role_changed" | "team.member_removed" | "team.pending_added" | "team.pending_cancelled" | "team.import_applied" | "github.installation_linked" | "github.installation_unlinked" | "github.installation_removed" | "github.repositories_changed" | "chat_workspace.installed" | "chat_workspace.confirmed" | "chat_workspace.revoked" | "chat_workspace.token_refresh_failed" | "chat_channel.bound" | "chat_channel.unbound" | "chat_channel.moved" | "chat_workspace.runtime_read" | "chat_workspace.revoke_refused" | "chat.session_created" | "chat.session_deleted" | "artifact.shared" | "artifact.updated" | "artifact.revoked" | "artifact.continued" | "subsidy.granted" | "subsidy.used" | "subsidy.paid" | "subsidy.expired" | "credit.purchased" | "credit.reversed" | "credit.restored" | "credit.auto_topup_changed" | "artifact.access_changed" | "artifact.access_requested" | "artifact.reported" | "ledger.reservation_released" | "ledger.reservation_settled_late" | "connector_grant.granted" | "connector_grant.revoked" | "connector_availability.changed" | "connector.write" | "connector.write_attempt" | "connector.read" | "chat_write_setting.changed" | "agent_write_setting.changed" | "review_event_setting.changed" | "policy.approval.requested" | "policy.approval.confirmed" | "policy.approval.denied" | "policy.approval.cancelled" | "policy.approval.used" | "page.created" | "page.version_written" | "page.restored" | "page.deleted" | "page.trashed" | "page.restored_from_trash" | "page_query.saved" | "page_query.deleted" | "design_system.saved" | "design_system.default_set" | "design_system.deleted" | "skill.created" | "skill.version_written" | "skill.deleted" | "skill.promotion_requested" | "skill.promotion_approved" | "skill.promotion_refused" | "skill.promotion_withdrawn" | "billing.customer_created" | "billing.customer_deleted" | "billing.payment_method_changed" | "billing.invoice_sent" | "billing.invoice_paid" | "billing.invoice_failed" | "billing.plan_changed" | "billing.plan_change_scheduled" | "billing.after_the_fact_changed" | "billing.usage_charged" | "billing.usage_charge_failed" | "billing.payment_disputed" | "billing.dispute_closed" | "observability.exported" | "observability.directory_exported" | "service_account.created" | "service_account.key_created" | "service_account.key_rotated" | "service_account.key_revoked" | "service_account.revoked" | "sandbox_session.started" | "sandbox_session.ended" | "agent_session.started" | "agent_session.ended" | "operator_grant.issued" | "operator_grant.revoked" | "operator.request" | "org.marked" | "person.marked" | "desktop.revocations_changed" | "staff.person_viewed" | "staff.list_viewed" | "agent.linked" | "agent.unlinked" | "agent.memory_written" | "agent.memory_deleted" | "agent.memory_cleared" | "agent.profile_created" | "agent.profile_updated" | "agent.profile_deleted" | "project.created" | "project.updated" | "project.archived" | "project.moved_to_org" | "project.repo_added" | "project.repo_removed" | "project.member_set" | "project.member_removed" | "secret.set" | "secret.deleted" | "project.setup_saved" | "subscription.changed" | "subscription.status_changed" | "referral.recorded" | "referral.reward_voided" | "invite.created" | "invite.revoked" | "invite.approved" | "platform_role.granted" | "platform_role.revoked" | "schedule.upserted" | "schedule.paused" | "schedule.resumed" | "schedule.deleted", required): Stable and dotted - `target` (object, required) - `type` (string, required) - `id` (string, required) - `slug` (string) - `before` (any): The record before the change (credentials redacted) - `after` (any): The record after the change (credentials redacted) - `requestId` (string): The request's x-request-id - `metadata` (object) - `nextCursor` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/audit" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.audit({ since: "7d", action: "team.*" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Faudit) ## Export audit events `GET /v1/audit/export.csv` Every matching audit event you may read, newest first, streamed as CSV (owners, admins and team leads). Permission: `audit.export` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `since` | query | string | no | ISO time, or relative: 30m, 24h, 7d, 2w | | `until` | query | string | no | ISO time, or relative | | `action` | query | string | no | An action, a comma-separated list, or a prefix ending in * (team.*) | | `actor` | query | string | no | The actor's user id or email | | `target` | query | string | no | The target's id or slug | | `team` | query | string | no | A team slug or id: events of that team and every team under it | ### Responses - `200` CSV: id, at, action, actor_email, actor_user_id, actor_kind, key_id, surface, target_type, target_id, target_slug, request_id, before, after, metadata (text/csv, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/audit/export.csv" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.auditCsv({ since: "30d" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Faudit%2Fexport.csv) --- <!-- /docs/api/models --> # Models and policies > The model catalog (supported and coming soon), model access policies (allow and deny lists per organization, team and coding agent; a deny always wins; levels only narrow), and the policy test. Nexus calls providers directly. ## List models `GET /v1/models` The models you may use under your organization's, team's and key's policies (OpenAI-compatible list, with Nexus's fields: each supported model's context window, output limit, reasoning and list prices, enough for a client to offer it without a catalog of its own). Send the key as `Authorization: Bearer <key>` or `x-api-key: <key>`. **With a key**: `status=allowed` (the default) gives the models you may use; `status=all` the whole catalog with `allowed` and `status`; `supported` or `coming_soon` filter it. `team`: as for a call (else `x-nexus-team`, else your default team). **Without a key** (the public catalog, for the model pages and other readers): the catalog itself, the same for everyone, `supported` models by default and `status=all` or `coming_soon` on request, with no `allowed` field, no `status=allowed` and no `team` (asking for `status=allowed` or a team, by `team` or `x-nexus-team`, is a 401); limited per address, and cacheable (`Cache-Control: public`, `Vary: Authorization, X-Api-Key, X-Nexus-Ui-Secret`). A wrong key is a 401, as on every route. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `status` | query | "allowed" \| "all" \| "supported" \| "coming_soon" | no | With a key: `allowed` (the default), `all`, `supported` or `coming_soon`. Without a key: `supported` (the default), `all` or `coming_soon`; `allowed` needs a key and is a 401 without one. | | `team` | query | string | no | | ### Responses - `200` OK (application/json, object) - `object` ("list") - `data` (array of Model) - `id` (string): Canonical: maker/model - `object` ("model") - `created` (integer) - `owned_by` (string): The maker: who made the model, the first part of its id - `provider` (string): Supported models: the host that serves it, whose rules price it and whose key pays for it - `name` (string) - `family` (string) - `status` ("supported" | "coming_soon") - `allowed` (boolean) - `surfaces` (array of string) - `input` (array of "text" | "image"): Supported models: what it reads; `image` when chat questions with images may use it - `provider_model` (string) - `context_window` (integer): Supported models: input and output tokens together, at most - `web_search_usd` (number): One hosted web search's list price in US dollars, set when the model can run a chat's web search; absent otherwise - `max_output_tokens` (integer): Supported models: the longest output, which Core reserves when a call names no limit. It holds on the agents' pass-through (`/v1/anthropic`, `/v1/openai`); the chat paths cap output at the deployment's limit (`NEXUS_MAX_TOKENS`, 4,096 by default): `/v1/chat/completions` refuses a larger `max_tokens` with a 400, and Nexus chat answers within it, except rounds that offer the `write_page` tool, which ask for up to 16,384 tokens within the model's own limit - `reasoning` (object): Supported models: how it reasons - `mode` ("effort" | "budget" | "none"): How a call steers it: an effort level (`efforts`), a token budget (Anthropic extended thinking, `budget_tokens`), or not at all (the model does not reason) - `efforts` (array of "low" | "medium" | "high" | "xhigh" | "max"): The values the provider's effort setting takes (Anthropic `output_config.effort`, OpenAI `reasoning.effort`), lowest first; empty unless `mode` is `effort` - `default_effort` (string | null): The provider's default effort; null where the provider states none - `can_disable` (boolean): Whether a call may turn reasoning off with the provider's own switch (Anthropic `thinking: {"type": "disabled"}`, OpenAI `reasoning.effort: "none"`), at some effort at least: see `disable_max_effort` - `disable_max_effort` ("low" | "medium" | "high" | "xhigh" | "max" | null): The highest effort at which `can_disable` holds (Claude Opus 5 and Claude Haiku 5.5: `high`); null when it holds at every effort, or `can_disable` is false - `pricing` (object): List prices Core meters with, per million tokens (supported models). An OpenAI model's `cache_write` sizes a call's reservation, but settlement does not charge it yet - `input` (number) - `output` (number) - `cache_read` (number): Cache reads - `cache_write` (number): Cache writes (Anthropic: 5-minute writes; 0 where the provider does not price them) - `cache_write_1h` (number): Anthropic: 1-hour cache writes - `long_context` (object): The rates above `above` input tokens, where the model has a long-context tier - `above` (integer) - `input` (number) - `output` (number) - `cache_read` (number): Cache reads - `cache_write` (number): Cache writes (Anthropic: 5-minute writes; 0 where the provider does not price them) - `cache_write_1h` (number): Anthropic: 1-hour cache writes - `unit` (string) - `default_for` (array of string) - `note` (string) - `openWeights` (boolean | null): Catalog classification. True means open weights. Null means unclassified. - `unavailable` (array of object): Models the Gateway knows of but cannot serve yet, each with why. They are not in `data` and cannot be called. A model may move from here to `data` without notice. - `id` (string, required) - `reason` (string, required) - `team` (string) - `400` The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller may not do this: for example, the role does not have the permission (`role_required`), or the team named is not the caller's (`not_in_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Nothing matches. A path parameter outside its pattern is a 404 "no such endpoint", before the credential is checked. A team named that does not exist is `unknown_team`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `426` The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Retry after `Retry-After` seconds. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `504` The request passed Gateway's deadline, 30 seconds by default (`timeout`). Model calls that may stream are outside it. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid; the message names the field. A JSON body that is not an object, or a string in it that holds U+0000 (`nul_in_string`), is a 400 on every route that reads one. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | Nothing matches. A path parameter outside its pattern is a 404 "no such endpoint", before the credential is checked. A team named that does not exist is `unknown_team`. | | 426 | | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Retry after `Retry-After` seconds. | | 504 | | The request passed Gateway's deadline, 30 seconds by default (`timeout`). Model calls that may stream are outside it. | ### Example ```sh curl "$NEXUS_URL/v1/models" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.models({ status: "all" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fmodels) ## List providers `GET /v1/providers` The providers the Gateway calls, from the catalog: each one's id, name, country, whether an organization may bring its own key (`byok`), whether the Gateway calls it (`status`), how many listed models it hosts, its `rates` (what a model on it costs beyond its input and output prices), the host of its API (`apiHost`) and what the Gateway calls it for (`serving`). Send the key as `Authorization: Bearer <key>` or `x-api-key: <key>`. **With a key**: each BYOK provider also carries `key`, the state of the organization's own key: `none` (none stored, or disabled), `valid` or `rejected`. It never returns the key or any part of it; `listProviderKeys` shows the last four characters. **Without a key**: the same list for everyone, with no `key` field; limited per address with the public model catalog, and cacheable (`Cache-Control: public`, `Vary: Authorization, X-Api-Key, X-Nexus-Ui-Secret`). A wrong key is a 401, as on every route. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, object) - `object` ("list", required) - `data` (array of Provider, required) - `id` (string, required): Its id in stored keys, spend records and the policy's `providers` lists (`anthropic`). - `name` (string, required): Its name in messages (`Anthropic`). - `country` (string, required): The ISO 3166-1 alpha-2 code of the country it is headquartered in. - `byok` (boolean, required): Whether an organization may bring its own key for it (`addProviderKey`). - `status` ("active" | "inactive", required): Whether the Gateway calls it. A model on an inactive provider is neither listed nor callable. - `models` (integer, required): How many listed models it hosts. [min 0] - `rates` (ProviderRates, required): What a model on the provider costs beyond its input and output prices, where the model states no price of its own. `listModels` gives each model's own prices. - `cacheReadShare` (number | null, required): A cache read's price, as a share of the model's input price (`0.1` is 10%). `null`: each model has its own cache-read price. - `cacheWrite` (object | object, required): How a cache write is priced. `multipliers`: a multiple of the model's input price, by how long the cache entry lives. `model_rate`: the model's own cache-write price, or its input price when it has none. - `webSearchUsd` (string | null, required): One hosted web search, in US dollars, as a decimal string (`"0.010000"`). `null`: the Gateway runs no hosted web search on this provider. - `apiHost` (string, required): The host of the provider's public API (`api.anthropic.com`). - `serving` ("model_api" | "decisions", required): What the Gateway calls the provider for. `model_api`: its models, on chat completions and the pass-through APIs. `decisions`: typed decisions only (`POST /v1/decisions`). - `key` ("none" | "valid" | "rejected"): With a key, on a BYOK provider only: the organization's own key. `none`: none stored, or disabled. `rejected`: the provider refused it. `valid`: a call uses it. - `enabled` (boolean): With a key: whether the organization's provider policy (`ModelRule.providers`) lets calls use it. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller may not do this: for example, the role does not have the permission (`role_required`), or the team named is not the caller's (`not_in_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/providers" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fproviders) ## Get organization policy `GET /v1/policies/organization` The organization's model policy, what it inherits from this Gateway, and what it allows. Permission: `policy.read` (Every member). ### Responses - `200` OK (application/json, ModelPolicy) - `level` ("organization" | "team" | "agent") - `subject` (string) - `team` (object) - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported). - `allow` (array of string) [at most 100 items] - `deny` (array of string) [at most 100 items] - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists. - `chat` (string) - `claude` (string) - `codex` (string) - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows. - `input` (number) [min 0] - `output` (number) [min 0] - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows. - `maker` (array of string) - `provider` (array of string) - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`. - `allow` (array of string) - `deny` (array of string) - `custom` (boolean): False: no rule at this level - `migrated` (boolean): Read from the old agent policy, not saved since - `updatedAt` (string (date-time)) - `inherited` (array of object) - `effective` (object): What the levels down to this one allow, and the defaults they resolve to - `notes` (array of string) - `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/organization" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.policy("organization"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Forganization) ## Set organization policy `PUT /v1/policies/organization` Replace the organization's model policy (owners and admins). An empty rule removes it. Audited as `policy.changed`. Permission: `policy.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `allow` (array of string) [at most 100 items] - `deny` (array of string) [at most 100 items] - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists. - `chat` (string) - `claude` (string) - `codex` (string) - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows. - `input` (number) [min 0] - `output` (number) [min 0] - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows. - `maker` (array of string) - `provider` (array of string) - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`. - `allow` (array of string) - `deny` (array of string) ### Responses - `200` OK (application/json, ModelPolicy) - `level` ("organization" | "team" | "agent") - `subject` (string) - `team` (object) - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported). - `allow` (array of string) [at most 100 items] - `deny` (array of string) [at most 100 items] - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists. - `chat` (string) - `claude` (string) - `codex` (string) - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows. - `input` (number) [min 0] - `output` (number) [min 0] - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows. - `maker` (array of string) - `provider` (array of string) - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`. - `allow` (array of string) - `deny` (array of string) - `custom` (boolean): False: no rule at this level - `migrated` (boolean): Read from the old agent policy, not saved since - `updatedAt` (string (date-time)) - `inherited` (array of object) - `effective` (object): What the levels down to this one allow, and the defaults they resolve to - `notes` (array of string) - `400` Not a valid rule (`invalid_policy`), or `providers` names an id that is not a catalog provider (`unknown_provider`), or `providers.allow` is empty (`providers_allow_empty`): omit `allow` to allow every provider (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller does not hold `policy.manage`: only owners and admins set the organization's policy (`role_required`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a valid rule (`invalid_policy`), or `providers` names an id that is not a catalog provider (`unknown_provider`), or `providers.allow` is empty (`providers_allow_empty`): omit `allow` to allow every provider | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins set the organization's policy (`role_required`). | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/policies/organization" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "deny": [ "anthropic/claude-fable-*" ] }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.setPolicy("organization", undefined, { deny: ["anthropic/claude-fable-*"] }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Forganization) ## Get team policy `GET /v1/policies/teams/{slug}` A team's model policy: its own rule, the organization's and its parent teams' (it only narrows them), and what they add up to. Permission: `policy.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | ### Responses - `200` OK (application/json, ModelPolicy) - `level` ("organization" | "team" | "agent") - `subject` (string) - `team` (object) - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported). - `allow` (array of string) [at most 100 items] - `deny` (array of string) [at most 100 items] - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists. - `chat` (string) - `claude` (string) - `codex` (string) - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows. - `input` (number) [min 0] - `output` (number) [min 0] - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows. - `maker` (array of string) - `provider` (array of string) - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`. - `allow` (array of string) - `deny` (array of string) - `custom` (boolean): False: no rule at this level - `migrated` (boolean): Read from the old agent policy, not saved since - `updatedAt` (string (date-time)) - `inherited` (array of object) - `effective` (object): What the levels down to this one allow, and the defaults they resolve to - `notes` (array of string) - `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No team with this slug or id in this organization (`unknown_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No team with this slug or id in this organization (`unknown_team`). | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/teams/platform" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.policy("team", "platform"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Fteams%2F%7Bslug%7D) ## Set team policy `PUT /v1/policies/teams/{slug}` Replace a team's model policy (owners and admins; a team lead for a team they lead or one under it, and only to narrow it). Audited. Permission: `policy.manage_team` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `allow` (array of string) [at most 100 items] - `deny` (array of string) [at most 100 items] - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists. - `chat` (string) - `claude` (string) - `codex` (string) - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows. - `input` (number) [min 0] - `output` (number) [min 0] - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows. - `maker` (array of string) - `provider` (array of string) - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`. - `allow` (array of string) - `deny` (array of string) ### Responses - `200` OK (application/json, ModelPolicy) - `level` ("organization" | "team" | "agent") - `subject` (string) - `team` (object) - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported). - `allow` (array of string) [at most 100 items] - `deny` (array of string) [at most 100 items] - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists. - `chat` (string) - `claude` (string) - `codex` (string) - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows. - `input` (number) [min 0] - `output` (number) [min 0] - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows. - `maker` (array of string) - `provider` (array of string) - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`. - `allow` (array of string) - `deny` (array of string) - `custom` (boolean): False: no rule at this level - `migrated` (boolean): Read from the old agent policy, not saved since - `updatedAt` (string (date-time)) - `inherited` (array of object) - `effective` (object): What the levels down to this one allow, and the defaults they resolve to - `notes` (array of string) - `400` Not a valid rule (`invalid_policy`). `providers` is refused here too: it is set on the organization's policy only. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller is not an owner, an admin or a team lead (`role_required`); a lead names a team outside their teams (`outside_led_teams`); or a lead's rule widens the stored one (`policy_widens`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Nothing matches. A path parameter outside its pattern is a 404 "no such endpoint", before the credential is checked. A team named that does not exist is `unknown_team`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a valid rule (`invalid_policy`). `providers` is refused here too: it is set on the organization's policy only. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The caller is not an owner, an admin or a team lead (`role_required`); a lead names a team outside their teams (`outside_led_teams`); or a lead's rule widens the stored one (`policy_widens`) | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Nothing matches. A path parameter outside its pattern is a 404 "no such endpoint", before the credential is checked. A team named that does not exist is `unknown_team`. | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/policies/teams/platform" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "allow": [ "anthropic/*" ], "defaults": { "chat": "anthropic/claude-haiku-5.5" } }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.setPolicy("team", "platform", { allow: ["anthropic/*"] }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Fteams%2F%7Bslug%7D) ## Get agent policy `GET /v1/policies/agents/{agent}` A coding agent's model policy (was the old agent policy, migrated as its allow list and default). Permission: `policy.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `agent` | path | "claude" \| "codex" \| "antigravity" \| "cursor" \| "opencode" | yes | | ### Responses - `200` OK (application/json, ModelPolicy) - `level` ("organization" | "team" | "agent") - `subject` (string) - `team` (object) - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported). - `allow` (array of string) [at most 100 items] - `deny` (array of string) [at most 100 items] - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists. - `chat` (string) - `claude` (string) - `codex` (string) - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows. - `input` (number) [min 0] - `output` (number) [min 0] - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows. - `maker` (array of string) - `provider` (array of string) - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`. - `allow` (array of string) - `deny` (array of string) - `custom` (boolean): False: no rule at this level - `migrated` (boolean): Read from the old agent policy, not saved since - `updatedAt` (string (date-time)) - `inherited` (array of object) - `effective` (object): What the levels down to this one allow, and the defaults they resolve to - `notes` (array of string) - `400` The path names no coding agent: `agent` must be `claude`, `codex`, `antigravity` or `cursor` (`invalid_request`); or it names one without a Gateway route, which has no model policy (`route_unsupported`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | The path names no coding agent: `agent` must be `claude`, `codex`, `antigravity` or `cursor` (`invalid_request`); or it names one without a Gateway route, which has no model policy (`route_unsupported`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). | | 404 | `not_found` | Nothing matches the path in your organization | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/agents/claude" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.policy("agent", "claude"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Fagents%2F%7Bagent%7D) ## Set agent policy `PUT /v1/policies/agents/{agent}` Replace a coding agent's model policy (owners and admins). Audited. Permission: `policy.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `agent` | path | "claude" \| "codex" \| "antigravity" \| "cursor" \| "opencode" | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `allow` (array of string) [at most 100 items] - `deny` (array of string) [at most 100 items] - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists. - `chat` (string) - `claude` (string) - `codex` (string) - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows. - `input` (number) [min 0] - `output` (number) [min 0] - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows. - `maker` (array of string) - `provider` (array of string) - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`. - `allow` (array of string) - `deny` (array of string) ### Responses - `200` OK (application/json, ModelPolicy) - `level` ("organization" | "team" | "agent") - `subject` (string) - `team` (object) - `rule` (ModelRule): A model access rule. Patterns: an exact model (`anthropic/claude-opus-5.5`, any spelling), a provider (`anthropic/*`) or a family (`openai/gpt-6-*`). No allow list (or an empty one): every model the levels above allow. A deny wins at any level. Coming-soon models may be named (accepted with a note; no effect until supported). - `allow` (array of string) [at most 100 items] - `deny` (array of string) [at most 100 items] - `defaults` (object): What `nexus/auto` and `nexus/default` resolve to, per kind; the most specific level that names one wins. Must be supported and allowed by this rule's own lists. - `chat` (string) - `claude` (string) - `codex` (string) - `maxPrice` (object): Refuses a model priced above either limit, in USD per million tokens. A price equal to the limit passes. A side left out has no limit. A model with no price is refused. Applies at every level, and a lower level only narrows. - `input` (number) [min 0] - `output` (number) [min 0] - `denyCountries` (object): Refuses a model whose maker country or provider country is listed. Countries are ISO 3166-1 alpha-2 codes, listed one by one. A model with no catalog entry is refused when a side is listed. Applies at every level, and a lower level only narrows. - `maker` (array of string) - `provider` (array of string) - `providers` (object): Which providers calls may use, by catalog provider id (`GET /v1/providers`). A provider in `deny` is off. With `allow`, only the providers it lists are on, so a provider added to the catalog later stays off until it is listed. Without either, every provider is on. A provider in both lists is off: `deny` wins. An empty `allow` is refused with 400 `providers_allow_empty`: omit `allow` to allow every provider. A model whose providers are all off is refused with 403 `provider_disabled`, and is not `allowed` in `GET /v1/models`. Set on the organization's policy only. An unknown id is refused with 400 `unknown_provider`. - `allow` (array of string) - `deny` (array of string) - `custom` (boolean): False: no rule at this level - `migrated` (boolean): Read from the old agent policy, not saved since - `updatedAt` (string (date-time)) - `inherited` (array of object) - `effective` (object): What the levels down to this one allow, and the defaults they resolve to - `notes` (array of string) - `400` Not a valid rule (`invalid_policy`), including `providers`, which is set on the organization's policy only; or the path names no coding agent (`invalid_request`); or it names one without a Gateway route, which has no model policy (`route_unsupported`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller does not hold `policy.manage`: only owners and admins set the coding agents' policies (`role_required`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a valid rule (`invalid_policy`), including `providers`, which is set on the organization's policy only; or the path names no coding agent (`invalid_request`); or it names one without a Gateway route, which has no model policy (`route_unsupported`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins set the coding agents' policies (`role_required`). | | 404 | `not_found` | Nothing matches the path in your organization | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/policies/agents/claude" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "allow": [ "anthropic/claude-opus-*", "anthropic/claude-haiku-*" ], "defaults": { "claude": "anthropic/claude-opus-5.5" } }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.setPolicy("agent", "claude", { allow: ["anthropic/claude-opus-*", "anthropic/claude-haiku-*"], defaults: { claude: "anthropic/claude-opus-5.5" } }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Fagents%2F%7Bagent%7D) ## Test policy `POST /v1/policies/test` Would this person (or key) be allowed this model, in this team, with this agent, and by which rule? The same decision enforcement makes, plus warnings (e.g. a rule that blocks Claude Code's small background Haiku model). Testing for someone else needs owner or admin. Permission: `policy.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `as` (string): An email, a user id or a key id; default: you - `team` (string) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string): Default: nexus/default - `surface` ("chat" | "anthropic_messages" | "openai_responses" | "decisions") ### Responses - `200` OK (application/json, ModelDecision & object) - `allowed` (boolean) - `requested` (string) - `model` (string | null): Canonical id of the model that runs (or would) - `providerModel` (string) - `surface` ("chat" | "anthropic_messages" | "openai_responses" | "decisions") - `reason` (string) - `rule` (PolicyRuleRef) - `level` ("deployment" | "organization" | "team" | "agent" | "key" | "catalog" | "none") - `subject` (string) - `list` ("allow" | "deny" | "defaults" | "maxPrice" | "denyCountries" | "providers") - `pattern` (string) - `code` ("model_not_allowed" | "model_not_found" | "model_not_supported" | "provider_disabled") - `resolvedFrom` ("nexus/auto" | "nexus/default") - `defaultFrom` (PolicyRuleRef) - `level` ("deployment" | "organization" | "team" | "agent" | "key" | "catalog" | "none") - `subject` (string) - `list` ("allow" | "deny" | "defaults" | "maxPrice" | "denyCountries" | "providers") - `pattern` (string) - `notes` (array of string) - `as` (object) - `team` (string) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `allowedModels` (array of string) - `warnings` (array of string) - `400` A field has the wrong type or value: `agent` is not `claude`, `codex`, `antigravity` or `cursor`, `surface` is not one of its values, or `as`, `team` or `model` is not a string (`invalid_request`); or `agent` has no Gateway route (`route_unsupported`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` `as` names someone else and the caller does not hold `policy.manage`: only owners and admins test the policy for others (`role_required`). A credential without `policy.read` (a service account or sandbox key) gets the same code; a scoped module key gets `module_key`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` `team` names no team in this organization (`unknown_team`), or `as` names no member or key in it (`not_found`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A field has the wrong type or value: `agent` is not `claude`, `codex`, `antigravity` or `cursor`, `surface` is not one of its values, or `as`, `team` or `model` is not a string (`invalid_request`); or `agent` has no Gateway route (`route_unsupported`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | `as` names someone else and the caller does not hold `policy.manage`: only owners and admins test the policy for others (`role_required`). A credential without `policy.read` (a service account or sandbox key) gets the same code; a scoped module key gets `module_key`. | | 404 | | `team` names no team in this organization (`unknown_team`), or `as` names no member or key in it (`not_found`). | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/policies/test" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "agent": "claude", "model": "claude-haiku-5-5" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.testPolicy({ agent: "claude", model: "claude-haiku-5-5" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpolicies%2Ftest) ## List write grants `GET /v1/policies/grants` The organization's write grants (owners, admins, leads and members: `policy.read`; not module keys): which module may write through which connector operation (for Nexus Review: robustness/review may github/pull_review, check_run, issue_comment, reaction, resolve_thread; pull_review also covers pull_review_dismiss; pull_ready, pull_merge, pull_edit, pull_state, pull_reviewers and pull_labels each have their own grant, and no other grant covers a merge), who granted each and when, and the write operations that may be granted. A connector write without its grant is refused (403 write_not_granted). Permission: `policy.read` (Every member). ### Responses - `200` OK (application/json, WriteGrants) - `grants` (array of WriteGrant, required) - `module` (string, required): `<product>/<capability>` - `connector` (string, required) - `action` (string, required): The write operation - `grantedBy` (string | null): The user id of who granted it - `at` (string (date-time), required) - `grantable` (object, required): The write operations that may be granted, by connector - `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/grants" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Fgrants) ## Set write grants `PUT /v1/policies/grants/{product}/{capability}` Set the write operations of one connector a module may run in this organization (owners and admins: `policy.manage`), in full: the operations not listed are revoked, and an empty list revokes them all. Each grant and each revocation is audited (connector_grant.granted, connector_grant.revoked); a revocation applies from the module's next call. Policy's decide_call reads these grants before every scoped connector call. Each write attempt is audited as connector.write: outcome written; denied with the refusal's code (no grant, a review event other than COMMENT, a thread of another repository); or failed with the error's code and status when an allowed write failed (a rate limit, a timeout). A grant is per organization, module, connector and operation, not per repository: the module scopes repositories itself. Permission: `policy.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `product` | path | string | yes | The module's product slug (`robustness`) | | `capability` | path | string | yes | The module's capability slug (`review`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `connector` (string, required) - `actions` (array of string, required) ### Responses - `200` OK (application/json, WriteGrantsSet) - `module` (string, required) - `connector` (string, required) - `actions` (array of string, required): What the module now holds for this connector - `granted` (array of string, required) - `revoked` (array of string, required) - `400` Not a connector with writes, or not one of its write operations (`invalid_grant`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller does not hold `policy.manage`: only owners and admins grant connector writes (`role_required`). Under an operator grant, only a revoke (an empty `actions` list) is allowed (`operator_scope`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a connector with writes, or not one of its write operations (`invalid_grant`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins grant connector writes (`role_required`). Under an operator grant, only a revoke (an empty `actions` list) is allowed (`operator_scope`). | | 404 | `not_found` | Nothing matches the path in your organization | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/policies/grants/<product>/<capability>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "connector": "github", "actions": [ "pull_review", "check_run" ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Fgrants%2F%7Bproduct%7D%2F%7Bcapability%7D) ## Get review events `GET /v1/policies/review-events` Which review events a module may post on this organization's pull requests (owners, admins, leads and members: `policy.read`; not module keys): `comment` (COMMENT only), `request_changes` (COMMENT and REQUEST_CHANGES) or `full` (COMMENT, REQUEST_CHANGES and APPROVE). `full` by default: `default` is true while the organization never chose. Permission: `policy.read` (Every member). ### Responses - `200` OK (application/json, ReviewEventSetting) - `level` ("comment" | "request_changes" | "full", required): `comment`: COMMENT only. `request_changes`: COMMENT and REQUEST_CHANGES. `full`: COMMENT, REQUEST_CHANGES and APPROVE. - `default` (boolean, required): The organization never chose: full - `changedBy` (string) - `changedAt` (string (date-time)) ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/review-events" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Freview-events) ## Set review events `PUT /v1/policies/review-events` Choose which review events a module may post on this organization's pull requests (owners and admins: `policy.manage`; an operator may only lower it to `comment`). The github connector refuses a `pull_review` whose event is above it (403 `review_event_refused`) on the next call. Nexus Review reads it to choose its event: it requests changes on a failing check and approves a pull request it read in full with none, each only where the level allows. Audited as review_event_setting.changed with the setting before and after. Permission: `policy.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `level` ("comment" | "request_changes" | "full", required): `comment`: COMMENT only. `request_changes`: COMMENT and REQUEST_CHANGES. `full`: COMMENT, REQUEST_CHANGES and APPROVE. ### Responses - `200` OK (application/json, ReviewEventSetting) - `level` ("comment" | "request_changes" | "full", required): `comment`: COMMENT only. `request_changes`: COMMENT and REQUEST_CHANGES. `full`: COMMENT, REQUEST_CHANGES and APPROVE. - `default` (boolean, required): The organization never chose: full - `changedBy` (string) - `changedAt` (string (date-time)) - `400` Not a level (`invalid_setting`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a level (`invalid_setting`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `review_event_refused` | The github connector refuses a `pull_review` whose event is above it (403 `review_event_refused`) on the next call | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/policies/review-events" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "level": "comment" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Freview-events) ## List connector availability `GET /v1/policies/connectors` Every connector Gateway offers, with its availability in this organization (owners, admins, leads and members: `policy.read`): disabled, available (members opt in) or enabled_for_all, the teams it is limited to, and whether it is the connector's default (the organization never chose: enabled_for_all for github, disabled for every other connector). Permission: `policy.read` (Every member). ### Responses - `200` OK (application/json, ConnectorAvailabilityList) - `connectors` (array of ConnectorAvailability, required) - `name` (string, required) - `availability` ("disabled" | "available" | "enabled_for_all", required): Available: members opt in - `teams` (array of string | null, required): Team slugs (a deleted team's id); null for the whole organization - `default` (boolean, required): The connector's default: the organization never chose - `offered` (boolean, required): Whether this Gateway offers the connector. The organization's choice of one it does not offer is kept; no one uses it, and it may only be set to disabled - `changedBy` (string) - `changedAt` (string (date-time)) - `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/connectors" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Fconnectors) ## Set connector availability `PUT /v1/policies/connectors/{name}` Set one connector's availability in this organization, in full (owners and admins: `policy.manage`; an operator may only turn it off). With teams, only their members and the members of the teams under them may use it, and a module acting for no person may not. Every connector call reads it first: a person, or a module acting for one, it does not reach is refused with 403 connector_disabled. Audited as connector_availability.changed with the availability before and after. Permission: `policy.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `name` | path | string | yes | The connector (`github`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `availability` ("disabled" | "available" | "enabled_for_all", required): Available: members opt in - `teams` (array of string): Team slugs; leave it out for the whole organization ### Responses - `200` OK (application/json, ConnectorAvailability) - `name` (string, required) - `availability` ("disabled" | "available" | "enabled_for_all", required): Available: members opt in - `teams` (array of string | null, required): Team slugs (a deleted team's id); null for the whole organization - `default` (boolean, required): The connector's default: the organization never chose - `offered` (boolean, required): Whether this Gateway offers the connector. The organization's choice of one it does not offer is kept; no one uses it, and it may only be set to disabled - `changedBy` (string) - `changedAt` (string (date-time)) - `400` Not an availability: an empty or unknown team, or a state the connector cannot hold (`available` for one only the organization connects, `enabled_for_all` for one only a person connects) (`invalid_availability`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller does not hold `policy.manage`: only owners and admins choose which connectors members may use (`role_required`). Under an operator grant, only `disabled` is allowed (`operator_scope`). A connector this Gateway does not offer may only be set to `disabled` (`connector_not_offered`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such connector (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not an availability: an empty or unknown team, or a state the connector cannot hold (`available` for one only the organization connects, `enabled_for_all` for one only a person connects) (`invalid_availability`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins choose which connectors members may use (`role_required`). Under an operator grant, only `disabled` is allowed (`operator_scope`). A connector this Gateway does not offer may only be set to `disabled` (`connector_not_offered`). | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such connector | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/policies/connectors/Platform" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "availability": "disabled" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Fconnectors%2F%7Bname%7D) ## Get chat writes `GET /v1/policies/chat-writes` Whether this organization lets a person's confirmed write from chat run, and which connector operations it may run (owners, admins, leads and members: `policy.read`). On with every registered connector write by default. Saved organization choices, including empty operation lists, take precedence. `default` is true while the organization never chose. Permission: `policy.read` (Every member). ### Responses - `200` OK (application/json, ChatWriteSetting) - `enabled` (boolean, required) - `default` (boolean, required): The organization never chose: on with every registered write - `operations` (array of ChatWriteOperation, required): The effective allowed connector writes, sorted. Defaults to every registered write; saved lists take precedence - `connector` (string, required) [pattern ^[a-z][a-z0-9-]*$] - `operation` (string, required) [pattern ^[a-z][a-z0-9_-]*$] - `changedBy` (string) - `changedAt` (string (date-time)) ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/chat-writes" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Fchat-writes) ## Set chat writes `PUT /v1/policies/chat-writes` Turn writes from chat on or off for this organization and, with `operations`, replace its allowlist of connector operations; left out, the list is kept (owners and admins: `policy.manage`; an operator may only turn them off, and never sets the list). Each entry must be a connector write Core has. A write of an operation the list does not name is refused (403 `operation_not_allowed`), even with a confirmed record. Off, a chat agent's approval record is not made, confirmed or used, so a record confirmed before stops working too. What an allowed write lets a member's agent do: a `github` write runs as that member's own GitHub account, connected with POST /v1/connections/github/oauth, so GitHub allows it only what it allows the member, and it is refused (403 `connection_required`) while they have none connected; a module's write runs as the Nexus GitHub App. Audited as chat_write_setting.changed with the setting before and after. Permission: `policy.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `enabled` (boolean, required) - `operations` (array of ChatWriteOperation): Replaces the allowlist. Left out, the list is kept - `connector` (string, required) [pattern ^[a-z][a-z0-9-]*$] - `operation` (string, required) [pattern ^[a-z][a-z0-9_-]*$] ### Responses - `200` OK (application/json, ChatWriteSetting) - `enabled` (boolean, required) - `default` (boolean, required): The organization never chose: on with every registered write - `operations` (array of ChatWriteOperation, required): The effective allowed connector writes, sorted. Defaults to every registered write; saved lists take precedence - `connector` (string, required) [pattern ^[a-z][a-z0-9-]*$] - `operation` (string, required) [pattern ^[a-z][a-z0-9_-]*$] - `changedBy` (string) - `changedAt` (string (date-time)) - `400` Not a setting, or an entry that is no connector write (`invalid_setting`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a setting, or an entry that is no connector write (`invalid_setting`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `operation_not_allowed` | A write of an operation the list does not name is refused (403 `operation_not_allowed`), even with a confirmed record | | 403 | `connection_required` | A `github` write runs as that member's own GitHub account, connected with POST /v1/connections/github/oauth, so GitHub allows it only what it allows the member, and it is refused (403 `connection_required`) while they have none connected; a module's write runs as the Nexus GitHub App | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/policies/chat-writes" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "enabled": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Fchat-writes) ## Get agent writes `GET /v1/policies/agent-writes` Whether your agents may write in this organization: with it on, your agent links make the connector writes the organization allows its agents (`/v1/policies/chat-writes`) with no approval record per call. On by default; a saved OFF choice restores approval records per call. Your own session or key only (`approvals.decide`): an agent link gets 403 `person_only`. Permission: `approvals.decide` (Every member). ### Responses - `200` OK (application/json, AgentWriteSetting) - `enabled` (boolean, required): Whether your agent links make the organization's allowed writes with no record per call - `403` Not your own session or key: an agent link or any other credential (`person_only`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `person_only` | An agent link gets 403 `person_only` | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/agent-writes" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Fagent-writes) ## Set agent writes `PUT /v1/policies/agent-writes` Turn your agents' writes on or off in this organization. On, your agent links make the connector writes the organization allows its agents, while it has them on, with no approval record per call; the agent's own mode decides whether it asks first. A `github` write runs as your own GitHub account (POST /v1/connections/github/oauth), never as the Nexus GitHub App: without one connected it is refused (403 `connection_required`). Off, a write needs a record you confirmed. Your own session or key only (`approvals.decide`): no agent link and no operator grant holds it. Audited as agent_write_setting.changed with the setting before and after. Permission: `approvals.decide` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `enabled` (boolean, required): Whether your agent links make the organization's allowed writes with no record per call ### Responses - `200` OK (application/json, AgentWriteSetting) - `enabled` (boolean, required): Whether your agent links make the organization's allowed writes with no record per call - `400` Not a setting (`invalid_setting`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not your own session or key: an agent link or any other credential (`person_only`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a setting (`invalid_setting`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `connection_required` | Without one connected it is refused (403 `connection_required`) | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/policies/agent-writes" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "enabled": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpolicies%2Fagent-writes) ## Create approval `POST /v1/approvals` Ask Policy for an approval record bound to one exact connector call: the person, this agent link, the connector, the operation and a SHA-256 of the arguments' canonical JSON (keys sorted at every depth, no spaces). It keeps the arguments, so the person sees them. It is pending, expires in 30 minutes and allows the call once, after the person confirms it in Nexus (`confirmUrl`). A chat agent's link only (`connectors.use`): any other caller gets 403 `agent_only`. Refused while chat writes are off (`chat_writes_off`) and for an operation the organization's allowlist does not name (`operation_not_allowed`). Audited as policy.approval.requested, with the hash and never the arguments. Permission: `connectors.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `connector` (string, required) [pattern ^[a-z][a-z0-9-]*$] - `operation` (string, required) [pattern ^[a-z][a-z0-9_-]*$] - `arguments` (object, required): The body the write will send, exactly ### Responses - `201` Created (application/json, Approval) - `id` (string, required) [pattern ^apr_[0-9a-f]{32}$] - `connector` (string, required) - `operation` (string, required) - `arguments` (object, required): The call's body, as stored: what the person confirms, and what the write must send - `argumentsHash` (string, required): SHA-256 of the arguments' canonical JSON [pattern ^[0-9a-f]{64}$] - `status` ("pending" | "confirmed" | "denied" | "used" | "expired", required) - `expired` (boolean, required): Its expiry passed: it can no longer be confirmed or used - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `decidedAt` (string (date-time)) - `decidedBy` ("person" | "agent"): Who decided it: the person (confirm or deny in Nexus), or the agent link that cancelled it - `usedAt` (string (date-time)) - `confirmUrl` (string (uri)): Nexus UI's page where the person confirms or denies it, when Gateway knows Nexus UI's URL (`NEXUS_UI_URL`) - `400` Not a body (`invalid_approval`), or the operation only reads (`not_a_write`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a chat agent's link (`agent_only`), chat writes are off (`chat_writes_off`), or the operation is not on the allowlist (`operation_not_allowed`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such connector operation (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a body (`invalid_approval`), or the operation only reads (`not_a_write`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `agent_only` | Any other caller gets 403 `agent_only` | | 404 | | No such connector operation | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/approvals" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "connector": "<connector>", "operation": "<operation>", "arguments": {} }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fapprovals) ## Get approval `GET /v1/approvals/{id}` One approval record, with its arguments. The agent link that asked (`connectors.use`), or its person from their own session or key: any other caller of the organization gets 404 `approval_not_found`, and a caller that is neither a link nor a person 403 `agent_only`. Permission: `connectors.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The approval's id (`apr_…`) | ### Responses - `200` OK (application/json, Approval) - `id` (string, required) [pattern ^apr_[0-9a-f]{32}$] - `connector` (string, required) - `operation` (string, required) - `arguments` (object, required): The call's body, as stored: what the person confirms, and what the write must send - `argumentsHash` (string, required): SHA-256 of the arguments' canonical JSON [pattern ^[0-9a-f]{64}$] - `status` ("pending" | "confirmed" | "denied" | "used" | "expired", required) - `expired` (boolean, required): Its expiry passed: it can no longer be confirmed or used - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `decidedAt` (string (date-time)) - `decidedBy` ("person" | "agent"): Who decided it: the person (confirm or deny in Nexus), or the agent link that cancelled it - `usedAt` (string (date-time)) - `confirmUrl` (string (uri)): Nexus UI's page where the person confirms or denies it, when Gateway knows Nexus UI's URL (`NEXUS_UI_URL`) - `403` Neither an agent link nor a person (`agent_only`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such approval of this link's or this person's (`approval_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `agent_only` | Any other caller of the organization gets 404 `approval_not_found`, and a caller that is neither a link nor a person 403 `agent_only` | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such approval of this link's or this person's (`approval_not_found`) | | 404 | `approval_not_found` | Any other caller of the organization gets 404 `approval_not_found`, and a caller that is neither a link nor a person 403 `agent_only` | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/approvals/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fapprovals%2F%7Bid%7D) ## Confirm approval `POST /v1/approvals/{id}/confirm` The record's person confirms it, once, before it expires, from their own session in Nexus UI or their own key (`approvals.decide`). An agent link never confirms: it gets 403 `person_only`, so a link cannot approve its own write. Another person's record is 404 `approval_not_found`. Confirmed again, it answers the stored record. Refused while chat writes are off, and for an operation the allowlist does not name. Audited as policy.approval.confirmed, with the person as its actor. Permission: `approvals.decide` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The approval's id (`apr_…`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, Approval) - `id` (string, required) [pattern ^apr_[0-9a-f]{32}$] - `connector` (string, required) - `operation` (string, required) - `arguments` (object, required): The call's body, as stored: what the person confirms, and what the write must send - `argumentsHash` (string, required): SHA-256 of the arguments' canonical JSON [pattern ^[0-9a-f]{64}$] - `status` ("pending" | "confirmed" | "denied" | "used" | "expired", required) - `expired` (boolean, required): Its expiry passed: it can no longer be confirmed or used - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `decidedAt` (string (date-time)) - `decidedBy` ("person" | "agent"): Who decided it: the person (confirm or deny in Nexus), or the agent link that cancelled it - `usedAt` (string (date-time)) - `confirmUrl` (string (uri)): Nexus UI's page where the person confirms or denies it, when Gateway knows Nexus UI's URL (`NEXUS_UI_URL`) - `403` An agent link or another credential that is no person (`person_only`), chat writes are off (`chat_writes_off`), or the operation is not on the allowlist (`operation_not_allowed`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such approval of this person's (`approval_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` Expired (`approval_expired`), or already decided another way or used (`approval_settled`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `person_only` | It gets 403 `person_only`, so a link cannot approve its own write | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such approval of this person's (`approval_not_found`) | | 404 | `approval_not_found` | Another person's record is 404 `approval_not_found` | | 409 | | Expired (`approval_expired`), or already decided another way or used (`approval_settled`) | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/approvals/<id>/confirm" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fapprovals%2F%7Bid%7D%2Fconfirm) ## Deny approval `POST /v1/approvals/{id}/deny` The record's person denies it, once, from their own session in Nexus UI or their own key (`approvals.decide`). An agent link gets 403 `person_only` and cancels instead. Another person's record is 404 `approval_not_found`. Denied again, it answers the stored record. Audited as policy.approval.denied. Permission: `approvals.decide` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The approval's id (`apr_…`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, Approval) - `id` (string, required) [pattern ^apr_[0-9a-f]{32}$] - `connector` (string, required) - `operation` (string, required) - `arguments` (object, required): The call's body, as stored: what the person confirms, and what the write must send - `argumentsHash` (string, required): SHA-256 of the arguments' canonical JSON [pattern ^[0-9a-f]{64}$] - `status` ("pending" | "confirmed" | "denied" | "used" | "expired", required) - `expired` (boolean, required): Its expiry passed: it can no longer be confirmed or used - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `decidedAt` (string (date-time)) - `decidedBy` ("person" | "agent"): Who decided it: the person (confirm or deny in Nexus), or the agent link that cancelled it - `usedAt` (string (date-time)) - `confirmUrl` (string (uri)): Nexus UI's page where the person confirms or denies it, when Gateway knows Nexus UI's URL (`NEXUS_UI_URL`) - `403` An agent link or another credential that is no person (`person_only`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such approval of this person's (`approval_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` Expired (`approval_expired`), or already decided another way or used (`approval_settled`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `person_only` | An agent link gets 403 `person_only` and cancels instead | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such approval of this person's (`approval_not_found`) | | 404 | `approval_not_found` | Another person's record is 404 `approval_not_found` | | 409 | | Expired (`approval_expired`), or already decided another way or used (`approval_settled`) | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/approvals/<id>/deny" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fapprovals%2F%7Bid%7D%2Fdeny) ## Cancel approval `POST /v1/approvals/{id}/cancel` The agent link that asked cancels its own pending record (`connectors.use`): it moves to denied, once. Cancelling never confirms, so it needs no person. Any other caller gets 403 `agent_only`, and another link's record is 404 `approval_not_found`. Cancelled again, it answers the stored record; a confirmed or used one is 409 `approval_settled`. Audited as policy.approval.cancelled. Permission: `connectors.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The approval's id (`apr_…`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, Approval) - `id` (string, required) [pattern ^apr_[0-9a-f]{32}$] - `connector` (string, required) - `operation` (string, required) - `arguments` (object, required): The call's body, as stored: what the person confirms, and what the write must send - `argumentsHash` (string, required): SHA-256 of the arguments' canonical JSON [pattern ^[0-9a-f]{64}$] - `status` ("pending" | "confirmed" | "denied" | "used" | "expired", required) - `expired` (boolean, required): Its expiry passed: it can no longer be confirmed or used - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `decidedAt` (string (date-time)) - `decidedBy` ("person" | "agent"): Who decided it: the person (confirm or deny in Nexus), or the agent link that cancelled it - `usedAt` (string (date-time)) - `confirmUrl` (string (uri)): Nexus UI's page where the person confirms or denies it, when Gateway knows Nexus UI's URL (`NEXUS_UI_URL`) - `403` Not a chat agent's link (`agent_only`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such approval of this link's (`approval_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` Already confirmed or used (`approval_settled`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `agent_only` | Any other caller gets 403 `agent_only`, and another link's record is 404 `approval_not_found` | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such approval of this link's (`approval_not_found`) | | 404 | `approval_not_found` | Any other caller gets 403 `agent_only`, and another link's record is 404 `approval_not_found` | | 409 | | Already confirmed or used (`approval_settled`) | | 409 | `approval_settled` | Cancelled again, it answers the stored record; a confirmed or used one is 409 `approval_settled` | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/approvals/<id>/cancel" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fapprovals%2F%7Bid%7D%2Fcancel) ## List operator controls `GET /v1/policies/controls` The operator controls in force (`policy.read`). Owners and admins see every unexpired control of the organization. A lead or member sees only the controls that apply to them: the organization's, those on every team they are in and the teams above them, their own and their key's. An expired control is not listed. Permission: `policy.read` (Every member). ### Responses - `200` OK (application/json, OperatorControls) - `controls` (array of OperatorControl, required) - `id` (string, required) - `tenantId` (string, required) - `kind` (string, required) - `subjectLevel` (string, required) - `subject` (string) - `models` (array of string) - `reason` (string, required) - `createdBy` (string) - `createdAt` (string, required) - `expiresAt` (string, required) - `403` The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The credential does not hold `policy.read`. Every person in the organization holds it; a service account or sandbox key does not (`role_required`), nor a scoped module key (`module_key`). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/controls" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Fcontrols) ## Set operator control `POST /v1/policies/controls` Put an operator control in force (owners and admins: `policy.manage`). A pause refuses every model call of its subject, a limit allows only the listed models and an override allows the listed models over the rules. A control expires at `expiresAt` and applies from the next decision. An unknown team, person or key answers 404. It is audited (policy.control_set). Permission: `policy.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `kind` ("pause" | "limit" | "override", required) - `level` ("organization" | "team" | "person" | "key", required) - `subject` (string): A team's slug, a user id or a key id. Ignored for `organization`. - `models` (array of string): Required for a `limit` or an `override`; not allowed for a `pause`. - `reason` (string, required) - `expiresAt` (string, required): An ISO 8601 time in the future. ### Responses - `201` Created (application/json, OperatorControl) - `id` (string, required) - `tenantId` (string, required) - `kind` (string, required) - `subjectLevel` (string, required) - `subject` (string) - `models` (array of string) - `reason` (string, required) - `createdBy` (string) - `createdAt` (string, required) - `expiresAt` (string, required) - `400` Not a valid control (`invalid_control`): an unknown kind, level or model, no reason, an expiry in the past, models on a pause, or none on a limit or an override. Also when the organization already holds 200 live controls. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller does not hold `policy.manage`: only owners and admins set an organization-wide control (`role_required`). Team leads use the team's controls route. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such team, person or key in this organization (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a valid control (`invalid_control`): an unknown kind, level or model, no reason, an expiry in the past, models on a pause, or none on a limit or an override. Also when the organization already holds 200 live controls. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins set an organization-wide control (`role_required`). Team leads use the team's controls route. | | 404 | | No such team, person or key in this organization | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/policies/controls" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "kind": "pause", "level": "organization", "reason": "<reason>", "expiresAt": "<expiresAt>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpolicies%2Fcontrols) ## Clear operator control `DELETE /v1/policies/controls/{id}` Take an operator control out of force (owners and admins: `policy.manage`). It answers with the cleared control. It is audited (policy.control_cleared). Permission: `policy.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The control's id | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, OperatorControl) - `id` (string, required) - `tenantId` (string, required) - `kind` (string, required) - `subjectLevel` (string, required) - `subject` (string) - `models` (array of string) - `reason` (string, required) - `createdBy` (string) - `createdAt` (string, required) - `expiresAt` (string, required) - `403` The caller does not hold `policy.manage`: only owners and admins clear a control here (`role_required`). Team leads use the team's controls route. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such control in this organization (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins clear a control here (`role_required`). Team leads use the team's controls route. | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such control in this organization | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/policies/controls/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fpolicies%2Fcontrols%2F%7Bid%7D) ## List team operator controls `GET /v1/policies/teams/{slug}/controls` The operator controls in force on a team, on the teams under it, and on the people and keys in them (owners and admins; a team lead for a team they lead). Controls on the organization and on the teams above it are not listed. An expired control is not listed. Permission: `policy.manage_team` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | ### Responses - `200` OK (application/json, OperatorControls) - `controls` (array of OperatorControl, required) - `id` (string, required) - `tenantId` (string, required) - `kind` (string, required) - `subjectLevel` (string, required) - `subject` (string) - `models` (array of string) - `reason` (string, required) - `createdBy` (string) - `createdAt` (string, required) - `expiresAt` (string, required) - `403` The caller is not an owner, an admin or a team lead (`role_required`), or the team is not one they lead (`outside_led_teams`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such team in this organization (`unknown_team`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such team in this organization (`unknown_team`) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/teams/platform/controls" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Fteams%2F%7Bslug%7D%2Fcontrols) ## Set team operator control `POST /v1/policies/teams/{slug}/controls` Put an operator control in force on a team, or on a person or key in it or in a team under it (owners and admins; a team lead for a team they lead, who may pause or limit but not override). It works as `setOperatorControl` otherwise. It is audited (policy.control_set). Permission: `policy.manage_team` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `kind` ("pause" | "limit" | "override", required) - `level` ("organization" | "team" | "person" | "key", required) - `subject` (string): A team's slug, a user id or a key id. Ignored for `organization`. - `models` (array of string): Required for a `limit` or an `override`; not allowed for a `pause`. - `reason` (string, required) - `expiresAt` (string, required): An ISO 8601 time in the future. ### Responses - `201` Created (application/json, OperatorControl) - `id` (string, required) - `tenantId` (string, required) - `kind` (string, required) - `subjectLevel` (string, required) - `subject` (string) - `models` (array of string) - `reason` (string, required) - `createdBy` (string) - `createdAt` (string, required) - `expiresAt` (string, required) - `400` Not a valid control (`invalid_control`): an unknown kind, level or model, no reason, an expiry in the past, models on a pause, or none on a limit or an override. Also when the organization already holds 200 live controls. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller is not an owner, an admin or a team lead (`role_required`), the team is not one they lead (`outside_led_teams`), the subject is outside the team and the teams under it (`outside_team`), or a lead asked for an override (`override_needs_admin`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such team in this organization (`unknown_team` for the team in the path), or no such team, person or key as the subject (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a valid control (`invalid_control`): an unknown kind, level or model, no reason, an expiry in the past, models on a pause, or none on a limit or an override. Also when the organization already holds 200 live controls. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such team in this organization (`unknown_team` for the team in the path), or no such team, person or key as the subject | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/policies/teams/platform/controls" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "kind": "pause", "level": "organization", "reason": "<reason>", "expiresAt": "<expiresAt>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpolicies%2Fteams%2F%7Bslug%7D%2Fcontrols) ## Clear team operator control `DELETE /v1/policies/teams/{slug}/controls/{id}` Take an operator control on a team, or on a person or key in it or in a team under it, out of force (owners and admins; a team lead for a team they lead, only a control that lead set and never an override). It answers with the cleared control. It is audited (policy.control_cleared). Permission: `policy.manage_team` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | | `id` | path | string | yes | The control's id | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, OperatorControl) - `id` (string, required) - `tenantId` (string, required) - `kind` (string, required) - `subjectLevel` (string, required) - `subject` (string) - `models` (array of string) - `reason` (string, required) - `createdBy` (string) - `createdAt` (string, required) - `expiresAt` (string, required) - `403` The caller is not an owner, an admin or a team lead (`role_required`), the team is not one they lead (`outside_led_teams`), the control's subject is outside the team and the teams under it (`outside_team`), a lead tried to clear an override (`override_needs_admin`), or a lead tried to clear a control someone else set (`control_needs_admin`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such team (`unknown_team`), or no such control in this organization (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such team (`unknown_team`), or no such control in this organization | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/policies/teams/platform/controls/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fpolicies%2Fteams%2F%7Bslug%7D%2Fcontrols%2F%7Bid%7D) ## List team keys `GET /v1/policies/teams/{slug}/keys` The live API keys of the people in a team and the teams under it (owners and admins; a team lead for a team they lead). Key-minted CLI tokens are not listed. Lets a lead pick a key to pause or limit. It grants no revoke. Permission: `policy.manage_team` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | | ### Responses - `200` OK (application/json, object) - `tokens` (array of Token) - `id` (string, required) - `userId` (string, required) - `kind` ("api" | "cli" | "ui", required) - `prefix` (string, required) - `label` (string) - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time)) - `current` (boolean) - `nextCursor` (string): Never set: this route returns every key in one page. - `403` The caller is not an owner, an admin or a team lead (`role_required`), the team is not one they lead (`outside_led_teams`), or the caller acts under an operator grant (`operator_scope`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such team in this organization (`unknown_team`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such team in this organization (`unknown_team`) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/policies/teams/platform/keys" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpolicies%2Fteams%2F%7Bslug%7D%2Fkeys) ## Connect `POST /v1/connections/{connector}` Connect an account with the connector's key form (GET /v1/connectors lists who may connect and the form). The vendor checks the key first; nothing it refuses is kept. `scope: org` connects the organization's account (owners and admins: `policy.manage`); otherwise it is yours, and the organization must have made the connector available to you. Connecting an account again replaces its credential. Audited as connector_credential.added or .replaced, with the last four characters only. Permission: `connections.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `connector` | path | string | yes | The connector (`jira`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `scope` ("user" | "org") [default "user"] ### Responses - `200` OK (application/json, object) - `connections` (array of Connection, required) - `connector` (string, required) - `scope` ("user" | "org", required): A person's own (user) or the organization's (org) - `scopeId` (string, required): The person's user id, or the organization's id - `account` (string, required): The vendor's stable id for the account (an Atlassian cloud id) - `name` (string, required): The account's name, as a call's `account` may name it - `data` (object): What reaches the account and is not secret (its host) - `identity` (string): Who the vendor says the holder is there - `status` ("active" | "needs_reconnect", required) - `suspended` (boolean, required): Its connector is in preview and this Gateway does not offer it: no call uses the connection until the connector is offered. It can still be disconnected - `kind` ("api_key" | "basic" | "oauth2" | "installation", required) - `last4` (string): The last four characters of its secret; never the secret - `scopes` (array of string) - `expiresAt` (string (date-time)) - `createdAt` (string (date-time), required) - `400` A field the form does not take, a host the vendor does not serve, or a key the vendor refused (`credential_refused`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The organization's needs an owner or admin (`role_required`); the connector is not available to you (`connector_disabled`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such connector (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` The vendor is rate limiting the check (`rate_limited`, with `retry_after`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The vendor failed the check (`upstream_error`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A field the form does not take, a host the vendor does not serve, or a key the vendor refused (`credential_refused`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such connector | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | The vendor is rate limiting the check (`rate_limited`, with `retry_after`) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | The vendor failed the check (`upstream_error`) | ### Example ```sh curl -X POST "$NEXUS_URL/v1/connections/<connector>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "scope": "user" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fconnections%2F%7Bconnector%7D) ## List connections `GET /v1/connections` Your own live connections and the organization's (what it may lend), never a secret. The organization's GitHub App installations are listed too, as its github connections (the account is the installation id). A member sees the organization's without whose account it is or its last four characters. Permission: `connections.manage_own` (Every member). ### Responses - `200` OK (application/json, object) - `connections` (array of Connection, required) - `connector` (string, required) - `scope` ("user" | "org", required): A person's own (user) or the organization's (org) - `scopeId` (string, required): The person's user id, or the organization's id - `account` (string, required): The vendor's stable id for the account (an Atlassian cloud id) - `name` (string, required): The account's name, as a call's `account` may name it - `data` (object): What reaches the account and is not secret (its host) - `identity` (string): Who the vendor says the holder is there - `status` ("active" | "needs_reconnect", required) - `suspended` (boolean, required): Its connector is in preview and this Gateway does not offer it: no call uses the connection until the connector is offered. It can still be disconnected - `kind` ("api_key" | "basic" | "oauth2" | "installation", required) - `last4` (string): The last four characters of its secret; never the secret - `scopes` (array of string) - `expiresAt` (string (date-time)) - `createdAt` (string (date-time), required) ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/connections" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fconnections) ## Disconnect `DELETE /v1/connections/{connector}/{account}` Disconnect your own connection to an account (or, with `scope=org`, the organization's: owners and admins). The account is named by its id, name or host. Its credential is revoked once no live connection uses it; an OAuth grant is then revoked at the vendor too, and `vendorRevoked` says whether the vendor confirmed it. Audited as connector_credential.revoked. Permission: `connections.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `connector` | path | string | yes | | | `account` | path | string | yes | The account's id, name or host | | `scope` | query | "user" \| "org" | no | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `400` The connector takes no connection at that scope: a GitHub installation is unlinked with DELETE /v1/github/installations/{id} (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No live connection to that account (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The connector takes no connection at that scope: a GitHub installation is unlinked with DELETE /v1/github/installations/{id} | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No live connection to that account | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/connections/<connector>/<account>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fconnections%2F%7Bconnector%7D%2F%7Baccount%7D) ## Start oauth connection `POST /v1/connections/{connector}/oauth` Start connecting an account with OAuth: the vendor's authorize URL, good once for ten minutes. `scope: org` connects the organization's (owners and admins); otherwise it is yours, and the organization must have made the connector available to you. The vendor returns the person to Nexus UI, which finishes with POST /v1/connections/oauth/finish. Permission: `connections.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `connector` | path | string | yes | The connector (`notion`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json) - `scope` ("user" | "org") [default "user"] - `access` ("read" | "write"): Only when the server asks for write scopes on demand (NEXUS_CONNECTOR_WRITE_CONSENT); otherwise refused with 400. `read` asks the vendor for the connector's reads only. `write` asks for its reads and its write scopes: send it after a write answered 403 `write_consent_required`. The new tokens replace the connection's. [default "read"] ### Responses - `200` OK (application/json, object) - `authorizeUrl` (string (uri), required) - `403` The organization's needs an owner or admin (`role_required`); the connector is not available to you (`connector_disabled`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such connector (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` This gateway has no OAuth app for the connector (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such connector | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | This gateway has no OAuth app for the connector (`not_configured`) | ### Example ```sh curl -X POST "$NEXUS_URL/v1/connections/<connector>/oauth" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "scope": "user", "access": "read" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fconnections%2F%7Bconnector%7D%2Foauth) ## Finish oauth connection `POST /v1/connections/oauth/finish` Finish connecting an account with OAuth: the vendor returned the person to Nexus UI (`/settings/connectors/oauth`), which hands back its `code` (or `error`) and `state` with the person's session. Only the person who started may finish, so an authorize link sent to someone else connects nothing; availability and role are checked again. The tokens are kept for the holder the state names. Permission: `connections.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `state` (string, required) - `code` (string) - `error` (string) - `realmId` (string): The company QuickBooks names on its return, which Gateway checks with the new token. Another vendor's return adds nothing. ### Responses - `200` OK (application/json, object) - `connector` (string) - `connections` (array of Connection) - `connector` (string, required) - `scope` ("user" | "org", required): A person's own (user) or the organization's (org) - `scopeId` (string, required): The person's user id, or the organization's id - `account` (string, required): The vendor's stable id for the account (an Atlassian cloud id) - `name` (string, required): The account's name, as a call's `account` may name it - `data` (object): What reaches the account and is not secret (its host) - `identity` (string): Who the vendor says the holder is there - `status` ("active" | "needs_reconnect", required) - `suspended` (boolean, required): Its connector is in preview and this Gateway does not offer it: no call uses the connection until the connector is offered. It can still be disconnected - `kind` ("api_key" | "basic" | "oauth2" | "installation", required) - `last4` (string): The last four characters of its secret; never the secret - `scopes` (array of string) - `expiresAt` (string (date-time)) - `createdAt` (string (date-time), required) - `400` No state (`oauth_state_missing`); a state Nexus did not issue, not yours, or already finished (`oauth_state_invalid`); the person declined (`oauth_denied`); the vendor refused the code, or the account it names (`credential_refused`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The organization's needs an owner or admin (`role_required`); the connector is no longer available to you (`connector_disabled`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` Your state is older than ten minutes (`oauth_state_invalid`): connect again (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | No state (`oauth_state_missing`); a state Nexus did not issue, not yours, or already finished (`oauth_state_invalid`); the person declined (`oauth_denied`); the vendor refused the code, or the account it names (`credential_refused`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | Your state is older than ten minutes (`oauth_state_invalid`): connect again | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/connections/oauth/finish" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "state": "…" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fconnections%2Foauth%2Ffinish) --- <!-- /docs/api/agents --> # Agents > `nexus claude` and `nexus codex`: model policy and sessions. The agents' model calls go through the agent gateway, where each is reserved, metered, checked against the organization's policy and attributed to the person and their session. ## Agent policy (deprecated) `GET /v1/agents/policy` Deprecated: an alias of `GET /v1/policies/agents/{agent}`. Allowed and default models for each coding agent (`provider/model` ids), as the model policy resolves them. An agent without a Gateway route (`antigravity`, `cursor`) allows none, and its `defaultModel` is empty. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, AgentPolicy) - `agents` (object) - `claude` (object) - `allowedModels` (array of string) - `defaultModel` (string) - `codex` (object) - `allowedModels` (array of string) - `defaultModel` (string) - `antigravity` (object) - `allowedModels` (array of string) - `defaultModel` (string) - `cursor` (object) - `allowedModels` (array of string) - `defaultModel` (string) - `opencode` (object) - `allowedModels` (array of string) - `defaultModel` (string) - `403` The credential does not hold `org.read`: a service account or sandbox key (`role_required`), or a scoped module key (`module_key`). Also `not_in_team` when `x-nexus-team` names a team the caller is not in. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` `x-nexus-team` names a team that does not exist in this organization (`unknown_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | `x-nexus-team` names a team that does not exist in this organization (`unknown_team`). | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/agents/policy" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fpolicy) ## Set agent policy alias (deprecated) `POST /v1/agents/policy` Deprecated: an alias that writes the agent's model policy: `allowedModels` becomes its allow list and `defaultModel` its default (a deny list already set stays). Permission: `policy.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode", required): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `allowedModels` (array of string, required) - `defaultModel` (string, required) ### Responses - `200` OK (application/json, object) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `allowedModels` (array of string) - `defaultModel` (string) - `400` `agent` is not `claude`, `codex`, `antigravity` or `cursor`, or `allowedModels` (a non-empty list) or `defaultModel` is missing (`invalid_request`); `agent` runs only on the person's own plan (`route_unsupported`); or the rule it makes is not valid (`invalid_policy`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller does not hold `policy.manage`: only owners and admins set the agent policy (`role_required`). A scoped module key gets `module_key`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `agent` is not `claude`, `codex`, `antigravity` or `cursor`, or `allowedModels` (a non-empty list) or `defaultModel` is missing (`invalid_request`); `agent` runs only on the person's own plan (`route_unsupported`); or the rule it makes is not valid (`invalid_policy`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | The caller does not hold `policy.manage`: only owners and admins set the agent policy (`role_required`). A scoped module key gets `module_key`. | | 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/agents/policy" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "agent": "claude", "allowedModels": [ "anthropic/claude-fable-5.1" ], "defaultModel": "anthropic/claude-fable-5.1" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Fpolicy) ## Check agent `POST /v1/agents/check` May the agent launch on this model (no model: what `nexus/default` resolves to)? The model policy's decision, the same the gateway makes on every call. An agent without a Gateway route (`antigravity`, `cursor`) is a 400 `route_unsupported`. Permission: `products.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) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode", required): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string): Model id (`provider/model`, the provider's own id, or nexus/auto); omit for the default ### Responses - `200` OK (application/json, AgentCheck) - `allowed` (boolean) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string | null) - `reason` (string) - `allowedModels` (array of string) - `defaultModel` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | `route_unsupported` | An agent without a Gateway route (`antigravity`, `cursor`) is a 400 `route_unsupported` | | 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/agents/check" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "agent": "claude" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.checkAgent("claude"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Fcheck) ## Route agent `POST /v1/agents/route` Auto for a coding agent's session before it starts: the model, who pays and why. A signed-in plan with room comes first; a paid model is only returned as `ask_for_paid_fallback`, for the client to confirm. A dry run: it opens no session and holds no money. A model the policy refuses is never returned. Permission: `products.use` (Every member). ### Request body (application/json, required) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode" | "auto", required): The agent to start, or auto for Auto to pick among agents - `agents` (array of "claude" | "codex" | "antigravity" | "cursor" | "opencode"): With agent auto: the person's agents Auto may pick from. Ignored otherwise [at most 8 items] - `team` (string): Team slug or id; omit for the caller's default - `model` (string): A pinned model: Auto then picks only who pays - `plans` (array of object): The plan accounts the agent is signed in to on this machine [at most 8 items] - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): The agent the account is signed in to; required with agent auto - `account` (integer, required): The client's handle for the account, never an email [min 0] - `models` (array of object, required) [at most 64 items] - `id` (string, required): The agent's own id or the catalog id - `room` ("left" | "usedUp" | "unknown", required): Every limit window that applies to the model, folded: usedUp when any is used up, unknown when a reading is missing or old - `counts` (object): The first prompt as counts, never its text; omit before the first prompt - `inputTokens` (integer) [min 0] - `codeBlocks` (integer) [min 0] - `images` (boolean) ### Responses - `200` OK (application/json, AgentLaunchRoute) - `result` ("use_plan" | "ask_for_paid_fallback" | "stop", required) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode" | "auto", required): The agent to start; auto on a stop of an agent auto request - `version` (string, required): The auto router version that chose - `reason` (string, required): Plan_at_floor, plan_below_floor, paid_at_floor, paid_below_floor or pinned; for stop: no_classifier, no_offer or pinned_unavailable - `class` ("light" | "standard" | "heavy") - `model` (string): Canonical model id - `providerModel` (string | null): The id to start the agent with - `effort` (string | null) - `payer` ("plan" | "local_key" | "gateway") - `account` (integer | null): The plan account handle the request named - `access` ("byok" | "nexus" | null): Who pays on Gateway - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/agents/route" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "agent": "claude" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Froute) ## List agent sessions `GET /v1/agents/sessions` This tenant's coding-agent sessions, newest first. Permission: `spend.read_own` (Every member). ### Responses - `200` OK (application/json, object) - `sessions` (array of AgentSession) - `id` (string) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string) - `via` ("nexus" | "subscription" | "ori"): Nexus: every model call through Gateway's agent gateway; subscription: the person's own plan (Claude Code on their Claude login, Codex on their ChatGPT login), calls straight to the vendor, usage as the agent reported it; ori: sessions from before the agent gateway - `access` ("subscription" | "byok" | "nexus"): Who pays its model calls, as Gateway classified the session when it opened: subscription (the person's own plan), byok (the organization's own provider key, through Gateway) or nexus (Nexus's own key, for Nexus's own organizations; Nexus credit no longer pays an agent). Absent for ori, for sessions from before, and when no key would pay (Gateway refuses those calls). - `person` (string) - `cwd` (string) - `startedAt` (string (date-time)) - `endedAt` (string (date-time)) - `durationMs` (number) - `exitCode` (integer) - `signal` (string) - `agentSessionId` (string): The agent's own conversation id: `nexus claude --resume <id>` or `nexus codex resume <id>` picks it up again. [pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$] - `status` ("running" | "succeeded" | "failed" | "interrupted" | "lost") - `usage` (object): Subscription sessions, once the agent has reported: its calls summed. estimatedCostUsd is the list-price estimate of the priced calls (Claude Code's own, the catalog's for Codex), never charged; unpricedCalls counts the calls with no estimate - `calls` (integer) - `inputTokens` (integer) - `outputTokens` (integer) - `cacheReadTokens` (integer) - `cacheCreationTokens` (integer) - `estimatedCostUsd` (number) - `unpricedCalls` (integer): Calls with no estimate, because the agent stated no cost or the call names no model the catalog lists - `models` (array of string) - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `spend.read_own` (`role_required`: a service account, a sandbox, or an agent not granted it). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `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/agents/sessions" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.agentSessions(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fsessions) ## Open agent session `POST /v1/agents/sessions` Open a session before launching an agent. Through the gateway (via nexus, the default) the model is checked on every call; via ori (sessions from before the agent gateway) it is checked here (403 if not allowed). Permission: `products.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) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode", required): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `via` ("nexus" | "subscription" | "ori"): Nexus (default): the agent runs through the agent gateway; subscription: on the person's own Claude login, usage reported by Claude Code; ori: sessions from before the agent gateway - `model` (string): The model the agent was started on, as the agent names it; omit for the agent's default - `person` (string): Who runs it, e.g. the OS user [max length 80] - `cwd` (string): Working directory; only its basename is kept - `team` (string): A team slug you are in; default: your default team - `plan` (string): The plan tier of the person's own account, as the app read it on the device. claude: free, pro, max, team, enterprise or unknown; codex (ChatGPT): free, plus, pro, team, enterprise or unknown. Any other string is kept as unknown: a plan never refuses a session. Kept only where plan collection is on, and never shown on GET /v1/agents/sessions. Never send the raw string, an account id or an email. ### Responses - `201` Created (application/json, AgentSession) - `id` (string) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string) - `via` ("nexus" | "subscription" | "ori"): Nexus: every model call through Gateway's agent gateway; subscription: the person's own plan (Claude Code on their Claude login, Codex on their ChatGPT login), calls straight to the vendor, usage as the agent reported it; ori: sessions from before the agent gateway - `access` ("subscription" | "byok" | "nexus"): Who pays its model calls, as Gateway classified the session when it opened: subscription (the person's own plan), byok (the organization's own provider key, through Gateway) or nexus (Nexus's own key, for Nexus's own organizations; Nexus credit no longer pays an agent). Absent for ori, for sessions from before, and when no key would pay (Gateway refuses those calls). - `person` (string) - `cwd` (string) - `startedAt` (string (date-time)) - `endedAt` (string (date-time)) - `durationMs` (number) - `exitCode` (integer) - `signal` (string) - `agentSessionId` (string): The agent's own conversation id: `nexus claude --resume <id>` or `nexus codex resume <id>` picks it up again. [pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$] - `status` ("running" | "succeeded" | "failed" | "interrupted" | "lost") - `usage` (object): Subscription sessions, once the agent has reported: its calls summed. estimatedCostUsd is the list-price estimate of the priced calls (Claude Code's own, the catalog's for Codex), never charged; unpricedCalls counts the calls with no estimate - `calls` (integer) - `inputTokens` (integer) - `outputTokens` (integer) - `cacheReadTokens` (integer) - `cacheCreationTokens` (integer) - `estimatedCostUsd` (number) - `unpricedCalls` (integer): Calls with no estimate, because the agent stated no cost or the call names no model the catalog lists - `models` (array of string) - `400` The body is not valid: `agent` not claude, codex, antigravity or cursor, `via` not nexus, subscription or ori, `model`, `person` or `cwd` not a string, `team` not a slug, or a bad `Idempotency-Key`; or `via` nexus or ori for an agent that runs only on the person's own plan (`route_unsupported`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `products.use` (`role_required`: a service account, a sandbox, or an agent not granted it), the team named is not the caller's (`not_in_team`), or the organization turned subscription sessions off (`subscriptions_disabled`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` The team named does not exist in this organization (`unknown_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The `Idempotency-Key`'s first request still runs (`idempotency_in_progress`) or was interrupted (`idempotency_interrupted`). The request does not run again. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `422` The `Idempotency-Key` was used for a different request (`idempotency_key_reused`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not valid: `agent` not claude, codex, antigravity or cursor, `via` not nexus, subscription or ori, `model`, `person` or `cwd` not a string, `team` not a slug, or a bad `Idempotency-Key`; or `via` nexus or ori for an agent that runs only on the person's own plan (`route_unsupported`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | The team named does not exist in this organization (`unknown_team`). | | 409 | | The `Idempotency-Key`'s first request still runs (`idempotency_in_progress`) or was interrupted (`idempotency_interrupted`). The request does not run again. | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | | The `Idempotency-Key` was used for a different request (`idempotency_key_reused`). | | 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/agents/sessions" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "agent": "claude" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.openAgentSession({ agent: "claude", via: "nexus", team: "platform" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Fsessions) ## Get agent session `GET /v1/agents/sessions/{id}` One coding-agent session with what its metered calls cost: yours, or any of the organization's for an owner or admin. Anyone else gets 404, as for an unknown id. Permission: `spend.read_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id | ### Responses - `200` OK (application/json, AgentSessionWithSpend) - `id` (string) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string) - `via` ("nexus" | "subscription" | "ori"): Nexus: every model call through Gateway's agent gateway; subscription: the person's own plan (Claude Code on their Claude login, Codex on their ChatGPT login), calls straight to the vendor, usage as the agent reported it; ori: sessions from before the agent gateway - `access` ("subscription" | "byok" | "nexus"): Who pays its model calls, as Gateway classified the session when it opened: subscription (the person's own plan), byok (the organization's own provider key, through Gateway) or nexus (Nexus's own key, for Nexus's own organizations; Nexus credit no longer pays an agent). Absent for ori, for sessions from before, and when no key would pay (Gateway refuses those calls). - `person` (string) - `cwd` (string) - `startedAt` (string (date-time)) - `endedAt` (string (date-time)) - `durationMs` (number) - `exitCode` (integer) - `signal` (string) - `agentSessionId` (string): The agent's own conversation id: `nexus claude --resume <id>` or `nexus codex resume <id>` picks it up again. [pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$] - `status` ("running" | "succeeded" | "failed" | "interrupted" | "lost") - `usage` (object): Subscription sessions, once the agent has reported: its calls summed. estimatedCostUsd is the list-price estimate of the priced calls (Claude Code's own, the catalog's for Codex), never charged; unpricedCalls counts the calls with no estimate - `calls` (integer) - `inputTokens` (integer) - `outputTokens` (integer) - `cacheReadTokens` (integer) - `cacheCreationTokens` (integer) - `estimatedCostUsd` (number) - `unpricedCalls` (integer): Calls with no estimate, because the agent stated no cost or the call names no model the catalog lists - `models` (array of string) - `spend` (object, required): What the calls metered to this session cost (refused calls left out); zero without calls. - `usd` (number, required) [min 0] - `calls` (integer, required) [min 0] - `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/agents/sessions/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fsessions%2F%7Bid%7D) ## Export agent sessions CSV `GET /v1/agents/sessions/export.csv` Every coding-agent session of the organization that matches the filters, as CSV (owners and admins). Nexus Gateway keeps an organization's newest 500 sessions, so an older one is in no file. At most 100,000 rows a file: past that the file stops, and its manifest says `complete: false` and gives `nextCursor`. Each export is an audit event (`observability.exported`) with the file's manifest, never its rows. An organization runs at most 60 exports an hour: the 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's). A bad filter is a 400 before any row. Permission: `spend.export` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `from` | query | string (date) | no | The first UTC day a session started, YYYY-MM-DD; default 29 days before `to` | | `to` | query | string (date) | no | The last UTC day a session started, YYYY-MM-DD, included; default today. A range covers at most 366 days | | `team` | query | string | no | A team slug or id: that team and every team under it; `unassigned` for sessions with no team | | `person` | query | string | no | A person's user id | | `agent` | query | "claude" \| "codex" \| "antigravity" \| "cursor" \| "opencode" | no | `claude`, `codex`, `antigravity` or `cursor` | | `via` | query | "nexus" \| "subscription" \| "ori" | no | `nexus`, `subscription` or `ori` | | `status` | query | string | no | A comma-separated set of `running`, `succeeded`, `failed` and `interrupted`; default all four | | `cursor` | query | string | no | A cut file's `manifest.nextCursor`: the next file of the same query. A manifest's `watermark` also works: it starts the same series again. It is bound to the organization, the caller and the query: anywhere else it is a 400 `invalid_cursor` | ### Responses - `200` CSV with a header row: one column per field of `AgentSessionRow`, in its order. (text/csv, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `export_rate_limited` | The 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/agents/sessions/export.csv" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.agentSessionsExport("csv", { agent: "claude" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fsessions%2Fexport.csv) ## Export agent sessions JSON Lines `GET /v1/agents/sessions/export.jsonl` Every coding-agent session of the organization that matches the filters, as JSON Lines (owners and admins). Nexus Gateway keeps an organization's newest 500 sessions, so an older one is in no file. At most 100,000 rows a file: past that the file stops, and its manifest says `complete: false` and gives `nextCursor`. Each export is an audit event (`observability.exported`) with the file's manifest, never its rows. An organization runs at most 60 exports an hour: the 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's). A bad filter is a 400 before any row. Permission: `spend.export` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `from` | query | string (date) | no | The first UTC day a session started, YYYY-MM-DD; default 29 days before `to` | | `to` | query | string (date) | no | The last UTC day a session started, YYYY-MM-DD, included; default today. A range covers at most 366 days | | `team` | query | string | no | A team slug or id: that team and every team under it; `unassigned` for sessions with no team | | `person` | query | string | no | A person's user id | | `agent` | query | "claude" \| "codex" \| "antigravity" \| "cursor" \| "opencode" | no | `claude`, `codex`, `antigravity` or `cursor` | | `via` | query | "nexus" \| "subscription" \| "ori" | no | `nexus`, `subscription` or `ori` | | `status` | query | string | no | A comma-separated set of `running`, `succeeded`, `failed` and `interrupted`; default all four | | `cursor` | query | string | no | A cut file's `manifest.nextCursor`: the next file of the same query. A manifest's `watermark` also works: it starts the same series again. It is bound to the organization, the caller and the query: anywhere else it is a 400 `invalid_cursor` | ### Responses - `200` JSON Lines: one `AgentSessionRow` per line, then one line `{"manifest": ExportManifest}`. (application/jsonl, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `export_rate_limited` | The 61st is a 429 `export_rate_limited`, whose `Retry-After` is the seconds until the hour frees one (the `RateLimit-*` headers stay the per-minute limit's) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/agents/sessions/export.jsonl" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.agentSessionsExport("jsonl", { agent: "claude" }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fsessions%2Fexport.jsonl) ## End agent session `POST /v1/agents/sessions/{id}/end` Close a session with the agent's exit code and duration. Permission: `products.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `exitCode` (integer, required) [min 0; max 255] - `durationMs` (number) [min 0] - `signal` (string) - `agentSessionId` (string): The agent's own conversation id (Claude Code's session id, Codex's rollout id), so the session can be resumed. [pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$] ### Responses - `200` OK (application/json, AgentSession) - `id` (string) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string) - `via` ("nexus" | "subscription" | "ori"): Nexus: every model call through Gateway's agent gateway; subscription: the person's own plan (Claude Code on their Claude login, Codex on their ChatGPT login), calls straight to the vendor, usage as the agent reported it; ori: sessions from before the agent gateway - `access` ("subscription" | "byok" | "nexus"): Who pays its model calls, as Gateway classified the session when it opened: subscription (the person's own plan), byok (the organization's own provider key, through Gateway) or nexus (Nexus's own key, for Nexus's own organizations; Nexus credit no longer pays an agent). Absent for ori, for sessions from before, and when no key would pay (Gateway refuses those calls). - `person` (string) - `cwd` (string) - `startedAt` (string (date-time)) - `endedAt` (string (date-time)) - `durationMs` (number) - `exitCode` (integer) - `signal` (string) - `agentSessionId` (string): The agent's own conversation id: `nexus claude --resume <id>` or `nexus codex resume <id>` picks it up again. [pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$] - `status` ("running" | "succeeded" | "failed" | "interrupted" | "lost") - `usage` (object): Subscription sessions, once the agent has reported: its calls summed. estimatedCostUsd is the list-price estimate of the priced calls (Claude Code's own, the catalog's for Codex), never charged; unpricedCalls counts the calls with no estimate - `calls` (integer) - `inputTokens` (integer) - `outputTokens` (integer) - `cacheReadTokens` (integer) - `cacheCreationTokens` (integer) - `estimatedCostUsd` (number) - `unpricedCalls` (integer): Calls with no estimate, because the agent stated no cost or the call names no model the catalog lists - `models` (array of string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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 POST "$NEXUS_URL/v1/agents/sessions/<id>/end" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "exitCode": 0, "signal": "SIGINT" }' ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.endAgentSession("<session id>", { exitCode: 0, durationMs: 42_000 }); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Fsessions%2F%7Bid%7D%2Fend) ## Heartbeat agent session `POST /v1/agents/sessions/{id}/heartbeat` Say the agent still runs. The CLI sends one every 5 minutes; a running session with none for 15 minutes reads as lost until the next one or its end. Permission: `products.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, AgentSession) - `id` (string) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode"): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `model` (string) - `via` ("nexus" | "subscription" | "ori"): Nexus: every model call through Gateway's agent gateway; subscription: the person's own plan (Claude Code on their Claude login, Codex on their ChatGPT login), calls straight to the vendor, usage as the agent reported it; ori: sessions from before the agent gateway - `access` ("subscription" | "byok" | "nexus"): Who pays its model calls, as Gateway classified the session when it opened: subscription (the person's own plan), byok (the organization's own provider key, through Gateway) or nexus (Nexus's own key, for Nexus's own organizations; Nexus credit no longer pays an agent). Absent for ori, for sessions from before, and when no key would pay (Gateway refuses those calls). - `person` (string) - `cwd` (string) - `startedAt` (string (date-time)) - `endedAt` (string (date-time)) - `durationMs` (number) - `exitCode` (integer) - `signal` (string) - `agentSessionId` (string): The agent's own conversation id: `nexus claude --resume <id>` or `nexus codex resume <id>` picks it up again. [pattern ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$] - `status` ("running" | "succeeded" | "failed" | "interrupted" | "lost") - `usage` (object): Subscription sessions, once the agent has reported: its calls summed. estimatedCostUsd is the list-price estimate of the priced calls (Claude Code's own, the catalog's for Codex), never charged; unpricedCalls counts the calls with no estimate - `calls` (integer) - `inputTokens` (integer) - `outputTokens` (integer) - `cacheReadTokens` (integer) - `cacheCreationTokens` (integer) - `estimatedCostUsd` (number) - `unpricedCalls` (integer): Calls with no estimate, because the agent stated no cost or the call names no model the catalog lists - `models` (array of string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/agents/sessions/<id>/heartbeat" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Fsessions%2F%7Bid%7D%2Fheartbeat) ## Report agent session usage `POST /v1/agents/sessions/{id}/usage` Usage from a subscription session as an OpenTelemetry logs export (OTLP/HTTP JSON). Cursor sessions return 409 `usage_unsupported`. A record whose event.name (else its body) is api_request or claude_code.api_request counts as one model call. A request_id seen among the session's last 512 does not count again. Codex's codex.sse_event for response.completed counts too, once per conversation.id and event.timestamp. Other records are dropped unread. A body without resourceLogs is a 400. Permission: `products.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `resourceLogs` (array of object) ### Responses - `200` OK: an OTLP ExportLogsServiceResponse, empty, or with partialSuccess counting the entries that were not log objects (application/json, object) - `partialSuccess` (object) - `rejectedLogRecords` (integer) - `errorMessage` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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 | `usage_unsupported` | Cursor sessions return 409 `usage_unsupported` | | 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/agents/sessions/<id>/usage" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "resourceLogs": [ {} ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Fsessions%2F%7Bid%7D%2Fusage) ## Get agent access `GET /v1/agents/access` Routes for coding agents with a released Nexus launcher: for each agent, the route it takes when you name none (`from`: your preference, the default, or the organization when it turned subscriptions off), each route with who pays (the organization's own key, Nexus, or your plan), whether it can run, and the commands that install and sign in the agent. Permission: `products.use` (Every member). ### Responses - `200` OK (application/json, AgentAccess) - `agentSubscriptions` (boolean, required): Whether the organization allows subscription routes (GET/PUT /v1/orgs/settings) - `agents` (array of AgentAccessEntry, required) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode", required): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `name` (string, required) - `install` (string, required): How to install the agent (the vendor's own package; Nexus never installs it) - `route` ("gateway" | "subscription", required): The route it takes when the person names none - `from` ("preference" | "default" | "organization", required): Why: the person's preference, the default (gateway), or the organization (subscriptions turned off while the person prefers one) - `preference` ("gateway" | "subscription"): The person's saved route; absent when none - `routes` (array of AgentRoute, required) - `route` ("gateway" | "subscription", required) - `access` ("byok" | "nexus" | "subscription" | null, required): Who pays on this route: byok (the organization's own key), nexus (a key Nexus pays for) or subscription (the person's plan); null on gateway when no key would pay - `available` (boolean, required): Whether the route can run now; reason says why not - `reason` (string): Why it cannot, and the command that fixes it - `provider` (string): Gateway: the provider Gateway calls - `plan` (string): Subscription: the plan it runs on - `vendor` (string) - `login` (string): Subscription: how to sign the agent in to the plan, once, on the person's machine - `loginStatus` (string): Subscription: how to check that sign-in - `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/agents/access" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Faccess) ## Set agent access `PUT /v1/agents/access` Choose the route each of your coding agents takes when you name none (`nexus agents use`), in every client: `gateway` or `subscription`; null forgets it (the default: subscription, or gateway when the organization turned subscription mode off). Yours in every organization, not audited (each session records its route). 403 `subscriptions_disabled` for a subscription the organization turned off; 400 `route_unsupported` for the gateway route of an agent that runs only on the person's own plan; 400 for a key-only organization key (a route belongs to a person). Permission: `products.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) - `claude` ("gateway" | "subscription" | null) - `codex` ("gateway" | "subscription" | null) - `antigravity` ("subscription" | null): Antigravity runs only on the person's Google AI plan: `gateway` is a 400 `route_unsupported`. - `cursor` ("subscription" | null): Cursor runs only on the person's Cursor plan: `gateway` is a 400 `route_unsupported`. - `opencode` ("subscription" | null): OpenCode uses its configured provider. Gateway refuses `gateway` with `route_unsupported`. ### Responses - `200` OK (application/json, AgentAccess) - `agentSubscriptions` (boolean, required): Whether the organization allows subscription routes (GET/PUT /v1/orgs/settings) - `agents` (array of AgentAccessEntry, required) - `agent` ("claude" | "codex" | "antigravity" | "cursor" | "opencode", required): A coding agent's id. It names the agent in sessions, policies and routes. Its command may differ: `antigravity` runs as `nexus agy`. - `name` (string, required) - `install` (string, required): How to install the agent (the vendor's own package; Nexus never installs it) - `route` ("gateway" | "subscription", required): The route it takes when the person names none - `from` ("preference" | "default" | "organization", required): Why: the person's preference, the default (gateway), or the organization (subscriptions turned off while the person prefers one) - `preference` ("gateway" | "subscription"): The person's saved route; absent when none - `routes` (array of AgentRoute, required) - `route` ("gateway" | "subscription", required) - `access` ("byok" | "nexus" | "subscription" | null, required): Who pays on this route: byok (the organization's own key), nexus (a key Nexus pays for) or subscription (the person's plan); null on gateway when no key would pay - `available` (boolean, required): Whether the route can run now; reason says why not - `reason` (string): Why it cannot, and the command that fixes it - `provider` (string): Gateway: the provider Gateway calls - `plan` (string): Subscription: the plan it runs on - `vendor` (string) - `login` (string): Subscription: how to sign the agent in to the plan, once, on the person's machine - `loginStatus` (string): Subscription: how to check that sign-in - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | `route_unsupported` | 403 `subscriptions_disabled` for a subscription the organization turned off; 400 `route_unsupported` for the gateway route of an agent that runs only on the person's own plan; 400 for a key-only organization key (a route belongs to a person) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `subscriptions_disabled` | 403 `subscriptions_disabled` for a subscription the organization turned off; 400 `route_unsupported` for the gateway route of an agent that runs only on the person's own plan; 400 for a key-only organization key (a route belongs to a person) | | 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/agents/access" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "claude": "subscription", "codex": null }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fagents%2Faccess) ## List assistant conversations `GET /v1/agents/conversations` The Nexus assistant's conversations of yours, newest change first, without their messages. `limit` is 1 to 100 (30 when absent); `after` is the last page's `next`; `archived=true` includes archived ones; `externalKey` answers only the live conversation under that key, if any. Your own conversations only: the organization and the person come from the credential, never from the request, and another person's is a 404. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS). Permission: `agents.memory` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `after` | query | string | no | The `next` of the page before | | `limit` | query | integer | no | | | `archived` | query | boolean | no | | | `externalKey` | query | string | no | Only the live conversation under this key, such as `slack:T1:C1:1712.34` | ### Responses - `200` OK (application/json, AssistantConversationList) - `conversations` (array of AssistantConversation, required) - `id` (string, required) - `title` (string, required) - `externalKey` (string | null, required): What the conversation continues, when its creator named it - `messageCount` (integer, required) - `createdAt` (string, required) - `updatedAt` (string, required) - `archivedAt` (string | null, required) - `next` (string | null, required): The `after` of the next page; null on the last - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `assistant_conversations_off` | Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS) | | 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/agents/conversations" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fconversations) ## Create assistant conversation `POST /v1/agents/conversations` Starts a conversation, or returns your live one under the same `externalKey` (200, `created: false`). 201 for a new one. A person holds at most 1000 live conversations (413 assistant_conversations_full). Your own conversations only: the organization and the person come from the credential, never from the request, and another person's is a 404. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS). Permission: `agents.memory` (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) - `title` (string) [max length 200] - `externalKey` (string) [min length 1; max length 256] ### Responses - `200` The live conversation under the same externalKey (application/json, AssistantConversationCreated) - `id` (string, required) - `title` (string, required) - `externalKey` (string | null, required): What the conversation continues, when its creator named it - `messageCount` (integer, required) - `createdAt` (string, required) - `updatedAt` (string, required) - `archivedAt` (string | null, required) - `created` (boolean, required): False when the externalKey already named a live conversation - `201` Created (application/json, AssistantConversationCreated) - `id` (string, required) - `title` (string, required) - `externalKey` (string | null, required): What the conversation continues, when its creator named it - `messageCount` (integer, required) - `createdAt` (string, required) - `updatedAt` (string, required) - `archivedAt` (string | null, required) - `created` (boolean, required): False when the externalKey already named a live conversation - `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 | `assistant_conversations_off` | Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS) | | 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/agents/conversations" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "title": "<title>", "externalKey": "<externalKey>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Fconversations) ## Get assistant conversation `GET /v1/agents/conversations/{id}` One conversation and a page of its messages, in order. `after` is the number of the last message you read (the first page when absent); `limit` is 1 to 500 (100 when absent); `nextAfter` is the `after` of the next page. Your own conversations only: the organization and the person come from the credential, never from the request, and another person's is a 404. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS). Permission: `agents.memory` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | A conversation's id, as the list or the create answered it (404 assistant_conversation_not_found) | | `after` | query | integer | no | | | `limit` | query | integer | no | | ### Responses - `200` OK (application/json, AssistantConversationPage) - `id` (string, required) - `title` (string, required) - `externalKey` (string | null, required): What the conversation continues, when its creator named it - `messageCount` (integer, required) - `createdAt` (string, required) - `updatedAt` (string, required) - `archivedAt` (string | null, required) - `messages` (array of AssistantMessage, required) - `seq` (integer, required) [min 0] - `role` ("user" | "assistant" | "tool", required) - `content` (any, required): Any JSON but null, as it was written - `createdAt` (string, required) - `nextAfter` (integer | null, required): The `after` of the next page of messages; null on the last - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | `assistant_conversations_off` | Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS) | | 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/agents/conversations/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fconversations%2F%7Bid%7D) ## Rename assistant conversation `PATCH /v1/agents/conversations/{id}` Renames a conversation: a title of at most 200 characters. Your own conversations only: the organization and the person come from the credential, never from the request, and another person's is a 404. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS). Permission: `agents.memory` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | A conversation's id, as the list or the create answered it (404 assistant_conversation_not_found) | | `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) - `title` (string, required) [max length 200] ### Responses - `200` OK (application/json, AssistantConversation) - `id` (string, required) - `title` (string, required) - `externalKey` (string | null, required): What the conversation continues, when its creator named it - `messageCount` (integer, required) - `createdAt` (string, required) - `updatedAt` (string, required) - `archivedAt` (string | 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 | | 404 | `assistant_conversations_off` | Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS) | | 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/agents/conversations/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "title": "<title>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Fagents%2Fconversations%2F%7Bid%7D) ## Append assistant messages `POST /v1/agents/conversations/{id}/messages` Appends messages, numbered from 0, each one after the one before. Idempotent by `seq`: a message the conversation already holds with the same role and content changes nothing, so a retried batch is safe; other content at a held `seq` is a 409 assistant_seq_conflict, a `seq` past the next one a 409 assistant_seq_gap (`nextSeq` in the error), and an archived conversation takes no new message (409 assistant_conversation_archived). 1 to 100 messages of at most 256 KiB each; a conversation holds at most 5000 (413). Content is stored readable, not sealed. Your own conversations only: the organization and the person come from the credential, never from the request, and another person's is a 404. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS). Permission: `agents.memory` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | A conversation's id, as the list or the create answered it (404 assistant_conversation_not_found) | | `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) - `messages` (array of NewAssistantMessage, required) [at most 100 items] - `seq` (integer, required) [min 0] - `role` ("user" | "assistant" | "tool", required) - `content` (any, required): Any JSON but null; at most 256 KiB ### Responses - `200` OK (application/json, AssistantMessagesAppended) - `written` (integer, required): How many messages the append wrote; the ones already held do not count - `nextSeq` (integer, required): The number the next message takes - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | `assistant_conversations_off` | Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS) | | 409 | `seq` | A message the conversation already holds with the same role and content changes nothing, so a retried batch is safe; other content at a held `seq` is a 409 assistant_seq_conflict, a `seq` past the next one a 409 assistant_seq_gap (`nextSeq` in the error), and an archived conversation takes no new message (409 assistant_conversation_archived) | | 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/agents/conversations/<id>/messages" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "messages": [ { "seq": 0, "role": "user" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Fconversations%2F%7Bid%7D%2Fmessages) ## Archive assistant conversation `POST /v1/agents/conversations/{id}/archive` Archives a conversation: it leaves the default list, keeps its messages, and takes no new ones. Archiving again changes nothing. Nothing is deleted; account deletion and a member's removal delete conversations. Your own conversations only: the organization and the person come from the credential, never from the request, and another person's is a 404. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS). Permission: `agents.memory` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | A conversation's id, as the list or the create answered it (404 assistant_conversation_not_found) | | `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, AssistantConversation) - `id` (string, required) - `title` (string, required) - `externalKey` (string | null, required): What the conversation continues, when its creator named it - `messageCount` (integer, required) - `createdAt` (string, required) - `updatedAt` (string, required) - `archivedAt` (string | 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 | | 404 | `assistant_conversations_off` | Off, every call is a 404 `assistant_conversations_off` (NEXUS_ASSISTANT_CONVERSATIONS) | | 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/agents/conversations/<id>/archive" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Fconversations%2F%7Bid%7D%2Farchive) ## Clear agent memory `DELETE /v1/agents/memory` Delete every row of your agent memory in this organization: forget, unlink and uninstall. Audited as `agent.memory_cleared` when a row went. Your own rows only: the organization and the person come from the credential, never from the request. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Permission: `agents.memory` (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). | ### Responses - `200` OK (application/json, AgentMemoryCleared) - `deleted` (integer, required): How many rows went [min 0] - `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 | | 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/agents/memory" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fagents%2Fmemory) ## List agent memory `GET /v1/agents/memory/{collection}` One page of your agent memory's keys in a collection, in byte order, with their versions and no values. `limit` is 1 to 1000 (100 when absent; 400 agent_memory_limit_invalid); `after` is the last key of the page before (`next`). Your own rows only: the organization and the person come from the credential, never from the request. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Permission: `agents.memory` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `collection` | path | string | yes | 1 to 64 characters: a lowercase letter, then lowercase letters, digits, _ or - (400 agent_memory_collection_invalid) | | `after` | query | string | no | The `next` of the page before | | `limit` | query | integer | no | | ### Responses - `200` OK (application/json, AgentMemoryKeys) - `collection` (string, required) - `keys` (array of AgentMemoryEntry, required) - `key` (string, required) - `version` (integer, required): What a later write names in If-Match. It never repeats, also after a delete. [min 1] - `updatedAt` (string (date-time), required) - `next` (string | null, required): The `after` of the next page; null on the last - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/agents/memory/<collection>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fmemory%2F%7Bcollection%7D) ## Get agent memory `GET /v1/agents/memory/{collection}/{key}` One row of your agent memory: the value as the agent sealed it, and its version (also the `ETag`). 404 agent_memory_not_found when there is none. Your own rows only: the organization and the person come from the credential, never from the request. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Permission: `agents.memory` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `collection` | path | string | yes | 1 to 64 characters: a lowercase letter, then lowercase letters, digits, _ or - (400 agent_memory_collection_invalid) | | `key` | path | string | yes | 1 to 256 characters of A-Z, a-z, 0-9, ., _, ~ and -, and not . or .. (400 agent_memory_key_invalid). Encode any other key, as base64url. | ### Responses - `200` OK (application/json, AgentMemoryRow) - `collection` (string, required) - `key` (string, required) - `value` (string, required): The agent's sealed text, as it wrote it - `version` (integer, required): What a later write names in If-Match. It never repeats, also after a delete. [min 1] - `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/agents/memory/<collection>/<key>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fmemory%2F%7Bcollection%7D%2F%7Bkey%7D) ## Set agent memory `PUT /v1/agents/memory/{collection}/{key}` Write one row of your agent memory, if it is as you read it: `If-Match: <version>` replaces the row at that version, and `If-None-Match: *` creates it. With neither, a 428 agent_memory_precondition_required. A write that loses a race, or creates a row that exists, is a 409 agent_memory_version_conflict, and nothing changes. The value is the agent's sealed text, 1 byte to 256 KiB (413 agent_memory_value_too_large); Gateway never opens it. You hold at most 1000 rows and 8 MiB in an organization (413 agent_memory_full). Versions never repeat, also after a delete. Audited as `agent.memory_written`, without the value. Your own rows only: the organization and the person come from the credential, never from the request. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Permission: `agents.memory` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `collection` | path | string | yes | 1 to 64 characters: a lowercase letter, then lowercase letters, digits, _ or - (400 agent_memory_collection_invalid) | | `key` | path | string | yes | 1 to 256 characters of A-Z, a-z, 0-9, ., _, ~ and -, and not . or .. (400 agent_memory_key_invalid). Encode any other key, as base64url. | | `If-Match` | header | string | no | The version the write read (`"12"` or `12`, the row's `ETag`). The write happens only while the row is at it. | | `If-None-Match` | header | "*" | no | `*`: create the row, only when none exists. | | `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 agent's sealed text, at most 256 KiB [min length 1] ### Responses - `200` Written (application/json, AgentMemoryWritten) - `collection` (string, required) - `key` (string, required) - `version` (integer, required): What a later write names in If-Match. It never repeats, also after a delete. [min 1] - `created` (boolean, required): True when the write made the row (If-None-Match: *) - `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/agents/memory/<collection>/<key>" \ -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%2Fagents%2Fmemory%2F%7Bcollection%7D%2F%7Bkey%7D) ## Delete agent memory `DELETE /v1/agents/memory/{collection}/{key}` Delete one row of your agent memory; with `If-Match`, only at that version (409 agent_memory_version_conflict otherwise). Without it, a missing row is a 404 agent_memory_not_found. Audited as `agent.memory_deleted`. Your own rows only: the organization and the person come from the credential, never from the request. The person, or their own agent link that holds `agents.memory` (on the person's opt-in); any other caller answers 403, and no operator grant names it. Permission: `agents.memory` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `collection` | path | string | yes | 1 to 64 characters: a lowercase letter, then lowercase letters, digits, _ or - (400 agent_memory_collection_invalid) | | `key` | path | string | yes | 1 to 256 characters of A-Z, a-z, 0-9, ., _, ~ and -, and not . or .. (400 agent_memory_key_invalid). Encode any other key, as base64url. | | `If-Match` | header | string | no | The version the write read (`"12"` or `12`, the row's `ETag`). The write happens only while the row is at it. | | `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, AgentMemoryDeleted) - `collection` (string, required) - `key` (string, required) - `version` (integer, required): The version the row had - `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/agents/memory/<collection>/<key>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fagents%2Fmemory%2F%7Bcollection%7D%2F%7Bkey%7D) ## List agent state `GET /v1/agents/state/{collection}` One page of the agents service's keys in a collection, in byte order, with their versions and no values. `limit` is 1 to 1000 (100 when absent; 400 agent_memory_limit_invalid); `after` is the last key of the page before (`next`). The agents service only, with its platform secret in `x-nexus-agents-secret`: no person, key, agent link or operator of an organization reaches these rows, and every other route refuses the secret with a 403. Gateway never opens a value, and writes no audit event: the rows belong to no organization. Permission: `chat_apps.runtime` (). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `collection` | path | string | yes | 1 to 64 characters: a lowercase letter, then lowercase letters, digits, _ or - (400 agent_memory_collection_invalid) | | `after` | query | string | no | The `next` of the page before | | `limit` | query | integer | no | | ### Responses - `200` OK (application/json, AgentMemoryKeys) - `collection` (string, required) - `keys` (array of AgentMemoryEntry, required) - `key` (string, required) - `version` (integer, required): What a later write names in If-Match. It never repeats, also after a delete. [min 1] - `updatedAt` (string (date-time), required) - `next` (string | null, required): The `after` of the next page; null on the last - `400` The platform secret came with another credential, or twice (`credential_conflict`); or a bad collection, key, limit or precondition (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential, or a wrong platform secret (`missing_credential`, `invalid_credential`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Any other credential: a person's token, an agent link, a service account key, a module key or Nexus UI's secret (`agents_secret_refused`, `role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The Gateway holds no platform secret (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The platform secret came with another credential, or twice (`credential_conflict`); or a bad collection, key, limit or precondition | | 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 | | 503 | | The Gateway holds no platform secret (`not_configured`) | ### Example ```sh curl "$NEXUS_URL/v1/agents/state/<collection>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fstate%2F%7Bcollection%7D) ## Get agent state `GET /v1/agents/state/{collection}/{key}` One row of the agents service's own state (its links, journal and approvals): the value as the agent sealed it, and its version (also the `ETag`). 404 agent_memory_not_found when there is none. The agents service only, with its platform secret in `x-nexus-agents-secret`: no person, key, agent link or operator of an organization reaches these rows, and every other route refuses the secret with a 403. Gateway never opens a value, and writes no audit event: the rows belong to no organization. Permission: `chat_apps.runtime` (). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `collection` | path | string | yes | 1 to 64 characters: a lowercase letter, then lowercase letters, digits, _ or - (400 agent_memory_collection_invalid) | | `key` | path | string | yes | 1 to 256 characters of A-Z, a-z, 0-9, ., _, ~ and -, and not . or .. (400 agent_memory_key_invalid). Encode any other key, as base64url. | ### Responses - `200` OK (application/json, AgentMemoryRow) - `collection` (string, required) - `key` (string, required) - `value` (string, required): The agent's sealed text, as it wrote it - `version` (integer, required): What a later write names in If-Match. It never repeats, also after a delete. [min 1] - `updatedAt` (string (date-time), required) - `400` The platform secret came with another credential, or twice (`credential_conflict`); or a bad collection, key, limit or precondition (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential, or a wrong platform secret (`missing_credential`, `invalid_credential`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Any other credential: a person's token, an agent link, a service account key, a module key or Nexus UI's secret (`agents_secret_refused`, `role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The Gateway holds no platform secret (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | The platform secret came with another credential, or twice (`credential_conflict`); or a bad collection, key, limit or precondition | | 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 | | 503 | | The Gateway holds no platform secret (`not_configured`) | ### Example ```sh curl "$NEXUS_URL/v1/agents/state/<collection>/<key>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fstate%2F%7Bcollection%7D%2F%7Bkey%7D) ## Set agent state `PUT /v1/agents/state/{collection}/{key}` Write one row of the agents service's own state, if it is as the agent read it: `If-Match: <version>` replaces the row at that version, and `If-None-Match: *` creates it. With neither, a 428 agent_memory_precondition_required. A write that loses a race, or creates a row that exists, is a 409 agent_memory_version_conflict, and nothing changes. The value is the agent's sealed text, 1 byte to 256 KiB (413 agent_memory_value_too_large). A collection holds at most 100000 rows (413 agent_state_full). Versions never repeat, also after a delete. The agents service only, with its platform secret in `x-nexus-agents-secret`: no person, key, agent link or operator of an organization reaches these rows, and every other route refuses the secret with a 403. Gateway never opens a value, and writes no audit event: the rows belong to no organization. Permission: `chat_apps.runtime` (). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `collection` | path | string | yes | 1 to 64 characters: a lowercase letter, then lowercase letters, digits, _ or - (400 agent_memory_collection_invalid) | | `key` | path | string | yes | 1 to 256 characters of A-Z, a-z, 0-9, ., _, ~ and -, and not . or .. (400 agent_memory_key_invalid). Encode any other key, as base64url. | | `If-Match` | header | string | no | The version the write read (`"12"` or `12`, the row's `ETag`). The write happens only while the row is at it. | | `If-None-Match` | header | "*" | no | `*`: create the row, only when none exists. | | `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 agent's sealed text, at most 256 KiB [min length 1] ### Responses - `200` Written (application/json, AgentMemoryWritten) - `collection` (string, required) - `key` (string, required) - `version` (integer, required): What a later write names in If-Match. It never repeats, also after a delete. [min 1] - `created` (boolean, required): True when the write made the row (If-None-Match: *) - `updatedAt` (string (date-time), required) - `400` The platform secret came with another credential, or twice (`credential_conflict`); or a bad collection, key, limit or precondition (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential, or a wrong platform secret (`missing_credential`, `invalid_credential`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Any other credential: a person's token, an agent link, a service account key, a module key or Nexus UI's secret (`agents_secret_refused`, `role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The Gateway holds no platform secret (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The platform secret came with another credential, or twice (`credential_conflict`); or a bad collection, key, limit or precondition | | 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 | | 503 | | The Gateway holds no platform secret (`not_configured`) | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/agents/state/<collection>/<key>" \ -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%2Fagents%2Fstate%2F%7Bcollection%7D%2F%7Bkey%7D) ## Delete agent state `DELETE /v1/agents/state/{collection}/{key}` Delete one row of the agents service's own state at the version `If-Match: <version>` names (409 agent_memory_version_conflict when the row is at another version, or gone). Without `If-Match`, a 428 agent_memory_precondition_required: several processes share these rows, so a delete names what it read. The agents service only, with its platform secret in `x-nexus-agents-secret`: no person, key, agent link or operator of an organization reaches these rows, and every other route refuses the secret with a 403. Gateway never opens a value, and writes no audit event: the rows belong to no organization. Permission: `chat_apps.runtime` (). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `collection` | path | string | yes | 1 to 64 characters: a lowercase letter, then lowercase letters, digits, _ or - (400 agent_memory_collection_invalid) | | `key` | path | string | yes | 1 to 256 characters of A-Z, a-z, 0-9, ., _, ~ and -, and not . or .. (400 agent_memory_key_invalid). Encode any other key, as base64url. | | `If-Match` | header | string | no | The version the write read (`"12"` or `12`, the row's `ETag`). The write happens only while the row is at it. | | `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, AgentMemoryDeleted) - `collection` (string, required) - `key` (string, required) - `version` (integer, required): The version the row had - `400` The platform secret came with another credential, or twice (`credential_conflict`); or a bad collection, key, limit or precondition (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential, or a wrong platform secret (`missing_credential`, `invalid_credential`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Any other credential: a person's token, an agent link, a service account key, a module key or Nexus UI's secret (`agents_secret_refused`, `role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The Gateway holds no platform secret (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | The platform secret came with another credential, or twice (`credential_conflict`); or a bad collection, key, limit or precondition | | 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 | | 503 | | The Gateway holds no platform secret (`not_configured`) | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/agents/state/<collection>/<key>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fagents%2Fstate%2F%7Bcollection%7D%2F%7Bkey%7D) ## Get agent profile `GET /v1/agents/profiles/{id}` One agent profile you see. The person, or their own agent link that holds `agents.profiles` (on the person's opt-in); no operator grant names it. Another person's personal agent is a 404 agent_profile_not_found. 503 not_configured when Gateway has no database. Permission: `agents.profiles` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The profile's id (`agp_…`) | ### Responses - `200` OK (application/json, AgentProfile) - `name` (string): The display name: plain text without <, > or @. Not Nexus nor an admin's name (400 agent_profile_name_reserved), except that a personal agent may keep its own name, Nexus [min length 1; max length 40] - `avatar` (string | null): An emoji, a :shortcode: or an https image URL with no credentials (400 agent_profile_avatar_invalid) [max length 512] - `tone` ("calm" | "warm" | "direct" | "lively" | "custom" | null): A tone preset; custom leaves the tone to the instructions. null: the agent's own - `greeting` (string | null): One short line the agent says first in a conversation; control characters stripped (400 agent_profile_greeting_invalid) [max length 200] - `language` (string | null): A BCP-47 tag the agent answers in by default, such as es or pt-BR (400 agent_profile_language_invalid) [max length 35; pattern ^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$] - `labels` (array of string): Short labels that sort, route and filter agents; repeats are dropped [at most 8 items] - `instructions` (string): The owner's guidance, added to the agent's system prompt below its own rules [max length 4000] - `tools` (array of string | null): Null: every tool the agent's link holds. A list: only these connectors or connector.operation ids; an empty list offers none [at most 64 items] - `proactivity` ("always" | "ask_first" | "never"): W4.3's levels: whether the agent may start something the person did not ask for - `length` (integer | null): How much the agent says: 0 brief to 100 detailed. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `formality` (integer | null): How formal the agent is: 0 casual to 100 formal. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `humour` (integer | null): How much humour the agent uses: 0 none to 100 some. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `emoji` (boolean | null): Emoji in the agent's answers. null: off - `shortTexts` (boolean | null): Shorter answers by text and push than in the app. null: on - `id` (string, required) - `owner` ("person" | "team", required): Person: a personal agent. team: a company agent, on that team's budget and policy - `ownerId` (string, required): The person's user id, or the team's id - `teamSlug` (string): A company agent's team slug, while the team exists - `createdBy` (string, required): The user id of the person who created it - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/agents/profiles/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fprofiles%2F%7Bid%7D) ## Set agent profile `PUT /v1/agents/profiles/{id}` Replace an agent profile's fields; its owner never changes. The name is 1 to 40 characters of plain text, never Nexus nor a name that passes for an admin, except that a personal agent may keep its own name, Nexus (agent_profile_name_invalid, agent_profile_name_reserved). At most 8 labels (agent_profile_label_invalid), instructions of at most 4000 characters (agent_profile_instructions_invalid), and at most 64 tools, each a connector Gateway has or one of its operations (agent_profile_tool_invalid, agent_profile_tool_unknown). The tools narrow what the agent offers and never widen it: Policy still decides each call. Audited as `agent.profile_updated`, with the labels and never the instructions. Only a person, never an agent link: your own personal agent, and as an owner or admin a company agent (403 agent_profile_admin_required otherwise). No operator grant names it. 503 not_configured when Gateway has no database. Permission: `agents.profiles_manage` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The profile's id (`agp_…`) | | `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): The display name: plain text without <, > or @. Not Nexus nor an admin's name (400 agent_profile_name_reserved), except that a personal agent may keep its own name, Nexus [min length 1; max length 40] - `avatar` (string | null): An emoji, a :shortcode: or an https image URL with no credentials (400 agent_profile_avatar_invalid) [max length 512] - `tone` ("calm" | "warm" | "direct" | "lively" | "custom" | null): A tone preset; custom leaves the tone to the instructions. null: the agent's own - `greeting` (string | null): One short line the agent says first in a conversation; control characters stripped (400 agent_profile_greeting_invalid) [max length 200] - `language` (string | null): A BCP-47 tag the agent answers in by default, such as es or pt-BR (400 agent_profile_language_invalid) [max length 35; pattern ^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$] - `labels` (array of string): Short labels that sort, route and filter agents; repeats are dropped [at most 8 items] - `instructions` (string): The owner's guidance, added to the agent's system prompt below its own rules [max length 4000] - `tools` (array of string | null): Null: every tool the agent's link holds. A list: only these connectors or connector.operation ids; an empty list offers none [at most 64 items] - `proactivity` ("always" | "ask_first" | "never"): W4.3's levels: whether the agent may start something the person did not ask for - `length` (integer | null): How much the agent says: 0 brief to 100 detailed. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `formality` (integer | null): How formal the agent is: 0 casual to 100 formal. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `humour` (integer | null): How much humour the agent uses: 0 none to 100 some. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `emoji` (boolean | null): Emoji in the agent's answers. null: off - `shortTexts` (boolean | null): Shorter answers by text and push than in the app. null: on ### Responses - `200` OK (application/json, AgentProfile) - `name` (string): The display name: plain text without <, > or @. Not Nexus nor an admin's name (400 agent_profile_name_reserved), except that a personal agent may keep its own name, Nexus [min length 1; max length 40] - `avatar` (string | null): An emoji, a :shortcode: or an https image URL with no credentials (400 agent_profile_avatar_invalid) [max length 512] - `tone` ("calm" | "warm" | "direct" | "lively" | "custom" | null): A tone preset; custom leaves the tone to the instructions. null: the agent's own - `greeting` (string | null): One short line the agent says first in a conversation; control characters stripped (400 agent_profile_greeting_invalid) [max length 200] - `language` (string | null): A BCP-47 tag the agent answers in by default, such as es or pt-BR (400 agent_profile_language_invalid) [max length 35; pattern ^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$] - `labels` (array of string): Short labels that sort, route and filter agents; repeats are dropped [at most 8 items] - `instructions` (string): The owner's guidance, added to the agent's system prompt below its own rules [max length 4000] - `tools` (array of string | null): Null: every tool the agent's link holds. A list: only these connectors or connector.operation ids; an empty list offers none [at most 64 items] - `proactivity` ("always" | "ask_first" | "never"): W4.3's levels: whether the agent may start something the person did not ask for - `length` (integer | null): How much the agent says: 0 brief to 100 detailed. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `formality` (integer | null): How formal the agent is: 0 casual to 100 formal. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `humour` (integer | null): How much humour the agent uses: 0 none to 100 some. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `emoji` (boolean | null): Emoji in the agent's answers. null: off - `shortTexts` (boolean | null): Shorter answers by text and push than in the app. null: on - `id` (string, required) - `owner` ("person" | "team", required): Person: a personal agent. team: a company agent, on that team's budget and policy - `ownerId` (string, required): The person's user id, or the team's id - `teamSlug` (string): A company agent's team slug, while the team exists - `createdBy` (string, required): The user id of the person who created it - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/agents/profiles/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "name": "Platform", "avatar": "<avatar>", "tone": "calm", "greeting": "<greeting>", "language": "<language>", "labels": [ "CI" ], "instructions": "<instructions>", "tools": [ "<tool>" ], "proactivity": "always", "length": 0, "formality": 0, "humour": 0, "emoji": false, "shortTexts": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fagents%2Fprofiles%2F%7Bid%7D) ## Delete agent profile `DELETE /v1/agents/profiles/{id}` Delete an agent profile. Audited as `agent.profile_deleted`. Only a person, never an agent link: your own personal agent, and as an owner or admin a company agent (403 agent_profile_admin_required otherwise). No operator grant names it. 503 not_configured when Gateway has no database. Permission: `agents.profiles_manage` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The profile's id (`agp_…`) | | `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` Deleted - `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/agents/profiles/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fagents%2Fprofiles%2F%7Bid%7D) ## List agent profiles `GET /v1/agents/profiles` Your agents' profiles, by name: your own personal agent and every company agent in the organization. The person, or their own agent link that holds `agents.profiles` (on the person's opt-in); no operator grant names it. Another person's personal agent is a 404 agent_profile_not_found. 503 not_configured when Gateway has no database. Permission: `agents.profiles` (Every member). ### Responses - `200` OK (application/json, AgentProfileList) - `data` (array of AgentProfile, required) - `name` (string): The display name: plain text without <, > or @. Not Nexus nor an admin's name (400 agent_profile_name_reserved), except that a personal agent may keep its own name, Nexus [min length 1; max length 40] - `avatar` (string | null): An emoji, a :shortcode: or an https image URL with no credentials (400 agent_profile_avatar_invalid) [max length 512] - `tone` ("calm" | "warm" | "direct" | "lively" | "custom" | null): A tone preset; custom leaves the tone to the instructions. null: the agent's own - `greeting` (string | null): One short line the agent says first in a conversation; control characters stripped (400 agent_profile_greeting_invalid) [max length 200] - `language` (string | null): A BCP-47 tag the agent answers in by default, such as es or pt-BR (400 agent_profile_language_invalid) [max length 35; pattern ^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$] - `labels` (array of string): Short labels that sort, route and filter agents; repeats are dropped [at most 8 items] - `instructions` (string): The owner's guidance, added to the agent's system prompt below its own rules [max length 4000] - `tools` (array of string | null): Null: every tool the agent's link holds. A list: only these connectors or connector.operation ids; an empty list offers none [at most 64 items] - `proactivity` ("always" | "ask_first" | "never"): W4.3's levels: whether the agent may start something the person did not ask for - `length` (integer | null): How much the agent says: 0 brief to 100 detailed. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `formality` (integer | null): How formal the agent is: 0 casual to 100 formal. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `humour` (integer | null): How much humour the agent uses: 0 none to 100 some. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `emoji` (boolean | null): Emoji in the agent's answers. null: off - `shortTexts` (boolean | null): Shorter answers by text and push than in the app. null: on - `id` (string, required) - `owner` ("person" | "team", required): Person: a personal agent. team: a company agent, on that team's budget and policy - `ownerId` (string, required): The person's user id, or the team's id - `teamSlug` (string): A company agent's team slug, while the team exists - `createdBy` (string, required): The user id of the person who created it - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/agents/profiles" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagents%2Fprofiles) ## Create agent profile `POST /v1/agents/profiles` Create an agent profile: without `team`, your personal agent; with `team` (a slug or id), a company agent that answers on that team's budget and policy (404 unknown_team). One profile per owner (409 agent_profile_exists). The name is 1 to 40 characters of plain text, never Nexus nor a name that passes for an admin, except that a personal agent may keep its own name, Nexus (agent_profile_name_invalid, agent_profile_name_reserved). At most 8 labels (agent_profile_label_invalid), instructions of at most 4000 characters (agent_profile_instructions_invalid), and at most 64 tools, each a connector Gateway has or one of its operations (agent_profile_tool_invalid, agent_profile_tool_unknown). The tools narrow what the agent offers and never widen it: Policy still decides each call. Audited as `agent.profile_created`, with the labels and never the instructions. Only a person, never an agent link: your own personal agent, and as an owner or admin a company agent (403 agent_profile_admin_required otherwise). No operator grant names it. 503 not_configured when Gateway has no database. Permission: `agents.profiles_manage` (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): The display name: plain text without <, > or @. Not Nexus nor an admin's name (400 agent_profile_name_reserved), except that a personal agent may keep its own name, Nexus [min length 1; max length 40] - `avatar` (string | null): An emoji, a :shortcode: or an https image URL with no credentials (400 agent_profile_avatar_invalid) [max length 512] - `tone` ("calm" | "warm" | "direct" | "lively" | "custom" | null): A tone preset; custom leaves the tone to the instructions. null: the agent's own - `greeting` (string | null): One short line the agent says first in a conversation; control characters stripped (400 agent_profile_greeting_invalid) [max length 200] - `language` (string | null): A BCP-47 tag the agent answers in by default, such as es or pt-BR (400 agent_profile_language_invalid) [max length 35; pattern ^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$] - `labels` (array of string): Short labels that sort, route and filter agents; repeats are dropped [at most 8 items] - `instructions` (string): The owner's guidance, added to the agent's system prompt below its own rules [max length 4000] - `tools` (array of string | null): Null: every tool the agent's link holds. A list: only these connectors or connector.operation ids; an empty list offers none [at most 64 items] - `proactivity` ("always" | "ask_first" | "never"): W4.3's levels: whether the agent may start something the person did not ask for - `length` (integer | null): How much the agent says: 0 brief to 100 detailed. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `formality` (integer | null): How formal the agent is: 0 casual to 100 formal. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `humour` (integer | null): How much humour the agent uses: 0 none to 100 some. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `emoji` (boolean | null): Emoji in the agent's answers. null: off - `shortTexts` (boolean | null): Shorter answers by text and push than in the app. null: on - `team` (string): A team's slug or id: a company agent for that team. Absent: your personal agent ### Responses - `201` Created (application/json, AgentProfile) - `name` (string): The display name: plain text without <, > or @. Not Nexus nor an admin's name (400 agent_profile_name_reserved), except that a personal agent may keep its own name, Nexus [min length 1; max length 40] - `avatar` (string | null): An emoji, a :shortcode: or an https image URL with no credentials (400 agent_profile_avatar_invalid) [max length 512] - `tone` ("calm" | "warm" | "direct" | "lively" | "custom" | null): A tone preset; custom leaves the tone to the instructions. null: the agent's own - `greeting` (string | null): One short line the agent says first in a conversation; control characters stripped (400 agent_profile_greeting_invalid) [max length 200] - `language` (string | null): A BCP-47 tag the agent answers in by default, such as es or pt-BR (400 agent_profile_language_invalid) [max length 35; pattern ^[A-Za-z]{2,3}(-[A-Za-z0-9]{1,8})*$] - `labels` (array of string): Short labels that sort, route and filter agents; repeats are dropped [at most 8 items] - `instructions` (string): The owner's guidance, added to the agent's system prompt below its own rules [max length 4000] - `tools` (array of string | null): Null: every tool the agent's link holds. A list: only these connectors or connector.operation ids; an empty list offers none [at most 64 items] - `proactivity` ("always" | "ask_first" | "never"): W4.3's levels: whether the agent may start something the person did not ask for - `length` (integer | null): How much the agent says: 0 brief to 100 detailed. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `formality` (integer | null): How formal the agent is: 0 casual to 100 formal. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `humour` (integer | null): How much humour the agent uses: 0 none to 100 some. null: its tone's own (400 agent_profile_personality_invalid) [min 0; max 100] - `emoji` (boolean | null): Emoji in the agent's answers. null: off - `shortTexts` (boolean | null): Shorter answers by text and push than in the app. null: on - `id` (string, required) - `owner` ("person" | "team", required): Person: a personal agent. team: a company agent, on that team's budget and policy - `ownerId` (string, required): The person's user id, or the team's id - `teamSlug` (string): A company agent's team slug, while the team exists - `createdBy` (string, required): The user id of the person who created it - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/agents/profiles" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "name": "Platform", "avatar": "<avatar>", "tone": "calm", "greeting": "<greeting>", "language": "<language>", "labels": [ "CI" ], "instructions": "<instructions>", "tools": [ "<tool>" ], "proactivity": "always", "length": 0, "formality": 0, "humour": 0, "emoji": false, "shortTexts": false, "team": "platform" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagents%2Fprofiles) --- <!-- /docs/api/agent-gateway --> # Agent gateway > The Anthropic Messages API and the OpenAI Responses API, passed through to the provider. Authenticate with a personal Nexus token (`nexus auth login`) or API key (`Authorization: Bearer` or `x-api-key`); any member may call. Requests and responses, streaming included, are the providers' own; errors use the provider's error shape. Every call is reserved before it is forwarded and settled on the reported usage; a call over budget is refused with 402. ## Anthropic messages `POST /v1/anthropic/v1/messages` Anthropic Messages API (Claude Code: ANTHROPIC_BASE_URL=<core>/v1/anthropic). Metered. Permission: `agents.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-team` | header | string | no | The team (slug) this call's spend goes to; you must be in it (`nexus claude --team`). Default: your default team. | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) object: the provider's own request. ### Responses - `200` The provider's response: JSON, or server-sent events when the request streams. (application/json, object) - `400` The request is not valid: for example, it has no `model`, or its body is not UTF-8, not a JSON object, or repeats a field. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, ProviderError) - `401` No key (`missing_credential`; send `Authorization: Bearer <key>` or `x-api-key`), or a key Gateway does not accept (`invalid_credential`). (application/json, ProviderError) - `402` The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. Its `error.nexus` is a BudgetRefusal: each money figure with its exact decimal twin. (application/json, ProviderError) - `403` `model_not_allowed`: the model is refused by a model policy (the message names the level and rule; `error.nexus` carries them), or the organization has no provider key (`provider_key_required`: Nexus credit never pays a pass-through call); or the team in `x-nexus-team` is not the caller's (`not_in_team`). `provider_disabled`: the organization has turned off every provider that serves the model. (application/json, ProviderError) - `404` `model_not_found`: not in the model catalog; or the team in `x-nexus-team` does not exist (`unknown_team`). (application/json, ProviderError) - `408` The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). (application/json, ProviderError) - `409` The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. (application/json, ProviderError) - `413` The request body is over 32,000,000 bytes, the agent gateway's limit (`request_too_large`). (application/json, ProviderError) - `422` The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). (application/json, ProviderError) - `426` The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. (application/json, ProviderError) - `429` Over the caller's rate limit, in the provider's error shape: 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, ProviderError) - `502` The provider could not be reached, or the connection to it failed (`api_error`). (application/json, ProviderError) - `503` The provider's or the Gateway's own; every one may be retried. The provider's: its own 503 passes through as it wrote it, with its `retry-after` (OpenAI's overload; Anthropic's is a 529, not a 503); `/metrics` and the request log count it as `upstream_overloaded`. Retry after its wait, or try another model. The Gateway's, in the provider's error shape: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); it stopped before the call answered (`gateway_stopping`, send the call again: it reaches a running Gateway); or its database is busy (`database_busy`: nothing was committed, retry shortly). (application/json, ProviderError) - `504` The provider passed one of the call's deadlines (`upstream_timeout`; `nexus.phase` names which). (application/json, ProviderError) ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid: for example, it has no `model`, or its body is not UTF-8, not a JSON object, or repeats a field. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. Its `error.nexus` is a BudgetRefusal: each money figure with its exact decimal twin. | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | `model_not_allowed`: the model is refused by a model policy (the message names the level and rule; `error.nexus` carries them), or the organization has no provider key (`provider_key_required`: Nexus credit never pays a pass-through call); or the team in `x-nexus-team` is not the caller's (`not_in_team`). `provider_disabled`: the organization has turned off every provider that serves the model. | | 404 | | `model_not_found`: not in the model catalog; or the team in `x-nexus-team` does not exist (`unknown_team`). | | 408 | | The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). | | 409 | | The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 413 | | The request body is over 32,000,000 bytes, the agent gateway's limit (`request_too_large`). | | 422 | | The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 426 | | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | | 429 | | Over the caller's rate limit, in the provider's error shape: retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | The provider could not be reached, or the connection to it failed (`api_error`). | | 503 | | The provider's or the Gateway's own; every one may be retried. The provider's: its own 503 passes through as it wrote it, with its `retry-after` (OpenAI's overload; Anthropic's is a 529, not a 503); `/metrics` and the request log count it as `upstream_overloaded`. Retry after its wait, or try another model. The Gateway's, in the provider's error shape: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); it stopped before the call answered (`gateway_stopping`, send the call again: it reaches a running Gateway); or its database is busy (`database_busy`: nothing was committed, retry shortly). | | 504 | | The provider passed one of the call's deadlines (`upstream_timeout`; `nexus.phase` names which). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/anthropic/v1/messages" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-opus-5-5", "max_tokens": 1024, "messages": [ { "role": "user", "content": "Hello" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fanthropic%2Fv1%2Fmessages) ## Anthropic count tokens `POST /v1/anthropic/v1/messages/count_tokens` Anthropic token counting. Free (not metered), but checked against the model policies like every call. Permission: `agents.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) object: the provider's own request. ### Responses - `200` The provider's response: JSON, or server-sent events when the request streams. (application/json, object) - `400` The request is not valid: for example, it has no `model`, or its body is not UTF-8, not a JSON object, or repeats a field. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, ProviderError) - `401` No key (`missing_credential`; send `Authorization: Bearer <key>` or `x-api-key`), or a key Gateway does not accept (`invalid_credential`). (application/json, ProviderError) - `402` The call's maximum cost is more than the budget left. (application/json, ProviderError) - `403` `model_not_allowed`: the model is refused by a model policy (the message names the level and rule; `error.nexus` carries them), or the organization has no provider key (`provider_key_required`: Nexus credit never pays a pass-through call); or the team in `x-nexus-team` is not the caller's (`not_in_team`). (application/json, ProviderError) - `404` `model_not_found`: not in the model catalog; or the team in `x-nexus-team` does not exist (`unknown_team`). (application/json, ProviderError) - `408` The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). (application/json, ProviderError) - `409` The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. (application/json, ProviderError) - `413` The request body is over 32,000,000 bytes, the agent gateway's limit (`request_too_large`). (application/json, ProviderError) - `422` The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). (application/json, ProviderError) - `426` The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. (application/json, ProviderError) - `429` Over the caller's rate limit, in the provider's error shape: 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, ProviderError) - `502` The provider could not be reached, or the connection to it failed (`api_error`). (application/json, ProviderError) - `503` The provider's or the Gateway's own; every one may be retried. The provider's: its own 503 passes through as it wrote it, with its `retry-after` (OpenAI's overload; Anthropic's is a 529, not a 503); `/metrics` and the request log count it as `upstream_overloaded`. Retry after its wait, or try another model. The Gateway's, in the provider's error shape: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); or its database is busy (`database_busy`, retry shortly). A count is never `gateway_stopping`. (application/json, ProviderError) - `504` The provider passed one of the call's deadlines (`upstream_timeout`; `nexus.phase` names which). (application/json, ProviderError) ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid: for example, it has no `model`, or its body is not UTF-8, not a JSON object, or repeats a field. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The call's maximum cost is more than the budget left. | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | `model_not_allowed`: the model is refused by a model policy (the message names the level and rule; `error.nexus` carries them), or the organization has no provider key (`provider_key_required`: Nexus credit never pays a pass-through call); or the team in `x-nexus-team` is not the caller's (`not_in_team`). | | 404 | | `model_not_found`: not in the model catalog; or the team in `x-nexus-team` does not exist (`unknown_team`). | | 408 | | The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). | | 409 | | The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 413 | | The request body is over 32,000,000 bytes, the agent gateway's limit (`request_too_large`). | | 422 | | The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 426 | | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | | 429 | | Over the caller's rate limit, in the provider's error shape: retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | The provider could not be reached, or the connection to it failed (`api_error`). | | 503 | | The provider's or the Gateway's own; every one may be retried. The provider's: its own 503 passes through as it wrote it, with its `retry-after` (OpenAI's overload; Anthropic's is a 529, not a 503); `/metrics` and the request log count it as `upstream_overloaded`. Retry after its wait, or try another model. The Gateway's, in the provider's error shape: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); or its database is busy (`database_busy`, retry shortly). A count is never `gateway_stopping`. | | 504 | | The provider passed one of the call's deadlines (`upstream_timeout`; `nexus.phase` names which). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/anthropic/v1/messages/count_tokens" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "anthropic-version: 2023-06-01" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "model": "claude-opus-5-5", "messages": [ { "role": "user", "content": "Hello" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fanthropic%2Fv1%2Fmessages%2Fcount_tokens) ## OpenAI responses `POST /v1/openai/v1/responses` OpenAI Responses API (Codex: a model provider with base_url <core>/v1/openai/v1). Metered. A hosted tool Nexus cannot price yet (code_interpreter, file_search), or an image_generation model, quality or size it has no price for, is 400 hosted_tool_not_priced. Permission: `agents.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-team` | header | string | no | The team (slug) this call's spend goes to; you must be in it (`nexus claude --team`). Default: your default team. | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) object: the provider's own request. ### Responses - `200` The provider's response: JSON, or server-sent events when the request streams. (application/json, object) - `400` The request is not valid: for example, it has no `model`, or its body is not UTF-8, not a JSON object, or repeats a field. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). (application/json, ProviderError) - `401` No key (`missing_credential`; send `Authorization: Bearer <key>` or `x-api-key`), or a key Gateway does not accept (`invalid_credential`). (application/json, ProviderError) - `402` The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. Its `error.nexus` is a BudgetRefusal: each money figure with its exact decimal twin. (application/json, ProviderError) - `403` `model_not_allowed`: the model is refused by a model policy (the message names the level and rule; `error.nexus` carries them), or the organization has no provider key (`provider_key_required`: Nexus credit never pays a pass-through call); or the team in `x-nexus-team` is not the caller's (`not_in_team`). `provider_disabled`: the organization has turned off every provider that serves the model. (application/json, ProviderError) - `404` `model_not_found`: not in the model catalog; or the team in `x-nexus-team` does not exist (`unknown_team`). (application/json, ProviderError) - `408` The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). (application/json, ProviderError) - `409` The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. (application/json, ProviderError) - `413` The request body is over 32,000,000 bytes, the agent gateway's limit (`request_too_large`). (application/json, ProviderError) - `422` The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). (application/json, ProviderError) - `426` The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. (application/json, ProviderError) - `429` Over the caller's rate limit, in the provider's error shape: 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, ProviderError) - `502` The provider could not be reached, or the connection to it failed (`api_error`). (application/json, ProviderError) - `503` The provider's or the Gateway's own; every one may be retried. The provider's: its own 503 passes through as it wrote it, with its `retry-after` (OpenAI's overload; Anthropic's is a 529, not a 503); `/metrics` and the request log count it as `upstream_overloaded`. Retry after its wait, or try another model. The Gateway's, in the provider's error shape: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); it stopped before the call answered (`gateway_stopping`, send the call again: it reaches a running Gateway); or its database is busy (`database_busy`: nothing was committed, retry shortly). (application/json, ProviderError) - `504` The provider passed one of the call's deadlines (`upstream_timeout`; `nexus.phase` names which). (application/json, ProviderError) ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The request is not valid: for example, it has no `model`, or its body is not UTF-8, not a JSON object, or repeats a field. So is an `Idempotency-Key` that is not 1 to 255 printable ASCII characters (`invalid_idempotency_key`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | The call's maximum cost is more than the budget left (`budget_exceeded`), or the organization has an unpaid Nexus invoice past its grace (`payment_past_due`). A `budget_exceeded` refusal carries `notified: true` in its details once Gateway has told the refused person and the organization's owners and admins. Its `error.nexus` is a BudgetRefusal: each money figure with its exact decimal twin. | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | `model_not_allowed`: the model is refused by a model policy (the message names the level and rule; `error.nexus` carries them), or the organization has no provider key (`provider_key_required`: Nexus credit never pays a pass-through call); or the team in `x-nexus-team` is not the caller's (`not_in_team`). `provider_disabled`: the organization has turned off every provider that serves the model. | | 404 | | `model_not_found`: not in the model catalog; or the team in `x-nexus-team` does not exist (`unknown_team`). | | 408 | | The request body stopped arriving for 30 seconds, or took longer than 10 minutes in all (`request_timeout`; `nexus` holds `gap_seconds` and `total_seconds`). | | 409 | | The `Idempotency-Key` cannot run or replay: its first request still runs (`idempotency_in_progress`), was a stream (`idempotency_stream_replay`), or its answer was not kept, being over 2,000,000 bytes (`idempotency_response_not_stored`). The request does not run again. | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 413 | | The request body is over 32,000,000 bytes, the agent gateway's limit (`request_too_large`). | | 422 | | The `Idempotency-Key` was used for a different request: another method, path, query or body (`idempotency_key_reused`). | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 426 | | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | | 429 | | Over the caller's rate limit, in the provider's error shape: retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | The provider could not be reached, or the connection to it failed (`api_error`). | | 503 | | The provider's or the Gateway's own; every one may be retried. The provider's: its own 503 passes through as it wrote it, with its `retry-after` (OpenAI's overload; Anthropic's is a 529, not a 503); `/metrics` and the request log count it as `upstream_overloaded`. Retry after its wait, or try another model. The Gateway's, in the provider's error shape: it is at its limit of requests in flight (`overloaded`, retry after 1 s); it is stopping and takes no new request (`draining`, retry after 5 s); it stopped before the call answered (`gateway_stopping`, send the call again: it reaches a running Gateway); or its database is busy (`database_busy`: nothing was committed, retry shortly). | | 504 | | The provider passed one of the call's deadlines (`upstream_timeout`; `nexus.phase` names which). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/openai/v1/responses" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.3-codex", "input": "Hello" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fopenai%2Fv1%2Fresponses) ## Anthropic models `GET /v1/anthropic/v1/models` The models you may use on the Anthropic API, by the provider's own ids, in the provider's list shape (for clients that query it). Permission: `agents.use` (Every member). ### Responses - `200` OK (application/json, object) - `401` No key (`missing_credential`; send `Authorization: Bearer <key>` or `x-api-key`), or a key Gateway does not accept (`invalid_credential`). (application/json, ProviderError) - `403` The caller may not do this: for example, the role does not have the permission (`role_required`), or the team named is not the caller's (`not_in_team`). (application/json, ProviderError) - `404` The team named in `x-nexus-team` does not exist (`unknown_team`). (application/json, ProviderError) - `426` The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. (application/json, ProviderError) - `429` Over the caller's rate limit, in the provider's error shape: 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, ProviderError) - `503` Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Retry after `Retry-After` seconds. (application/json, ProviderError) ### 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 | | The team named in `x-nexus-team` does not exist (`unknown_team`). | | 426 | | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | | 429 | | Over the caller's rate limit, in the provider's error shape: retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Retry after `Retry-After` seconds. | ### Example ```sh curl "$NEXUS_URL/v1/anthropic/v1/models" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "anthropic-version: 2023-06-01" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fanthropic%2Fv1%2Fmodels) ## OpenAI models `GET /v1/openai/v1/models` The models you may use on the OpenAI API, by the provider's own ids, in the provider's list shape (for clients that query it). Permission: `agents.use` (Every member). ### Responses - `200` OK (application/json, object) - `401` No key (`missing_credential`; send `Authorization: Bearer <key>` or `x-api-key`), or a key Gateway does not accept (`invalid_credential`). (application/json, ProviderError) - `403` The caller may not do this: for example, the role does not have the permission (`role_required`), or the team named is not the caller's (`not_in_team`). (application/json, ProviderError) - `404` The team named in `x-nexus-team` does not exist (`unknown_team`). (application/json, ProviderError) - `426` The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. (application/json, ProviderError) - `429` Over the caller's rate limit, in the provider's error shape: 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, ProviderError) - `503` Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Retry after `Retry-After` seconds. (application/json, ProviderError) ### 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 | | The team named in `x-nexus-team` does not exist (`unknown_team`). | | 426 | | The `nexus` CLI that sent `x-nexus-cli-version` is older than Gateway supports (`cli_too_old`; `minimum` names the oldest it takes). A request without that header is never refused. | | 429 | | Over the caller's rate limit, in the provider's error shape: retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Gateway takes no new request now: it is at its limit of requests in flight (`overloaded`), or it is stopping (`draining`). Retry after `Retry-After` seconds. | ### Example ```sh curl "$NEXUS_URL/v1/openai/v1/models" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fopenai%2Fv1%2Fmodels) --- <!-- /docs/api/github --> # GitHub > The Nexus GitHub App, linked repositories and their Nexus Wiki runs. ## GitHub app `GET /v1/github/app` Whether the Nexus GitHub App is configured; for owners and admins, its install link for this organization. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, object) - `configured` (boolean) - `slug` (string) - `installUrl` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/github/app" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.githubApp(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fgithub%2Fapp) ## List repositories `GET /v1/github/repositories` Installations and linked repositories, with each one's last Nexus Wiki run. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, Repositories) - `installations` (array of object) - `repositories` (array of object) - `id` (string) - `fullName` (string) - `url` (string) - `defaultBranch` (string) - `private` (boolean) - `linkedAt` (string) - `lastWikiRun` (object) - `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/github/repositories" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.repositories(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fgithub%2Frepositories) ## Link installation `POST /v1/github/installations` Link a GitHub App installation to this organization (owners and admins), with the `state` of its install link; starts Wiki runs for its repositories. When Gateway has the App's OAuth client (`GITHUB_APP_CLIENT_ID`, `GITHUB_APP_CLIENT_SECRET`), the setup redirect's `code` is required and the GitHub user it names must administer every repository of the installation (an owner does, and so does the user account itself): 403 `invalid_code` for a code GitHub refuses, 403 `installer_not_authorized` otherwise. `installerChecked` says whether that check ran. Permission: `repositories.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `installationId` (string, required) - `state` (string, required) - `code` (string): The setup redirect's one-time `code`, when the App asks for user authorization on install. Used once to check the installer, never stored. ### Responses - `201` Created (application/json, Repositories & object) - `installations` (array of object) - `repositories` (array of object) - `id` (string) - `fullName` (string) - `url` (string) - `defaultBranch` (string) - `private` (boolean) - `linkedAt` (string) - `lastWikiRun` (object) - `installerChecked` (boolean): Whether the installer's GitHub identity was checked: false while Gateway has no OAuth client for the App. - `400` No `installationId`, no `state` (`missing_state`), or a `state` Nexus did not sign (`invalid_state`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` No owner or admin (`role_required`), another org's `state` (`invalid_state`), or an installer GitHub refuses (`invalid_code`, `installer_not_authorized`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` This org's install link expired (`invalid_state`), or another org already linked the installation (`installation_taken`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | No `installationId`, no `state` (`missing_state`), or a `state` Nexus did not sign (`invalid_state`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `invalid_code` | 403 `invalid_code` for a code GitHub refuses, 403 `installer_not_authorized` otherwise | | 403 | `installer_not_authorized` | 403 `invalid_code` for a code GitHub refuses, 403 `installer_not_authorized` otherwise | | 409 | | This org's install link expired (`invalid_state`), or another org already linked the installation (`installation_taken`) | | 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/github/installations" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "installationId": "12345678", "state": "…" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fgithub%2Finstallations) ## Unlink installation `DELETE /v1/github/installations/{id}` Unlink an installation and its repositories (owners and admins). Permission: `repositories.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` OK (application/json, object) - `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/github/installations/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.unlinkInstallation("<installation id>"); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fgithub%2Finstallations%2F%7Bid%7D) ## Run repository Wiki `POST /v1/github/repositories/{id}/wiki` Start a Nexus Wiki run on a linked repository now. Permission: `wiki.run` (Owner). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `202` Accepted (application/json, object) - `runId` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/github/repositories/<id>/wiki" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fgithub%2Frepositories%2F%7Bid%7D%2Fwiki) ## GitHub webhook `POST /v1/github/webhook` GitHub's webhooks for the Nexus GitHub App, verified by X-Hub-Signature-256: installation changes, and pushes to a linked repository's default branch (which re-run its Wiki). Permission: `public` (Anyone, signed in or not). ### Responses - `202` Accepted (application/json, object) ### Errors | Status | Code | When | | --- | --- | --- | ### Example ```sh curl -X POST "$NEXUS_URL/v1/github/webhook" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fgithub%2Fwebhook) --- <!-- /docs/api/connectors --> # Connectors > Connector reads and module writes with a standing Policy grant, shared by every module. ## Connectors `GET /v1/connectors` The connectors Gateway offers, their operations, and whether each is usable by the caller. A connector reaches an outside service by name, such as `linear`, `github`, `jira`, `slack` or `notion`: issues and tickets, pull requests, messages, mail, calendars, docs and files. Check it before you say a named service is unavailable. Permission: `connectors.use` (Every member, module keys). ### Responses - `200` OK (application/json, object) - `connectors` (array of object) - `stage` ("preview" | "released"): How far it is along its release: production offers only released connectors, a preview Gateway both - `offered` (boolean): Whether this Gateway offers it. No one uses one it does not offer: a call answers 403 connector_not_offered - `usable` (boolean | null): Whether the organization made it available to the caller (GET /v1/policies/connectors); null when it could not be read; false for one this Gateway does not offer - `connects` (array of "user" | "org"): Whose connections it runs with: a person's own (user), the organization's (org); empty when it resolves its own credential. A call takes an optional `account` when it is not empty. - `form` (object | null): The fields POST /v1/connections/{connector} takes, as a JSON Schema whose secret fields carry `x-nexus-secret: true`; null when it does not connect with a key - `oauth` (boolean): Whether it connects with OAuth on this gateway (POST /v1/connections/{connector}/oauth) - `offline_input` (object): Only on a gateway that reads this connector's offline test data (NEXUS_CONNECTORS=mock): the form's fields that test data accepts. POST them to /v1/connections/{connector} with the `scope` that `connects` admits: `user` or `org`. A secret field holds a placeholder, never a key. Absent when the connector calls its vendor. - `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/connectors" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` ```ts import { createCoreClient } from "@nexus/kit"; const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY }); const result = await core.connectors(); ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fconnectors) ## Describe connector `GET /v1/connectors/{name}` One connector by its service's name (`linear` for Linear issues and tickets) and its operations, each with its `effect` (`read` or `mutate`) and its `request` schema, and whether the caller may use it (`usable`). It answers for every connector; readConnector and writeConnector run only one the organization made available to the caller. 404 when no connector has this name. Permission: `connectors.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `name` | path | string | yes | The connector, as `GET /v1/connectors` lists it (`github`, `jira`) | ### Responses - `200` OK (application/json, object) - `name` (string) - `description` (string) - `stage` ("preview" | "released"): How far it is along its release: production offers only released connectors, a preview Gateway both - `offered` (boolean): Whether this Gateway offers it. No one uses one it does not offer: a call answers 403 connector_not_offered - `usable` (boolean | null): Whether the organization made it available to the caller (GET /v1/policies/connectors); null when it could not be read; false for one this Gateway does not offer - `connects` (array of "user" | "org"): Whose connections it runs with: a person's own (user), the organization's (org); empty when it resolves its own credential. A call takes an optional `account` when it is not empty. - `form` (object | null): The fields POST /v1/connections/{connector} takes, as a JSON Schema whose secret fields carry `x-nexus-secret: true`; null when it does not connect with a key - `oauth` (boolean): Whether it connects with OAuth on this gateway (POST /v1/connections/{connector}/oauth) - `operations` (array of object) - `name` (string) - `summary` (string) - `effect` ("read" | "mutate") - `request` (object): The JSON schema of the operation's parameters. - `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/connectors/Platform" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fconnectors%2F%7Bname%7D) ## Write connector `POST /v1/connectors/{name}/{operation}` Run one connector operation, a read or a change. A change runs only for a module holding a write grant for it (PUT /v1/policies/grants/{product}/{capability}); a person's change is refused with 403 `write_not_granted` until people get write scopes. A chat agent's link writes only with the approval record the person confirmed for exactly this call, named in `x-nexus-approval`, while the organization has chat writes on: else 403 `write_not_granted` (no record), `approval_invalid` or `chat_writes_off`. The record is used by the call, once. Every change attempt and every scoped read is audited as `connector.write`. `github/pull_merge` squash-merges only at `expected_head_sha` and only when branch protection allows it, never past it: 400 `merge_method_refused`, 409 `head_changed`, `not_mergeable` or `pull_not_open`. `github/pull_edit` and `pull_reviewers` change only an open pull request (409 `pull_not_open`), and GitHub's refusal of a reviewer is 422 `reviewer_refused`. `github/pull_state` closes or reopens and never merges: 409 `pull_merged`, 422 `not_reopenable`. `github/pull_labels` adds only a label the repository has: 404 `label_unknown`. A runner's change inside a native session names the session and its fencing token (`x-nexus-cloud-session`, `x-nexus-fencing-token`): 400 `invalid_session_fence` without both, 404 `session_not_found` for a session that is not yours, 409 `session_ended` for an ended one, and 409 `lost_runner` when another runner took the session; nothing is called, and the refusal is audited. A change that names no fence while its credential holds a native session's live runner lease is refused with 409 `fence_required` (`error.nexus.session` names the session) when the server requires the fence; nothing is called, and the refusal is audited. When the server asks for write scopes on demand (NEXUS_CONNECTOR_WRITE_CONSENT), a change on an OAuth connection that holds none of the connector's write scopes is refused with 403 `write_consent_required`; nothing is called. `error.nexus` names the `connector`, the `account`, the `scopes` the change needs, and the `consent` call that asks for them (POST /v1/connections/{connector}/oauth with `access: write`). A change sent with `Idempotency-Key` carries a hidden marker in the body it writes (`github/issue_comment`, `pull_review`, `issue_create`). When GitHub got the write but its answer was lost, the 502 says `error.nexus.outcome: unknown` and the key is kept: a retry with the same key reads the target for the marker, answers what it found as a replay, or writes once. A retry that cannot read the target is 502 `reconciliation_failed` and writes nothing. Send an `Idempotency-Key` with every change. While the Gateway enforces connector write keys (off by default), a change without one is 428 `idempotency_key_required`, and nothing is called. A read never needs one. Permission: `connectors.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `name` | path | string | yes | The connector, as `GET /v1/connectors` lists it (`github`, `jira`) | | `operation` | path | string | yes | The operation, as `GET /v1/connectors/{name}` lists it | | `x-nexus-approval` | header | string | no | A chat agent's confirmed approval record for this exact call (`POST /v1/approvals`) | | `x-nexus-cloud-session` | header | string | no | The native session (`/v1/sessions`) a runner's change is made inside, with `x-nexus-fencing-token`. Send both or neither. | | `x-nexus-fencing-token` | header | string | no | The fencing token the runner got when it took the session (POST /v1/sessions/{id}/runner). A change whose token is not the session's current one is refused with 409 `lost_runner` before the outside system is called, and audited as `connector.write` with `outcome: denied`. | | `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) object: the provider's own request. ### Responses - `200` OK (application/json, object) - `428` Only while the Gateway enforces connector write keys (off by default): a change sent without `Idempotency-Key` (`idempotency_key_required`). Nothing was called. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | `merge_method_refused` | 400 `merge_method_refused`, 409 `head_changed`, `not_mergeable` or `pull_not_open` | | 400 | `invalid_session_fence` | 400 `invalid_session_fence` without both, 404 `session_not_found` for a session that is not yours, 409 `session_ended` for an ended one, and 409 `lost_runner` when another runner took the session; nothing is called, and the refusal is audited | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `write_not_granted` | A change runs only for a module holding a write grant for it (PUT /v1/policies/grants/{product}/{capability}); a person's change is refused with 403 `write_not_granted` until people get write scopes | | 403 | `write_consent_required` | When the server asks for write scopes on demand (NEXUS_CONNECTOR_WRITE_CONSENT), a change on an OAuth connection that holds none of the connector's write scopes is refused with 403 `write_consent_required`; nothing is called | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | `label_unknown` | 404 `label_unknown` | | 404 | `session_not_found` | 400 `invalid_session_fence` without both, 404 `session_not_found` for a session that is not yours, 409 `session_ended` for an ended one, and 409 `lost_runner` when another runner took the session; nothing is called, and the refusal is audited | | 409 | `head_changed` | 400 `merge_method_refused`, 409 `head_changed`, `not_mergeable` or `pull_not_open` | | 409 | `pull_not_open` | `github/pull_edit` and `pull_reviewers` change only an open pull request (409 `pull_not_open`), and GitHub's refusal of a reviewer is 422 `reviewer_refused` | | 409 | `pull_merged` | 409 `pull_merged`, 422 `not_reopenable` | | 409 | `session_ended` | 400 `invalid_session_fence` without both, 404 `session_not_found` for a session that is not yours, 409 `session_ended` for an ended one, and 409 `lost_runner` when another runner took the session; nothing is called, and the refusal is audited | | 409 | `lost_runner` | 400 `invalid_session_fence` without both, 404 `session_not_found` for a session that is not yours, 409 `session_ended` for an ended one, and 409 `lost_runner` when another runner took the session; nothing is called, and the refusal is audited | | 409 | `fence_required` | A change that names no fence while its credential holds a native session's live runner lease is refused with 409 `fence_required` (`error.nexus.session` names the session) when the server requires the fence; nothing is called, and the refusal is audited | | 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 | `reviewer_refused` | `github/pull_edit` and `pull_reviewers` change only an open pull request (409 `pull_not_open`), and GitHub's refusal of a reviewer is 422 `reviewer_refused` | | 422 | `not_reopenable` | 409 `pull_merged`, 422 `not_reopenable` | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 428 | | Only while the Gateway enforces connector write keys (off by default): a change sent without `Idempotency-Key` (`idempotency_key_required`). Nothing was called. | | 428 | `idempotency_key_required` | While the Gateway enforces connector write keys (off by default), a change without one is 428 `idempotency_key_required`, and nothing is called | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | `reconciliation_failed` | A retry that cannot read the target is 502 `reconciliation_failed` and writes nothing | ### Example ```sh curl -X POST "$NEXUS_URL/v1/connectors/Platform/<operation>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fconnectors%2F%7Bname%7D%2F%7Boperation%7D) ## Read connector `POST /v1/connectors/{name}/{operation}/read` Run one connector operation that only reads, as the caller, with the credential the connector resolves for the call. 403 `not_a_read` when the operation changes something (use writeConnector), and 403 `connector_disabled` when the organization has not made the connector available to the caller. A scoped read is audited as `connector.write`. A repeat is safe, so it takes no idempotency key. Permission: `connectors.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `name` | path | string | yes | The connector, as `GET /v1/connectors` lists it (`github`, `jira`) | | `operation` | path | string | yes | The operation, as `GET /v1/connectors/{name}` lists it | ### Request body (application/json, required) object: the provider's own request. ### Responses - `200` OK (application/json, object) - `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 | | 403 | `not_a_read` | 403 `not_a_read` when the operation changes something (use writeConnector), and 403 `connector_disabled` when the organization has not made the connector available to the caller | | 403 | `connector_disabled` | 403 `not_a_read` when the operation changes something (use writeConnector), and 403 `connector_disabled` when the organization has not made the connector available to the caller | | 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/connectors/Platform/<operation>/read" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fconnectors%2F%7Bname%7D%2F%7Boperation%7D%2Fread) --- <!-- /docs/api/jobs --> # Jobs > Jobs: a module's verb with its input, run in the background for the member who submitted it. A job is `accepted`, then `running`, then `done`, `failed` or `cancelled`. Its id is derived from the submit's `Idempotency-Key`, so a resend names the same job. A job is its creator's and its organization's owners' and admins'; to anyone else it does not exist. ## Submit job `POST /v1/jobs` Submit a job: the verb of a module to run, with its input. `module` is `<product>/<capability>` (`intelligence/wiki`), the path of the verb's own route, and the caller needs the action the module declares for the verb (`wiki.run` for Nexus Wiki's `run`), as on that route. Needs an `Idempotency-Key`: the job's id is derived from it, with the organization and the credential, so a resend names the job the first send made. For 24 hours a resend replays the first answer (202, with `Idempotent-Replayed: true`), even after the job has moved on. After that it answers 200 with the job as it is now. A resend with a different `module`, `verb` or `input` is a 422 `idempotency_key_reused`. `team` (or `x-nexus-team`) names the team the job's model calls go to; the caller's default team when absent. A job stays `accepted` until a worker takes it. Permission: `products.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) - `module` (string, required): The module whose verb runs, as `<product>/<capability>` (`intelligence/wiki`): the path of the verb's own route. [min length 1; max length 100; pattern ^[a-z0-9][a-z0-9-]*/[a-z0-9][a-z0-9-]*$] - `verb` (string, required) [min length 1; max length 100] - `input` (object): The verb's input; `{}` when left out. The organization's owners and admins can read it, so do not put secrets in it. - `team` (string): The team the job's model calls go to, by slug or id; the caller's default team when left out. ### Responses - `200` The job a send with this key made, found after its replay window (application/json, Job) - `id` (string, required): `job_` and 43 base64url characters - `module` (string, required): `<product>/<capability>`, such as `intelligence/wiki`. - `verb` (string, required) - `state` ("accepted" | "running" | "waiting_approval" | "done" | "failed" | "cancelled", required): `done`, `failed` and `cancelled` are final. - `teamId` (string): The team the job's model calls go to; absent when its creator is in none. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `deadlineAt` (string (date-time)) - `startedAt` (string (date-time)) - `finishedAt` (string (date-time)) - `failureKind` (string): Why it failed. - `202` Accepted: the job is recorded (application/json, Job) - `id` (string, required): `job_` and 43 base64url characters - `module` (string, required): `<product>/<capability>`, such as `intelligence/wiki`. - `verb` (string, required) - `state` ("accepted" | "running" | "waiting_approval" | "done" | "failed" | "cancelled", required): `done`, `failed` and `cancelled` are final. - `teamId` (string): The team the job's model calls go to; absent when its creator is in none. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `deadlineAt` (string (date-time)) - `startedAt` (string (date-time)) - `finishedAt` (string (date-time)) - `failureKind` (string): Why it failed. - `400` No `Idempotency-Key`, or `module`, `verb`, `input` or `team` is not valid. `module` is not `<product>/<capability>` (`invalid_request`). A malformed `Idempotency-Key` is `invalid_idempotency_key`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller does not hold the action the module declares for the verb (`role_required`), or the team named is not the caller's (`not_in_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No registered module is `module`, or it does not declare `verb` (`not_found`). The team named does not exist in this organization (`unknown_team`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The `Idempotency-Key`'s first request still runs (`idempotency_in_progress`) or was interrupted (`idempotency_interrupted`). The request does not run again. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `422` The `Idempotency-Key` named a different job (`idempotency_key_reused`): a resend with another `module`, `verb` or `input`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` No registered module is `module` and a module did not answer, so it may be that one (`module_unavailable`); try again. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | No `Idempotency-Key`, or `module`, `verb`, `input` or `team` is not valid. `module` is not `<product>/<capability>` (`invalid_request`). A malformed `Idempotency-Key` is `invalid_idempotency_key`. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | No registered module is `module`, or it does not declare `verb` (`not_found`). The team named does not exist in this organization (`unknown_team`). | | 409 | | The `Idempotency-Key`'s first request still runs (`idempotency_in_progress`) or was interrupted (`idempotency_interrupted`). The request does not run again. | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | | The `Idempotency-Key` named a different job (`idempotency_key_reused`): a resend with another `module`, `verb` or `input`. | | 422 | `idempotency_key_reused` | A resend with a different `module`, `verb` or `input` is a 422 `idempotency_key_reused` | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | No registered module is `module` and a module did not answer, so it may be that one (`module_unavailable`); try again. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/jobs" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "module": "intelligence/wiki", "verb": "run", "input": { "repo": "https://github.com/nexus-demo/hello-factory" } }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fjobs) ## Get job `GET /v1/jobs/{id}` A job's state: `accepted`, `running`, `done`, `failed` or `cancelled`. Permission: `products.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The job's id (`job_…`), as POST /v1/jobs answered it | ### Responses - `200` OK (application/json, Job) - `id` (string, required): `job_` and 43 base64url characters - `module` (string, required): `<product>/<capability>`, such as `intelligence/wiki`. - `verb` (string, required) - `state` ("accepted" | "running" | "waiting_approval" | "done" | "failed" | "cancelled", required): `done`, `failed` and `cancelled` are final. - `teamId` (string): The team the job's model calls go to; absent when its creator is in none. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `deadlineAt` (string (date-time)) - `startedAt` (string (date-time)) - `finishedAt` (string (date-time)) - `failureKind` (string): Why it failed. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `products.use` (`role_required`: a service account, a sandbox, or an agent not granted it). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such job of yours (`not_found`): a job is its creator's and its organization's owners' and admins'. Another member's job, and another organization's, is as absent as a missing one. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such job of yours (`not_found`): a job is its creator's and its organization's owners' and admins'. Another member's job, and another organization's, is as absent as a missing one. | | 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/jobs/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fjobs%2F%7Bid%7D) ## Cancel job `POST /v1/jobs/{id}/cancel` Cancel a job that no worker has taken (`accepted` becomes `cancelled`). A job in any other state comes back as it is: a running one is its backend's to stop, and a finished one is never left. Cancelling twice is the same as once. Permission: `products.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The job's id (`job_…`), as POST /v1/jobs answered it | | `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, Job) - `id` (string, required): `job_` and 43 base64url characters - `module` (string, required): `<product>/<capability>`, such as `intelligence/wiki`. - `verb` (string, required) - `state` ("accepted" | "running" | "waiting_approval" | "done" | "failed" | "cancelled", required): `done`, `failed` and `cancelled` are final. - `teamId` (string): The team the job's model calls go to; absent when its creator is in none. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `deadlineAt` (string (date-time)) - `startedAt` (string (date-time)) - `finishedAt` (string (date-time)) - `failureKind` (string): Why it failed. - `400` A malformed `Idempotency-Key` (`invalid_idempotency_key`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `products.use` (`role_required`: a service account, a sandbox, or an agent not granted it). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such job of yours (`not_found`): a job is its creator's and its organization's owners' and admins'. Another member's job, and another organization's, is as absent as a missing one. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The `Idempotency-Key`'s first request still runs (`idempotency_in_progress`) or was interrupted (`idempotency_interrupted`). The request does not run again. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `422` The `Idempotency-Key` was used for a different request (`idempotency_key_reused`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `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 | | A malformed `Idempotency-Key` (`invalid_idempotency_key`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such job of yours (`not_found`): a job is its creator's and its organization's owners' and admins'. Another member's job, and another organization's, is as absent as a missing one. | | 409 | | The `Idempotency-Key`'s first request still runs (`idempotency_in_progress`) or was interrupted (`idempotency_interrupted`). The request does not run again. | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | | The `Idempotency-Key` was used for a different request (`idempotency_key_reused`). | | 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/jobs/<id>/cancel" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fjobs%2F%7Bid%7D%2Fcancel) ## Get job result `GET /v1/jobs/{id}/result` A job's state, and its `result` once it is `done` or `failed` (with `failureKind` when it failed). Permission: `products.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The job's id (`job_…`), as POST /v1/jobs answered it | ### Responses - `200` OK (application/json, JobResult) - `id` (string, required) - `state` ("accepted" | "running" | "waiting_approval" | "done" | "failed" | "cancelled", required) - `result` (any): What the verb answered; set once the job is `done` or `failed`. - `failureKind` (string): Why it failed. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `products.use` (`role_required`: a service account, a sandbox, or an agent not granted it). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such job of yours (`not_found`): a job is its creator's and its organization's owners' and admins'. Another member's job, and another organization's, is as absent as a missing one. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such job of yours (`not_found`): a job is its creator's and its organization's owners' and admins'. Another member's job, and another organization's, is as absent as a missing one. | | 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/jobs/<id>/result" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fjobs%2F%7Bid%7D%2Fresult) --- <!-- /docs/api/cloud-machines --> # Cloud machines > Cloud machines: a Linux machine at a cloud provider (boat.dev in v1) for each person, on Nexus's own provider account. Nobody opens a provider account or sees Nexus's key. Gateway charges a machine's running time to the organization as cloud compute (product `cloud`, capability `compute` in GET /v1/spend), at the provider's price per second, when it sleeps or is deleted and every 15 minutes while it runs. A machine is its person's alone: to anyone else it does not exist. One live machine per person in an organization. Without a provider account on the Gateway (`BOAT_API_KEY`), every route answers 503 `cloud_unavailable`. ## List cloud machines `GET /v1/cloud/machines` Your live cloud machines in this organization, one for each desktop session at most, each state read from the provider. Permission: `cloud.machines.use` (Every member). ### Responses - `200` OK (application/json, CloudMachineList) - `machines` (array of CloudMachine, required) - `id` (string, required): `cm_` and up to 64 base64url characters - `sessionId` (string | null, required): The desktop session the machine is for; null on a machine made before sessions. - `title` (string | null, required): The session's title, on one line; null when the create sent none. - `name` (string, required): The session's title, cut to 120 characters, or `Cloud`. - `provider` ("boat", required) - `size` ("small" | "default" | "large" | "xlarge", required): Nexus chooses it: `NEXUS_CLOUD_DEFAULT_SIZE` when made. - `state` ("queued" | "creating" | "starting" | "ready" | "sleeping" | "stopping" | "failed" | "gone", required): The desktop's `CloudState`. `queued` waits for a place, the person's next start or the provider; nothing runs. Running time is charged in `creating`, `starting` and `ready`. - `error` (string | null, required): Why it failed; null otherwise. - `createdAt` (string (date-time), required) - `sleepingSince` (string (date-time) | null, required): When it went to sleep; null unless `sleeping`. - `stopReason` ("budget" | "max_run" | "not_enabled" | "idle" | "resize" | null, required): Why Gateway put it to sleep: `budget` when its compute was refused, `max_run` after its longest run with no interaction (24 hours by default, from the person's last interaction, create, wake or access), `not_enabled` when the organization may no longer run machines, `idle` when nobody needs it (its agent idle 5 minutes and its person idle 20 minutes, or its host silent 15 minutes, or no report from its host in the 5 minutes after its last create, wake, access or connect), `resize` while it restarts one size bigger after it ran out of memory. Null otherwise, and cleared by a wake. - `queuedUntil` (string (date-time) | null, required): While `queued`: the earliest time Gateway tries to start it (the person's next start, the provider's `nextStartAt`, or the meter's next pass). Null otherwise. - `hostOnline` (boolean, required): The machine's host has its control connection open on this copy of Gateway: GET /v1/cloud/machines/{id}/connect can open a stream. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. | ### Example ```sh curl "$NEXUS_URL/v1/cloud/machines" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcloud%2Fmachines) ## Create cloud machine `POST /v1/cloud/machines` Create the cloud machine of a desktop session. Send `sessionId` and the session's `title`: a create for a session that has a live machine returns that machine. Nexus names and sizes every machine (`NEXUS_CLOUD_DEFAULT_SIZE`), so `name` and `size` are read and ignored. The machine starts from Nexus's image, with its own Nexus token in `~/.nexus/host/credentials`; deleting the machine revokes that token. Send an `Idempotency-Key`: the machine's id is derived from it, so a resend names the machine the first send made, and finishes it when the provider's answer was lost. A machine that cannot start now waits in the queue (202, state `queued`): Gateway runs its most machines, the person runs their share (`NEXUS_CLOUD_MAX_PER_PERSON`), the person started 20 machines and gets one more every 5 minutes, or the provider is at its limits. The meter starts the queue oldest first. A person asks for at most 200 starts (creates and wakes) in a UTC day, and an organization's people 500 together: one more answers 429 `cloud_daily_starts` until 00:00 UTC (`Retry-After`). An organization with only the free start is on the trial: it runs one machine at a time, and all trial organizations together a few. A trial machine never waits in the queue: one more answers 429 `cloud_trial_limit` or `cloud_trial_busy` (`Retry-After`), which name Billing. Credits, a card or a contract lift the trial. A person keeps at most 50 machines, asleep or not: one more answers 429 `cloud_machine_limit`. Read the queued machine (GET) while you wait: one nobody read for 10 minutes ends, `failed`. Its running time is charged as cloud compute from its start. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-github-token` | header | string | no | The person's own GitHub token. With `repo`, Gateway asks GitHub with it whether the person may read the repository, and only then starts the machine from the organization's saved copy of it. Used for that check only, never kept. | | `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) - `sessionId` (string): The desktop session the machine is for (`t_<uuid>`). One live machine for each session. An older app sends none, and gets a new machine each time. [pattern ^[A-Za-z0-9_-]{1,128}$] - `title` (string): The session's title. Gateway keeps its first line, cut to 200 characters. - `name` (string): Read and ignored: the machine's name is the session's title. - `size` (string): Read and ignored: Nexus sizes every machine. - `repo` (string): The repository the session clones: a URL, or a GitHub `owner/name`. With `NEXUS_CLOUD_WARM_SNAPSHOTS` on, a GitHub one starts the machine from the organization's saved copy of it, when there is one and GitHub lets the person read it (`x-nexus-github-token`). Anything else is ignored. [max length 512] ### Responses - `200` The machine a send with this key made, or the live machine of this session (application/json, CloudMachine) - `id` (string, required): `cm_` and up to 64 base64url characters - `sessionId` (string | null, required): The desktop session the machine is for; null on a machine made before sessions. - `title` (string | null, required): The session's title, on one line; null when the create sent none. - `name` (string, required): The session's title, cut to 120 characters, or `Cloud`. - `provider` ("boat", required) - `size` ("small" | "default" | "large" | "xlarge", required): Nexus chooses it: `NEXUS_CLOUD_DEFAULT_SIZE` when made. - `state` ("queued" | "creating" | "starting" | "ready" | "sleeping" | "stopping" | "failed" | "gone", required): The desktop's `CloudState`. `queued` waits for a place, the person's next start or the provider; nothing runs. Running time is charged in `creating`, `starting` and `ready`. - `error` (string | null, required): Why it failed; null otherwise. - `createdAt` (string (date-time), required) - `sleepingSince` (string (date-time) | null, required): When it went to sleep; null unless `sleeping`. - `stopReason` ("budget" | "max_run" | "not_enabled" | "idle" | "resize" | null, required): Why Gateway put it to sleep: `budget` when its compute was refused, `max_run` after its longest run with no interaction (24 hours by default, from the person's last interaction, create, wake or access), `not_enabled` when the organization may no longer run machines, `idle` when nobody needs it (its agent idle 5 minutes and its person idle 20 minutes, or its host silent 15 minutes, or no report from its host in the 5 minutes after its last create, wake, access or connect), `resize` while it restarts one size bigger after it ran out of memory. Null otherwise, and cleared by a wake. - `queuedUntil` (string (date-time) | null, required): While `queued`: the earliest time Gateway tries to start it (the person's next start, the provider's `nextStartAt`, or the meter's next pass). Null otherwise. - `hostOnline` (boolean, required): The machine's host has its control connection open on this copy of Gateway: GET /v1/cloud/machines/{id}/connect can open a stream. - `201` Created: the machine is starting (application/json, CloudMachine) - `id` (string, required): `cm_` and up to 64 base64url characters - `sessionId` (string | null, required): The desktop session the machine is for; null on a machine made before sessions. - `title` (string | null, required): The session's title, on one line; null when the create sent none. - `name` (string, required): The session's title, cut to 120 characters, or `Cloud`. - `provider` ("boat", required) - `size` ("small" | "default" | "large" | "xlarge", required): Nexus chooses it: `NEXUS_CLOUD_DEFAULT_SIZE` when made. - `state` ("queued" | "creating" | "starting" | "ready" | "sleeping" | "stopping" | "failed" | "gone", required): The desktop's `CloudState`. `queued` waits for a place, the person's next start or the provider; nothing runs. Running time is charged in `creating`, `starting` and `ready`. - `error` (string | null, required): Why it failed; null otherwise. - `createdAt` (string (date-time), required) - `sleepingSince` (string (date-time) | null, required): When it went to sleep; null unless `sleeping`. - `stopReason` ("budget" | "max_run" | "not_enabled" | "idle" | "resize" | null, required): Why Gateway put it to sleep: `budget` when its compute was refused, `max_run` after its longest run with no interaction (24 hours by default, from the person's last interaction, create, wake or access), `not_enabled` when the organization may no longer run machines, `idle` when nobody needs it (its agent idle 5 minutes and its person idle 20 minutes, or its host silent 15 minutes, or no report from its host in the 5 minutes after its last create, wake, access or connect), `resize` while it restarts one size bigger after it ran out of memory. Null otherwise, and cleared by a wake. - `queuedUntil` (string (date-time) | null, required): While `queued`: the earliest time Gateway tries to start it (the person's next start, the provider's `nextStartAt`, or the meter's next pass). Null otherwise. - `hostOnline` (boolean, required): The machine's host has its control connection open on this copy of Gateway: GET /v1/cloud/machines/{id}/connect can open a stream. - `202` Accepted: the machine waits in the queue (`queued`, with `queuedUntil`) (application/json, CloudMachine) - `id` (string, required): `cm_` and up to 64 base64url characters - `sessionId` (string | null, required): The desktop session the machine is for; null on a machine made before sessions. - `title` (string | null, required): The session's title, on one line; null when the create sent none. - `name` (string, required): The session's title, cut to 120 characters, or `Cloud`. - `provider` ("boat", required) - `size` ("small" | "default" | "large" | "xlarge", required): Nexus chooses it: `NEXUS_CLOUD_DEFAULT_SIZE` when made. - `state` ("queued" | "creating" | "starting" | "ready" | "sleeping" | "stopping" | "failed" | "gone", required): The desktop's `CloudState`. `queued` waits for a place, the person's next start or the provider; nothing runs. Running time is charged in `creating`, `starting` and `ready`. - `error` (string | null, required): Why it failed; null otherwise. - `createdAt` (string (date-time), required) - `sleepingSince` (string (date-time) | null, required): When it went to sleep; null unless `sleeping`. - `stopReason` ("budget" | "max_run" | "not_enabled" | "idle" | "resize" | null, required): Why Gateway put it to sleep: `budget` when its compute was refused, `max_run` after its longest run with no interaction (24 hours by default, from the person's last interaction, create, wake or access), `not_enabled` when the organization may no longer run machines, `idle` when nobody needs it (its agent idle 5 minutes and its person idle 20 minutes, or its host silent 15 minutes, or no report from its host in the 5 minutes after its last create, wake, access or connect), `resize` while it restarts one size bigger after it ran out of memory. Null otherwise, and cleared by a wake. - `queuedUntil` (string (date-time) | null, required): While `queued`: the earliest time Gateway tries to start it (the person's next start, the provider's `nextStartAt`, or the meter's next pass). Null otherwise. - `hostOnline` (boolean, required): The machine's host has its control connection open on this copy of Gateway: GET /v1/cloud/machines/{id}/connect can open a stream. - `400` The body is not an object, or `sessionId` is not 1 to 128 letters, digits, `_` and `-` (`invalid_session_id`). - `402` Nothing covers 15 minutes of this machine's cloud compute (`budget_exceeded`), so no new compute starts. Nexus pays for cloud compute: it is held on the organization's Nexus balance (its subsidy, then its credits, then its contract), and on its budget. An organization past due gets `payment_past_due`. The refusal is recorded. When a running machine's next 15 minutes are refused, Gateway puts it to sleep, with `stopReason` `budget`. - `403` Cloud machines are not turned on for this organization (`cloud_not_enabled`). Only the organizations Nexus lists may start or use a machine; anyone may still list, sleep and delete their own. - `409` The create took so long that Gateway ended it (`machine_gone`); send a new one. - `422` This `Idempotency-Key` names another machine (`idempotency_key_reused`); send a new key. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 202 | `queued` | A machine that cannot start now waits in the queue (202, state `queued`): Gateway runs its most machines, the person runs their share (`NEXUS_CLOUD_MAX_PER_PERSON`), the person started 20 machines and gets one more every 5 minutes, or the provider is at its limits | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not an object, or `sessionId` is not 1 to 128 letters, digits, `_` and `-` (`invalid_session_id`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | Nothing covers 15 minutes of this machine's cloud compute (`budget_exceeded`), so no new compute starts. Nexus pays for cloud compute: it is held on the organization's Nexus balance (its subsidy, then its credits, then its contract), and on its budget. An organization past due gets `payment_past_due`. The refusal is recorded. When a running machine's next 15 minutes are refused, Gateway puts it to sleep, with `stopReason` `budget`. | | 403 | `role_required` | Your role does not have this permission | | 409 | | The create took so long that Gateway ended it (`machine_gone`); send a new one. | | 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 | | This `Idempotency-Key` names another machine (`idempotency_key_reused`); send a new key. | | 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 | `cloud_daily_starts` | One more answers 429 `cloud_daily_starts` until 00:00 UTC (`Retry-After`) | | 429 | `cloud_trial_limit` | One more answers 429 `cloud_trial_limit` or `cloud_trial_busy` (`Retry-After`), which name Billing | | 429 | `cloud_machine_limit` | One more answers 429 `cloud_machine_limit` | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/machines" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "sessionId": "<sessionId>", "title": "<title>", "name": "Platform", "size": "<size>", "repo": "<repo>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines) ## Pair cloud server `POST /v1/cloud/machines/pair` Pair your own server, so Nexus Desktop reaches it through Gateway with no SSH and no open port. `nexus-host login` calls this with the token its device sign-in got, and that token becomes the machine's own: only it opens the machine's host connection, and deleting the machine revokes it. It reads `ready`, with provider `own`; `hostOnline` says whether it answers. Nexus never starts, stops, sizes or charges it, and any organization may pair one. A second pairing with the same token answers the same machine. A person pairs at most 10 servers (409 `own_servers_full`). Permission: `cloud.machines.use` (Every member). ### Request body (application/json, required) - `name` (string, required): The server's name for your list. Gateway keeps its first line, cut to 120 characters. ### Responses - `200` OK (application/json, CloudMachine) - `id` (string, required): `cm_` and up to 64 base64url characters - `sessionId` (string | null, required): The desktop session the machine is for; null on a machine made before sessions. - `title` (string | null, required): The session's title, on one line; null when the create sent none. - `name` (string, required): The session's title, cut to 120 characters, or `Cloud`. - `provider` ("boat", required) - `size` ("small" | "default" | "large" | "xlarge", required): Nexus chooses it: `NEXUS_CLOUD_DEFAULT_SIZE` when made. - `state` ("queued" | "creating" | "starting" | "ready" | "sleeping" | "stopping" | "failed" | "gone", required): The desktop's `CloudState`. `queued` waits for a place, the person's next start or the provider; nothing runs. Running time is charged in `creating`, `starting` and `ready`. - `error` (string | null, required): Why it failed; null otherwise. - `createdAt` (string (date-time), required) - `sleepingSince` (string (date-time) | null, required): When it went to sleep; null unless `sleeping`. - `stopReason` ("budget" | "max_run" | "not_enabled" | "idle" | "resize" | null, required): Why Gateway put it to sleep: `budget` when its compute was refused, `max_run` after its longest run with no interaction (24 hours by default, from the person's last interaction, create, wake or access), `not_enabled` when the organization may no longer run machines, `idle` when nobody needs it (its agent idle 5 minutes and its person idle 20 minutes, or its host silent 15 minutes, or no report from its host in the 5 minutes after its last create, wake, access or connect), `resize` while it restarts one size bigger after it ran out of memory. Null otherwise, and cleared by a wake. - `queuedUntil` (string (date-time) | null, required): While `queued`: the earliest time Gateway tries to start it (the person's next start, the provider's `nextStartAt`, or the meter's next pass). Null otherwise. - `hostOnline` (boolean, required): The machine's host has its control connection open on this copy of Gateway: GET /v1/cloud/machines/{id}/connect can open a stream. - `400` The name is empty (`invalid_name`), or the token may not pair a server (`not_a_host_token`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` You have 10 servers paired already (`own_servers_full`) - `503` No provider account on this Gateway (`cloud_unavailable`), or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The name is empty (`invalid_name`), or the token may not pair a server (`not_a_host_token`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | You have 10 servers paired already (`own_servers_full`) | | 409 | `own_servers_full` | A person pairs at most 10 servers (409 `own_servers_full`) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`), or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/machines/pair" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Platform" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines%2Fpair) ## Get cloud machine `GET /v1/cloud/machines/{id}` One of your machines, its state read from the provider. A machine the provider no longer has is `gone`. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | ### Responses - `200` OK (application/json, CloudMachine) - `id` (string, required): `cm_` and up to 64 base64url characters - `sessionId` (string | null, required): The desktop session the machine is for; null on a machine made before sessions. - `title` (string | null, required): The session's title, on one line; null when the create sent none. - `name` (string, required): The session's title, cut to 120 characters, or `Cloud`. - `provider` ("boat", required) - `size` ("small" | "default" | "large" | "xlarge", required): Nexus chooses it: `NEXUS_CLOUD_DEFAULT_SIZE` when made. - `state` ("queued" | "creating" | "starting" | "ready" | "sleeping" | "stopping" | "failed" | "gone", required): The desktop's `CloudState`. `queued` waits for a place, the person's next start or the provider; nothing runs. Running time is charged in `creating`, `starting` and `ready`. - `error` (string | null, required): Why it failed; null otherwise. - `createdAt` (string (date-time), required) - `sleepingSince` (string (date-time) | null, required): When it went to sleep; null unless `sleeping`. - `stopReason` ("budget" | "max_run" | "not_enabled" | "idle" | "resize" | null, required): Why Gateway put it to sleep: `budget` when its compute was refused, `max_run` after its longest run with no interaction (24 hours by default, from the person's last interaction, create, wake or access), `not_enabled` when the organization may no longer run machines, `idle` when nobody needs it (its agent idle 5 minutes and its person idle 20 minutes, or its host silent 15 minutes, or no report from its host in the 5 minutes after its last create, wake, access or connect), `resize` while it restarts one size bigger after it ran out of memory. Null otherwise, and cleared by a wake. - `queuedUntil` (string (date-time) | null, required): While `queued`: the earliest time Gateway tries to start it (the person's next start, the provider's `nextStartAt`, or the meter's next pass). Null otherwise. - `hostOnline` (boolean, required): The machine's host has its control connection open on this copy of Gateway: GET /v1/cloud/machines/{id}/connect can open a stream. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. | ### Example ```sh curl "$NEXUS_URL/v1/cloud/machines/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D) ## Delete cloud machine `DELETE /v1/cloud/machines/{id}` Delete your machine at the provider, disk and all, and charge its running time. You may then create another. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `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, CloudMachineDeleted) - `id` (string, required) - `deleted` (boolean, required) - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 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 | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/cloud/machines/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D) ## Wake cloud machine `POST /v1/cloud/machines/{id}/wake` Wake your machine from its saved disk. Its address and host key change: ask for access again. Its running time is charged from now. When Gateway runs its most machines, the person woke 20 machines and gets one more wake a minute, or the provider is at its limits, the wake waits in the queue (202, state `queued`); the meter starts it in turn. A wake counts toward the day's starts: past them it answers 429 `cloud_daily_starts`. An organization with only the free start is on the trial: it runs one machine at a time, and all trial organizations together a few. A trial machine never waits in the queue: one more answers 429 `cloud_trial_limit` or `cloud_trial_busy` (`Retry-After`), which name Billing. Credits, a card or a contract lift the trial. A trial machine sleeps 2 hours after its wake (`max_run`). A run that stops in its first minute is charged a minute. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `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, CloudMachine) - `id` (string, required): `cm_` and up to 64 base64url characters - `sessionId` (string | null, required): The desktop session the machine is for; null on a machine made before sessions. - `title` (string | null, required): The session's title, on one line; null when the create sent none. - `name` (string, required): The session's title, cut to 120 characters, or `Cloud`. - `provider` ("boat", required) - `size` ("small" | "default" | "large" | "xlarge", required): Nexus chooses it: `NEXUS_CLOUD_DEFAULT_SIZE` when made. - `state` ("queued" | "creating" | "starting" | "ready" | "sleeping" | "stopping" | "failed" | "gone", required): The desktop's `CloudState`. `queued` waits for a place, the person's next start or the provider; nothing runs. Running time is charged in `creating`, `starting` and `ready`. - `error` (string | null, required): Why it failed; null otherwise. - `createdAt` (string (date-time), required) - `sleepingSince` (string (date-time) | null, required): When it went to sleep; null unless `sleeping`. - `stopReason` ("budget" | "max_run" | "not_enabled" | "idle" | "resize" | null, required): Why Gateway put it to sleep: `budget` when its compute was refused, `max_run` after its longest run with no interaction (24 hours by default, from the person's last interaction, create, wake or access), `not_enabled` when the organization may no longer run machines, `idle` when nobody needs it (its agent idle 5 minutes and its person idle 20 minutes, or its host silent 15 minutes, or no report from its host in the 5 minutes after its last create, wake, access or connect), `resize` while it restarts one size bigger after it ran out of memory. Null otherwise, and cleared by a wake. - `queuedUntil` (string (date-time) | null, required): While `queued`: the earliest time Gateway tries to start it (the person's next start, the provider's `nextStartAt`, or the meter's next pass). Null otherwise. - `hostOnline` (boolean, required): The machine's host has its control connection open on this copy of Gateway: GET /v1/cloud/machines/{id}/connect can open a stream. - `202` Accepted: the wake waits in the queue (`queued`, with `queuedUntil`) (application/json, CloudMachine) - `id` (string, required): `cm_` and up to 64 base64url characters - `sessionId` (string | null, required): The desktop session the machine is for; null on a machine made before sessions. - `title` (string | null, required): The session's title, on one line; null when the create sent none. - `name` (string, required): The session's title, cut to 120 characters, or `Cloud`. - `provider` ("boat", required) - `size` ("small" | "default" | "large" | "xlarge", required): Nexus chooses it: `NEXUS_CLOUD_DEFAULT_SIZE` when made. - `state` ("queued" | "creating" | "starting" | "ready" | "sleeping" | "stopping" | "failed" | "gone", required): The desktop's `CloudState`. `queued` waits for a place, the person's next start or the provider; nothing runs. Running time is charged in `creating`, `starting` and `ready`. - `error` (string | null, required): Why it failed; null otherwise. - `createdAt` (string (date-time), required) - `sleepingSince` (string (date-time) | null, required): When it went to sleep; null unless `sleeping`. - `stopReason` ("budget" | "max_run" | "not_enabled" | "idle" | "resize" | null, required): Why Gateway put it to sleep: `budget` when its compute was refused, `max_run` after its longest run with no interaction (24 hours by default, from the person's last interaction, create, wake or access), `not_enabled` when the organization may no longer run machines, `idle` when nobody needs it (its agent idle 5 minutes and its person idle 20 minutes, or its host silent 15 minutes, or no report from its host in the 5 minutes after its last create, wake, access or connect), `resize` while it restarts one size bigger after it ran out of memory. Null otherwise, and cleared by a wake. - `queuedUntil` (string (date-time) | null, required): While `queued`: the earliest time Gateway tries to start it (the person's next start, the provider's `nextStartAt`, or the meter's next pass). Null otherwise. - `hostOnline` (boolean, required): The machine's host has its control connection open on this copy of Gateway: GET /v1/cloud/machines/{id}/connect can open a stream. - `402` Nothing covers 15 minutes of this machine's cloud compute (`budget_exceeded`), so no new compute starts. Nexus pays for cloud compute: it is held on the organization's Nexus balance (its subsidy, then its credits, then its contract), and on its budget. An organization past due gets `payment_past_due`. The refusal is recorded. When a running machine's next 15 minutes are refused, Gateway puts it to sleep, with `stopReason` `budget`. - `403` Cloud machines are not turned on for this organization (`cloud_not_enabled`). Only the organizations Nexus lists may start or use a machine; anyone may still list, sleep and delete their own. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `409` The machine slept 14 days and the provider deleted its disk (`snapshot_data_expired`): it is now `gone`. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`), or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 202 | `queued` | When Gateway runs its most machines, the person woke 20 machines and gets one more wake a minute, or the provider is at its limits, the wake waits in the queue (202, state `queued`); the meter starts it in turn | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | Nothing covers 15 minutes of this machine's cloud compute (`budget_exceeded`), so no new compute starts. Nexus pays for cloud compute: it is held on the organization's Nexus balance (its subsidy, then its credits, then its contract), and on its budget. An organization past due gets `payment_past_due`. The refusal is recorded. When a running machine's next 15 minutes are refused, Gateway puts it to sleep, with `stopReason` `budget`. | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 409 | | The machine slept 14 days and the provider deleted its disk (`snapshot_data_expired`): it is now `gone`. | | 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 | `cloud_daily_starts` | Past them it answers 429 `cloud_daily_starts` | | 429 | `cloud_trial_limit` | One more answers 429 `cloud_trial_limit` or `cloud_trial_busy` (`Retry-After`), which name Billing | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`), or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/machines/<id>/wake" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fwake) ## Sleep cloud machine `POST /v1/cloud/machines/{id}/sleep` Put your machine to sleep: the provider saves its disk and frees the machine. Its running time is charged up to now. A queued wake leaves the queue, and the machine stays asleep. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `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, CloudMachine) - `id` (string, required): `cm_` and up to 64 base64url characters - `sessionId` (string | null, required): The desktop session the machine is for; null on a machine made before sessions. - `title` (string | null, required): The session's title, on one line; null when the create sent none. - `name` (string, required): The session's title, cut to 120 characters, or `Cloud`. - `provider` ("boat", required) - `size` ("small" | "default" | "large" | "xlarge", required): Nexus chooses it: `NEXUS_CLOUD_DEFAULT_SIZE` when made. - `state` ("queued" | "creating" | "starting" | "ready" | "sleeping" | "stopping" | "failed" | "gone", required): The desktop's `CloudState`. `queued` waits for a place, the person's next start or the provider; nothing runs. Running time is charged in `creating`, `starting` and `ready`. - `error` (string | null, required): Why it failed; null otherwise. - `createdAt` (string (date-time), required) - `sleepingSince` (string (date-time) | null, required): When it went to sleep; null unless `sleeping`. - `stopReason` ("budget" | "max_run" | "not_enabled" | "idle" | "resize" | null, required): Why Gateway put it to sleep: `budget` when its compute was refused, `max_run` after its longest run with no interaction (24 hours by default, from the person's last interaction, create, wake or access), `not_enabled` when the organization may no longer run machines, `idle` when nobody needs it (its agent idle 5 minutes and its person idle 20 minutes, or its host silent 15 minutes, or no report from its host in the 5 minutes after its last create, wake, access or connect), `resize` while it restarts one size bigger after it ran out of memory. Null otherwise, and cleared by a wake. - `queuedUntil` (string (date-time) | null, required): While `queued`: the earliest time Gateway tries to start it (the person's next start, the provider's `nextStartAt`, or the meter's next pass). Null otherwise. - `hostOnline` (boolean, required): The machine's host has its control connection open on this copy of Gateway: GET /v1/cloud/machines/{id}/connect can open a stream. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 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 | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/machines/<id>/sleep" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fsleep) ## Report cloud machine activity `POST /v1/cloud/machines/{id}/activity` A cloud machine's heartbeat, sent by its host (`nexus-host`) every minute with the machine's own Nexus token (the one in `~/.nexus/host/credentials`): whether its agent works, since when it is idle, the person's last interaction and the kernel's out-of-memory kill count. Gateway stores the last report. A time after now is taken as now. The report never extends the machine's longest run (`NEXUS_CLOUD_MAX_RUN_HOURS`, from the person's last create, wake or access). Gateway puts the machine to sleep (`idle`) when its agent was idle 5 minutes and its person did not interact for 20 minutes, and never while its agent works. A machine whose host sends no report for 15 minutes (or never sent one) sleeps 20 minutes after its last interaction, create, wake or access. A rise in the out-of-memory count restarts the machine one size bigger, up to `large` (`resize`). Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | ### Request body (application/json, required) - `busy` (boolean, required): Whether an agent on the machine works now. A permission prompt counts as idle. - `agentIdleSince` (string (date-time) | null): Since when every agent is idle; null while one works or before the first. - `interactedAt` (string (date-time) | null): The person's last interaction with the machine's sessions; null when there is none. - `oomKills` (integer): How many processes the kernel killed for want of memory since the machine started (its cgroup's `oom_kill`, else the system's). [min 0] ### Responses - `200` OK (application/json, CloudMachine) - `id` (string, required): `cm_` and up to 64 base64url characters - `sessionId` (string | null, required): The desktop session the machine is for; null on a machine made before sessions. - `title` (string | null, required): The session's title, on one line; null when the create sent none. - `name` (string, required): The session's title, cut to 120 characters, or `Cloud`. - `provider` ("boat", required) - `size` ("small" | "default" | "large" | "xlarge", required): Nexus chooses it: `NEXUS_CLOUD_DEFAULT_SIZE` when made. - `state` ("queued" | "creating" | "starting" | "ready" | "sleeping" | "stopping" | "failed" | "gone", required): The desktop's `CloudState`. `queued` waits for a place, the person's next start or the provider; nothing runs. Running time is charged in `creating`, `starting` and `ready`. - `error` (string | null, required): Why it failed; null otherwise. - `createdAt` (string (date-time), required) - `sleepingSince` (string (date-time) | null, required): When it went to sleep; null unless `sleeping`. - `stopReason` ("budget" | "max_run" | "not_enabled" | "idle" | "resize" | null, required): Why Gateway put it to sleep: `budget` when its compute was refused, `max_run` after its longest run with no interaction (24 hours by default, from the person's last interaction, create, wake or access), `not_enabled` when the organization may no longer run machines, `idle` when nobody needs it (its agent idle 5 minutes and its person idle 20 minutes, or its host silent 15 minutes, or no report from its host in the 5 minutes after its last create, wake, access or connect), `resize` while it restarts one size bigger after it ran out of memory. Null otherwise, and cleared by a wake. - `queuedUntil` (string (date-time) | null, required): While `queued`: the earliest time Gateway tries to start it (the person's next start, the provider's `nextStartAt`, or the meter's next pass). Null otherwise. - `hostOnline` (boolean, required): The machine's host has its control connection open on this copy of Gateway: GET /v1/cloud/machines/{id}/connect can open a stream. - `400` The body is not `{ busy, agentIdleSince, interactedAt, oomKills }`, or a time is not RFC 3339 (`invalid_time`). - `403` The caller's token is not this machine's own (`not_machine_token`): only the machine reports its activity. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `409` The provider has not made the machine yet (`machine_not_made`). - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`). ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not `{ busy, agentIdleSince, interactedAt, oomKills }`, or a time is not RFC 3339 (`invalid_time`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 409 | | The provider has not made the machine yet (`machine_not_made`). | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/machines/<id>/activity" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "busy": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Factivity) ## Cloud machine setup token `POST /v1/cloud/machines/{id}/setup-token` The machine's own setup at boot (on with `NEXUS_CLOUD_BOOT_SETUP`). The machine's host sends the sealed grant from its `cloud.json` with the machine's own Nexus token. Gateway answers the repository and a GitHub App token that may only read it, for an hour at most. Gateway seals a grant only when GitHub lets the session's person read the repository and the organization's GitHub App reaches it. The grant works for one hour after the create, and ends sooner when the machine's setup is ready (`setup-done`). Gateway never logs the token. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | ### Request body (application/json, required) - `grant` (string, required): The sealed grant from the machine's `cloud.json` (`setup.grant`). It holds no credential. [max length 4096] ### Responses - `200` OK (application/json, CloudSetupToken) - `repo` (string, required): The repository the machine sets up (`owner/name`). - `token` (string, required): A GitHub App token that may only read `repo`, for an hour at most. Keep it in memory only. - `400` The body is not `{ grant }`. - `403` The caller's token is not this machine's own (`not_machine_token`), or the grant is not this machine's, ran out, or the setup is off (`setup_grant_refused`). The app clones the repository instead. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `409` The organization's GitHub App no longer reaches the repository (`github_app_not_installed`), or the provider has not made the machine yet (`machine_not_made`). - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` GitHub gave no token (`github_unavailable`). Try again. - `503` No provider account on this Gateway (`cloud_unavailable`). ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not `{ grant }`. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 409 | | The organization's GitHub App no longer reaches the repository (`github_app_not_installed`), or the provider has not made the machine yet (`machine_not_made`). | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | GitHub gave no token (`github_unavailable`). Try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/machines/<id>/setup-token" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "grant": "<grant>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fsetup-token) ## Cloud machine setup done `POST /v1/cloud/machines/{id}/setup-done` The machine's own setup at boot is ready. The machine's host sends the sealed grant from its `cloud.json` with the machine's own Nexus token, and Gateway ends the grant: no setup token is given for the machine again. A repeat is fine. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | ### Request body (application/json, required) - `grant` (string, required): The sealed grant from the machine's `cloud.json` (`setup.grant`). It holds no credential. [max length 4096] ### Responses - `200` OK (application/json, CloudSetupDone) - `ended` (boolean, required): True: the grant ended, and no setup token is given for the machine again. - `400` The body is not `{ grant }`. - `403` The caller's token is not this machine's own (`not_machine_token`), or the grant is not this machine's, ran out, or the setup is off (`setup_grant_refused`). The app clones the repository instead. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `409` The provider has not made the machine yet (`machine_not_made`). - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`). ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not `{ grant }`. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 409 | | The provider has not made the machine yet (`machine_not_made`). | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/machines/<id>/setup-done" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "grant": "<grant>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fsetup-done) ## Cloud machine access `POST /v1/cloud/machines/{id}/access` Add this device's SSH public key to your machine. Answers where to connect and the host key to pin. Both change on every wake. An access with the machine's own Nexus token does not count as the person's activity. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `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) - `publicKey` (string, required): One SSH public key line, such as `ssh-ed25519 AAAA…`. [max length 4096] ### Responses - `200` OK (application/json, CloudAccess) - `host` (string, required) - `port` (integer, required) [min 1; max 65535] - `user` (string, required) - `hostKey` (string, required): The machine's SSH host key, to pin. - `400` `publicKey` is not one SSH public key line (`invalid_ssh_key`), or the machine is not running (`machine_not_running`). - `403` Cloud machines are not turned on for this organization (`cloud_not_enabled`). Only the organizations Nexus lists may start or use a machine; anyone may still list, sleep and delete their own. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `publicKey` is not one SSH public key line (`invalid_ssh_key`), or the machine is not running (`machine_not_running`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 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 | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/machines/<id>/access" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "publicKey": "<publicKey>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Faccess) ## Cloud machine connect `GET /v1/cloud/machines/{id}/connect` A stream to your machine's host, a WebSocket, with your Gateway token: the desktop app's connection to its cloud session, with no SSH. Gateway asks the host to open its side and joins the two. Each text and binary frame and the close pass on as they came. Gateway reads and stores no frame. A frame is at most 16 MiB. Gateway pings every 20 seconds. When the host does not open its side within 10 seconds, the stream closes with 1013 (try again later); when Gateway stops, with 1012. A joined stream counts as an interaction, as an access does. Gateway holds the streams in memory, on one copy. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `Upgrade` | header | "websocket" | yes | A WebSocket upgrade (RFC 6455). | ### Responses - `101` Switching Protocols: Gateway asks the host to open its side. - `400` The request is not a WebSocket upgrade (`websocket_required`). - `403` Cloud machines are not turned on for this organization (`cloud_not_enabled`). - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `409` The machine's host is not connected (`host_offline`): it is asleep or still starting. Wake it, or try again after `Retry-After` seconds. - `429` The machine has its most streams open, 8 (`too_many_streams`): close one first. Also over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. - `503` No provider account on this Gateway (`cloud_unavailable`). Also `machine_not_ready`: the provider has not made the machine yet. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | The request is not a WebSocket upgrade (`websocket_required`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 409 | | The machine's host is not connected (`host_offline`): it is asleep or still starting. Wake it, or try again after `Retry-After` seconds. | | 429 | | The machine has its most streams open, 8 (`too_many_streams`): close one first. Also over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`). Also `machine_not_ready`: the provider has not made the machine yet. | ### Example ```sh curl "$NEXUS_URL/v1/cloud/machines/<id>/connect" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fconnect) ## Cloud machine host `GET /v1/cloud/machines/{id}/host` The control connection of a cloud machine's host (`nexus-host`), a WebSocket, with the machine's own Nexus token (the one in `~/.nexus/host/credentials`). Gateway sends it a text frame `{"type":"open","stream":"<id>"}` for each app stream, and the host opens that stream within 10 seconds (GET /v1/cloud/machines/{id}/host/streams/{stream}). The host sends nothing but pings. One per machine: a new one closes the old one (close code 1000, `replaced`). Gateway pings every 20 seconds and closes with 1012 when it stops. While it is open, the machine's `hostOnline` is true. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `Upgrade` | header | "websocket" | yes | A WebSocket upgrade (RFC 6455). | ### Responses - `101` Switching Protocols: the control connection is open. - `400` The request is not a WebSocket upgrade (`websocket_required`). - `403` The caller's token is not this machine's own (`not_machine_token`): only the machine's host opens it. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`). ### Errors | Status | Code | When | | --- | --- | --- | | 100 | `replaced` | A new one closes the old one (close code 1000, `replaced`) | | 400 | | The request is not a WebSocket upgrade (`websocket_required`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`). | ### Example ```sh curl "$NEXUS_URL/v1/cloud/machines/<id>/host" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fhost) ## Cloud machine host stream `GET /v1/cloud/machines/{id}/host/streams/{stream}` A stream from a cloud machine's host, a WebSocket, with the machine's own Nexus token: the answer to an `open` frame of its control connection. Gateway joins it to the app that waits, and passes each text and binary frame and the close on as they came. Gateway reads and stores no frame. A frame is at most 16 MiB. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `stream` | path | string | yes | The stream's id, from the control connection's `open` frame | | `Upgrade` | header | "websocket" | yes | A WebSocket upgrade (RFC 6455). | ### Responses - `101` Switching Protocols: the stream is joined to the app's. - `400` The request is not a WebSocket upgrade (`websocket_required`). - `403` The caller's token is not this machine's own (`not_machine_token`): only the machine's host opens it. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. Also `no_such_stream`: no app waits for this stream (it gave up after 10 seconds, or the id is another machine's). - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`). ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | The request is not a WebSocket upgrade (`websocket_required`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. Also `no_such_stream`: no app waits for this stream (it gave up after 10 seconds, or the id is another machine's). | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`). | ### Example ```sh curl "$NEXUS_URL/v1/cloud/machines/<id>/host/streams/<stream>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fhost%2Fstreams%2F%7Bstream%7D) ## Cloud machine link `POST /v1/cloud/machines/{id}/links` A private link to a port on your machine (`{kind: "port", port}`, until it sleeps), or to its desktop stream (`{kind: "desktop"}`, for 10 minutes). On the cloud trial, a port link answers 403 `cloud_trial_no_links`. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `kind` ("port" | "desktop", required) - `port` (integer): Required with `kind: port`. [min 1; max 65535] ### Responses - `200` OK (application/json, CloudLink) - `url` (string (uri), required) - `expiresAt` (string (date-time) | null, required): When the link stops working; null when it lasts until the machine sleeps. - `400` `kind` or `port` is not valid (`invalid_port`: 1 to 65535, not 22, 6080, 8090, 8911 or 47984 to 48010). - `403` Cloud machines are not turned on for this organization (`cloud_not_enabled`). Only the organizations Nexus lists may start or use a machine; anyone may still list, sleep and delete their own. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `kind` or `port` is not valid (`invalid_port`: 1 to 65535, not 22, 6080, 8090, 8911 or 47984 to 48010). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `cloud_trial_no_links` | On the cloud trial, a port link answers 403 `cloud_trial_no_links` | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 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 | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/machines/<id>/links" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "kind": "port" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Flinks) ## Cloud machine sleep key `POST /v1/cloud/machines/{id}/sleep-key` A provider key that may only read and stop this one machine, for the machine's own idle timer, with the provider API it calls and the machine's id there. Gateway makes it once and keeps it sealed with the machine: each call answers the same key, a new one is made only when the provider no longer takes the old one, and the key is revoked when the machine is deleted. `key` is null when the provider refuses to make one. It is the only provider key that leaves Gateway. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `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, CloudSleepKey) - `key` (string | null, required): A provider key that may only read and stop this machine; null when the provider refused. - `apiUrl` (string (uri), required): The provider API the key calls. - `providerId` (string, required): The machine's id at the provider. - `403` Cloud machines are not turned on for this organization (`cloud_not_enabled`). Only the organizations Nexus lists may start or use a machine; anyone may still list, sleep and delete their own. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 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 | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`) or the machine is not ready yet (the provider's code, such as `sandbox_restoring`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/machines/<id>/sleep-key" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fsleep-key) ## List cloud history threads `GET /v1/cloud/machines/{id}/history` The machine's workbench threads that have stored history, most recently updated first, at most 500, with each one's stored range. The machine's owner reads it, and so does the machine's own Nexus token, which backfills after the last stored event when it wakes. `enabled` is false, with no threads, while the organization's `cloudHistory` is off. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | ### Responses - `200` OK (application/json, CloudHistoryThreads) - `machineId` (string, required) - `enabled` (boolean, required): The organization's `cloudHistory` - `threads` (array of CloudHistoryThread, required) - `threadId` (string, required) - `firstSeq` (integer, required): The first stored event's number - `lastSeq` (integer, required): The last stored event's number: every number from firstSeq to it is stored - `lastEventAt` (integer, required): The machine's time of the last event, in milliseconds since 1970 - `updatedAt` (string (date-time), required) - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 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/cloud/machines/<id>/history" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fhistory) ## Delete cloud history thread `DELETE /v1/cloud/machines/{id}/history/{threadId}` Deletes a thread's stored history, as the workbench deleted or archived the thread. The machine's owner or its own Nexus token. A repeat changes nothing. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `threadId` | path | string | yes | The workbench thread id on the machine: the session's `sessionId` (`t_…`) for its main thread | ### Responses - `200` OK (application/json, CloudHistoryThreadDeleted) - `machineId` (string, required) - `threadId` (string, required) - `deleted` (boolean, required) - `400` The thread id is not 1 to 128 letters, digits, `_` and `-` (`invalid_request`). - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | The thread id is not 1 to 128 letters, digits, `_` and `-` (`invalid_request`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 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/cloud/machines/<id>/history/<threadId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fhistory%2F%7BthreadId%7D) ## List cloud history events `GET /v1/cloud/machines/{id}/history/{threadId}/events` A page of a thread's stored events, in number order, for the machine's owner only. Without `after` or `before`, the page is the thread's latest events. With `before`, it ends just before that event; with `after`, it starts just after it. A page holds at most `limit` events and about 4 MiB of bodies after its first event. An event whose body was over the per-event cap (256 KiB) has a null `body` and its size in `omittedBytes`. A thread with nothing stored answers no events and null numbers. While the organization's `cloudHistory` is off, `enabled` is false and there are no events. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `threadId` | path | string | yes | The workbench thread id on the machine: the session's `sessionId` (`t_…`) for its main thread | | `after` | query | integer | no | Start just after this event number | | `before` | query | integer | no | End just before this event number; not with `after` | | `limit` | query | integer | no | The most events a page holds | ### Responses - `200` OK (application/json, CloudHistoryEventPage) - `machineId` (string, required) - `threadId` (string, required) - `enabled` (boolean, required): The organization's `cloudHistory` - `firstSeq` (integer | null, required): The first stored event's number; null when none is stored - `lastSeq` (integer | null, required): The last stored event's number; null when none is stored - `events` (array of CloudHistoryEvent, required) - `seq` (integer, required): The machine's workbench event number [min 1] - `at` (integer, required): The machine's time of the event, in milliseconds since 1970 - `body` (string | null, required): The workbench event's JSON text, as the machine sent it; null when it was over the per-event cap - `omittedBytes` (integer): The size of a body over the per-event cap; absent when `body` is there [min 0] - `400` `after` with `before`, a number that is not a whole number, a `limit` outside 1 to 500, or a bad thread id (`invalid_request`). - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `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 | | --- | --- | --- | | 256 | `body` | An event whose body was over the per-event cap (256 KiB) has a null `body` and its size in `omittedBytes` | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `after` with `before`, a number that is not a whole number, a `limit` outside 1 to 500, or a bad thread id (`invalid_request`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 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/cloud/machines/<id>/history/<threadId>/events" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fhistory%2F%7BthreadId%7D%2Fevents) ## Append cloud history events `POST /v1/cloud/machines/{id}/history/{threadId}/events` Stores a thread's next events, sent by the machine's host (`nexus-host`) with the machine's own Nexus token as its workbench log appends them. 1 to 64 events with consecutive numbers. The first is at most one past the last stored, or 1 for a new thread. An event already stored must come back identical, so a retried batch never duplicates. All or nothing. A body over 256 KiB is stored as omitted, with its size, and never refused. While the organization's `cloudHistory` is off, nothing is stored and `enabled` is false. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The machine's id (`cm_…`), as POST /v1/cloud/machines answered it | | `threadId` | path | string | yes | The workbench thread id on the machine: the session's `sessionId` (`t_…`) for its main thread | ### Request body (application/json, required) - `events` (array of object, required) [at most 64 items] - `seq` (integer, required) [min 1] - `at` (integer, required): Milliseconds since 1970 [min 0] - `body` (string): The workbench event's JSON text - `omittedBytes` (integer): Instead of `body`: the host dropped a body over the per-event cap, of this size [min 0] ### Responses - `200` OK (application/json, CloudHistoryAppended) - `machineId` (string, required) - `threadId` (string, required) - `enabled` (boolean, required): The organization's `cloudHistory`; false, and nothing was stored - `lastSeq` (integer | null, required): The last stored event's number: send the next one after it; null when nothing is stored - `appended` (integer, required): How many events this call stored [min 0] - `400` No events, more than 64, numbers that are not consecutive or under 1, a bad time, a body that is not JSON, or an event with both or neither of `body` and `omittedBytes` (`invalid_request`). - `403` The caller's token is not this machine's own (`not_machine_token`): only the machine sends its history. - `404` No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. - `409` The first event is past the next one Gateway expects (`seq_gap`): read listCloudHistoryThreads and send from its `lastSeq` + 1. Or an event already stored differs from the one sent (`event_conflict`). - `413` The person's cloud history in this organization holds its cap (`cloud_history_full`), or the body is over 1 MB. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | No events, more than 64, numbers that are not consecutive or under 1, a bad time, a body that is not JSON, or an event with both or neither of `body` and `omittedBytes` (`invalid_request`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such machine of yours: another person's machine, another organization's and a deleted one are as absent as a missing one. | | 409 | | The first event is past the next one Gateway expects (`seq_gap`): read listCloudHistoryThreads and send from its `lastSeq` + 1. Or an event already stored differs from the one sent (`event_conflict`). | | 413 | | The person's cloud history in this organization holds its cap (`cloud_history_full`), or the body is over 1 MB. | | 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/cloud/machines/<id>/history/<threadId>/events" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "events": [ { "seq": 1, "at": 0 } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fmachines%2F%7Bid%7D%2Fhistory%2F%7BthreadId%7D%2Fevents) --- <!-- /docs/api/cloud-sessions --> # Cloud sessions > Headless cloud sessions: a cloud session that starts with no desktop app, for the assistant, the CLI, MCP and the apps. Each session runs on its own cloud machine of yours, with the cloud machines' limits and charges. A session is its person's alone: to anyone else it does not exist. Off unless `NEXUS_SESSIONS_API` is on: every route then answers 404. ## List sessions `GET /v1/sessions` Your headless cloud sessions in this organization, newest first (at most 50), each with its cloud machine. Permission: `cloud.machines.use` (Every member). ### Responses - `200` OK (application/json, SessionList) - `sessions` (array of Session, required) - `id` (string, required): `cs_` and 40 hex characters - `repo` (string, required): GitHub `owner/name`, lowercased - `agent` (string, required): `claude` or `codex`: a cloud session launches only these two agents today. - `model` (string | null, required): The agent's model name; null for its default. - `title` (string | null, required): The session's title; null when the start sent none. - `state` ("starting" | "running" | "stopped" | "failed", required): `starting`: the machine boots or sets the repository up, or the prompt waits for its host. `running`: the agent started. `stopped` and `failed` are final. - `threadId` (string | null, required): The session's id on its machine once the agent started (`t_<uuid>`). - `error` (string | null, required): Why it failed, or why the last message may not have reached it. - `startedBy` (SessionStartedBy, required): Who started a session. Absent on a start: you (`person`). - `kind` ("person" | "assistant_conversation" | "room" | "session", required) - `id` (string, required): A user id (yours, for `person`), an assistant conversation's id, a room's id, or a session of yours (`cs_…`). - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `stoppedAt` (string (date-time) | null, required): When it stopped or failed. - `machine` (CloudMachine | null, required): Its cloud machine; null once the machine is deleted. - `fencingToken` (integer, required): The session's current fencing token: 0 until a runner first takes it, then raised by one on each take. [min 0] - `runner` (SessionRunner | null, required): The runner that took the session last, and its lease; null until one takes it. - `404` `NEXUS_SESSIONS_API` is off. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. ### 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 | | `NEXUS_SESSIONS_API` is off. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl "$NEXUS_URL/v1/sessions" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fsessions) ## Create session `POST /v1/sessions` Start a headless cloud session: a cloud session with no desktop app. Gateway creates your cloud machine for the session (as POST /v1/cloud/machines does, with its limits and charges), the machine clones `repo` and runs its `.agents/setup` at boot with the organization's Nexus GitHub App, and Gateway then starts the agent on the machine with `prompt` as its first message. The prompt never goes to the provider: Gateway sends it to the machine's host once the host is online. The agent runs on the Nexus route, charged to the organization, in `auto` permission mode. Send `idempotencyKey` (or an `Idempotency-Key` header): the session's id is derived from it, so a resend answers the same session. Read the session (GET) to see it move from `starting` to `running`. Off unless `NEXUS_SESSIONS_API` is on. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-github-token` | header | string | no | Your own GitHub token. Gateway asks GitHub with it whether you may read `repo`. Used for that check only, never kept, and never sent to the machine. Without it, Gateway uses your own `github` connection (connect it with `POST /v1/connections/github/oauth`). | | `x-nexus-github-account` | header | string | no | The id of your linked GitHub account when you have more than one. | | `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) - `repo` (string): The GitHub repository, `owner/name` (a github.com URL also works). Required for now. - `projectId` (string): Reserved for projects: refused for now (`project_id_unsupported`). - `agent` (string): A coding agent that runs in cloud sessions: `claude` or `codex`, and `opencode` when the Gateway turns it on. Absent, empty or `auto`: the model picks it (open-weight models run on `opencode`, Anthropic models on `claude`, OpenAI models on `codex`). Another agent is refused with `invalid_agent`. - `model` (string): A catalog model (`GET /v1/models`) or the agent's own model name; absent for the agent's default. Required when `agent` is absent. With `agent`, a catalog model that another agent runs is refused with `agent_model_mismatch`. - `prompt` (string, required): The session's first message, 1 to 100000 characters. - `title` (string): The session's title, kept on one line, at most 200 characters. - `idempotencyKey` (string): Names the session: a resend with the same body answers the same session. Else the `Idempotency-Key` header's. - `startedBy` (SessionStartedBy): Who started a session. Absent on a start: you (`person`). - `kind` ("person" | "assistant_conversation" | "room" | "session", required) - `id` (string, required): A user id (yours, for `person`), an assistant conversation's id, a room's id, or a session of yours (`cs_…`). ### Responses - `200` The session a start with this key made (application/json, Session) - `id` (string, required): `cs_` and 40 hex characters - `repo` (string, required): GitHub `owner/name`, lowercased - `agent` (string, required): `claude` or `codex`: a cloud session launches only these two agents today. - `model` (string | null, required): The agent's model name; null for its default. - `title` (string | null, required): The session's title; null when the start sent none. - `state` ("starting" | "running" | "stopped" | "failed", required): `starting`: the machine boots or sets the repository up, or the prompt waits for its host. `running`: the agent started. `stopped` and `failed` are final. - `threadId` (string | null, required): The session's id on its machine once the agent started (`t_<uuid>`). - `error` (string | null, required): Why it failed, or why the last message may not have reached it. - `startedBy` (SessionStartedBy, required): Who started a session. Absent on a start: you (`person`). - `kind` ("person" | "assistant_conversation" | "room" | "session", required) - `id` (string, required): A user id (yours, for `person`), an assistant conversation's id, a room's id, or a session of yours (`cs_…`). - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `stoppedAt` (string (date-time) | null, required): When it stopped or failed. - `machine` (CloudMachine | null, required): Its cloud machine; null once the machine is deleted. - `fencingToken` (integer, required): The session's current fencing token: 0 until a runner first takes it, then raised by one on each take. [min 0] - `runner` (SessionRunner | null, required): The runner that took the session last, and its lease; null until one takes it. - `201` Created: the machine starts, and the prompt waits for its host (application/json, Session) - `id` (string, required): `cs_` and 40 hex characters - `repo` (string, required): GitHub `owner/name`, lowercased - `agent` (string, required): `claude` or `codex`: a cloud session launches only these two agents today. - `model` (string | null, required): The agent's model name; null for its default. - `title` (string | null, required): The session's title; null when the start sent none. - `state` ("starting" | "running" | "stopped" | "failed", required): `starting`: the machine boots or sets the repository up, or the prompt waits for its host. `running`: the agent started. `stopped` and `failed` are final. - `threadId` (string | null, required): The session's id on its machine once the agent started (`t_<uuid>`). - `error` (string | null, required): Why it failed, or why the last message may not have reached it. - `startedBy` (SessionStartedBy, required): Who started a session. Absent on a start: you (`person`). - `kind` ("person" | "assistant_conversation" | "room" | "session", required) - `id` (string, required): A user id (yours, for `person`), an assistant conversation's id, a room's id, or a session of yours (`cs_…`). - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `stoppedAt` (string (date-time) | null, required): When it stopped or failed. - `machine` (CloudMachine | null, required): Its cloud machine; null once the machine is deleted. - `fencingToken` (integer, required): The session's current fencing token: 0 until a runner first takes it, then raised by one on each take. [min 0] - `runner` (SessionRunner | null, required): The runner that took the session last, and its lease; null until one takes it. - `400` A field is wrong: `invalid_repo` (not GitHub `owner/name`), `invalid_agent` (not an agent this Gateway runs in cloud sessions), `invalid_model`, `model_required` (no agent and no model), `unknown_model`, `model_coming_soon` or `unsupported_cloud_model` (no cloud agent runs the model), `agent_model_mismatch` (the model runs on another agent; `error.nexus` names `agent`, `model` and `modelAgent`), `invalid_prompt`, `invalid_started_by`, `idempotency_key_required`, or `project_id_unsupported` (`projectId` is reserved). - `402` Nothing covers 15 minutes of the machine's cloud compute (`budget_exceeded`), or the organization is past due (`payment_past_due`). - `403` Cloud machines are disabled (`cloud_not_enabled`), the organization disallows the GitHub connection (`connector_disabled`), or it needs reconnecting (`connection_expired`). - `404` `NEXUS_SESSIONS_API` is off. - `409` No `x-nexus-github-token` header and no `github` connection of your own (`github_connection_required`, with `error.nexus.connect` set to `github`): connect your GitHub account, then start again. Or the machine may not set the repository up (`repo_setup_unavailable`): you cannot read it, or the organization's Nexus GitHub App does not reach it. - `422` This key names another session (`idempotency_key_reused`); send a new key. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A field is wrong: `invalid_repo` (not GitHub `owner/name`), `invalid_agent` (not an agent this Gateway runs in cloud sessions), `invalid_model`, `model_required` (no agent and no model), `unknown_model`, `model_coming_soon` or `unsupported_cloud_model` (no cloud agent runs the model), `agent_model_mismatch` (the model runs on another agent; `error.nexus` names `agent`, `model` and `modelAgent`), `invalid_prompt`, `invalid_started_by`, `idempotency_key_required`, or `project_id_unsupported` (`projectId` is reserved). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | Nothing covers 15 minutes of the machine's cloud compute (`budget_exceeded`), or the organization is past due (`payment_past_due`). | | 403 | `role_required` | Your role does not have this permission | | 404 | | `NEXUS_SESSIONS_API` is off. | | 409 | | No `x-nexus-github-token` header and no `github` connection of your own (`github_connection_required`, with `error.nexus.connect` set to `github`): connect your GitHub account, then start again. Or the machine may not set the repository up (`repo_setup_unavailable`): you cannot read it, or the organization's Nexus GitHub App does not reach it. | | 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 | | This key names another session (`idempotency_key_reused`); send a new key. | | 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 | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/sessions" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "prompt": "<prompt>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fsessions) ## Get session `GET /v1/sessions/{id}` Your session: its state, its id on the machine once it started, its lineage and its cloud machine. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`cs_…`), as POST /v1/sessions answered it | ### Responses - `200` OK (application/json, Session) - `id` (string, required): `cs_` and 40 hex characters - `repo` (string, required): GitHub `owner/name`, lowercased - `agent` (string, required): `claude` or `codex`: a cloud session launches only these two agents today. - `model` (string | null, required): The agent's model name; null for its default. - `title` (string | null, required): The session's title; null when the start sent none. - `state` ("starting" | "running" | "stopped" | "failed", required): `starting`: the machine boots or sets the repository up, or the prompt waits for its host. `running`: the agent started. `stopped` and `failed` are final. - `threadId` (string | null, required): The session's id on its machine once the agent started (`t_<uuid>`). - `error` (string | null, required): Why it failed, or why the last message may not have reached it. - `startedBy` (SessionStartedBy, required): Who started a session. Absent on a start: you (`person`). - `kind` ("person" | "assistant_conversation" | "room" | "session", required) - `id` (string, required): A user id (yours, for `person`), an assistant conversation's id, a room's id, or a session of yours (`cs_…`). - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `stoppedAt` (string (date-time) | null, required): When it stopped or failed. - `machine` (CloudMachine | null, required): Its cloud machine; null once the machine is deleted. - `fencingToken` (integer, required): The session's current fencing token: 0 until a runner first takes it, then raised by one on each take. [min 0] - `runner` (SessionRunner | null, required): The runner that took the session last, and its lease; null until one takes it. - `404` No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl "$NEXUS_URL/v1/sessions/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fsessions%2F%7Bid%7D) ## Send session message `POST /v1/sessions/{id}/messages` Send the session's agent its next message. It waits for the machine's host, after the messages before it, and a sleeping machine wakes for it (with the wake's limits and charges). A message whose answer the host lost is not sent again: the session's `error` says so. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`cs_…`), as POST /v1/sessions answered it | | `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) - `text` (string, required): 1 to 100000 characters. ### Responses - `202` Accepted: the message waits for the machine's host (application/json, Session) - `id` (string, required): `cs_` and 40 hex characters - `repo` (string, required): GitHub `owner/name`, lowercased - `agent` (string, required): `claude` or `codex`: a cloud session launches only these two agents today. - `model` (string | null, required): The agent's model name; null for its default. - `title` (string | null, required): The session's title; null when the start sent none. - `state` ("starting" | "running" | "stopped" | "failed", required): `starting`: the machine boots or sets the repository up, or the prompt waits for its host. `running`: the agent started. `stopped` and `failed` are final. - `threadId` (string | null, required): The session's id on its machine once the agent started (`t_<uuid>`). - `error` (string | null, required): Why it failed, or why the last message may not have reached it. - `startedBy` (SessionStartedBy, required): Who started a session. Absent on a start: you (`person`). - `kind` ("person" | "assistant_conversation" | "room" | "session", required) - `id` (string, required): A user id (yours, for `person`), an assistant conversation's id, a room's id, or a session of yours (`cs_…`). - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `stoppedAt` (string (date-time) | null, required): When it stopped or failed. - `machine` (CloudMachine | null, required): Its cloud machine; null once the machine is deleted. - `fencingToken` (integer, required): The session's current fencing token: 0 until a runner first takes it, then raised by one on each take. [min 0] - `runner` (SessionRunner | null, required): The runner that took the session last, and its lease; null until one takes it. - `400` `text` is blank or longer than 100000 characters (`invalid_text`). - `404` No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off. - `409` The session stopped or failed (`session_ended`). - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `text` is blank or longer than 100000 characters (`invalid_text`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off. | | 409 | | The session stopped or failed (`session_ended`). | | 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 | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/sessions/<id>/messages" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "text": "<text>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fsessions%2F%7Bid%7D%2Fmessages) ## Stop session `POST /v1/sessions/{id}/stop` Stop the session. Before its agent started, it ends now and its machine goes to sleep. After, Gateway asks the machine's host to stop the agent, and the session ends (`stopped`) once it did; the machine then sleeps when idle. A stop of an ended session changes nothing. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`cs_…`), as POST /v1/sessions answered it | | `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, Session) - `id` (string, required): `cs_` and 40 hex characters - `repo` (string, required): GitHub `owner/name`, lowercased - `agent` (string, required): `claude` or `codex`: a cloud session launches only these two agents today. - `model` (string | null, required): The agent's model name; null for its default. - `title` (string | null, required): The session's title; null when the start sent none. - `state` ("starting" | "running" | "stopped" | "failed", required): `starting`: the machine boots or sets the repository up, or the prompt waits for its host. `running`: the agent started. `stopped` and `failed` are final. - `threadId` (string | null, required): The session's id on its machine once the agent started (`t_<uuid>`). - `error` (string | null, required): Why it failed, or why the last message may not have reached it. - `startedBy` (SessionStartedBy, required): Who started a session. Absent on a start: you (`person`). - `kind` ("person" | "assistant_conversation" | "room" | "session", required) - `id` (string, required): A user id (yours, for `person`), an assistant conversation's id, a room's id, or a session of yours (`cs_…`). - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `stoppedAt` (string (date-time) | null, required): When it stopped or failed. - `machine` (CloudMachine | null, required): Its cloud machine; null once the machine is deleted. - `fencingToken` (integer, required): The session's current fencing token: 0 until a runner first takes it, then raised by one on each take. [min 0] - `runner` (SessionRunner | null, required): The runner that took the session last, and its lease; null until one takes it. - `404` No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off. | | 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 | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/sessions/<id>/stop" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fsessions%2F%7Bid%7D%2Fstop) ## Take session runner `POST /v1/sessions/{id}/runner` Take the session as its runner: the desktop app, nexus-host or a cloud machine that runs its agent. The runner gets the session's next fencing token and a lease of 60 seconds, which it renews every 20 seconds (POST /v1/sessions/{id}/runner/renew). Without `seenToken`, the take succeeds only when no runner's lease is live: the first take, or a takeover after the lease passed. With `seenToken` (the session's `fencingToken` as you read it), it is a handoff: it takes the session from whoever holds it, while that is still the session's token. Each take raises the token by one, so the runner it replaced gets 409 `lost_runner` on its next renewal or connector write. Of two takes at once, one wins and the other gets 409 `takeover_conflict`. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`cs_…`), as POST /v1/sessions answered it | ### Request body (application/json, required) - `runnerId` (string, required): Who takes the session: a name of the runner's own, such as its device id. [min length 1; max length 200] - `seenToken` (integer | null): The session's `fencingToken` as you read it: take the session over from its holder (a handoff) while that is still its token. [min 0] ### Responses - `200` OK (application/json, SessionRunner) - `runnerId` (string, required): The runner, as it named itself when it took the session. - `fencingToken` (integer, required): The token the runner holds. Its connector writes inside the session send it in `x-nexus-fencing-token`. [min 1] - `leaseExpiresAt` (string (date-time), required): When the lease ends unless the runner renews it. After it, another runner may take the session without `seenToken`. - `400` `invalid_runner_id` or `invalid_token`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` `takeover_conflict`: another runner's lease is live and the take named no `seenToken`, or the token you saw is no longer the session's (`error.nexus.currentFencingToken`). `session_ended`: the session stopped or failed. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `invalid_runner_id` or `invalid_token`. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off. | | 409 | | `takeover_conflict`: another runner's lease is live and the take named no `seenToken`, or the token you saw is no longer the session's (`error.nexus.currentFencingToken`). `session_ended`: the session stopped or failed. | | 409 | `lost_runner` | Each take raises the token by one, so the runner it replaced gets 409 `lost_runner` on its next renewal or connector write | | 409 | `takeover_conflict` | Of two takes at once, one wins and the other gets 409 `takeover_conflict` | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/sessions/<id>/runner" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "runnerId": "<runnerId>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fsessions%2F%7Bid%7D%2Frunner) ## Renew session runner `POST /v1/sessions/{id}/runner/renew` Renew the runner's lease for 60 seconds more. Only the holder of the session's current fencing token renews; a lease that passed renews too while no other runner took the session. Send it without `Idempotency-Key`: a retry has the same effect while the token is current. A key, when sent, is kept and replayed as on any write. Permission: `cloud.machines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The session's id (`cs_…`), as POST /v1/sessions answered it | ### Request body (application/json, required) - `fencingToken` (integer, required): The token the runner got when it took the session. [min 1] ### Responses - `200` OK (application/json, SessionRunner) - `runnerId` (string, required): The runner, as it named itself when it took the session. - `fencingToken` (integer, required): The token the runner holds. Its connector writes inside the session send it in `x-nexus-fencing-token`. [min 1] - `leaseExpiresAt` (string (date-time), required): When the lease ends unless the runner renews it. After it, another runner may take the session without `seenToken`. - `400` The body is not `{ fencingToken }`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` `lost_runner`: another runner took the session, so stop running it and stop writing for it (`error.nexus.currentFencingToken`). `session_ended`: the session stopped or failed. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not `{ fencingToken }`. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such session of yours: another person's session and another organization's are as absent as a missing one. Every sessions route answers 404 while `NEXUS_SESSIONS_API` is off. | | 409 | | `lost_runner`: another runner took the session, so stop running it and stop writing for it (`error.nexus.currentFencingToken`). `session_ended`: the session stopped or failed. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/sessions/<id>/runner/renew" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "fencingToken": 1 }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fsessions%2F%7Bid%7D%2Frunner%2Frenew) --- <!-- /docs/api/cloud-sandboxes --> # Cloud sandboxes > Cloud sandboxes: a module's throwaway machine at a cloud provider (boat.dev in v1), on Nexus's own provider account, for commands Nexus does not trust. Nexus Review's agent runs its commands in one. Only Nexus Review's module key may use them (`cloud.sandboxes.use`, product `robustness`, capability `review`). A sandbox gets no Nexus token and no files. At most `NEXUS_CLOUD_MAX_SANDBOXES` live at once; one more is refused, with no queue. Gateway charges a sandbox's running time to the organization as cloud compute (product `cloud`, capability `compute` in GET /v1/spend), from its create to its delete, and deletes it at its `expiresAt`. Without a provider account on the Gateway (`BOAT_API_KEY`), every route answers 503 `cloud_unavailable`. ## Create cloud sandbox `POST /v1/cloud/sandboxes` Create a throwaway sandbox for untrusted commands. Send `ttlSeconds` (60 to 7200): Gateway deletes the sandbox then, and the provider's own timer stops it. `size` is one of `NEXUS_CLOUD_SIZES` (`small` when absent). `labels` are at most 16, keys and values of at most 64 characters; Gateway adds `nexus.sandbox` and `nexus.tenant` itself. The sandbox starts from `NEXUS_CLOUD_SANDBOX_IMAGE` with no Nexus token and no files. Send an `Idempotency-Key`: the sandbox's id is derived from it, so a resend names the sandbox the first send made. Its running time is charged as cloud compute from the create. Permission: `cloud.sandboxes.use` (module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `size` ("small" | "default" | "large" | "xlarge"): One of `NEXUS_CLOUD_SIZES`; `small` when absent. - `ttlSeconds` (integer, required) [min 60; max 7200] - `labels` (object): Keys of 1 to 64 characters, not starting with `nexus.`. ### Responses - `200` The sandbox a send with this key made (application/json, CloudSandbox) - `id` (string, required): `csb_…` - `state` ("creating" | "starting" | "ready" | "failed" | "gone", required) - `size` ("small" | "default" | "large" | "xlarge", required) - `labels` (object, required): The labels the create sent. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required): When Gateway deletes the sandbox. - `error` (string | null, required): Why it failed; null otherwise. - `201` Created: the sandbox is starting (application/json, CloudSandbox) - `id` (string, required): `csb_…` - `state` ("creating" | "starting" | "ready" | "failed" | "gone", required) - `size` ("small" | "default" | "large" | "xlarge", required) - `labels` (object, required): The labels the create sent. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required): When Gateway deletes the sandbox. - `error` (string | null, required): Why it failed; null otherwise. - `400` The body is not an object, or `size` (`invalid_size`), `ttlSeconds` (`invalid_ttl`) or `labels` (`invalid_labels`) is out of bounds. - `402` Nothing covers 15 minutes of this sandbox's cloud compute (`budget_exceeded`), or the organization is past due (`payment_past_due`). The refusal is recorded. - `403` Cloud machines are not turned on for this organization (`cloud_not_enabled`), or the key is not Nexus Review's module key (`role_required`, `module_key`). - `422` This `Idempotency-Key` names another sandbox (`idempotency_key_reused`); send a new key. - `429` Gateway runs its most sandboxes (`cloud_capacity`, `NEXUS_CLOUD_MAX_SANDBOXES`), or the provider is busy (`cloud_busy`). There is no queue: try again after `Retry-After`. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not an object, or `size` (`invalid_size`), `ttlSeconds` (`invalid_ttl`) or `labels` (`invalid_labels`) is out of bounds. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | Nothing covers 15 minutes of this sandbox's cloud compute (`budget_exceeded`), or the organization is past due (`payment_past_due`). The refusal is recorded. | | 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 | | This `Idempotency-Key` names another sandbox (`idempotency_key_reused`); send a new key. | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Gateway runs its most sandboxes (`cloud_capacity`, `NEXUS_CLOUD_MAX_SANDBOXES`), or the provider is busy (`cloud_busy`). There is no queue: try again after `Retry-After`. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`), or the provider has no free machine (`cloud_capacity`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/sandboxes" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "ttlSeconds": 60 }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fsandboxes) ## Get cloud sandbox `GET /v1/cloud/sandboxes/{id}` Your organization's sandbox, its state read from the provider. A deleted or expired one answers `gone`. Permission: `cloud.sandboxes.use` (module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The sandbox's id (`csb_…`), as POST /v1/cloud/sandboxes answered it | ### Responses - `200` OK (application/json, CloudSandbox) - `id` (string, required): `csb_…` - `state` ("creating" | "starting" | "ready" | "failed" | "gone", required) - `size` ("small" | "default" | "large" | "xlarge", required) - `labels` (object, required): The labels the create sent. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required): When Gateway deletes the sandbox. - `error` (string | null, required): Why it failed; null otherwise. - `403` The key is not Nexus Review's module key (`role_required`), or a person's or another credential's (`module_key`, `role_required`). - `404` No such sandbox in your organization: another organization's is as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such sandbox in your organization: another organization's is as absent as a missing one. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl "$NEXUS_URL/v1/cloud/sandboxes/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcloud%2Fsandboxes%2F%7Bid%7D) ## Delete cloud sandbox `DELETE /v1/cloud/sandboxes/{id}` Delete the sandbox at the provider and charge its running time. A sandbox already gone answers the same. Permission: `cloud.sandboxes.use` (module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The sandbox's id (`csb_…`), as POST /v1/cloud/sandboxes answered it | | `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, CloudSandboxDeleted) - `id` (string, required) - `deleted` (boolean, required) - `403` The key is not Nexus Review's module key (`role_required`), or a person's or another credential's (`module_key`, `role_required`). - `404` No such sandbox in your organization: another organization's is as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such sandbox in your organization: another organization's is as absent as a missing one. | | 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 | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/cloud/sandboxes/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fcloud%2Fsandboxes%2F%7Bid%7D) ## Exec cloud sandbox `POST /v1/cloud/sandboxes/{id}/exec` Run one command in the sandbox with `sh -c` and wait for it. `command` is 1 to 16384 bytes and `timeoutSeconds` 1 to 600: the provider stops the command then and answers `timedOut`. `stdoutTruncated` and `stderrTruncated` say the provider cut that stream. The call waits up to `timeoutSeconds` plus 30 seconds. Permission: `cloud.sandboxes.use` (module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The sandbox's id (`csb_…`), as POST /v1/cloud/sandboxes answered it | | `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) - `command` (string, required): Run with `sh -c`; at most 16384 bytes. [min length 1] - `timeoutSeconds` (integer, required) [min 1; max 600] ### Responses - `200` OK (application/json, CloudSandboxExecResult) - `exitCode` (integer | null, required): Null when the command was killed (a timeout or a signal). - `stdout` (string, required) - `stderr` (string, required) - `timedOut` (boolean, required) - `durationMs` (integer, required) [min 0] - `stdoutTruncated` (boolean, required): The provider cut stdout: its text is not complete. - `stderrTruncated` (boolean, required): The provider cut stderr: its text is not complete. - `400` `command` (`invalid_command`) or `timeoutSeconds` (`invalid_timeout`) is out of bounds. - `403` The key is not Nexus Review's module key (`role_required`), or a person's or another credential's (`module_key`, `role_required`). - `404` No such sandbox in your organization: another organization's is as absent as a missing one. - `409` The sandbox is not ready yet, or has ended (`sandbox_not_ready`); read it and try again once it is `ready`. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`). The command may still have run: an answer larger than 1 MiB, or one lost on the way, comes after it ran. Do not send it again unless it is safe to run twice. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `command` (`invalid_command`) or `timeoutSeconds` (`invalid_timeout`) is out of bounds. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such sandbox in your organization: another organization's is as absent as a missing one. | | 409 | | The sandbox is not ready yet, or has ended (`sandbox_not_ready`); read it and try again once it is `ready`. | | 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 | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`). The command may still have run: an answer larger than 1 MiB, or one lost on the way, comes after it ran. Do not send it again unless it is safe to run twice. | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/sandboxes/<id>/exec" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "command": "<command>", "timeoutSeconds": 1 }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fsandboxes%2F%7Bid%7D%2Fexec) ## Cloud sandbox upload url `POST /v1/cloud/sandboxes/{id}/upload-url` A provider link that takes one file for the sandbox. PUT the bytes to `url` with no auth header; the provider writes them at `$HOME/<path>` (`/home/user`). `path` is relative, with no `..`, at most 256 characters. The link works for `ttlSeconds` (60 to 900, 900 when absent). Permission: `cloud.sandboxes.use` (module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The sandbox's id (`csb_…`), as POST /v1/cloud/sandboxes answered it | | `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) - `path` (string, required): Relative to the sandbox's home, with no `..`. [min length 1; max length 256] - `ttlSeconds` (integer): 900 when absent. [min 60; max 900] ### Responses - `200` OK (application/json, CloudSandboxUploadUrl) - `url` (string (uri), required) - `400` `path` (`invalid_path`) or `ttlSeconds` (`invalid_ttl`) is out of bounds. - `403` The key is not Nexus Review's module key (`role_required`), or a person's or another credential's (`module_key`, `role_required`). - `404` No such sandbox in your organization: another organization's is as absent as a missing one. - `409` The sandbox is not ready yet, or has ended (`sandbox_not_ready`). - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The cloud provider failed or did not answer (`cloud_provider_error`); try again. - `503` No provider account on this Gateway (`cloud_unavailable`); try again later. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `path` (`invalid_path`) or `ttlSeconds` (`invalid_ttl`) is out of bounds. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such sandbox in your organization: another organization's is as absent as a missing one. | | 409 | | The sandbox is not ready yet, or has ended (`sandbox_not_ready`). | | 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 | | 502 | | The cloud provider failed or did not answer (`cloud_provider_error`); try again. | | 503 | | No provider account on this Gateway (`cloud_unavailable`); try again later. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/sandboxes/<id>/upload-url" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "path": "<path>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fsandboxes%2F%7Bid%7D%2Fupload-url) --- <!-- /docs/api/service-accounts --> # 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. ## 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. Permission: `service_accounts.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `limit` | query | integer | no | Items per page, 1 to 500 (default 100). Without limit or cursor the answer holds the whole list. | | `cursor` | query | string | no | NextCursor from the previous page. A cursor whose item left the list answers 400 `invalid_cursor`. | ### Responses - `200` OK (application/json, ServiceAccountList) - `serviceAccounts` (array of ServiceAccount, required) - `id` (string, required): `sva_…` - `name` (string, required) - `ownerUserId` (string, required): The member who answers for it. Its keys stop when they leave the organization. - `teamId` (string, required): The team that owns it. Its keys stop when the team is deleted. - `createdBy` (string, required): The person who made it. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `keys` (array of ServiceAccountKey, required): Every key it held, newest first. - `id` (string, required): `sak_…` - `serviceAccountId` (string, required) - `ownerUserId` (string, required): The member who answers for its account, as the account holds it now. The key stops when they leave the organization. - `scope` (ServiceAccountScope, required): What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key. - `teamId` (string, required): The team that owns the account. Its keys stop when the team is deleted. - `prefix` (string, required): The first characters of the token, to recognise it in a list. - `label` (string) - `createdBy` (string, required): The person who issued it. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `lastUsedAt` (string (date-time)): When the key last authenticated, written at most once an hour. - `rotatedFrom` (string): The key this one replaced in a rotation. - `nextCursor` (string): The next page's cursor, while more items follow. Only when limit or cursor was sent. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/service-accounts" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fservice-accounts) ## 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. Permission: `service_accounts.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `name` (string, required) [min length 1; max length 64] - `ownerUserId` (string): The member who answers for it. The caller by default. - `team` (string, required): The team that owns it: its slug or id. - `expiresAt` (string (date-time), required): In the future, at most 365 days from now. - `dryRun` (boolean): Check everything and write nothing. [default false] ### Responses - `200` A dry run: the account as it would be made (application/json, CreatedServiceAccount) - `id` (string, required): `sva_…` - `name` (string, required) - `ownerUserId` (string, required): The member who answers for it. Its keys stop when they leave the organization. - `teamId` (string, required): The team that owns it. Its keys stop when the team is deleted. - `createdBy` (string, required): The person who made it. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `keys` (array of ServiceAccountKey, required): Every key it held, newest first. - `id` (string, required): `sak_…` - `serviceAccountId` (string, required) - `ownerUserId` (string, required): The member who answers for its account, as the account holds it now. The key stops when they leave the organization. - `scope` (ServiceAccountScope, required): What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key. - `teamId` (string, required): The team that owns the account. Its keys stop when the team is deleted. - `prefix` (string, required): The first characters of the token, to recognise it in a list. - `label` (string) - `createdBy` (string, required): The person who issued it. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `lastUsedAt` (string (date-time)): When the key last authenticated, written at most once an hour. - `rotatedFrom` (string): The key this one replaced in a rotation. - `dryRun` (boolean, required): A dry run's id is never used. - `201` Created (application/json, CreatedServiceAccount) - `id` (string, required): `sva_…` - `name` (string, required) - `ownerUserId` (string, required): The member who answers for it. Its keys stop when they leave the organization. - `teamId` (string, required): The team that owns it. Its keys stop when the team is deleted. - `createdBy` (string, required): The person who made it. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `keys` (array of ServiceAccountKey, required): Every key it held, newest first. - `id` (string, required): `sak_…` - `serviceAccountId` (string, required) - `ownerUserId` (string, required): The member who answers for its account, as the account holds it now. The key stops when they leave the organization. - `scope` (ServiceAccountScope, required): What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key. - `teamId` (string, required): The team that owns the account. Its keys stop when the team is deleted. - `prefix` (string, required): The first characters of the token, to recognise it in a list. - `label` (string) - `createdBy` (string, required): The person who issued it. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `lastUsedAt` (string (date-time)): When the key last authenticated, written at most once an hour. - `rotatedFrom` (string): The key this one replaced in a rotation. - `dryRun` (boolean, required): A dry run's id is never used. - `400` Not 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, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 101 | `service_account_limit` | The 101st is a 409 `service_account_limit` | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not 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`) | | 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/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" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fservice-accounts) ## Revoke service account `DELETE /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. Permission: `service_accounts.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The service account's id (`sva_…`) | | `dryRun` | query | "1" \| "true" \| "0" \| "false" | no | `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-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, ServiceAccountRevoked) - `id` (string, required) - `already` (boolean, required): It was revoked before this request. - `dryRun` (boolean, required) - `revokedAt` (string (date-time) | null) - `keysRevoked` (integer, required): The live keys it stopped (with `dryRun`, the ones it would stop). - `400` `dryRun` is not `1`, `true`, `0` or `false` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such service account in this organization (`unknown_service_account`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `dryRun` is not `1`, `true`, `0` or `false` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such service account in this organization (`unknown_service_account`) | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | 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/service-accounts/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fservice-accounts%2F%7Bid%7D) ## 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. Permission: `service_accounts.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The service account's id (`sva_…`) | | `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) - `label` (string): Required to issue a key. A rotation keeps the old label when it names none. [min length 1; max length 80] - `expiresAt` (string (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 - `201` Created (application/json, CreatedServiceAccountKey) - `id` (string, required): `sak_…` - `serviceAccountId` (string, required) - `ownerUserId` (string, required): The member who answers for its account, as the account holds it now. The key stops when they leave the organization. - `scope` (ServiceAccountScope, required): What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key. - `teamId` (string, required): The team that owns the account. Its keys stop when the team is deleted. - `prefix` (string, required): The first characters of the token, to recognise it in a list. - `label` (string) - `createdBy` (string, required): The person who issued it. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `lastUsedAt` (string (date-time)): When the key last authenticated, written at most once an hour. - `rotatedFrom` (string): The key this one replaced in a rotation. - `token` (string, required): `nxsa_…`. In this answer, and in a replay of it (same `Idempotency-Key`) within 24 hours. - `400` No label (1 to 80 characters), or an `expiresAt` that is not a future time within the account's life (`invalid_expiry`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such service account in this organization (`unknown_service_account`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The account is revoked or expired, or holds 5 live keys (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | No label (1 to 80 characters), or an `expiresAt` that is not a future time within the account's life (`invalid_expiry`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such service account in this organization (`unknown_service_account`) | | 409 | | The account is revoked or expired, or holds 5 live keys | | 409 | `service_account_key_limit` | The sixth is a 409 `service_account_key_limit` | | 409 | `service_account_revoked` | A revoked or expired account takes no key (409 `service_account_revoked`, `service_account_expired`) | | 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/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" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fservice-accounts%2F%7Bid%7D%2Fkeys) ## Revoke service account key `DELETE /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`. Permission: `service_accounts.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The service account's id (`sva_…`) | | `keyId` | path | string | yes | The key's id (`sak_…`) | | `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, ServiceAccountKey) - `id` (string, required): `sak_…` - `serviceAccountId` (string, required) - `ownerUserId` (string, required): The member who answers for its account, as the account holds it now. The key stops when they leave the organization. - `scope` (ServiceAccountScope, required): What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key. - `teamId` (string, required): The team that owns the account. Its keys stop when the team is deleted. - `prefix` (string, required): The first characters of the token, to recognise it in a list. - `label` (string) - `createdBy` (string, required): The person who issued it. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `lastUsedAt` (string (date-time)): When the key last authenticated, written at most once an hour. - `rotatedFrom` (string): The key this one replaced in a rotation. - `404` No such key in this service account (`unknown_service_account_key`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such key in this service account (`unknown_service_account_key`) | | 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/service-accounts/<id>/keys/<keyId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fservice-accounts%2F%7Bid%7D%2Fkeys%2F%7BkeyId%7D) ## 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`. Permission: `service_accounts.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The service account's id (`sva_…`) | | `keyId` | path | string | yes | The key's id (`sak_…`) | | `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) - `label` (string): Required to issue a key. A rotation keeps the old label when it names none. [min length 1; max length 80] - `expiresAt` (string (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 - `200` OK (application/json, CreatedServiceAccountKey) - `id` (string, required): `sak_…` - `serviceAccountId` (string, required) - `ownerUserId` (string, required): The member who answers for its account, as the account holds it now. The key stops when they leave the organization. - `scope` (ServiceAccountScope, required): What a key reaches, which is its account's. Read from the account when the key is shown, never stored on the key. - `teamId` (string, required): The team that owns the account. Its keys stop when the team is deleted. - `prefix` (string, required): The first characters of the token, to recognise it in a list. - `label` (string) - `createdBy` (string, required): The person who issued it. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `lastUsedAt` (string (date-time)): When the key last authenticated, written at most once an hour. - `rotatedFrom` (string): The key this one replaced in a rotation. - `token` (string, required): `nxsa_…`. In this answer, and in a replay of it (same `Idempotency-Key`) within 24 hours. - `400` A 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, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such key in this service account, or no such service account (`unknown_service_account_key`, `unknown_service_account`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The key is not live (`key_not_live`), or its account is revoked or expired (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A label that is not 1 to 80 characters, or an `expiresAt` that is not a future time within the account's life (`invalid_expiry`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such key in this service account, or no such service account (`unknown_service_account_key`, `unknown_service_account`) | | 409 | | The key is not live (`key_not_live`), or its account is revoked or expired | | 409 | `key_not_live` | A key that is revoked or expired does not rotate (409 `key_not_live`) | | 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/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" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fservice-accounts%2F%7Bid%7D%2Fkeys%2F%7BkeyId%7D%2Frotate) --- <!-- /docs/api/agent-links --> # 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. ## List agent links `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. Permission: `agent_links.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `all` | query | "1" | no | `1` lists everyone's links. Only owners and admins may: anyone else answers 403 `role_required`. | | `limit` | query | integer | no | Items per page, 1 to 500 (default 100). Without limit or cursor the answer holds the whole list. | | `cursor` | query | string | no | NextCursor from the previous page. A cursor whose item left the list answers 400 `invalid_cursor`. | ### Responses - `200` OK (application/json, AgentLinkList) - `agentLinks` (array of AgentLink, required) - `id` (string, required): `agl_…` - `userId` (string, required): The person the agent acts for. - `agent` (string, required): What the agent is, as a slug (`slack`). - `label` (string, required) - `grant` (array of string, required): 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. - `prefix` (string, required): The first characters of the token, to recognise it in a list. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `lastUsedAt` (string (date-time)): When the link last authenticated, written at most once an hour. - `nextCursor` (string): 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, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 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/agent-links" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent-links) ## Link agent `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. Permission: `agent_links.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `agent` (string, required): What the agent is, as a slug (`slack`). [min length 1; max length 40; pattern ^[a-z0-9][a-z0-9-]*$] - `label` (string, required) [min length 1; max length 80] - `grant` (array of "models.use" | "spend.read_own"): What the agent may do. `models.use` by default. - `expiresAt` (string (date-time)): In the future, at most 365 days from now. 90 days from now by default. - `session` (boolean): 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] - `dryRun` (boolean): Check everything and write nothing. [default false] ### Responses - `200` A dry run: the link as it would be made, with no token (application/json, CreatedAgentLink) - `id` (string, required): `agl_…` - `userId` (string, required): The person the agent acts for. - `agent` (string, required): What the agent is, as a slug (`slack`). - `label` (string, required) - `grant` (array of string, required): 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. - `prefix` (string, required): The first characters of the token, to recognise it in a list. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `lastUsedAt` (string (date-time)): When the link last authenticated, written at most once an hour. - `token` (string): `nxo_…`. In this answer, and again in a repeat with the same `Idempotency-Key` within 24 hours. None with `dryRun`. - `dryRun` (boolean, required): The link was not written. Its id is never used. - `201` Created (application/json, CreatedAgentLink) - `id` (string, required): `agl_…` - `userId` (string, required): The person the agent acts for. - `agent` (string, required): What the agent is, as a slug (`slack`). - `label` (string, required) - `grant` (array of string, required): 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. - `prefix` (string, required): The first characters of the token, to recognise it in a list. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `lastUsedAt` (string (date-time)): When the link last authenticated, written at most once an hour. - `token` (string): `nxo_…`. In this answer, and again in a repeat with the same `Idempotency-Key` within 24 hours. None with `dryRun`. - `dryRun` (boolean, required): The link was not written. Its id is never used. - `400` Not 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 (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller may not 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, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The person already holds 20 live links (`agent_link_limit`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not valid: 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 | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | The person already holds 20 live links (`agent_link_limit`) | | 409 | `agent_link_limit` | The next is 409 `agent_link_limit` | | 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/agent-links" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "agent": "claude", "label": "CI" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent-links) ## Unlink agent `DELETE /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`. Permission: `agent_links.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The link's id (`agl_…`) | | `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: the link, with `revokedAt` (application/json, AgentLink) - `id` (string, required): `agl_…` - `userId` (string, required): The person the agent acts for. - `agent` (string, required): What the agent is, as a slug (`slack`). - `label` (string, required) - `grant` (array of string, required): 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. - `prefix` (string, required): The first characters of the token, to recognise it in a list. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `lastUsedAt` (string (date-time)): When the link last authenticated, written at most once an hour. - `403` Another person's link, and the caller is no owner or admin (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such link in this organization (`unknown_agent_link`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such link in this organization (`unknown_agent_link`) | | 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/agent-links/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fagent-links%2F%7Bid%7D) --- <!-- /docs/api/developer-clients --> # Developer clients > The OAuth clients a person registered for their forks of Nexus's apps. ## List developer clients `GET /v1/developer/clients` The OAuth clients you registered for your forks, revoked ones included, oldest first, and the scopes a fork may ask for (`grantableScopes`). People only. Permission: `keys.manage_own` (Every member). ### Responses - `200` OK (application/json, DeveloperClientList) - `clients` (array of DeveloperClient, required) - `id` (string, required): `nxc_…` - `name` (string, required) - `tier` ("official" | "registered_fork" | "unregistered", required) - `allowedScopes` (array of string, required): The actions a token of this client may hold: the client's own list, or every third-party scope when it has none. - `rateLimitPerMinute` (integer): Omitted: the tier's default limit. - `maxConcurrentPerUser` (integer): Omitted: the tier's default limit. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `revokedReason` (string) - `grantableScopes` (array of string, required): The scopes a fork may ask for, in their canonical order. - `403` A caller that is not a person: a service account, a module, a sandbox, an agent link or a third-party token (`person_required` or `role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/developer/clients" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdeveloper%2Fclients) ## Register developer client `POST /v1/developer/clients` Register an OAuth client for your fork of a Nexus app. It gets its own `nxc_…` id. `allowedScopes` names what its tokens may hold, each one of `grantableScopes`; without it, all of them. No scope for administration, billing, provider keys, invitations or token management is allowed. People only. Permission: `keys.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `name` (string, required) [min length 1; max length 100] - `allowedScopes` (array of string): Each one of `grantableScopes`. Omitted: all of them. ### Responses - `201` Created (application/json, DeveloperClient) - `id` (string, required): `nxc_…` - `name` (string, required) - `tier` ("official" | "registered_fork" | "unregistered", required) - `allowedScopes` (array of string, required): The actions a token of this client may hold: the client's own list, or every third-party scope when it has none. - `rateLimitPerMinute` (integer): Omitted: the tier's default limit. - `maxConcurrentPerUser` (integer): Omitted: the tier's default limit. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `revokedReason` (string) - `400` A blank or too long name, an unknown field, or a scope a third-party client may not hold (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` A caller that is not a person: a service account, a module, a sandbox, an agent link or a third-party token (`person_required` or `role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A blank or too long name, an unknown field, or a scope a third-party client may not hold | | 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/developer/clients" \ -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%2Fdeveloper%2Fclients) ## Revoke developer client `POST /v1/developer/clients/{id}/revoke` Revoke an OAuth client you registered. `reason` defaults to `revoked by owner`. A revoked client answers as it was: its first time and reason stay. People only. Permission: `keys.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The client's id (`nxc_…`) | | `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) - `reason` (string): Omitted: `revoked by owner`. [min length 1; max length 500] ### Responses - `200` OK: the client, with `revokedAt` (application/json, DeveloperClient) - `id` (string, required): `nxc_…` - `name` (string, required) - `tier` ("official" | "registered_fork" | "unregistered", required) - `allowedScopes` (array of string, required): The actions a token of this client may hold: the client's own list, or every third-party scope when it has none. - `rateLimitPerMinute` (integer): Omitted: the tier's default limit. - `maxConcurrentPerUser` (integer): Omitted: the tier's default limit. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `revokedReason` (string) - `400` A blank or too long reason, or an unknown field (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` An official client, which only Nexus's staff revoke, or a caller that is not a person (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No client with this id that you registered (`not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A blank or too long reason, or an unknown field | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No client with this id that you registered (`not_found`) | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/developer/clients/<id>/revoke" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "reason": "<reason>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdeveloper%2Fclients%2F%7Bid%7D%2Frevoke) --- <!-- /docs/api/devices --> # Devices > Devices: a person's device keys and device pairing for end-to-end encrypted session sync. Each device makes its own key pairs and sends only the public keys: an X25519 key that each thread's content key is locked to (HPKE), and an Ed25519 key it signs with. Gateway stores the public keys and the locked copies and cannot open any of them. A device belongs to the person, whichever organization they are signed in to; someone else's is a 404. The person's first device is trusted at once. Every later one is pending until a trusted device signs its id and keys, and a revocation needs a trusted device's signature too, so signing in alone never adds or removes a trusted device. ## List member key holders `GET /v1/orgs/members/{userId}/holders` A member's trusted and revoked holders, with public keys and approvals. Clients remember revocations. Permission: `members.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `userId` | path | string | yes | | ### Responses - `200` OK (application/json, TeamKeyHolderList) - `personId` (string, required) - `teamKeyId` (string | null, required): The current epoch; null when none is current. - `epoch` (integer | null, required) - `holders` (array of TeamKeyHolder, required): Oldest first. - `id` (string, required) - `kind` ("device" | "passkey" | "recovery_code", required) - `encryptionKey` (string, required): X25519 public key, base64url: seal the team key's copy to it. - `signingKey` (string | null, required): Ed25519 public key, base64url. Null for a recovery key. - `approvedBy` (string | null, required): The holder that approved it; null for the person's root. - `approvalSignature` (string | null, required): The approver's signature, as `Device.approvalSignature`. - `approvedAt` (string (date-time) | null, required) - `hasCurrentTeamKey` (boolean, required): Whether it holds a copy of the current epoch. Hand the key only to a holder without one. - `state` ("trusted" | "revoked", required): Observed revoked holders must never receive a new key, even if later listed as trusted. - `403` Not a person (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not a member of this organization (`member_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not a member of this organization (`member_not_found`) | | 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/orgs/members/user_123/holders" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fmembers%2F%7BuserId%7D%2Fholders) ## List devices `GET /v1/devices` Your devices for end-to-end encrypted session sync, oldest first, with their public keys and approvals. Permission: `chat.use` (Every member). ### Responses - `200` OK (application/json, DeviceList) - `devices` (array of Device, required) - `id` (string, required) - `name` (string, required) - `kind` ("device" | "passkey" | "recovery_code", required): `device`, or one of your recovery keys: a `passkey` (WebAuthn PRF) or a printable `recovery_code`. A recovery key has an X25519 key and no Ed25519 key: it receives locked copies and never signs. - `encryptionKey` (string, required): X25519 public key, base64url. - `signingKey` (string | null, required): Ed25519 public key, base64url. Null for a recovery key, which never signs. - `state` ("pending" | "trusted" | "revoked", required) - `approvedBy` (string | null, required): The device that approved it; null for a device trusted without an approval (your first device, or a recovered one) and for one never approved. - `approvalSignature` (string | null, required): The approver's signature over `nexus-device-approval:v1:{id}:{encryptionKey}:{signingKey}` for a device, or `nexus-device-approval:v2:{id}:{kind}:{encryptionKey}:` for a recovery key. - `createdAt` (string (date-time), required) - `approvedAt` (string (date-time) | null, required): When it became trusted. - `revokedAt` (string (date-time) | null, required) - `handover` (string | null, required): The approver's trusted list, signed and sealed to this device (`approveDevice`'s `handover`). Null for a root, a recovery key and an approval sent without one. Only this device opens it. - `trust` ("approvals" | "gateway", required): How this Gateway trusts a person's later devices (`NEXUS_DEVICE_TRUST`). `approvals`: a trusted device signs each one's approval. `gateway`: Gateway trusts each device a signed-in person registers at once, with no approver. An older Gateway leaves it out: read that as `approvals`. - `403` Not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/devices" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdevices) ## Register device `POST /v1/devices` Register a device's or a recovery key's public keys. Your first device is trusted at once; anything later is pending until a trusted device approves it. Permission: `chat.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): 1 to 64 characters, none a control character. [min length 1; max length 64] - `kind` ("device" | "passkey" | "recovery_code"): `device`, or one of your recovery keys: a `passkey` (WebAuthn PRF) or a printable `recovery_code`. A recovery key has an X25519 key and no Ed25519 key: it receives locked copies and never signs. [default "device"] - `encryptionKey` (string, required): The holder's X25519 public key: 32 bytes, base64url without padding. Copies for it are locked to it. [pattern ^[A-Za-z0-9_-]{43}$] - `signingKey` (string): The device's Ed25519 public key: 32 bytes, base64url without padding. It signs approvals and revocations. Required for a device; absent for a recovery key. [pattern ^[A-Za-z0-9_-]{43}$] ### Responses - `201` Registered (application/json, Device) - `id` (string, required) - `name` (string, required) - `kind` ("device" | "passkey" | "recovery_code", required): `device`, or one of your recovery keys: a `passkey` (WebAuthn PRF) or a printable `recovery_code`. A recovery key has an X25519 key and no Ed25519 key: it receives locked copies and never signs. - `encryptionKey` (string, required): X25519 public key, base64url. - `signingKey` (string | null, required): Ed25519 public key, base64url. Null for a recovery key, which never signs. - `state` ("pending" | "trusted" | "revoked", required) - `approvedBy` (string | null, required): The device that approved it; null for a device trusted without an approval (your first device, or a recovered one) and for one never approved. - `approvalSignature` (string | null, required): The approver's signature over `nexus-device-approval:v1:{id}:{encryptionKey}:{signingKey}` for a device, or `nexus-device-approval:v2:{id}:{kind}:{encryptionKey}:` for a recovery key. - `createdAt` (string (date-time), required) - `approvedAt` (string (date-time) | null, required): When it became trusted. - `revokedAt` (string (date-time) | null, required) - `handover` (string | null, required): The approver's trusted list, signed and sealed to this device (`approveDevice`'s `handover`). Null for a root, a recovery key and an approval sent without one. Only this device opens it. - `400` A name or key of the wrong form (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: an agent link, a module or a service account (`person_required`); or a device from Nexus UI while the organization's `webSessionViewer` is off (`web_session_viewer_off`). A recovery key still registers (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` 10 pending devices already (`too_many_pending_devices`): approve or revoke one first (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A name or key of the wrong form | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | 10 pending devices already (`too_many_pending_devices`): approve or revoke one first | | 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/devices" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "name": "Platform", "encryptionKey": "<encryptionKey>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdevices) ## Recover device `POST /v1/devices/recover` The way back after every device is lost: with a recovery key's proof, revoke your devices and register this one as a new root. Permission: `chat.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): 1 to 64 characters, none a control character. [min length 1; max length 64] - `encryptionKey` (string, required): The new device's X25519 public key: 32 bytes, base64url without padding. [pattern ^[A-Za-z0-9_-]{43}$] - `signingKey` (string, required): The new device's Ed25519 public key: 32 bytes, base64url without padding. [pattern ^[A-Za-z0-9_-]{43}$] - `holderId` (string, required): The recovery key (`dev_…`, a `passkey` or `recovery_code`) whose sealed challenge this device opened. - `challenge` (string, required): The challenge sealed to `holderId`, opened: 32 bytes, base64url without padding. [pattern ^[A-Za-z0-9_-]{43}$] ### Responses - `201` Registered as your new root (application/json, Device) - `id` (string, required) - `name` (string, required) - `kind` ("device" | "passkey" | "recovery_code", required): `device`, or one of your recovery keys: a `passkey` (WebAuthn PRF) or a printable `recovery_code`. A recovery key has an X25519 key and no Ed25519 key: it receives locked copies and never signs. - `encryptionKey` (string, required): X25519 public key, base64url. - `signingKey` (string | null, required): Ed25519 public key, base64url. Null for a recovery key, which never signs. - `state` ("pending" | "trusted" | "revoked", required) - `approvedBy` (string | null, required): The device that approved it; null for a device trusted without an approval (your first device, or a recovered one) and for one never approved. - `approvalSignature` (string | null, required): The approver's signature over `nexus-device-approval:v1:{id}:{encryptionKey}:{signingKey}` for a device, or `nexus-device-approval:v2:{id}:{kind}:{encryptionKey}:` for a recovery key. - `createdAt` (string (date-time), required) - `approvedAt` (string (date-time) | null, required): When it became trusted. - `revokedAt` (string (date-time) | null, required) - `handover` (string | null, required): The approver's trusted list, signed and sealed to this device (`approveDevice`'s `handover`). Null for a root, a recovery key and an approval sent without one. Only this device opens it. - `400` A name or key of the wrong form (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` No proof (`recovery_proof_required`), a proof that does not match an open challenge for that recovery key: wrong, expired, used or replaced (`invalid_recovery_proof`), or not a person (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A name or key of the wrong form | | 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/devices/recover" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "name": "Platform", "encryptionKey": "<encryptionKey>", "signingKey": "<signingKey>", "holderId": "<holderId>", "challenge": "<challenge>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdevices%2Frecover) ## Recover device challenge `POST /v1/devices/recover/challenge` Challenges sealed to each of your trusted recovery keys, the first step of the way back. Permission: `chat.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). | ### Responses - `201` Issued (application/json, RecoveryChallenge) - `challenges` (array of object, required) - `holderId` (string, required) - `kind` ("passkey" | "recovery_code", required) - `sealed` (string, required): The challenge, HPKE-sealed to the recovery key (DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, AES-256-GCM, base mode) with `info` the length-prefixed `nexus-recover-challenge-v1`, your `users.id` and `holderId`: base64url without padding. - `expiresAt` (string (date-time), required): Five minutes after it was issued. - `403` Not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` You have no trusted passkey or recovery code (`no_recovery_key`): your history cannot be recovered, and your devices cannot be reset (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` More than 5 challenges in an hour (`too_many_recovery_challenges`) (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 | | 409 | | You have no trusted passkey or recovery code (`no_recovery_key`): your history cannot be recovered, and your devices cannot be reset | | 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 | | More than 5 challenges in an hour (`too_many_recovery_challenges`) | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/devices/recover/challenge" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdevices%2Frecover%2Fchallenge) ## Approve device `POST /v1/devices/{id}/approve` Approve your pending device or recovery key with a trusted device's signature, and store its first locked copies. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The device's id (`dev_…`) | | `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) - `approverDeviceId` (string, required): Your trusted device that signs. - `signature` (string, required): Ed25519 over `nexus-device-approval:v1:{deviceId}:{encryptionKey}:{signingKey}`: 64 bytes, base64url without padding. [pattern ^[A-Za-z0-9_-]{86}$] - `keys` (array of DeviceThreadKey): The new device's copies of key versions you already hold, each signed by the approver. [at most 1000 items] - `threadId` (string, required) [pattern ^[A-Za-z0-9_-]{1,128}$] - `keyVersion` (integer, required): The content key's version: 1 first, one more at each rotation. [min 1] - `lockedKey` (string, required): The thread's content key, HPKE-sealed to the device's `encryptionKey`, base64url. [pattern ^[A-Za-z0-9_-]{1,512}$] - `signature` (string, required): The approver's Ed25519 signature over `nexus-thread-key:v1:{threadId}:{keyVersion}:{deviceId}:{lockedKey}`, where deviceId is the device being approved: 64 bytes, base64url without padding. [pattern ^[A-Za-z0-9_-]{86}$] - `handover` (string): For a device only: the approver's trusted holders and remembered revoked ids, signed by the approver over `nexus-device-handover:v1:{deviceId}:{approverDeviceId}:{payload}` and HPKE-sealed to the new device's `encryptionKey`, base64url without padding. Gateway stores it unread and lists it on the new device, which alone opens it. [min length 1; max length 65536; pattern ^[A-Za-z0-9_-]+$] ### Responses - `200` Approved (application/json, Device) - `id` (string, required) - `name` (string, required) - `kind` ("device" | "passkey" | "recovery_code", required): `device`, or one of your recovery keys: a `passkey` (WebAuthn PRF) or a printable `recovery_code`. A recovery key has an X25519 key and no Ed25519 key: it receives locked copies and never signs. - `encryptionKey` (string, required): X25519 public key, base64url. - `signingKey` (string | null, required): Ed25519 public key, base64url. Null for a recovery key, which never signs. - `state` ("pending" | "trusted" | "revoked", required) - `approvedBy` (string | null, required): The device that approved it; null for a device trusted without an approval (your first device, or a recovered one) and for one never approved. - `approvalSignature` (string | null, required): The approver's signature over `nexus-device-approval:v1:{id}:{encryptionKey}:{signingKey}` for a device, or `nexus-device-approval:v2:{id}:{kind}:{encryptionKey}:` for a recovery key. - `createdAt` (string (date-time), required) - `approvedAt` (string (date-time) | null, required): When it became trusted. - `revokedAt` (string (date-time) | null, required) - `handover` (string | null, required): The approver's trusted list, signed and sealed to this device (`approveDevice`'s `handover`). Null for a root, a recovery key and an approval sent without one. Only this device opens it. - `400` A malformed signature, key or handover, a handover for a recovery key, a thread named twice, or more than 1000 keys (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The signature does not verify with the approver's signing key (`invalid_signature`), the approver is a recovery key (`recovery_key_cannot_sign`), or not a person (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not your device, or not your thread (`device_not_found`, `thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The approver is not trusted (`device_not_trusted`), the holder is not pending and is no recovery key whose approver is revoked (`device_not_pending`), it registered more than 15 minutes ago (`pairing_expired`), or you already have a trusted recovery key of its kind (`recovery_key_exists`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed signature, key or handover, a handover for a recovery key, a thread named twice, or more than 1000 keys | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not your device, or not your thread (`device_not_found`, `thread_not_found`) | | 409 | | The approver is not trusted (`device_not_trusted`), the holder is not pending and is no recovery key whose approver is revoked (`device_not_pending`), it registered more than 15 minutes ago (`pairing_expired`), or you already have a trusted recovery key of its kind (`recovery_key_exists`) | | 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/devices/<id>/approve" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "approverDeviceId": "<approverDeviceId>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdevices%2F%7Bid%7D%2Fapprove) ## Revoke device `POST /v1/devices/{id}/revoke` Revoke one of your devices or recovery keys with a trusted device's signature, and delete its locked copies. Revoked is final. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The device's id (`dev_…`) | | `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) - `revokerDeviceId` (string, required): Your trusted device that signs: the revoked device itself, or another. - `signature` (string, required): Ed25519 over `nexus-device-revoke:v1:{deviceId}`: 64 bytes, base64url without padding. [pattern ^[A-Za-z0-9_-]{86}$] ### Responses - `200` Revoked (application/json, Device) - `id` (string, required) - `name` (string, required) - `kind` ("device" | "passkey" | "recovery_code", required): `device`, or one of your recovery keys: a `passkey` (WebAuthn PRF) or a printable `recovery_code`. A recovery key has an X25519 key and no Ed25519 key: it receives locked copies and never signs. - `encryptionKey` (string, required): X25519 public key, base64url. - `signingKey` (string | null, required): Ed25519 public key, base64url. Null for a recovery key, which never signs. - `state` ("pending" | "trusted" | "revoked", required) - `approvedBy` (string | null, required): The device that approved it; null for a device trusted without an approval (your first device, or a recovered one) and for one never approved. - `approvalSignature` (string | null, required): The approver's signature over `nexus-device-approval:v1:{id}:{encryptionKey}:{signingKey}` for a device, or `nexus-device-approval:v2:{id}:{kind}:{encryptionKey}:` for a recovery key. - `createdAt` (string (date-time), required) - `approvedAt` (string (date-time) | null, required): When it became trusted. - `revokedAt` (string (date-time) | null, required) - `handover` (string | null, required): The approver's trusted list, signed and sealed to this device (`approveDevice`'s `handover`). Null for a root, a recovery key and an approval sent without one. Only this device opens it. - `400` A malformed signature (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The signature does not verify with the revoker's signing key (`invalid_signature`), the revoker is a recovery key (`recovery_key_cannot_sign`), or not a person (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not your device (`device_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The revoker is not trusted (`device_not_trusted`), or the device is already revoked (`device_revoked`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed signature | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not your device (`device_not_found`) | | 409 | | The revoker is not trusted (`device_not_trusted`), or the device is already revoked (`device_revoked`) | | 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/devices/<id>/revoke" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "revokerDeviceId": "<revokerDeviceId>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdevices%2F%7Bid%7D%2Frevoke) ## List device thread keys `GET /v1/devices/{id}/keys` Your trusted device's locked copies, in thread and key version order, a page at a time: a newly paired device catches up. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The device's id (`dev_…`) | | `after` | query | string | no | The `nextAfter` of the previous page: `{threadId}:{keyVersion}` | | `limit` | query | integer | no | The most copies a page holds | ### Responses - `200` OK (application/json, ThreadKeyList) - `keys` (array of ThreadKey, required) - `threadId` (string, required) - `keyVersion` (integer, required) - `deviceId` (string, required) - `lockedKey` (string, required): The thread's content key, HPKE-sealed to the device's `encryptionKey`, base64url. [pattern ^[A-Za-z0-9_-]{1,512}$] - `senderDeviceId` (string, required): Your trusted device that stored the copy. - `signature` (string, required): The sender's Ed25519 signature over `nexus-thread-key:v1:{threadId}:{keyVersion}:{deviceId}:{lockedKey}`. Check it with the sender's `signingKey` before you use the copy. [pattern ^[A-Za-z0-9_-]{86}$] - `createdAt` (string (date-time), required) - `nextAfter` (string | null, required): The `after` of the next page (`{threadId}:{keyVersion}`); null on the last. - `400` A malformed `after` or `limit` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: an agent link, a module or a service account (`person_required`); or Nexus UI while the organization's `webSessionViewer` is off (`web_session_viewer_off`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not your device (`device_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The device is pending or revoked (`device_not_trusted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed `after` or `limit` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not your device (`device_not_found`) | | 409 | | The device is pending or revoked (`device_not_trusted`) | | 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/devices/<id>/keys" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdevices%2F%7Bid%7D%2Fkeys) ## Get thread key `GET /v1/threads/{threadId}/keys` The locked copy of a thread's content key for one of your trusted devices, at the newest version it holds unless you name one. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's id, as its client names it | | `device` | query | string | yes | Your trusted device's id (`dev_…`) | | `version` | query | integer | no | The key version; the newest one the device holds when absent | ### Responses - `200` OK (application/json, ThreadKey) - `threadId` (string, required) - `keyVersion` (integer, required) - `deviceId` (string, required) - `lockedKey` (string, required): The thread's content key, HPKE-sealed to the device's `encryptionKey`, base64url. [pattern ^[A-Za-z0-9_-]{1,512}$] - `senderDeviceId` (string, required): Your trusted device that stored the copy. - `signature` (string, required): The sender's Ed25519 signature over `nexus-thread-key:v1:{threadId}:{keyVersion}:{deviceId}:{lockedKey}`. Check it with the sender's `signingKey` before you use the copy. [pattern ^[A-Za-z0-9_-]{86}$] - `createdAt` (string (date-time), required) - `400` No `device` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: an agent link, a module or a service account (`person_required`); or Nexus UI while the organization's `webSessionViewer` is off (`web_session_viewer_off`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not your device, or no copy for it (`device_not_found`, `thread_key_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The device is pending or revoked (`device_not_trusted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | No `device` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not your device, or no copy for it (`device_not_found`, `thread_key_not_found`) | | 409 | | The device is pending or revoked (`device_not_trusted`) | | 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/threads/<threadId>/keys?device=%3Cdevice%3E" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fkeys) ## Put thread keys `PUT /v1/threads/{threadId}/keys` Store a thread's locked copies at one key version for your trusted devices, each signed by one of them. A copy already stored is kept, and the answer says which. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's id, as its client names it | ### Request body (application/json, required) - `keyVersion` (integer, required): A version one of your devices still holds, or one more than the latest to rotate the content key: 1 for a new thread. [min 1] - `senderDeviceId` (string, required): Your trusted device that signs every copy. - `keys` (array of ThreadDeviceKey, required) [at most 100 items] - `deviceId` (string, required) - `lockedKey` (string, required): The thread's content key, HPKE-sealed to the device's `encryptionKey`, base64url. [pattern ^[A-Za-z0-9_-]{1,512}$] - `signature` (string, required): The sender's Ed25519 signature over `nexus-thread-key:v1:{threadId}:{keyVersion}:{deviceId}:{lockedKey}`: 64 bytes, base64url without padding. [pattern ^[A-Za-z0-9_-]{86}$] ### Responses - `200` Stored (application/json, ThreadKeysStored) - `threadId` (string, required) - `keyVersion` (integer, required) - `stored` (array of string, required): The devices whose copy this stored. - `alreadyPresent` (array of string, required): The devices that had a copy, kept as it was. - `400` No keys, more than 100, a device named twice, a malformed copy or signature, or a key version that skips one (`key_version_gap`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person (`person_required`), a signature that does not verify with the sender's signing key (`invalid_signature`), or a sender that is a recovery key (`recovery_key_cannot_sign`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not your device or sender, or another person's thread (`device_not_found`, `thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` A device or the sender is pending or revoked (`device_not_trusted`), or no device holds the key version any more (`key_version_not_held`): rotate to the next one (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. - `410` The thread was deleted in the session store (`thread_deleted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | No keys, more than 100, a device named twice, a malformed copy or signature, or a key version that skips one (`key_version_gap`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not your device or sender, or another person's thread (`device_not_found`, `thread_not_found`) | | 409 | | A device or the sender is pending or revoked (`device_not_trusted`), or no device holds the key version any more (`key_version_not_held`): rotate to the next one | | 410 | | The thread was deleted in the session store (`thread_deleted`) | | 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/threads/<threadId>/keys" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "keyVersion": 1, "senderDeviceId": "<senderDeviceId>", "keys": [ { "deviceId": "<deviceId>", "lockedKey": "<lockedKey>", "signature": "<signature>" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fkeys) ## Put org thread key `PUT /v1/threads/{threadId}/org-key` Store your thread's content key locked for the organization's current recovery key, signed by one of your trusted devices. A copy already stored is kept, and the answer says so. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's id, as its client names it | ### Request body (application/json, required) - `keyVersion` (integer, required): A version your devices hold a copy of. [min 1] - `orgKeyId` (string, required): The organization's current recovery key (`GET /v1/orgs/recovery-key`), whose fingerprint you confirmed. - `lockedKey` (string, required): The content key, HPKE-sealed to the organization key's `encryptionKey`: base64url without padding. [min length 1; max length 512; pattern ^[A-Za-z0-9_-]+$] - `senderDeviceId` (string, required): Your trusted device that signs the copy. - `signature` (string, required): Ed25519 over `nexus-org-thread-key:v1:{threadId}:{keyVersion}:{orgKeyId}:{lockedKey}`: 64 bytes in base64url without padding. ### Responses - `200` Stored, or already stored (application/json, OrgThreadKeyStored) - `threadId` (string, required) - `keyVersion` (integer, required) - `orgKeyId` (string, required) - `stored` (boolean, required): False when the copy was already stored: the stored one is kept. - `400` A malformed thread id, key version, copy or signature (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person (`person_required`), or the signature does not verify with the sender's signing key (`invalid_signature`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not your thread in this organization, or not your device (`thread_not_found`, `device_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The sender is pending or revoked (`device_not_trusted`); none of your devices holds `keyVersion` (`key_version_not_held`); the organization has no recovery key (`org_recovery_key_required`); or `orgKeyId` is not its current key (`org_key_replaced`) (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. - `410` You deleted the thread (`thread_deleted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed thread id, key version, copy or signature | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not your thread in this organization, or not your device (`thread_not_found`, `device_not_found`) | | 409 | | The sender is pending or revoked (`device_not_trusted`); none of your devices holds `keyVersion` (`key_version_not_held`); the organization has no recovery key (`org_recovery_key_required`); or `orgKeyId` is not its current key (`org_key_replaced`) | | 410 | | You deleted the thread (`thread_deleted`) | | 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/threads/<threadId>/org-key" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "keyVersion": 1, "orgKeyId": "<orgKeyId>", "lockedKey": "<lockedKey>", "senderDeviceId": "<senderDeviceId>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Forg-key) ## List org thread keys `GET /v1/threads/{threadId}/org-keys` An organization thread's content key copies locked for the organization's recovery keys, current and replaced, for an auditor. Audited. Permission: `synced_sessions.audit` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's id, as its client names it | ### Responses - `200` OK (application/json, OrgThreadKeyList) - `threadId` (string, required) - `keys` (array of OrgThreadKey, required) - `threadId` (string, required) - `keyVersion` (integer, required) - `orgKeyId` (string, required): The organization key it is locked for, current or replaced. - `personId` (string, required): The thread's person. - `lockedKey` (string, required) - `senderDeviceId` (string, required): The person's trusted device that signed it. - `signature` (string, required) - `createdAt` (string (date-time), required) - `400` A malformed thread id (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Without `synced_sessions.audit` (`role_required`), or not a person (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such thread in this organization, or it was deleted (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | A malformed thread id | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such thread in this organization, or it was deleted (`thread_not_found`) | | 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/threads/<threadId>/org-keys" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Forg-keys) ## Put team thread key `PUT /v1/threads/{threadId}/team-key` Store your team-visible thread's content key locked to the team key's current epoch, signed by one of your trusted devices. A copy already stored is kept, and the answer says so. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's id, as its client names it | ### Request body (application/json, required) - `keyVersion` (integer, required): A version your devices hold a copy of. [min 1] - `teamKeyId` (string, required): The team key's current epoch (`GET /v1/orgs/team-key`). - `lockedKey` (string, required): The content key, HPKE-sealed to the epoch's encryptionKey: base64url without padding. [min length 1; max length 512; pattern ^[A-Za-z0-9_-]+$] - `senderDeviceId` (string, required): Your trusted device that signs the copy. - `signature` (string, required): Ed25519 over `nexus-team-thread-key:v1:{threadId}:{keyVersion}:{teamKeyId}:{lockedKey}`: 64 bytes in base64url without padding. ### Responses - `200` Stored, or already stored (application/json, TeamThreadKeyStored) - `threadId` (string, required) - `keyVersion` (integer, required) - `teamKeyId` (string, required) - `stored` (boolean, required): False when the copy was already stored: the stored one is kept. - `400` A malformed thread id, key version, copy or signature (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person (`person_required`), or the signature does not verify with the sender's signing key (`invalid_signature`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not your thread in this organization, or not your device (`thread_not_found`, `device_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The sender is pending or revoked (`device_not_trusted`); none of your devices holds `keyVersion` (`key_version_not_held`); the thread is private (`thread_private`); or `teamKeyId` is not the current epoch (`team_key_retired`) (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. - `410` You deleted the thread (`thread_deleted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed thread id, key version, copy or signature | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not your thread in this organization, or not your device (`thread_not_found`, `device_not_found`) | | 409 | | The sender is pending or revoked (`device_not_trusted`); none of your devices holds `keyVersion` (`key_version_not_held`); the thread is private (`thread_private`); or `teamKeyId` is not the current epoch (`team_key_retired`) | | 410 | | You deleted the thread (`thread_deleted`) | | 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/threads/<threadId>/team-key" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "keyVersion": 1, "teamKeyId": "<teamKeyId>", "lockedKey": "<lockedKey>", "senderDeviceId": "<senderDeviceId>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fteam-key) ## List team thread keys `GET /v1/threads/{threadId}/team-keys` A thread's content key copies locked to the team key's epochs, for its person and for teammates who read it. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's id, as its client names it | ### Responses - `200` OK (application/json, TeamThreadKeyList) - `threadId` (string, required) - `keys` (array of TeamThreadKey, required) - `threadId` (string, required) - `keyVersion` (integer, required) - `teamKeyId` (string, required) - `personId` (string, required): The thread's person. - `lockedKey` (string, required) - `senderDeviceId` (string, required): The person's trusted device that signed it. - `signature` (string, required) - `createdAt` (string (date-time), required) - `400` A malformed thread id (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person (`person_required`); or Nexus UI while the organization's `webSessionViewer` is off (`web_session_viewer_off`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such thread you read in this organization (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | A malformed thread id | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such thread you read in this organization (`thread_not_found`) | | 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/threads/<threadId>/team-keys" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fteam-keys) ## Get org recovery key `GET /v1/orgs/recovery-key` The organization's current recovery key: the public half runners lock thread content keys to under the user_and_org content policy, with its fingerprint. key is null until one is registered. Permission: `org.read` (Every member). ### Responses - `200` OK (application/json, OrgRecoveryKeyState) - `key` (OrgRecoveryKey | null, required): Null until the organization registers a key - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/orgs/recovery-key" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Frecovery-key) ## Put org recovery key `PUT /v1/orgs/recovery-key` Register the organization's recovery key, or replace the current one. Audited as org.recovery_key_changed. Permission: `synced_sessions.manage_policy` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `encryptionKey` (string, required): The organization's X25519 public key: 32 bytes, base64url without padding. Its private half stays in the organization's vault. [pattern ^[A-Za-z0-9_-]{43}$] ### Responses - `200` OK (application/json, OrgRecoveryKeyState) - `key` (OrgRecoveryKey | null, required): Null until the organization registers a key - `400` A key of the wrong form (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Without synced_sessions.manage_policy (`role_required`), or not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A key of the wrong form | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `model_not_allowed` | Without synced_sessions.manage_policy (`role_required`), or not a person: an agent link, a module or a service account (`person_required`) | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/orgs/recovery-key" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "encryptionKey": "<encryptionKey>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Forgs%2Frecovery-key) ## Get org recovery key coverage `GET /v1/orgs/recovery-key/coverage` Which members lock their synced threads for the organization's current recovery key: each member with synced threads, those with no copy for the key first. Permission: `synced_sessions.audit` (Owner, Admin). ### Responses - `200` OK (application/json, OrgKeyCoverage) - `keyId` (string | null, required): The current key; null until one is registered. - `members` (array of OrgKeyMemberCoverage, required) - `personId` (string, required) - `threads` (integer, required): Their synced threads that are not deleted. - `lockedThreads` (integer, required): Those with a copy for the current key. - `confirmed` (boolean, required): Whether any of their threads has a copy for the current key. - `lastLockedAt` (string (date-time) | null, required) - `403` Without `synced_sessions.audit` (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/orgs/recovery-key/coverage" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Frecovery-key%2Fcoverage) ## Get team key `GET /v1/orgs/team-key` The team key's newest epoch, current or retired, and your holder's copies of every epoch when `holder` names one. Permission: `org.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `holder` | query | string | no | One of your trusted holders: its copies come back | ### Responses - `200` OK (application/json, TeamKeyState) - `key` (TeamKey | null, required): The newest epoch, current or retired; null before the first. - `copies` (array of TeamKeyCopy, required): The named holder's copies of every epoch, in epoch order; empty without `holder`. - `teamKeyId` (string, required) - `epoch` (integer, required) - `holderId` (string, required) - `lockedKey` (string, required): The epoch's private half, HPKE-sealed to the holder's encryptionKey. - `senderDeviceId` (string, required): The member's trusted device that signed it. - `signature` (string, required) - `createdAt` (string (date-time), required) - `403` `holder` named and not a person (`person_required`), or named by Nexus UI while the organization's `webSessionViewer` is off (`web_session_viewer_off`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` `holder` is not your device (`device_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` `holder` is pending or revoked (`device_not_trusted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | `holder` is not your device (`device_not_found`) | | 409 | | `holder` is pending or revoked (`device_not_trusted`) | | 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/orgs/team-key" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Forgs%2Fteam-key) ## Create team key `POST /v1/orgs/team-key` Make the team key's next epoch, with its first copies for members' trusted holders. One epoch at a time; audited as org.team_key_rotated. Permission: `chat.use` (Every member). ### Request body (application/json, required) - `epoch` (integer, required): One more than the newest epoch: 1 for the first. [min 1] - `encryptionKey` (string, required): The new epoch's X25519 public half: 32 bytes in base64url without padding. [pattern ^[A-Za-z0-9_-]{43}$] - `senderDeviceId` (string, required): Your trusted device that made the epoch and signs its copies. - `copies` (array of TeamKeyCopyRequest): The new epoch's first copies, each of `epoch`. [at most 500 items] - `epoch` (integer, required) [min 1] - `holderId` (string, required): A trusted holder of a member of this organization. - `lockedKey` (string, required): The epoch's private half, HPKE-sealed to the holder's encryptionKey: base64url without padding. [min length 1; max length 512; pattern ^[A-Za-z0-9_-]+$] - `signature` (string, required): Ed25519 over `nexus-team-key:v1:{orgId}:{epoch}:{holderId}:{lockedKey}`: 64 bytes in base64url without padding. ### Responses - `201` Created (application/json, TeamKey) - `id` (string, required) - `epoch` (integer, required): 1 first, one more at each rotation. [min 1] - `encryptionKey` (string, required): X25519 public half, base64url: runners lock team-visible threads' content keys to it. - `createdBy` (string, required): The member who made the epoch. - `createdAt` (string (date-time), required) - `retiredAt` (string (date-time) | null, required): Set when a member's removal or a device revoke retired the epoch: the next epoch is due. - `retiredReason` ("member_removed" | "device_revoked" | null, required): Why the epoch retired; null while it is current. - `400` A malformed key, copy or signature, or an epoch after a gap (`team_key_epoch_gap`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person (`person_required`), or the signature does not verify with the sender's signing key (`invalid_signature`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` The sender is not your device (`device_not_found`), or a holder is no member's (`holder_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The epoch is taken (`team_key_epoch_taken`); the newest epoch is current (`team_key_current`); or the sender or a holder is pending or revoked (`device_not_trusted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed key, copy or signature, or an epoch after a gap (`team_key_epoch_gap`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | The sender is not your device (`device_not_found`), or a holder is no member's (`holder_not_found`) | | 409 | | The epoch is taken (`team_key_epoch_taken`); the newest epoch is current (`team_key_current`); or the sender or a holder is pending or revoked (`device_not_trusted`) | | 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/orgs/team-key" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "epoch": 1, "encryptionKey": "<encryptionKey>", "senderDeviceId": "<senderDeviceId>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Forgs%2Fteam-key) ## Put team key copies `PUT /v1/orgs/team-key/copies` Hand team-key epochs your device holds to members' trusted holders. A copy already stored is kept. Permission: `chat.use` (Every member). ### Request body (application/json, required) - `senderDeviceId` (string, required): Your trusted device. It holds a copy of every epoch it hands over. - `copies` (array of TeamKeyCopyRequest, required) [at most 500 items] - `epoch` (integer, required) [min 1] - `holderId` (string, required): A trusted holder of a member of this organization. - `lockedKey` (string, required): The epoch's private half, HPKE-sealed to the holder's encryptionKey: base64url without padding. [min length 1; max length 512; pattern ^[A-Za-z0-9_-]+$] - `signature` (string, required): Ed25519 over `nexus-team-key:v1:{orgId}:{epoch}:{holderId}:{lockedKey}`: 64 bytes in base64url without padding. ### Responses - `200` OK (application/json, TeamKeyCopiesStored) - `stored` (integer, required) - `alreadyPresent` (integer, required): Copies already stored: the stored ones are kept. - `400` A malformed copy or signature (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person (`person_required`), or the signature does not verify with the sender's signing key (`invalid_signature`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such epoch (`team_key_not_found`), the sender is not your device (`device_not_found`), or a holder is no member's (`holder_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The sender holds no copy of an epoch it hands over (`team_key_not_held`), or the sender or a holder is pending or revoked (`device_not_trusted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed copy or signature | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | No such epoch (`team_key_not_found`), the sender is not your device (`device_not_found`), or a holder is no member's (`holder_not_found`) | | 409 | | The sender holds no copy of an epoch it hands over (`team_key_not_held`), or the sender or a holder is pending or revoked (`device_not_trusted`) | | 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/orgs/team-key/copies" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "senderDeviceId": "<senderDeviceId>", "copies": [ { "epoch": 1, "holderId": "<holderId>", "lockedKey": "<lockedKey>", "signature": "<signature>" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Forgs%2Fteam-key%2Fcopies) --- <!-- /docs/api/operator-grants --> # Operator grants > Operator grants: the one way a Nexus operator reaches a customer's organization. A person with a platform role (`operator` or `platform_admin`) asks for a grant with a reason, a list of actions and an expiry (24 hours by default, 7 days at most). The customer's owners and admins read every grant, and every act under it in their audit log, and revoke it at once. A grant makes no member and no seat. The operator then sends its own person's API key or token with the header `x-nexus-operator-grant: opg_…`. The header can give: 400 `invalid_operator_grant` (not one `opg_…` id), 400 `operator_header_refused` (with a module key, a service account key, Nexus UI's server or a public endpoint), 403 `operator_grant_invalid` (unknown, ended, revoked, held by another person, or its operator's platform role was revoked), 403 `operator_scope` (the grant does not name the route's action) and 503 `operator_log_unavailable` (the `operator.request` audit event could not be written, so the request did not run). ## List operator grants `GET /v1/operator-grants` The operator grants on the caller's organization, live and dead, newest first (owners and admins: `operator_grants.read`). Each names the operator, read from their user record now: the grant stores no name or email. `status` is `live`, `expired` or `revoked`. `limit` and `cursor` page it. Audited as `operator_grant.issued` and `operator_grant.revoked`; each request an operator makes under a grant is `operator.request` in the same log. Permission: `operator_grants.read` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `limit` | query | integer | no | Items per page, 1 to 500 (default 100). Without limit or cursor the answer holds the whole list. | | `cursor` | query | string | no | NextCursor from the previous page. A cursor whose item left the list answers 400 `invalid_cursor`. | ### Responses - `200` OK (application/json, OperatorGrantList) - `grants` (array of OperatorGrant, required) - `id` (string, required): `opg_…` - `tenantId` (string, required): The customer organization the grant reaches. - `operator` (object, required): The operator who holds the grant. The name and the email are read from their user record when the grant is read; nothing stores them with the grant or in the customer's audit log. - `userId` (string, required) - `name` (string) - `email` (string) - `reason` (string, required) [min length 1; max length 500] - `scope` (array of string, required): The actions the operator may do, by name in the permission matrix. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `revokedBy` (string): The person who revoked it: the operator, or an owner or admin of the customer. - `status` ("live" | "expired" | "revoked", required): `revoked` wins over `expired`. - `nextCursor` (string): The next page's cursor, while more items follow. Only when limit or cursor was sent. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/operator-grants" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Foperator-grants) ## Create operator grant `POST /v1/operator-grants` Ask for an operator grant on a customer's organization (`operator_grants.issue`; the caller must also hold a platform role, else 403 `operator_required`). The grant names a reason, a list of actions and an expiry (24 hours by default, at most 7 days). Each action must be one an admin may do. It must not spend the organization's money or act as one of its people (model and chat calls, the coding-agent gateway, the caller's own keys and tokens, the organization switch, modules and connectors, sharing and reading artifacts, search, device login approval, the operator grants themselves). It must not change, for good, who reaches the organization (members, invitations, email domains, teams, artifact shares outside it), its credentials (provider keys, anyone's API keys and tokens, GitHub installations), its money limits (budgets and spend limits) or its settings (chat retention, artifact sharing limits). A name from either list is a 400 `invalid_scope`. Policy changes (`policy.manage`, `policy.manage_team`) are open to a grant. It makes no member and no seat. The operator then sends its own person token with the header `x-nexus-operator-grant: opg_…`. Audited as `operator_grant.issued` in both organizations. With `dryRun: true` everything is checked and nothing is written: the answer is a 200 with the grant as it would be made, and its id is never used. Permission: `operator_grants.issue` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `tenantId` (string, required): The customer organization to reach. - `reason` (string, required) [min length 1; max length 500] - `scope` (array of string, required): The actions the operator may do, by name in the permission matrix. Each is one an admin may do and none that spends money, acts as a person, or changes access, credentials, limits or settings. - `expiresAt` (string (date-time)): In the future, at most 7 days from now. 24 hours from now by default. - `dryRun` (boolean): Check everything and write nothing. [default false] ### Responses - `200` A dry run: the grant as it would be made (application/json, CreatedOperatorGrant) - `id` (string, required): `opg_…` - `tenantId` (string, required): The customer organization the grant reaches. - `operator` (object, required): The operator who holds the grant. The name and the email are read from their user record when the grant is read; nothing stores them with the grant or in the customer's audit log. - `userId` (string, required) - `name` (string) - `email` (string) - `reason` (string, required) [min length 1; max length 500] - `scope` (array of string, required): The actions the operator may do, by name in the permission matrix. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `revokedBy` (string): The person who revoked it: the operator, or an owner or admin of the customer. - `status` ("live" | "expired" | "revoked", required): `revoked` wins over `expired`. - `dryRun` (boolean, required): A dry run's id is never used. - `201` Created (application/json, CreatedOperatorGrant) - `id` (string, required): `opg_…` - `tenantId` (string, required): The customer organization the grant reaches. - `operator` (object, required): The operator who holds the grant. The name and the email are read from their user record when the grant is read; nothing stores them with the grant or in the customer's audit log. - `userId` (string, required) - `name` (string) - `email` (string) - `reason` (string, required) [min length 1; max length 500] - `scope` (array of string, required): The actions the operator may do, by name in the permission matrix. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `revokedBy` (string): The person who revoked it: the operator, or an owner or admin of the customer. - `status` ("live" | "expired" | "revoked", required): `revoked` wins over `expired`. - `dryRun` (boolean, required): A dry run's id is never used. - `400` Not valid: no reason (1 to 500 characters, `invalid_reason`), no scope or a scope that names an unknown action or one no grant may name (`invalid_scope`), an `expiresAt` that is not a future time within 7 days (`invalid_expiry`), or a target that is the caller's own organization or a personal organization (`invalid_target`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller is no person (`person_required`) or holds no platform role (`operator_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such organization (`unknown_organization`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The operator already holds 20 live grants (`operator_grant_limit`): revoke one, or wait for one to end (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not valid: no reason (1 to 500 characters, `invalid_reason`), no scope or a scope that names an unknown action or one no grant may name (`invalid_scope`), an `expiresAt` that is not a future time within 7 days (`invalid_expiry`), or a target that is the caller's own organization or a personal organization (`invalid_target`) | | 400 | `invalid_scope` | A name from either list is a 400 `invalid_scope` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `operator_required` | Sk for an operator grant on a customer's organization (`operator_grants.issue`; the caller must also hold a platform role, else 403 `operator_required`) | | 404 | | No such organization (`unknown_organization`) | | 409 | | The operator already holds 20 live grants (`operator_grant_limit`): revoke one, or wait for one to end | | 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/operator-grants" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "tenantId": "<tenantId>", "reason": "<reason>", "scope": [ "<scope>" ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Foperator-grants) ## Revoke operator grant `DELETE /v1/operator-grants/{id}` Revoke an operator grant (owners and admins of the organization it reaches: `operator_grants.read`; or the operator who holds it, calling from the organization they asked from, as a person). The operator's next request under it is a 403 `operator_grant_invalid`. Revoking a revoked grant answers it as it was and changes nothing. Audited as `operator_grant.revoked` in both organizations. A grant that is not on the caller's organization and not the caller's is a 404. Permission: `operator_grants.read` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The grant's id (`opg_…`) | | `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, OperatorGrant) - `id` (string, required): `opg_…` - `tenantId` (string, required): The customer organization the grant reaches. - `operator` (object, required): The operator who holds the grant. The name and the email are read from their user record when the grant is read; nothing stores them with the grant or in the customer's audit log. - `userId` (string, required) - `name` (string) - `email` (string) - `reason` (string, required) [min length 1; max length 500] - `scope` (array of string, required): The actions the operator may do, by name in the permission matrix. - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `revokedBy` (string): The person who revoked it: the operator, or an owner or admin of the customer. - `status` ("live" | "expired" | "revoked", required): `revoked` wins over `expired`. - `403` The caller is neither an owner or admin of the organization the grant reaches nor the operator who holds it (`role_required`), or is no person (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such operator grant on this organization (`unknown_operator_grant`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `operator_grant_invalid` | The operator's next request under it is a 403 `operator_grant_invalid` | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such operator grant on this organization (`unknown_operator_grant`) | | 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/operator-grants/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Foperator-grants%2F%7Bid%7D) ## Set organization mark `PUT /v1/marks/organizations/{id}` Mark an organization as Nexus's own (`staff`, `test` or `demo`), or clear its mark with `null`. Only a person with a platform role may. Audited in the organization, so it sees who marked it, and in the operator's. Figures that leave an organization count marked accounts apart. Permission: `accounts.mark` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The organization's id | ### Request body (application/json, required) - `mark` ("staff" | "test" | "demo" | null, required): The mark, or null to clear it ### Responses - `200` OK (application/json, AccountMarkView) - `id` (string, required) - `mark` ("staff" | "test" | "demo" | null, required): The mark now; null for a customer's account - `400` The body names no `mark`, an unknown one, or another field (`invalid_mark`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Without a platform role (`operator_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such organization (`unknown_organization`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body names no `mark`, an unknown one, or another field (`invalid_mark`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such organization (`unknown_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 PUT "$NEXUS_URL/v1/marks/organizations/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mark": "staff" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fmarks%2Forganizations%2F%7Bid%7D) ## Set person mark `PUT /v1/marks/people/{id}` Mark a person as one of Nexus's own (`staff`, `test` or `demo`), or clear their mark with `null`. Only a person with a platform role may. Audited in each organization the person is a member of, and in the operator's. Permission: `accounts.mark` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The person's id | ### Request body (application/json, required) - `mark` ("staff" | "test" | "demo" | null, required): The mark, or null to clear it ### Responses - `200` OK (application/json, AccountMarkView) - `id` (string, required) - `mark` ("staff" | "test" | "demo" | null, required): The mark now; null for a customer's account - `400` The body names no `mark`, an unknown one, or another field (`invalid_mark`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Without a platform role (`operator_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such person (`unknown_person`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body names no `mark`, an unknown one, or another field (`invalid_mark`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such person (`unknown_person`) | | 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/marks/people/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "mark": "staff" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fmarks%2Fpeople%2F%7Bid%7D) ## Get desktop revocations `GET /v1/desktop/revocations` The desktop app versions this Gateway refuses: a minimum (every older version is refused) and a list of exact versions. Only a person with a platform role may read them. Permission: `desktop.revoke` (Owner, Admin). ### Responses - `200` OK (application/json, DesktopRevocations) - `minimum` (string | null, required): Every version older than this one is refused. - `versions` (array of string, required): These exact versions are refused. - `reason` (string | null, required) - `changedBy` (string | null, required): The operator's user id. - `changedAt` (string | null, required) - `403` Without a platform role (`operator_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/desktop/revocations" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdesktop%2Frevocations) ## Set desktop revocations `PUT /v1/desktop/revocations` Replace the desktop app versions this Gateway refuses. A call whose `x-nexus-client` names a refused `desktop/<version>` then answers 426 `desktop_revoked` on every `/v1` path except device sign-in, sign-out and `/v1/desktop/download-access`, so the build can still update. Takes effect on every Gateway copy within seconds, with no deploy. Only a person with a platform role may. Audited in the operator's organization (`desktop.revocations_changed`). Permission: `desktop.revoke` (Owner, Admin). ### Request body (application/json, required) - `minimum` (string | null, required): Refuse every version older than this one, such as `0.9.1`; `null` for no minimum. - `versions` (array of string, required): Refuse these exact versions, such as `0.9.0` or `0.10.0-internal.376`. [at most 100 items] - `reason` (string, required): Why, for the audit log: an issue id, say. [min length 1; max length 500] ### Responses - `200` OK (application/json, DesktopRevocations) - `minimum` (string | null, required): Every version older than this one is refused. - `versions` (array of string, required): These exact versions are refused. - `reason` (string | null, required) - `changedBy` (string | null, required): The operator's user id. - `changedAt` (string | null, required) - `400` The body misses `minimum`, `versions` or `reason`, holds another field (`invalid_desktop_revocations`), or a version that is not `MAJOR.MINOR.PATCH[-prerelease]` (`invalid_desktop_version`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Without a platform role (`operator_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body misses `minimum`, `versions` or `reason`, holds another field (`invalid_desktop_revocations`), or a version that is not `MAJOR.MINOR.PATCH[-prerelease]` (`invalid_desktop_version`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 426 | `desktop_revoked` | A call whose `x-nexus-client` names a refused `desktop/<version>` then answers 426 `desktop_revoked` on every `/v1` path except device sign-in, sign-out and `/v1/desktop/download-access`, so the build can still update | | 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/desktop/revocations" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "minimum": "<minimum>", "versions": [ "<version>" ], "reason": "<reason>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fdesktop%2Frevocations) --- <!-- /docs/api/pages --> # Pages > Pages: standalone HTML, Markdown, React (`jsx`) or spreadsheet (`sheet`, JSON data) pages, and whiteboards (`board`, JSON data that every version must parse as, else 400 `page_board_invalid` with `nexus.problems`; a board may be written as a layout, a timeline, columns, a flow, a mind map or a grid, which Gateway lays out on top of the latest version, else 400 `page_board_layout_invalid`), in versions that never change. Every write makes the next version; a write built on an old version is refused (409 `page_version_conflict`), and a restore makes a new version from an old one. At most 16 MiB a version. Writes that contain what phishing needs (password fields, forms that submit somewhere, meta refresh, iframes, object and embed, obfuscated eval) are refused with the reason (400 `page_content_blocked`). Private to their owner for now: sharing and the sandboxed viewer come next. ## List pages `GET /v1/pages` Your pages in this organization, most recently written first. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `q` | query | string | no | A case-insensitive match in the title. | | `order` | query | "recent" \| "name" \| "kind" \| "created" | no | The order for this list. Keep the same filter and order when sending its cursor. | | `limit` | query | integer | no | At most this many (default 30) | | `docText` | query | boolean | no | Match saved Markdown in owned Docs as well as titles when q is set. | | `cursor` | query | string | no | `nextCursor` from the previous page | ### Responses - `200` OK (application/json, PageList) - `contentMatches` (object): Saved Doc excerpts keyed by page ID for matches in this list. - `pages` (array of PageSummary, required) - `id` (string, required): `pag_…` - `title` (string, required): The latest version's title - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written - `nextCursor` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/pages" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages) ## Create page `POST /v1/pages` Create a page from finished HTML, Markdown or a React component: version 1. Audited as page.created. Permission: `chat.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) - `routes` (array of SiteRouteWrite): Additional saved HTML or React Site routes. The content field holds the root. On a version write, omission carries the previous routes and an empty list removes them. [at most 31 items] - `path` (string, required) [max length 128] - `title` (string, required) [max length 120] - `content` (string, required): Document source in the Site’s format. - `title` (string, required): 1 to 120 characters [min length 1; max length 120] - `format` ("html" | "md" | "jsx" | "sheet" | "board") [default "html"] - `content` (string, required): The page's source: HTML, or Markdown. At most 16 MiB of UTF-8. ### Responses - `201` Created (application/json, PageWritten) - `page` (PageSummary, required) - `id` (string, required): `pag_…` - `title` (string, required): The latest version's title - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written - `version` (PageVersion, required) - `pageId` (string, required) - `version` (integer, required) - `title` (string, required) - `contentSha256` (string, required): The content's SHA-256, lowercase hex - `bytes` (integer, required): The content's size in bytes (UTF-8) - `createdVia` ("chat_tool" | "api" | "cli" | "restore" | "remix", required) - `restoredFrom` (integer): A restore's source version - `remixedFrom` (PageRemixedFrom): A remix's source: the share it was read through and the page version it copies. - `artifactId` (string, required) - `pageId` (string, required) - `version` (integer, required) - `createdAt` (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 | | 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/pages" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "title": "<title>", "content": "<content>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages) ## List page trash `GET /v1/pages/trash` The caller’s pages in Trash. Permission: `chat.use` (Every member). ### Responses - `200` OK (application/json, TrashedPageList) - `pages` (array of TrashedPage, required) - `page` (PageSummary, required) - `id` (string, required): `pag_…` - `title` (string, required): The latest version's title - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written - `trashedAt` (string (date-time), required) - `purgeAfter` (string (date-time), required) ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/pages/trash" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2Ftrash) ## Change page trash `PUT /v1/pages/{id}/trash` Move an owned page to Trash or restore it. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | | ### Request body (application/json, required) - `trashed` (boolean, required) ### Responses - `204` OK ### 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 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/pages/<id>/trash" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "trashed": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpages%2F%7Bid%7D%2Ftrash) ## Purge page trash `DELETE /v1/pages/{id}/trash` Permanently delete an owned page that is in Trash. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | | ### Responses - `204` OK ### 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 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/pages/<id>/trash" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fpages%2F%7Bid%7D%2Ftrash) ## Get page `GET /v1/pages/{id}` One of your pages and its versions, newest first. Each version lists its title and size, not its content: read the content with getPageSource. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | ### Responses - `200` OK (application/json, PageDetail) - `id` (string, required): `pag_…` - `title` (string, required): The latest version's title - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written - `versions` (array of PageVersion, required): Newest first - `pageId` (string, required) - `version` (integer, required) - `title` (string, required) - `contentSha256` (string, required): The content's SHA-256, lowercase hex - `bytes` (integer, required): The content's size in bytes (UTF-8) - `createdVia` ("chat_tool" | "api" | "cli" | "restore" | "remix", required) - `restoredFrom` (integer): A restore's source version - `remixedFrom` (PageRemixedFrom): A remix's source: the share it was read through and the page version it copies. - `artifactId` (string, required) - `pageId` (string, required) - `version` (integer, required) - `createdAt` (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/pages/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D) ## Delete page `DELETE /v1/pages/{id}` Delete one of your pages, every version and its content, for good. Audited as page.deleted. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `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` Deleted (application/json, PageDeleted) - `deleted` (boolean, required) - `id` (string, required) - `versions` (integer, required): How many versions went with it - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (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/pages/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fpages%2F%7Bid%7D) ## Write page version `POST /v1/pages/{id}/versions` Write the next version of one of your pages, or of a page shared with you with edit access (a viewer gets 403 page_read_only). With `baseVersion`, refused with 409 `page_version_conflict` when that is no longer the latest. Audited as page.version_written. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `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) - `routes` (array of SiteRouteWrite): Additional saved HTML or React Site routes. The content field holds the root. On a version write, omission carries the previous routes and an empty list removes them. [at most 31 items] - `path` (string, required) [max length 128] - `title` (string, required) [max length 120] - `content` (string, required): Document source in the Site’s format. - `content` (string, required): The page's source: HTML, or Markdown. At most 16 MiB of UTF-8. - `title` (string): A new title; unset keeps the latest one [min length 1; max length 120] - `format` ("html" | "md" | "jsx" | "sheet" | "board"): Must be the page's format when set - `baseVersion` (integer): The version this was built on: refused with 409 `page_version_conflict` when it is no longer the latest [min 1] - `agent` (string): An agent writing for you: its name, such as Claude. People with the page open see it on the canvas, next to your name, on the boards this write changes. Unset from an MCP server: Agent [min length 1; max length 40] ### Responses - `201` Written (application/json, PageWritten) - `page` (PageSummary, required) - `id` (string, required): `pag_…` - `title` (string, required): The latest version's title - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written - `version` (PageVersion, required) - `pageId` (string, required) - `version` (integer, required) - `title` (string, required) - `contentSha256` (string, required): The content's SHA-256, lowercase hex - `bytes` (integer, required): The content's size in bytes (UTF-8) - `createdVia` ("chat_tool" | "api" | "cli" | "restore" | "remix", required) - `restoredFrom` (integer): A restore's source version - `remixedFrom` (PageRemixedFrom): A remix's source: the share it was read through and the page version it copies. - `artifactId` (string, required) - `pageId` (string, required) - `version` (integer, required) - `createdAt` (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 | `page_version_conflict` | With `baseVersion`, refused with 409 `page_version_conflict` when that is no longer the latest | | 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/pages/<id>/versions" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "content": "<content>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fversions) ## Restore page `POST /v1/pages/{id}/restore` Restore an old version: the next version gets its title and content. Audited as page.restored. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `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) - `version` (integer, required): The version to restore [min 1] - `baseVersion` (integer): As for writePageVersion [min 1] ### Responses - `201` Restored (application/json, PageWritten) - `page` (PageSummary, required) - `id` (string, required): `pag_…` - `title` (string, required): The latest version's title - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written - `version` (PageVersion, required) - `pageId` (string, required) - `version` (integer, required) - `title` (string, required) - `contentSha256` (string, required): The content's SHA-256, lowercase hex - `bytes` (integer, required): The content's size in bytes (UTF-8) - `createdVia` ("chat_tool" | "api" | "cli" | "restore" | "remix", required) - `restoredFrom` (integer): A restore's source version - `remixedFrom` (PageRemixedFrom): A remix's source: the share it was read through and the page version it copies. - `artifactId` (string, required) - `pageId` (string, required) - `version` (integer, required) - `createdAt` (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 POST "$NEXUS_URL/v1/pages/<id>/restore" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "version": 1 }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages%2F%7Bid%7D%2Frestore) ## Get page version `GET /v1/pages/{id}/versions/{version}` One version of one of your pages, or of a page shared with you with edit access. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `version` | path | string | yes | A version number, or `latest` | ### Responses - `200` OK (application/json, PageVersion) - `pageId` (string, required) - `version` (integer, required) - `title` (string, required) - `contentSha256` (string, required): The content's SHA-256, lowercase hex - `bytes` (integer, required): The content's size in bytes (UTF-8) - `createdVia` ("chat_tool" | "api" | "cli" | "restore" | "remix", required) - `restoredFrom` (integer): A restore's source version - `remixedFrom` (PageRemixedFrom): A remix's source: the share it was read through and the page version it copies. - `artifactId` (string, required) - `pageId` (string, required) - `version` (integer, required) - `createdAt` (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/pages/<id>/versions/<version>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fversions%2F%7Bversion%7D) ## Get site routes `GET /v1/pages/{id}/versions/{version}/site-routes` List a saved Site version’s routes Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `version` | path | string | yes | A version number, or `latest` | ### Responses - `200` OK (application/json, SiteRoutes) - `pageId` (string, required) - `version` (integer, required) [min 1] - `routes` (array of SiteRoute, required) [at most 32 items] - `path` (string, required) [max length 128] - `title` (string, required) [max length 120] - `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/pages/<id>/versions/<version>/site-routes" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fversions%2F%7Bversion%7D%2Fsite-routes) ## Get page source `GET /v1/pages/{id}/versions/{version}/source` A version's source as written, as plain text: the HTML, Markdown or JSX to edit and write back with writePageVersion. Use version `latest` for the newest. It is never rendered on the API's origin. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `version` | path | string | yes | A version number, or `latest` | ### Responses - `200` The source, `text/plain`; the `x-nexus-page-version` header names the version (text/plain, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/pages/<id>/versions/<version>/source" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fversions%2F%7Bversion%7D%2Fsource) ## Stream page events `GET /v1/pages/{id}/events` A page's live events, as server-sent events: a version event when a version is written, a preview event when an editor posts unsaved text, and its shared draft's updates, to whoever may open the page. A query event (PageQueryEvent) says one of the page's queries has a new result (Nexus Data). Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | ### Responses - `200` The event stream (text/event-stream, PageVersionEvent) - `pageId` (string, required) - `version` (integer, required) - `title` (string, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `contentSha256` (string): SHA-256 of the content, lowercase hex: a shared draft tells its own saves from other writes by it. Gateway sends it; a client treats an event without it as a write from elsewhere. - `404` Not a page you may open, or a pinned share (`page_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Too many live readers on this Gateway copy (`page_events_full`): poll instead (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not a page you may open, or a pinned share (`page_not_found`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Too many live readers on this Gateway copy (`page_events_full`): poll instead | ### Example ```sh curl "$NEXUS_URL/v1/pages/<id>/events" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fevents) ## Get page doc `GET /v1/pages/{id}/doc` The page's shared draft: the Yjs updates its editors posted, oldest first, for an editor that joins late. Its owner and the editors of an edit share. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | ### Responses - `200` The draft (application/json, PageDoc) - `seed` (integer): The version the draft was started from. Unset: no draft. - `last` (integer): The newest update's id. - `updates` (array of string, required): The Yjs updates, oldest first, base64url. - `403` A reader who may only view the page (`page_read_only`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not a page you may edit (`page_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not a page you may edit (`page_not_found`) | | 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/pages/<id>/doc" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fdoc) ## Post page doc `POST /v1/pages/{id}/doc` Post to the page's shared draft: a Yjs update, a compacted snapshot, an editor's awareness (cursor and name), or their presence. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | ### Request body (application/json, required) - `seed` (integer): The version the draft was started from: required with `update`. [min 1] - `update` (string): A Yjs update, or with `snapshot` the whole draft (`Y.encodeStateAsUpdate`), base64url. [pattern ^[A-Za-z0-9_-]+$] - `snapshot` (boolean): `update` is a snapshot that replaces the updates up to `upTo`. - `upTo` (integer): A snapshot's last update: the `last` of the read it applied. Unset: the snapshot replaces nothing. [min 1] - `awareness` (string): An awareness update (y-protocols), base64url: relayed, never stored. [pattern ^[A-Za-z0-9_-]+$] - `presence` (object): A reader's presence, a JSON object of at most 4 KiB, relayed as posted: Nexus UI sends `client`, `at` (its pointer, or null) and `leave`. Never stored. ### Responses - `200` Stored (its id) or relayed (application/json, PageDocPosted) - `id` (integer): The stored update's id; unset for an awareness or presence post. - `400` A malformed body, or a `seed` that is not one of the page's versions (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` A reader who may only view the page posted an update or a snapshot (`page_read_only`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not a page you may edit, or for presence, open at its latest version (`page_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The draft started over from a newer version (`page_doc_stale`, `details.seed`): read it again (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `413` Over its size limit (`page_doc_too_large`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed body, or a `seed` that is not one of the page's versions | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not a page you may edit, or for presence, open at its latest version (`page_not_found`) | | 409 | | The draft started over from a newer version (`page_doc_stale`, `details.seed`): read it again | | 413 | | Over its size limit (`page_doc_too_large`) | | 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/pages/<id>/doc" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "seed": 1, "update": "<update>", "snapshot": false, "upTo": 1, "awareness": "<awareness>", "presence": {} }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fdoc) ## Put page preview `PUT /v1/pages/{id}/preview` Post the shared draft's text as the page's live preview, so every reader sees an edit before it is saved. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | ### Request body (application/json, required) - `baseVersion` (integer, required): The version the text is built on: the page's latest. [min 1] - `content` (string, required): The draft's whole text, at most 16 MiB, checked as a version's content. ### Responses - `200` Stored and announced (application/json, PagePreviewEvent) - `pageId` (string, required) - `version` (integer, required): The version the text is built on. - `contentSha256` (string, required): SHA-256 of the text, lowercase hex. - `400` A malformed body, content a page may not hold (`page_content_blocked`), a `sheet` that breaks its schema (`page_sheet_invalid`, with the first problem at `error.nexus.path`), or a board that does not parse (`page_board_invalid`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` A reader who may only view the page (`page_read_only`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Not a page you may edit (`page_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` A version was written since `baseVersion` (`page_preview_stale`, `details.latestVersion`): post the draft built on it (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `413` Over a page's 16 MiB (`page_too_large`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed body, content a page may not hold (`page_content_blocked`), a `sheet` that breaks its schema (`page_sheet_invalid`, with the first problem at `error.nexus.path`), or a board that does not parse (`page_board_invalid`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Not a page you may edit (`page_not_found`) | | 409 | | A version was written since `baseVersion` (`page_preview_stale`, `details.latestVersion`): post the draft built on it | | 413 | | Over a page's 16 MiB (`page_too_large`) | | 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/pages/<id>/preview" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "baseVersion": 1, "content": "<content>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fpreview) ## Share page `POST /v1/pages/{id}/share` Share one of your pages as an artifact, with the same audiences as a chat: the organization, chosen teams or people, or outside it (named people by email, or anyone with the link) as its settings allow. Pin a version, or follow the latest. Sharing again makes a new version of the artifact. Audited as artifact.shared. Permission: `artifacts.share` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `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) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string): Team slugs or ids (audience teams) - `people` (array of string): Kind people: members' emails or ids; kind external: the emails of people outside the organization (checked against artifacts.external.domains) - `expiresIn` (string | number): Kind public: 30d, 12h or a number of days (within artifacts.external.expiry) - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `version` ("latest" | integer): The version readers see: latest (follows new versions) or a number (pinned) [default "latest"] - `role` ("view" | "edit"): Edit lets the readers join the page's shared draft and write its versions. Only for audiences org, teams and people, on the latest version. Deleting, sharing and restoring stay the owner's. [default "view"] ### Responses - `201` Shared (application/json, Artifact) - `id` (string, required): Art_…; one per version - `version` (integer, required): 1 for a session's first share, then 2, 3… [min 1] - `sessionId` (string, required): The session it was shared from (which may have changed or been deleted since) - `title` (string, required) - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The session's model when shared: nexus/auto or a pinned model - `models` (array of string, required): The models that answered, in order of first use - `author` (ArtifactAuthor, required): Readers outside the organization get the name only - `email` (string) - `name` (string) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required): Readers may continue it in a new private chat of their own - `status` ("active" | "revoked", required): Only its author sees a revoked artifact - `mine` (boolean, required): You shared it - `latest` (boolean): No newer active version you can read - `messageCount` (integer, required) - `costUsd` (number): What the shared answers cost; absent for readers outside the organization - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external, and for every reader outside), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL, else a path - `path` (string, required): /app/<org>/artifacts/<id> - `markdownUrl` (string, required): GET /v1/artifacts/{id}.md - `createdAt` (string (date-time), required): When it was shared - `sessionCreatedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `viewerUrl` (string): The fast viewer outside the app shell: <origin>/a/<id> (read through a public link: that link) - `publicUrl` (string): Kind public, for its author and the organization's owners and admins (and whoever holds it): <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `external` (boolean): Shared outside the organization (kind external or public) - `includeCode` (boolean): Outside the organization: whether Ask your code's sources are in the snapshot - `organization` (string): The organization's name, shown to every reader - `kind` ("page" | "session"): Page for a shared page (no messages; open it with GET /v1/artifacts/{id}/frame); session for a shared coding-agent session (its messages derived from its timeline, `session` on ArtifactDetail); absent for a chat - `pageId` (string): A shared page: the page - `pageFormat` ("html" | "md" | "jsx" | "sheet" | "board") - `pageVersion` (integer): A shared page: the version it pins; absent: the latest - `pageRole` ("view" | "edit"): A shared page: edit when its readers in the organization may edit the page; absent for a chat - `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 POST "$NEXUS_URL/v1/pages/<id>/share" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "audience": "org" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fshare) ## List page comments `GET /v1/pages/{id}/comments` The comments on a page, oldest first, with whether you own it. Whoever may open the page: its owner, or anyone who may open one of its active shares (a comment is a read: the shares have no comment role). A public link alone is not enough. Anyone else: 404 page_not_found. A reader of a pinned share sees the threads on the versions it shows. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | ### Responses - `200` OK (application/json, PageComments) - `comments` (array of PageComment, required): Oldest first - `id` (string, required): `pcm_…` - `pageId` (string, required) - `threadId` (string): The thread's first comment; absent on that first comment - `author` (string): The author's name or email. Absent for a reader outside the page's organization, except on their own comments - `mine` (boolean, required): Whether you wrote it - `body` (string, required) - `quote` (string): The passage the thread is about - `prefix` (string): Up to 200 characters just before the passage, to find it again in a later version - `suffix` (string): Up to 200 characters just after the passage - `pin` (PagePin): The point on a design's board the thread is pinned to - `board` (string, required): The board's data-id, else its data-artboard name [min length 1; max length 200] - `x` (number, required): From the board's left edge, in its pixels [min 0; max 100000] - `y` (number, required): From the board's top edge, in its pixels [min 0; max 100000] - `at` (integer): The part's data-nx-at: its place in the source of the comment's version [min 0; max 2147483647] - `tag` (string): The part's tag, lower case [pattern ^[a-z][a-z0-9:-]{0,40}$] - `layer` (string): The part's data-layer name [min length 1; max length 200] - `path` (string): The part's place under the board, as child indices: finds it again in a later version [pattern ^\d{1,5}(\.\d{1,5}){0,63}$] - `px` (number): The point inside the part, as a fraction of its width; with py [min 0; max 1] - `py` (number): The point inside the part, as a fraction of its height; with px [min 0; max 1] - `version` (integer, required): The version it was made on - `resolvedAt` (string (date-time)): When the thread was resolved; absent while it is open - `chatSessionId` (string): The chat Ask Nexus opened, on the reply it posted - `createdAt` (string (date-time), required) - `owner` (boolean, required): Whether you own the page: you may delete any comment, resolve any thread, and ask Nexus - `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/pages/<id>/comments" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fcomments) ## Create page comment `POST /v1/pages/{id}/comments` Comment on a page: a new thread on a passage (quote, with the text before and after it, on a version) or on a point of a design's board (pin), or a reply (threadId). Whoever may open the page: its owner, or anyone who may open one of its active shares (a comment is a read: the shares have no comment role). A public link alone is not enough. Anyone else: 404 page_not_found. 403 pages_off when the organization turned pages off; 400 page_comment_limit at 1000 comments. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `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) - `body` (string, required) [min length 1; max length 4000] - `threadId` (string): Reply in this thread (a reply's id joins its thread). A reply has no quote, prefix, suffix or pin - `quote` (string): The passage a new thread is about; unset comments on the whole page [max length 2000] - `prefix` (string): The text just before the quote [max length 200] - `suffix` (string): The text just after the quote [max length 200] - `pin` (PagePin): A new thread's point on a design's board, instead of a quote. A reply has none - `board` (string, required): The board's data-id, else its data-artboard name [min length 1; max length 200] - `x` (number, required): From the board's left edge, in its pixels [min 0; max 100000] - `y` (number, required): From the board's top edge, in its pixels [min 0; max 100000] - `at` (integer): The part's data-nx-at: its place in the source of the comment's version [min 0; max 2147483647] - `tag` (string): The part's tag, lower case [pattern ^[a-z][a-z0-9:-]{0,40}$] - `layer` (string): The part's data-layer name [min length 1; max length 200] - `path` (string): The part's place under the board, as child indices: finds it again in a later version [pattern ^\d{1,5}(\.\d{1,5}){0,63}$] - `px` (number): The point inside the part, as a fraction of its width; with py [min 0; max 1] - `py` (number): The point inside the part, as a fraction of its height; with px [min 0; max 1] - `version` (integer): The version the passage is on; unset: the newest you can open [min 1] ### Responses - `201` Created (application/json, PageComment) - `id` (string, required): `pcm_…` - `pageId` (string, required) - `threadId` (string): The thread's first comment; absent on that first comment - `author` (string): The author's name or email. Absent for a reader outside the page's organization, except on their own comments - `mine` (boolean, required): Whether you wrote it - `body` (string, required) - `quote` (string): The passage the thread is about - `prefix` (string): Up to 200 characters just before the passage, to find it again in a later version - `suffix` (string): Up to 200 characters just after the passage - `pin` (PagePin): The point on a design's board the thread is pinned to - `board` (string, required): The board's data-id, else its data-artboard name [min length 1; max length 200] - `x` (number, required): From the board's left edge, in its pixels [min 0; max 100000] - `y` (number, required): From the board's top edge, in its pixels [min 0; max 100000] - `at` (integer): The part's data-nx-at: its place in the source of the comment's version [min 0; max 2147483647] - `tag` (string): The part's tag, lower case [pattern ^[a-z][a-z0-9:-]{0,40}$] - `layer` (string): The part's data-layer name [min length 1; max length 200] - `path` (string): The part's place under the board, as child indices: finds it again in a later version [pattern ^\d{1,5}(\.\d{1,5}){0,63}$] - `px` (number): The point inside the part, as a fraction of its width; with py [min 0; max 1] - `py` (number): The point inside the part, as a fraction of its height; with px [min 0; max 1] - `version` (integer, required): The version it was made on - `resolvedAt` (string (date-time)): When the thread was resolved; absent while it is open - `chatSessionId` (string): The chat Ask Nexus opened, on the reply it posted - `createdAt` (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 POST "$NEXUS_URL/v1/pages/<id>/comments" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "body": "<body>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fcomments) ## Resolve page comment `PATCH /v1/pages/{id}/comments/{commentId}` Resolve a thread, or open it again: its first comment, by its author or the page's owner (else 403 page_comment_forbidden). Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `commentId` | path | string | yes | The comment's id (`pcm_…`) | | `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) - `resolved` (boolean, required) ### Responses - `200` OK (application/json, PageComment) - `id` (string, required): `pcm_…` - `pageId` (string, required) - `threadId` (string): The thread's first comment; absent on that first comment - `author` (string): The author's name or email. Absent for a reader outside the page's organization, except on their own comments - `mine` (boolean, required): Whether you wrote it - `body` (string, required) - `quote` (string): The passage the thread is about - `prefix` (string): Up to 200 characters just before the passage, to find it again in a later version - `suffix` (string): Up to 200 characters just after the passage - `pin` (PagePin): The point on a design's board the thread is pinned to - `board` (string, required): The board's data-id, else its data-artboard name [min length 1; max length 200] - `x` (number, required): From the board's left edge, in its pixels [min 0; max 100000] - `y` (number, required): From the board's top edge, in its pixels [min 0; max 100000] - `at` (integer): The part's data-nx-at: its place in the source of the comment's version [min 0; max 2147483647] - `tag` (string): The part's tag, lower case [pattern ^[a-z][a-z0-9:-]{0,40}$] - `layer` (string): The part's data-layer name [min length 1; max length 200] - `path` (string): The part's place under the board, as child indices: finds it again in a later version [pattern ^\d{1,5}(\.\d{1,5}){0,63}$] - `px` (number): The point inside the part, as a fraction of its width; with py [min 0; max 1] - `py` (number): The point inside the part, as a fraction of its height; with px [min 0; max 1] - `version` (integer, required): The version it was made on - `resolvedAt` (string (date-time)): When the thread was resolved; absent while it is open - `chatSessionId` (string): The chat Ask Nexus opened, on the reply it posted - `createdAt` (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 PATCH "$NEXUS_URL/v1/pages/<id>/comments/<commentId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "resolved": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fcomments%2F%7BcommentId%7D) ## Delete page comment `DELETE /v1/pages/{id}/comments/{commentId}` Delete a comment, by its author or the page's owner (else 403 page_comment_forbidden). A thread's replies go with it. Deleting the page deletes all its comments. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `commentId` | path | string | yes | The comment's id (`pcm_…`) | | `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` Deleted (application/json, PageCommentDeleted) - `deleted` (boolean, required) - `id` (string, 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/pages/<id>/comments/<commentId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fcomments%2F%7BcommentId%7D) ## Ask nexus on page comment `POST /v1/pages/{id}/comments/{commentId}/ask` Ask Nexus to make the change a thread asks for (the page's owner only, else 403 page_owner_only): opens a new chat of yours that holds the page's latest version, posts a reply in the thread that names the chat, and answers the instruction to send there as your first message. That turn is an ordinary chat turn, billed to you, and its write_page writes the page's next version. Audited as chat.session_created. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `commentId` | path | string | yes | The comment's id (`pcm_…`) | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `201` Created (application/json, PageCommentAsked) - `comment` (PageComment, required): A comment on a page. A thread's first comment quotes a passage or pins a point on a design's board; a reply names its thread. - `id` (string, required): `pcm_…` - `pageId` (string, required) - `threadId` (string): The thread's first comment; absent on that first comment - `author` (string): The author's name or email. Absent for a reader outside the page's organization, except on their own comments - `mine` (boolean, required): Whether you wrote it - `body` (string, required) - `quote` (string): The passage the thread is about - `prefix` (string): Up to 200 characters just before the passage, to find it again in a later version - `suffix` (string): Up to 200 characters just after the passage - `pin` (PagePin): The point on a design's board the thread is pinned to - `board` (string, required): The board's data-id, else its data-artboard name [min length 1; max length 200] - `x` (number, required): From the board's left edge, in its pixels [min 0; max 100000] - `y` (number, required): From the board's top edge, in its pixels [min 0; max 100000] - `at` (integer): The part's data-nx-at: its place in the source of the comment's version [min 0; max 2147483647] - `tag` (string): The part's tag, lower case [pattern ^[a-z][a-z0-9:-]{0,40}$] - `layer` (string): The part's data-layer name [min length 1; max length 200] - `path` (string): The part's place under the board, as child indices: finds it again in a later version [pattern ^\d{1,5}(\.\d{1,5}){0,63}$] - `px` (number): The point inside the part, as a fraction of its width; with py [min 0; max 1] - `py` (number): The point inside the part, as a fraction of its height; with px [min 0; max 1] - `version` (integer, required): The version it was made on - `resolvedAt` (string (date-time)): When the thread was resolved; absent while it is open - `chatSessionId` (string): The chat Ask Nexus opened, on the reply it posted - `createdAt` (string (date-time), required) - `session` (ChatSession, required): A chat session, private to its author unless shared as an artifact. - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `instruction` (string, required): Send it as the chat's next message: the comment, with the passage it is about - `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/pages/<id>/comments/<commentId>/ask" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fcomments%2F%7BcommentId%7D%2Fask) ## Ask nexus on page comments `POST /v1/pages/{id}/comments/ask` Ask Nexus to make the changes several threads ask for, in one chat (the page's owner only, else 403 page_owner_only): the threads threadIds names (a reply names its thread), else every open thread, oldest first. Opens a new chat of yours that holds the page's latest version, posts a reply in each thread that names the chat, and answers one instruction with every comment and its passage or pin. 400 page_comment_none_open when there is none, page_comment_ask_limit above 50 threads, page_comment_ask_too_long when the instruction would pass a chat message's 32000 characters; 404 page_comment_not_found for an id not on the page. That turn is an ordinary chat turn, billed to you. Audited as chat.session_created. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `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) - `threadIds` (array of string): The threads to send (a reply's id names its thread); unset: every open thread [at most 50 items] ### Responses - `201` Created (application/json, PageCommentsAsked) - `comments` (array of PageComment, required): The reply in each thread, in the threads' order - `id` (string, required): `pcm_…` - `pageId` (string, required) - `threadId` (string): The thread's first comment; absent on that first comment - `author` (string): The author's name or email. Absent for a reader outside the page's organization, except on their own comments - `mine` (boolean, required): Whether you wrote it - `body` (string, required) - `quote` (string): The passage the thread is about - `prefix` (string): Up to 200 characters just before the passage, to find it again in a later version - `suffix` (string): Up to 200 characters just after the passage - `pin` (PagePin): The point on a design's board the thread is pinned to - `board` (string, required): The board's data-id, else its data-artboard name [min length 1; max length 200] - `x` (number, required): From the board's left edge, in its pixels [min 0; max 100000] - `y` (number, required): From the board's top edge, in its pixels [min 0; max 100000] - `at` (integer): The part's data-nx-at: its place in the source of the comment's version [min 0; max 2147483647] - `tag` (string): The part's tag, lower case [pattern ^[a-z][a-z0-9:-]{0,40}$] - `layer` (string): The part's data-layer name [min length 1; max length 200] - `path` (string): The part's place under the board, as child indices: finds it again in a later version [pattern ^\d{1,5}(\.\d{1,5}){0,63}$] - `px` (number): The point inside the part, as a fraction of its width; with py [min 0; max 1] - `py` (number): The point inside the part, as a fraction of its height; with px [min 0; max 1] - `version` (integer, required): The version it was made on - `resolvedAt` (string (date-time)): When the thread was resolved; absent while it is open - `chatSessionId` (string): The chat Ask Nexus opened, on the reply it posted - `createdAt` (string (date-time), required) - `session` (ChatSession, required): A chat session, private to its author unless shared as an artifact. - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `instruction` (string, required): Send it as the chat's next message: every comment, numbered, with its passage or pin - `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 POST "$NEXUS_URL/v1/pages/<id>/comments/ask" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "threadIds": [ "<threadId>" ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fcomments%2Fask) ## Ask nexus on page board `POST /v1/pages/{id}/boards/ask` Ask Nexus about one board of a design (the page's owner only, else 403 page_owner_only): regenerate it, make 3 variants of it under it (each data-status="proposed" with data-variant-of and a one-line data-note), or keep a variant in place of its original. Opens a new chat of yours that holds the page's latest version and answers the instruction to send there as its first message, so that turn writes the next version and the one before stays in the versions. 400 when ask or board is malformed (read after the page's access check); 404 page_board_not_found when the latest version has no board with that data-id. That turn is an ordinary chat turn, billed to you. Audited as chat.session_created. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `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) - `ask` ("regenerate" | "variants" | "keep", required): Regenerate: write that board again. variants: add 3 proposed variants under it. keep: keep this variant in place of its original - `board` (string, required): The board's data-id (for keep, the variant's) [pattern ^[A-Za-z0-9_.:-]{1,64}$] ### Responses - `201` Created (application/json, PageBoardAsked) - `session` (ChatSession, required): A chat session, private to its author unless shared as an artifact. - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `instruction` (string, required): Send it as the chat's next message: what to do with the board, by its data-id - `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 POST "$NEXUS_URL/v1/pages/<id>/boards/ask" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "ask": "regenerate", "board": "<board>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fboards%2Fask) ## Frame page version `GET /v1/pages/{id}/versions/{version}/frame` Your own preview of a version, or of the page's live state (`live`: its unsaved preview, else its latest version): a signed URL on the sandbox origin, valid five minutes. 503 pages_viewer_unconfigured when this Gateway has no sandbox origin. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `siteVersion` | query | integer | no | Request signed routes for this exact authorized saved Site version. | | `id` | path | string | yes | The page's id (`pag_…`) | | `version` | path | string | yes | A version number, `latest`, or `live` | ### Responses - `200` OK (application/json, PageFrame) - `siteRoutes` (array of SiteFrameRoute): The root and signed additional routes of the authorized saved Site version. - `path` (string, required) - `title` (string, required) - `url` (string, required) - `url` (string (uri), required): The signed URL on the sandbox origin; frame it with sandbox="allow-scripts" only - `expiresAt` (string (date-time), required): When the URL stops opening; mint another to reload - `pageId` (string, required) - `version` (integer, required) - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `title` (string, 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 "$NEXUS_URL/v1/pages/<id>/versions/<version>/frame" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fversions%2F%7Bversion%7D%2Fframe) ## Get page poster `GET /v1/pages/{id}/versions/{version}/poster` A small WebP picture of a page version (640 by 400), for the Artifacts library's cards. Only html, jsx and md pages have one; any other format is 404 poster_unavailable. The page checker renders it on the first request, and Gateway stores it; later requests serve the stored bytes. Without a checker, 503 poster_not_configured; a busy checker is 503 poster_busy; a checker that cannot render the page is 404 poster_unavailable; any other failure is 502 poster_failed. To whoever may open the version: its owner, or a reader of one of its active shares; anyone else gets 404 page_not_found. A person only. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `version` | path | string | yes | A version number, or `latest`: the newest version the caller may open | ### Responses - `200` The poster (image/webp, 640 by 400). Like every credentialed answer, it is cache-control: no-store. (image/webp, string (binary)) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/pages/<id>/versions/<version>/poster" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fversions%2F%7Bversion%7D%2Fposter) ## List page storage `GET /v1/pages/{id}/storage/{scope}` A page's storage: the keys of one scope, in order. To whoever may open the page: its owner, or a reader of one of its active shares; anyone else gets 404 page_not_found. A person only: a public link's reader with no Nexus identity is refused. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `scope` | path | string | yes | `personal`: the caller's own copy, which no other reader sees. `shared`: one copy for everyone who may open the page | | `prefix` | query | string | no | Only the keys that start with it | | `limit` | query | integer | no | At most this many (default 1000) | | `cursor` | query | string | no | `nextCursor` from the previous list | ### Responses - `200` OK (application/json, PageStorageKeys) - `scope` ("personal" | "shared", required) - `prefix` (string, required) - `keys` (array of string, required) - `nextCursor` (string): Pass as `cursor` for the next keys; absent on the last list - `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 "$NEXUS_URL/v1/pages/<id>/storage/<scope>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fstorage%2F%7Bscope%7D) ## Get page storage value `GET /v1/pages/{id}/storage/{scope}/{key}` One value of a page's storage. 404 page_storage_key_not_found when the key has none. To whoever may open the page: its owner, or a reader of one of its active shares; anyone else gets 404 page_not_found. A person only: a public link's reader with no Nexus identity is refused. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `scope` | path | string | yes | `personal`: the caller's own copy, which no other reader sees. `shared`: one copy for everyone who may open the page | | `key` | path | string | yes | 1 to 200 characters, with no whitespace, control character, slash, backslash or quote, and not . or .. (400 page_storage_key_invalid) | ### Responses - `200` OK (application/json, PageStorageValue) - `key` (string, required) - `scope` ("personal" | "shared", required) - `value` (string, 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/pages/<id>/storage/<scope>/<key>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fstorage%2F%7Bscope%7D%2F%7Bkey%7D) ## Set page storage value `PUT /v1/pages/{id}/storage/{scope}/{key}` Write one value of a page's storage, replacing the key's. Text only: 400 page_storage_value_invalid for anything else; 413 page_storage_value_too_large over 5 MiB; 413 page_storage_full when the caller would reach over 20 MiB of keys and values on the page: the shared scope and their own personal one. Other readers' personal values do not count. Not audited. To whoever may open the page: its owner, or a reader of one of its active shares; anyone else gets 404 page_not_found. A person only: a public link's reader with no Nexus identity is refused. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `scope` | path | string | yes | `personal`: the caller's own copy, which no other reader sees. `shared`: one copy for everyone who may open the page | | `key` | path | string | yes | 1 to 200 characters, with no whitespace, control character, slash, backslash or quote, and not . or .. (400 page_storage_key_invalid) | | `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): UTF-8 text of at most 5 MiB, without NUL; store JSON as text [max length 5242880] ### Responses - `200` Written (application/json, PageStorageWritten) - `key` (string, required) - `scope` ("personal" | "shared", required) - `bytes` (integer, required): The key's and the value's size in UTF-8 bytes, as the page's 20 MiB counts them - `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/pages/<id>/storage/<scope>/<key>" \ -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%2Fpages%2F%7Bid%7D%2Fstorage%2F%7Bscope%7D%2F%7Bkey%7D) ## Delete page storage value `DELETE /v1/pages/{id}/storage/{scope}/{key}` Delete one value of a page's storage. A missing key is no error (`deleted: false`). Deleting the page deletes all of its storage. To whoever may open the page: its owner, or a reader of one of its active shares; anyone else gets 404 page_not_found. A person only: a public link's reader with no Nexus identity is refused. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `scope` | path | string | yes | `personal`: the caller's own copy, which no other reader sees. `shared`: one copy for everyone who may open the page | | `key` | path | string | yes | 1 to 200 characters, with no whitespace, control character, slash, backslash or quote, and not . or .. (400 page_storage_key_invalid) | | `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, PageStorageDeleted) - `key` (string, required) - `scope` ("personal" | "shared", required) - `deleted` (boolean, required): Whether there was a value - `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/pages/<id>/storage/<scope>/<key>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fstorage%2F%7Bscope%7D%2F%7Bkey%7D) ## List page files `GET /v1/pages/{id}/files` A page version's data files, by name, without their bytes: read-only copies of the files its source names, attached in the chat that wrote it. To whoever may open the page: its owner, or a reader of one of its active shares; anyone else gets 404 page_not_found. A person only: a public link's reader with no Nexus identity is refused. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `version` | query | string | no | The version whose files to read: one the caller may open. Default: the newest they may open (a pinned share's version). Another is 404 page_not_found. | ### Responses - `200` OK (application/json, PageFiles) - `files` (array of PageFile, required) - `name` (string, required) - `mediaType` ("text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required) - `bytes` (integer, required) - `version` (integer, required): The page version it belongs to - `createdAt` (string (date-time), required) - `data` (string): Standard base64. Only when one file is read (getPageFile) - `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 "$NEXUS_URL/v1/pages/<id>/files" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Ffiles) ## Get page file `GET /v1/pages/{id}/files/{name}` One of a page version's data files with its bytes, for the page's window.fs.readFile. 404 page_file_not_found when it has none by that name. To whoever may open the page: its owner, or a reader of one of its active shares; anyone else gets 404 page_not_found. A person only: a public link's reader with no Nexus identity is refused. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `name` | path | string | yes | The file's name | | `version` | query | string | no | The version whose files to read: one the caller may open. Default: the newest they may open (a pinned share's version). Another is 404 page_not_found. | ### Responses - `200` OK (application/json, PageFile) - `name` (string, required) - `mediaType` ("text/csv" | "text/tab-separated-values" | "application/json" | "text/plain" | "text/markdown" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", required) - `bytes` (integer, required) - `version` (integer, required): The page version it belongs to - `createdAt` (string (date-time), required) - `data` (string): Standard base64. Only when one file is read (getPageFile) - `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 "$NEXUS_URL/v1/pages/<id>/files/Platform" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Ffiles%2F%7Bname%7D) ## List page queries `GET /v1/pages/{id}/queries` A page's queries (Nexus Data), by name. Its owner reads every field, pending ones included. A reader who is not the owner reads only the approved ones' names, parameters and refresh intervals, never a statement or a connection. To whoever may open the page: its owner, or a reader of one of its active shares; anyone else gets 404 page_not_found. 403 page_queries_off while the organization's artifacts.pages.queries is off (the default). A person only. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | ### Responses - `200` OK (application/json, PageQueryList) - `queries` (array of PageQuery, required) - `name` (string, required) - `params` (array of PageQueryParam, required) - `name` (string, required) [pattern ^[A-Za-z][A-Za-z0-9_]{0,62}$] - `type` ("text" | "integer" | "number" | "boolean" | "date", required): `date` is `YYYY-MM-DD` - `default` (any): What a run that names no value binds, of the parameter's type; with none, a run must name one - `refreshSeconds` (integer, required): How long a result is reused before a run reads it again [min 60; max 86400] - `status` ("approved" | "pending"): The owner's only. pending: chat proposed it and the owner has not approved it - `connector` ("postgres" | "snowflake"): The owner's only - `account` (string): The owner's only: the connection's account, as GET /v1/connections lists it - `statement` (string): The owner's only - `statementSha256` (string): The owner's only - `reason` (string): The owner's only: why it was proposed - `proposedBy` (string): The owner's only - `approvedBy` (string): The owner's only - `approvedAt` (string (date-time)): The owner's only - `createdAt` (string (date-time)): The owner's only - `updatedAt` (string (date-time)): The owner's only - `lastReadAt` (string (date-time)): When its most recent result was read: every reader sees it - `lastRowCount` (integer): The owner's only: that result's rows - `lastError` (PageQueryError): The owner's only: why its last refresh failed - `code` (string, required) - `message` (string, required): Fixed per code: never the database's own message - `owner` (boolean, required): Whether the caller owns the page and reads every field - `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/pages/<id>/queries" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fqueries) ## Save page query `PUT /v1/pages/{id}/queries/{name}` Save and approve one of your page's queries (Nexus Data): a new one, or a change to one, a pending one included. One SELECT or WITH statement on a connection of postgres or snowflake that you may use, as a call of yours would pick it (403 connection_required, connector_disabled or not_granted otherwise). 503 page_query_unconfigured when this Gateway does not offer the connector. Parameters are declared with a type and bound as $1, $2… when it runs, never spliced into the text; a Snowflake query declares none. 400 page_query_statement_invalid for anything but one SELECT or WITH of at most 100,000 bytes, page_query_connector_unsupported, page_query_params_invalid, page_query_refresh_invalid, page_query_limit past 20 per page. Only the page's owner: 403 page_query_owner_only for a reader, 404 page_not_found for anyone else; 403 page_queries_off while artifacts.pages.queries is off. Audited as page_query.saved, with the statement's SHA-256, never its text. 201 when new, 200 when changed. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `name` | path | string | yes | The query's name: what the page's code passes to `window.nexus.query` | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `connector` ("postgres" | "snowflake", required) - `account` (string, required): The connection: its account, name or host, as a connector call's `account` names it - `statement` (string, required): One SELECT or WITH statement, with $1-style parameters [max length 100000] - `params` (array of PageQueryParam) [at most 10 items] - `name` (string, required) [pattern ^[A-Za-z][A-Za-z0-9_]{0,62}$] - `type` ("text" | "integer" | "number" | "boolean" | "date", required): `date` is `YYYY-MM-DD` - `default` (any): What a run that names no value binds, of the parameter's type; with none, a run must name one - `refreshSeconds` (integer) [min 60; max 86400; default 300] - `reason` (string) [max length 500] ### Responses - `200` Changed (application/json, PageQuerySaved) - `query` (PageQuery, required): One of a page's queries (Nexus Data). A reader who is not the page's owner gets name, params and refreshSeconds only - `name` (string, required) - `params` (array of PageQueryParam, required) - `name` (string, required) [pattern ^[A-Za-z][A-Za-z0-9_]{0,62}$] - `type` ("text" | "integer" | "number" | "boolean" | "date", required): `date` is `YYYY-MM-DD` - `default` (any): What a run that names no value binds, of the parameter's type; with none, a run must name one - `refreshSeconds` (integer, required): How long a result is reused before a run reads it again [min 60; max 86400] - `status` ("approved" | "pending"): The owner's only. pending: chat proposed it and the owner has not approved it - `connector` ("postgres" | "snowflake"): The owner's only - `account` (string): The owner's only: the connection's account, as GET /v1/connections lists it - `statement` (string): The owner's only - `statementSha256` (string): The owner's only - `reason` (string): The owner's only: why it was proposed - `proposedBy` (string): The owner's only - `approvedBy` (string): The owner's only - `approvedAt` (string (date-time)): The owner's only - `createdAt` (string (date-time)): The owner's only - `updatedAt` (string (date-time)): The owner's only - `lastReadAt` (string (date-time)): When its most recent result was read: every reader sees it - `lastRowCount` (integer): The owner's only: that result's rows - `lastError` (PageQueryError): The owner's only: why its last refresh failed - `code` (string, required) - `message` (string, required): Fixed per code: never the database's own message - `created` (boolean, required) - `201` Created (application/json, PageQuerySaved) - `query` (PageQuery, required): One of a page's queries (Nexus Data). A reader who is not the page's owner gets name, params and refreshSeconds only - `name` (string, required) - `params` (array of PageQueryParam, required) - `name` (string, required) [pattern ^[A-Za-z][A-Za-z0-9_]{0,62}$] - `type` ("text" | "integer" | "number" | "boolean" | "date", required): `date` is `YYYY-MM-DD` - `default` (any): What a run that names no value binds, of the parameter's type; with none, a run must name one - `refreshSeconds` (integer, required): How long a result is reused before a run reads it again [min 60; max 86400] - `status` ("approved" | "pending"): The owner's only. pending: chat proposed it and the owner has not approved it - `connector` ("postgres" | "snowflake"): The owner's only - `account` (string): The owner's only: the connection's account, as GET /v1/connections lists it - `statement` (string): The owner's only - `statementSha256` (string): The owner's only - `reason` (string): The owner's only: why it was proposed - `proposedBy` (string): The owner's only - `approvedBy` (string): The owner's only - `approvedAt` (string (date-time)): The owner's only - `createdAt` (string (date-time)): The owner's only - `updatedAt` (string (date-time)): The owner's only - `lastReadAt` (string (date-time)): When its most recent result was read: every reader sees it - `lastRowCount` (integer): The owner's only: that result's rows - `lastError` (PageQueryError): The owner's only: why its last refresh failed - `code` (string, required) - `message` (string, required): Fixed per code: never the database's own message - `created` (boolean, 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/pages/<id>/queries/Platform" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "connector": "postgres", "account": "<account>", "statement": "<statement>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fqueries%2F%7Bname%7D) ## Delete page query `DELETE /v1/pages/{id}/queries/{name}` Remove one of your page's queries, approved or pending. The page's code gets 404 page_query_not_found for it from then on. Only the page's owner: 403 page_query_owner_only for a reader, 404 page_not_found for anyone else; 403 page_queries_off while artifacts.pages.queries is off. Audited as page_query.deleted. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `name` | path | string | yes | The query's name: what the page's code passes to `window.nexus.query` | | `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, PageQueryDeleted) - `name` (string, required) - `deleted` (true, 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/pages/<id>/queries/Platform" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fqueries%2F%7Bname%7D) ## Run page query `POST /v1/pages/{id}/queries/{name}/run` A page query's result (Nexus Data): the snapshot every reader of the page shares for these parameter values. A run inside the query's refresh interval answers it; past it, Gateway reads it again as the query's approver, one refresh at a time, and announces the new result on the page's events (`query`). The body names parameter values, and `refresh` for the owner's Refresh now: 400 page_query_run_invalid for any other field, page_query_params_invalid for an undeclared name, a missing value or a value of another type. 409 page_query_pending until the owner approves it, 404 page_query_not_found once removed. When the approver left the organization or their access to the connection ended, every snapshot of the query is deleted and the run is refused with the connector call's code (connection_required, connector_disabled, not_granted) or 409 page_query_approver_gone. 503 page_query_unconfigured when this Gateway does not offer the connector. A refresh that fails answers the last rows with `error`, or 502 page_query_failed with none; its message never quotes the database. 429 past 240 runs a minute per person or 2,400 per page. To whoever may open the page: its owner, or a reader of one of its active shares; anyone else gets 404 page_not_found. 403 page_queries_off while artifacts.pages.queries is off. A person only. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `name` | path | string | yes | The query's name: what the page's code passes to `window.nexus.query` | ### Request body (application/json) - `params` (object): The query's parameter values by name; a missing one takes its default - `refresh` (boolean): Read it again now, whatever its interval: the page's owner only (403 page_query_owner_only for a reader) ### Responses - `200` OK (application/json, PageQueryResult) - `name` (string, required) - `paramsKey` (string, required): The SHA-256 of the bound values: which parameter set this is - `columns` (array of PageQueryColumn, required) - `name` (string, required) - `type` (string, required): The database's type name - `rows` (array of array of any, required): Each row as an array, in the columns' order. Columns named like secrets come back as "[hidden]" - `truncated` (boolean, required) - `readAt` (string (date-time), required) - `refreshSeconds` (integer, required) - `error` (PageQueryError): Set when the last refresh failed: these rows are older than the interval - `code` (string, required) - `message` (string, required): Fixed per code: never the database's own message - `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/pages/<id>/queries/Platform/run" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "params": {}, "refresh": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fqueries%2F%7Bname%7D%2Frun) ## Export page `GET /v1/pages/{id}/export` A page version as a file: PNG (one board, at 1x or 2x), SVG (one board, as shapes and text: its box shadows and filters are dropped, and it names its fonts without embedding them), PDF (one page per board, at its size), PPTX (one slide per board), standalone HTML (the page with the canvas, its scripts and fonts inlined) or zip (the PNGs, the HTML and the source). A Nexus Design page's boards are its top-level data-artboard elements. A Nexus Slides deck's boards are its top-level section[data-slide] elements, each at its own size, and its PPTX carries each slide's data-notes as speaker notes by default. Hidden slides are excluded. Any other html or jsx page is one board. Markdown exports as a printable PDF. It renders in the page checker's Chrome; without one, 503 export_not_configured. A board that did not render is named in x-nexus-export-failed (percent-encoded JSON, [{ board, error }]) and the others still export. To whoever may open the version: its owner, or a reader of one of its active shares; anyone else gets 404 page_not_found. A person only. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `format` | query | "png" \| "svg" \| "pdf" \| "pptx" \| "html" \| "zip" | yes | The file's format | | `board` | query | string | no | One board or slide, by its data-id, its name or its number from 1. Required for a PNG or SVG of a design or a deck with several (400 board_required); one that matches none is 404 board_not_found. | | `scale` | query | "1" \| "2" | no | The pixel ratio the boards render at. Default: 2 for pdf and pptx, 1 otherwise. | | `notes` | query | boolean | no | Include speaker notes in deck exports. Defaults to true in PowerPoint and false in PDF. | | `version` | query | string | no | The version to export: one the caller may open. Default: the newest they may open. | ### Responses - `200` The file, as an attachment; x-nexus-export-failed names the boards that did not render (image/png, string (binary)) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/pages/<id>/export?format=png" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fexport) ## Remix artifact `POST /v1/artifacts/{id}/remix` Remix a shared page (its artifact's id, or a public link's token): copy the version it shows into a new page of your own, in the organization you call with, and open a new chat on the copy, so the chat's next write_page writes its version 2. The original page and its shares do not change. Needs your organization's pages on (403 pages_off). A page shared in one of your organizations is remixed there (403 stays_in_organization). From outside the sharer's organization, its artifacts.external.continue must be on (403 external_remix_off). A shared chat id returns 404 artifact_not_found. A shared chat's public token returns 400 not_a_page. Audited as page.created (via remix) and chat.session_created. Permission: `artifacts.read` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The artifact's id (`art_…`), or a public link's 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 - `201` Created (application/json, PageRemixed) - `page` (PageSummary, required) - `id` (string, required): `pag_…` - `title` (string, required): The latest version's title - `format` ("html" | "md" | "jsx" | "sheet" | "board", required) - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written - `version` (PageVersion, required) - `pageId` (string, required) - `version` (integer, required) - `title` (string, required) - `contentSha256` (string, required): The content's SHA-256, lowercase hex - `bytes` (integer, required): The content's size in bytes (UTF-8) - `createdVia` ("chat_tool" | "api" | "cli" | "restore" | "remix", required) - `restoredFrom` (integer): A restore's source version - `remixedFrom` (PageRemixedFrom): A remix's source: the share it was read through and the page version it copies. - `artifactId` (string, required) - `pageId` (string, required) - `version` (integer, required) - `createdAt` (string (date-time), required) - `session` (ChatSession, required): A chat session, private to its author unless shared as an artifact. - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/artifacts/<id>/remix" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fartifacts%2F%7Bid%7D%2Fremix) ## Get page frame content `GET /v1/page-frames/{pageId}/{version}` The bytes a signed frame URL names (a version, or `live`: the page's preview, else its latest version), for the sandbox host (which checks the same signature and serves them with the page's CSP). No credential but the signature: 403 page_frame_invalid when it is wrong or expired. Plain text here: Gateway's origin never runs a page. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `sitePath` | query | string | no | The canonical path covered by a saved Site route signature. | | `pageId` | path | string | yes | The page's id (`pag_…`) | | `version` | path | string | yes | The version number, or `live` | | `exp` | query | integer | yes | When the URL stops opening (unix seconds) | | `sig` | query | string | yes | HMAC-SHA256 of the page, version and exp, hex | ### Responses - `200` The source, `text/plain`; `x-nexus-page-format` (html, md, jsx or sheet) and `x-nexus-page-version` name it; `x-nexus-design-system` names the design system it links, when it links one (text/plain, string) ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 404 | `not_found` | Nothing matches the path in your organization | ### Example ```sh curl "$NEXUS_URL/v1/page-frames/<pageId>/<version>?exp=1&sig=%3Csig%3E" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpage-frames%2F%7BpageId%7D%2F%7Bversion%7D) ## Check page `POST /v1/pages/{id}/check` Check a design: load a version of an html or jsx page you may open in the page checker, with the CSS of the design system it links (else the organization's default), and list the colours, font sizes and spacing that are not on its tokens, and text below WCAG AA contrast. It never changes the page. Each finding names its board, its layer and a selector, and its box from the board's corner. 400 page_check_unsupported for Markdown, 503 page_check_not_configured without a page checker, 502 page_check_failed when it does not answer. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The page's id (`pag_…`) | | `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) - `version` (integer): The version to check (default: the latest) [min 1] ### Responses - `200` What Check found (application/json, PageCheck) - `pageId` (string, required) - `version` (integer, required) - `designSystem` (DesignSystem, required): A design system for Nexus Design, as the organization lists it. - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand` - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`) - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted - `isDefault` (boolean, required): The organization's default: new designs use it - `source` (string, required): Where it came from, in words - `variableCount` (integer, required) - `componentCount` (integer, required) - `updatedAt` (string (date-time)): Unset for the built-in - `linked` (boolean, required): Whether the page links it; else it is the organization's default - `findings` (array of PageCheckFinding, required) [at most 200 items] - `kind` ("color" | "font-size" | "spacing" | "contrast" | "overflow" | "clipped-text" | "outside-board" | "misaligned-rows", required) - `board` (string): The board's `data-artboard` name - `boardId` (string): The board's `data-id` - `layer` (string): The nearest `data-layer` name - `selector` (string, required): A CSS selector for the element, from its board - `box` (PageCheckBox, required): CSS pixels from the board's top-left corner (the page's, outside a board). - `x` (number, required) - `y` (number, required) - `w` (number, required) - `h` (number, required) - `property` (string, required) - `value` (string, required): The computed value - `expected` (string): The nearest token, or the contrast needed - `ratio` (number): A contrast finding's ratio - `message` (string, required) - `counts` (PageCheckCounts, required): Findings by kind, before the list is cut. - `color` (integer, required) - `fontSize` (integer, required) - `spacing` (integer, required) - `contrast` (integer, required) - `overflow` (integer) - `clippedText` (integer) - `outsideBoard` (integer) - `misalignedRows` (integer) - `truncated` (boolean, required) - `elements` (integer, required): How many elements were checked ### 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 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/pages/<id>/check" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "version": 1 }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fpages%2F%7Bid%7D%2Fcheck) ## Get page frame design system `GET /v1/page-frames/{pageId}/{version}/design-system` The CSS custom properties of the design system a framed page links, for the sandbox host to inject before the page's own styles, under the same signature as the page's bytes. The page's frame answer names the link in `x-nexus-design-system`. 204 when the page links none, or one its organization does not have. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `sitePath` | query | string | no | The canonical path covered by a saved Site route signature. | | `pageId` | path | string | yes | The page's id (`pag_…`) | | `version` | path | string | yes | The version number, or `live` | | `exp` | query | integer | yes | When the URL stops opening (unix seconds) | | `sig` | query | string | yes | HMAC-SHA256 of the page, version and exp, hex | ### Responses - `200` `text/css`: only `selector { --name: value; }` blocks (text/css, string) - `204` The page links no design system ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 404 | `not_found` | Nothing matches the path in your organization | ### Example ```sh curl "$NEXUS_URL/v1/page-frames/<pageId>/<version>/design-system?exp=1&sig=%3Csig%3E" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpage-frames%2F%7BpageId%7D%2F%7Bversion%7D%2Fdesign-system) --- <!-- /docs/api/skills --> # Skills > Skills: a person's own SKILL.md files (the open format), in versions that never change. A skill belongs to the person, whichever organization they are signed in to; someone else's skill is a 404. Every write makes the next version; a write built on an old version is refused (409 `skill_version_conflict`). A file is at most 1 MiB. A person keeps at most 200 skills (409 `skill_limit`) and a skill at most 500 versions (400 `skill_version_limit`). The file starts with YAML front matter that has a `name` (1 to 64 characters of `a-z`, `0-9` and single hyphens) and a `description` (1 to 1024 characters). A file that does not is refused with a code that says why: `invalid_frontmatter`, `missing_name`, `invalid_name`, `missing_description`, `invalid_description` or `skill_too_large` (413). Export returns the file byte for byte. Load records (`/v1/skill-loads`) say which skill and version a session loaded in web chat or was delivered by a launcher; a record holds no skill text and stays when the skill is deleted. Promotions (`/v1/skill-promotions`): a person asks to share one version of their skill with the organization or a team, and an approver who is not that person approves or refuses it. The request is a copy; the skill stays the person's own. ## List skills `GET /v1/skills` Your skills, most recently written first. A person keeps at most 200. Permission: `chat.use` (Every member). ### Responses - `200` OK (application/json, SkillList) - `skills` (array of SkillSummary, required) - `id` (string, required): `skl_…` - `name` (string, required): The latest version's name [max length 64; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `description` (string, required): The latest version's description [min length 1; max length 1024] - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written. For a library skill: when its latest approved version was approved - `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/skills" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fskills) ## Create skill `POST /v1/skills` Create a skill from a SKILL.md: version 1. Refused with 409 `duplicate_name` when you already have a skill of that name; `error.nexus.skillId` names it. Audited as skill.created. Permission: `chat.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) - `content` (string, required): The SKILL.md: YAML front matter between `---` lines with a `name` and a `description`, then the instructions. At most 1 MiB of UTF-8. Stored exactly as written. ### Responses - `201` Created (application/json, SkillWritten) - `skill` (SkillSummary, required) - `id` (string, required): `skl_…` - `name` (string, required): The latest version's name [max length 64; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `description` (string, required): The latest version's description [min length 1; max length 1024] - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written. For a library skill: when its latest approved version was approved - `version` (SkillVersion, required) - `skillId` (string, required) - `version` (integer, required) - `name` (string, required): This version's name - `description` (string, required): This version's description - `contentSha256` (string, required): The SKILL.md's SHA-256, lowercase hex - `bytes` (integer, required): The SKILL.md's size in bytes (UTF-8) - `createdVia` ("web" | "cli" | "api", required): How the version was written. For a library version: how its author wrote the version that was approved - `createdAt` (string (date-time), required): When the version was written. For a library version: when it was approved - `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 | `duplicate_name` | Refused with 409 `duplicate_name` when you already have a skill of that name; `error.nexus.skillId` names it | | 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/skills" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "content": "<content>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fskills) ## Get skill `GET /v1/skills/{id}` One of your skills and its versions, newest first. Or a library skill you may load (`listSkillLibrary`), where only the versions an approver approved and did not withdraw exist. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The skill's id (`skl_…`) | ### Responses - `200` OK (application/json, SkillDetail) - `id` (string, required): `skl_…` - `name` (string, required): The latest version's name [max length 64; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `description` (string, required): The latest version's description [min length 1; max length 1024] - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written. For a library skill: when its latest approved version was approved - `versions` (array of SkillVersion, required): Newest first - `skillId` (string, required) - `version` (integer, required) - `name` (string, required): This version's name - `description` (string, required): This version's description - `contentSha256` (string, required): The SKILL.md's SHA-256, lowercase hex - `bytes` (integer, required): The SKILL.md's size in bytes (UTF-8) - `createdVia` ("web" | "cli" | "api", required): How the version was written. For a library version: how its author wrote the version that was approved - `createdAt` (string (date-time), required): When the version was written. For a library version: when it was approved - `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/skills/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fskills%2F%7Bid%7D) ## Delete skill `DELETE /v1/skills/{id}` Delete one of your skills, every version and its content, for good. Audited as skill.deleted. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The skill's id (`skl_…`) | | `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` Deleted (application/json, SkillDeleted) - `deleted` (boolean, required) - `id` (string, required) - `versions` (integer, required): How many versions went with it - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (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/skills/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fskills%2F%7Bid%7D) ## Write skill version `POST /v1/skills/{id}/versions` Write the next version of one of your skills. With `baseVersion`, refused with 409 `skill_version_conflict` when that is no longer the latest. A new `name` in the front matter renames the skill (409 `duplicate_name` when you have another of that name). Audited as skill.version_written. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The skill's id (`skl_…`) | | `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) - `content` (string, required): The SKILL.md: YAML front matter between `---` lines with a `name` and a `description`, then the instructions. At most 1 MiB of UTF-8. Stored exactly as written. - `baseVersion` (integer): The version this was built on: refused with 409 `skill_version_conflict` when it is no longer the latest [min 1] ### Responses - `201` Written (application/json, SkillWritten) - `skill` (SkillSummary, required) - `id` (string, required): `skl_…` - `name` (string, required): The latest version's name [max length 64; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `description` (string, required): The latest version's description [min length 1; max length 1024] - `latestVersion` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required): When the latest version was written. For a library skill: when its latest approved version was approved - `version` (SkillVersion, required) - `skillId` (string, required) - `version` (integer, required) - `name` (string, required): This version's name - `description` (string, required): This version's description - `contentSha256` (string, required): The SKILL.md's SHA-256, lowercase hex - `bytes` (integer, required): The SKILL.md's size in bytes (UTF-8) - `createdVia` ("web" | "cli" | "api", required): How the version was written. For a library version: how its author wrote the version that was approved - `createdAt` (string (date-time), required): When the version was written. For a library version: when it was approved - `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 | `skill_version_conflict` | With `baseVersion`, refused with 409 `skill_version_conflict` when that is no longer the latest | | 409 | `duplicate_name` | A new `name` in the front matter renames the skill (409 `duplicate_name` when you have another of that name) | | 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/skills/<id>/versions" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "content": "<content>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fskills%2F%7Bid%7D%2Fversions) ## Get skill version `GET /v1/skills/{id}/versions/{version}` One version of one of your skills, with its SKILL.md. Or a library skill you may load (`listSkillLibrary`), where only the versions an approver approved and did not withdraw exist; `latest` is the newest approved one. A held, refused or withdrawn version is 404 `skill_version_not_found`, and a library skill you may not load is 404 `skill_not_found`. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The skill's id (`skl_…`) | | `version` | path | string | yes | A version number, or `latest` | ### Responses - `200` OK (application/json, SkillVersionDetail) - `skillId` (string, required) - `version` (integer, required) - `name` (string, required): This version's name - `description` (string, required): This version's description - `contentSha256` (string, required): The SKILL.md's SHA-256, lowercase hex - `bytes` (integer, required): The SKILL.md's size in bytes (UTF-8) - `createdVia` ("web" | "cli" | "api", required): How the version was written. For a library version: how its author wrote the version that was approved - `createdAt` (string (date-time), required): When the version was written. For a library version: when it was approved - `content` (string, required): The SKILL.md, exactly as it was written - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | `skill_version_not_found` | A held, refused or withdrawn version is 404 `skill_version_not_found`, and a library skill you may not load is 404 `skill_not_found` | | 404 | `skill_not_found` | A held, refused or withdrawn version is 404 `skill_version_not_found`, and a library skill you may not load is 404 `skill_not_found` | | 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/skills/<id>/versions/<version>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fskills%2F%7Bid%7D%2Fversions%2F%7Bversion%7D) ## Export skill `GET /v1/skills/{id}/versions/{version}/export` A version's SKILL.md exactly as it was written, byte for byte, as `text/markdown` (never rendered on the API's origin). The `ETag` is its SHA-256. A library skill you may load (`listSkillLibrary`) exports at an approved version, and `latest` is the newest approved one. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The skill's id (`skl_…`) | | `version` | path | string | yes | A version number, or `latest` | ### Responses - `200` The SKILL.md, `text/markdown`; the `x-nexus-skill-version` header names the version (text/markdown, string) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 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/skills/<id>/versions/<version>/export" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fskills%2F%7Bid%7D%2Fversions%2F%7Bversion%7D%2Fexport) ## Request skill promotion `POST /v1/skills/{id}/versions/{version}/promotions` Ask to promote one version of one of your skills to the organization or to a team you are in. A copy of the version is held until an approver who is not you approves or refuses it. Your skill stays yours. A repeat with the same `Idempotency-Key` within 24 hours gets the first answer and writes no second event. Audited as skill.promotion_requested, and the approvers are told. Permission: `skills.promote` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The skill's id (`skl_…`) | | `version` | path | string | yes | A version number, or `latest` | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `scope` ("org" | "team", required): The organization's library, or a team's (and the teams under it) - `team` (string): The target team, a slug or an id. With `scope` `team` only; you must be in it - `note` (string): Why, for the approvers [max length 500] ### Responses - `201` Held (application/json, SkillPromotion) - `id` (string, required): `spr_…` - `state` ("held" | "approved" | "refused" | "withdrawn", required) - `scope` ("org" | "team", required) - `teamId` (string): The target team's id, for scope `team` - `name` (string, required): The snapshot's name: what the version said when it was requested - `description` (string, required): The snapshot's description - `contentSha256` (string, required): The snapshot's SHA-256, lowercase hex - `bytes` (integer, required): The snapshot's size in bytes (UTF-8) - `sourceSkillId` (string, required): The author's skill (`skl_…`) the snapshot was taken from - `sourceVersion` (integer, required) [min 1] - `sourceWrittenVia` ("web" | "cli" | "api", required): How that version was written - `sourceWrittenAt` (string (date-time), required) - `requestedBy` (string, required): The requester's user id - `requestedVia` ("web" | "cli" | "api", required) - `requestedAt` (string (date-time), required) - `note` (string) [max length 500] - `decidedBy` (string): The approver's user id, once it is approved or refused - `decidedAt` (string (date-time)) - `decisionReason` (string) [max length 500] - `selfApproved` (boolean, required): Whether the approver was the requester. Always false: nobody approves their own request - `reviewed` (SkillPromotionReviewed): What the approver's client says they opened before they decided. Reported, not proved. - `content` (boolean): Opened the SKILL.md - `diff` (boolean): Opened the diff from the last approved version - `librarySkillId` (string): Once approved: the library skill (`skl_…`) this is a version of - `libraryVersion` (integer): Once approved: the library version [min 1] - `withdrawnBy` (string) - `withdrawnAt` (string (date-time)) - `withdrawnReason` (string) [max length 500] - `400` `invalid_promotion`: a field is missing, unknown or out of bounds, `team` goes with `scope` `team` only, or the note is over 500 characters (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` `not_in_team`: a team-scope request from someone who is not in the team; the matrix refuses a module key (`module_key`), a service account or an agent link (`role_required`) and an operator (`operator_scope`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` `skill_not_found`, `skill_version_not_found` or `unknown_team`: no such skill of yours, version, or team (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` `personal_org`: a personal organization has no one to approve; `promotion_exists`: this version already has a held or approved promotion to this target (`details` names it and its state); `promotion_limit`: you hold 20 undecided requests, or the organization 200 (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `invalid_promotion`: a field is missing, unknown or out of bounds, `team` goes with `scope` `team` only, or the note is over 500 characters | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | `skill_not_found`, `skill_version_not_found` or `unknown_team`: no such skill of yours, version, or team | | 409 | | `personal_org`: a personal organization has no one to approve; `promotion_exists`: this version already has a held or approved promotion to this target (`details` names it and its state); `promotion_limit`: you hold 20 undecided requests, or the organization 200 | | 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/skills/<id>/versions/<version>/promotions" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "scope": "org" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fskills%2F%7Bid%7D%2Fversions%2F%7Bversion%7D%2Fpromotions) ## List skill loads `GET /v1/skill-loads` The load records of one of your sessions, in the order they were written: which skill and version it loaded in web chat, or was delivered by a launcher. A session that is not yours, and a session with none, answer an empty list. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `sessionId` | query | string | yes | The chat session (`chs_…`) or the agent session | | `limit` | query | integer | no | The most records to answer | ### Responses - `200` OK (application/json, SkillLoadList) - `loads` (array of SkillLoad, required) - `id` (string, required): `sld_…` - `skillId` (string, required) - `skillName` (string, required): The name of the version that was served - `version` (integer, required) - `contentSha256` (string, required): The SHA-256 of the SKILL.md that was served, lowercase hex. With the skill and the version it names the bytes. - `surface` ("web_chat" | "nexus_claude" | "nexus_codex", required) - `kind` ("loaded" | "delivered", required): `loaded` in web chat, `delivered` by a launcher. Never that the skill ran. - `sessionId` (string, required) - `createdAt` (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 | | 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/skill-loads?sessionId=%3CsessionId%3E" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fskill-loads) ## Record skill loads `POST /v1/skill-loads` Record that a coding agent's session was delivered some of your skills, for a launcher (`nexus claude`, `nexus codex`). Each skill must be yours, or a library skill you may load (`listSkillLibrary`), and each version must exist and, for a library skill, be approved and not withdrawn (404 `skill_not_found`, `skill_version_not_found`); the record takes the version's name and SHA-256 from what Gateway stores, not from the request, and for a library skill also its scope (`team` or `org`) and the approved promotion that allowed it. The session must be one you opened, of the agent the surface names (404 `session_not_found`). All the records are written, or none (400 `invalid_load` for a request that is not well formed). It says what was delivered, never that the skill ran. Permission: `chat.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) - `surface` ("nexus_claude" | "nexus_codex", required): The launcher: web chat's loads are written by Gateway itself - `sessionId` (string, required): The agent session the launcher opened [min length 1; max length 128] - `skills` (array of object, required): The skills delivered, each once: your own and the library skills you may load. A larger delivery goes in several calls, each all or none [at most 900 items] - `skillId` (string, required): `skl_…` - `version` (integer, required) [min 1] ### Responses - `201` Recorded (application/json, SkillLoadList) - `loads` (array of SkillLoad, required) - `id` (string, required): `sld_…` - `skillId` (string, required) - `skillName` (string, required): The name of the version that was served - `version` (integer, required) - `contentSha256` (string, required): The SHA-256 of the SKILL.md that was served, lowercase hex. With the skill and the version it names the bytes. - `surface` ("web_chat" | "nexus_claude" | "nexus_codex", required) - `kind` ("loaded" | "delivered", required): `loaded` in web chat, `delivered` by a launcher. Never that the skill ran. - `sessionId` (string, required) - `createdAt` (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 | | 400 | `invalid_load` | All the records are written, or none (400 `invalid_load` for a request that is not well formed) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `skill_not_found` | Each skill must be yours, or a library skill you may load (`listSkillLibrary`), and each version must exist and, for a library skill, be approved and not withdrawn (404 `skill_not_found`, `skill_version_not_found`); the record takes the version's name and SHA-256 from what Gateway stores, not from the request, and for a library skill also its scope (`team` or `org`) and the approved promotion that allowed it | | 404 | `session_not_found` | The session must be one you opened, of the agent the surface names (404 `session_not_found`) | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/skill-loads" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "surface": "nexus_claude", "sessionId": "<sessionId>", "skills": [ { "skillId": "<skillId>", "version": 1 } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fskill-loads) ## List skill library `GET /v1/skill-library` The library skills you may load, at the version a session loads: the highest approved version that nobody withdrew. An organization's library reaches every member, and a team's reaches that team's members and the members of the teams under it. Membership is read at each call, so a person who left a team stops seeing its library at once. The organization's skills come first, then the teams' skills, all by name (not grouped by team). Each skill says whether its name collides with another's (`duplicateName`), so a client that holds your own list too can apply the name rules without the SHA-256 of your skills. It holds no skill text: read a version with `getSkillVersion` or `exportSkill` and the library skill's `id`. A personal organization has no library, and an organization with nothing approved answers an empty list. Permission: `chat.use` (Every member). ### Responses - `200` OK (application/json, SkillLibraryList) - `skills` (array of SkillLibraryEntry, required) - `id` (string, required): The library skill, `skl_…`. `getSkill`, `getSkillVersion` and `exportSkill` take it - `name` (string, required) [max length 64; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `description` (string, required) [min length 1; max length 1024] - `scope` ("org" | "team", required): The organization's library, or a team's (and the teams under it) - `teamId` (string): The team (`team_…`), for scope `team` - `version` (integer, required): The highest approved version that nobody withdrew: the one a session loads [min 1] - `approvedAt` (string (date-time), required): When that version was approved - `duplicateName` (boolean): Another skill of this name keeps it from loading, so neither is delivered or loaded. Left out when false. A skill of yours with this name collides too when any library skill of the name has this flag, and the library copy serves it, with the same bytes, when none has - `403` The matrix refuses a module key (`module_key`), a service account or an agent link (`role_required`) and an operator (`operator_scope`). The domain answers any other caller that is no person with `person_required`; the matrix stops each kind first (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/skill-library" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fskill-library) ## List skill promotions `GET /v1/skill-promotions` The skill promotion requests you reach, newest request first: your own, those to the teams you lead and the teams under them, and for owners and admins every one. It holds no skill text. Permission: `skills.promote` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `state` | query | "held" \| "approved" \| "refused" \| "withdrawn" | no | Only promotions in this state | | `scope` | query | "org" \| "team" | no | Only promotions to the organization or to a team | | `team` | query | string | no | A team slug or id: only promotions to that team | | `mine` | query | boolean | no | `true` for the requests you made, whatever else you reach | | `limit` | query | integer | no | Promotions per page, 1 to 200 (default 50). An empty value is no limit | | `cursor` | query | string | no | `nextCursor` from the previous page. A cursor this API did not return answers 400 `invalid_cursor`. An empty value is no cursor | ### Responses - `200` OK (application/json, SkillPromotionList) - `promotions` (array of SkillPromotion, required) - `id` (string, required): `spr_…` - `state` ("held" | "approved" | "refused" | "withdrawn", required) - `scope` ("org" | "team", required) - `teamId` (string): The target team's id, for scope `team` - `name` (string, required): The snapshot's name: what the version said when it was requested - `description` (string, required): The snapshot's description - `contentSha256` (string, required): The snapshot's SHA-256, lowercase hex - `bytes` (integer, required): The snapshot's size in bytes (UTF-8) - `sourceSkillId` (string, required): The author's skill (`skl_…`) the snapshot was taken from - `sourceVersion` (integer, required) [min 1] - `sourceWrittenVia` ("web" | "cli" | "api", required): How that version was written - `sourceWrittenAt` (string (date-time), required) - `requestedBy` (string, required): The requester's user id - `requestedVia` ("web" | "cli" | "api", required) - `requestedAt` (string (date-time), required) - `note` (string) [max length 500] - `decidedBy` (string): The approver's user id, once it is approved or refused - `decidedAt` (string (date-time)) - `decisionReason` (string) [max length 500] - `selfApproved` (boolean, required): Whether the approver was the requester. Always false: nobody approves their own request - `reviewed` (SkillPromotionReviewed): What the approver's client says they opened before they decided. Reported, not proved. - `content` (boolean): Opened the SKILL.md - `diff` (boolean): Opened the diff from the last approved version - `librarySkillId` (string): Once approved: the library skill (`skl_…`) this is a version of - `libraryVersion` (integer): Once approved: the library version [min 1] - `withdrawnBy` (string) - `withdrawnAt` (string (date-time)) - `withdrawnReason` (string) [max length 500] - `nextCursor` (string): Set while more follow: send it as `cursor` for the next page - `400` `invalid_promotion`: a filter, `limit` or `mine` is not valid, or the query holds a name this list does not read (it reads `state`, `scope`, `team`, `mine`, `limit` and `cursor`); `invalid_cursor`: `cursor` is not one this API returned (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The matrix refuses a module key (`module_key`), a service account or an agent link (`role_required`) and an operator (`operator_scope`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` `unknown_team`: no such team in this organization (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `invalid_promotion`: a filter, `limit` or `mine` is not valid, or the query holds a name this list does not read (it reads `state`, `scope`, `team`, `mine`, `limit` and `cursor`); `invalid_cursor`: `cursor` is not one this API returned | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | `unknown_team`: no such team in this 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/skill-promotions" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fskill-promotions) ## Get skill promotion `GET /v1/skill-promotions/{id}` One promotion request and its snapshot (`content`, the SKILL.md as the version held it), for its requester and the approvers who reach it. `previous` is the last approved version of the same library skill, with its content, for a diff; it is null when there is none or you do not load that library. Someone who only loads the library reads that version and its text; who asked for it and who approved it (`previous.promotion`) go to the approvers of it only. Anyone else, in any state, gets 404 `promotion_not_found`. Permission: `skills.promote` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The promotion's id (`spr_…`) | ### Responses - `200` OK (application/json, SkillPromotionDetail) - `id` (string, required): `spr_…` - `state` ("held" | "approved" | "refused" | "withdrawn", required) - `scope` ("org" | "team", required) - `teamId` (string): The target team's id, for scope `team` - `name` (string, required): The snapshot's name: what the version said when it was requested - `description` (string, required): The snapshot's description - `contentSha256` (string, required): The snapshot's SHA-256, lowercase hex - `bytes` (integer, required): The snapshot's size in bytes (UTF-8) - `sourceSkillId` (string, required): The author's skill (`skl_…`) the snapshot was taken from - `sourceVersion` (integer, required) [min 1] - `sourceWrittenVia` ("web" | "cli" | "api", required): How that version was written - `sourceWrittenAt` (string (date-time), required) - `requestedBy` (string, required): The requester's user id - `requestedVia` ("web" | "cli" | "api", required) - `requestedAt` (string (date-time), required) - `note` (string) [max length 500] - `decidedBy` (string): The approver's user id, once it is approved or refused - `decidedAt` (string (date-time)) - `decisionReason` (string) [max length 500] - `selfApproved` (boolean, required): Whether the approver was the requester. Always false: nobody approves their own request - `reviewed` (SkillPromotionReviewed): What the approver's client says they opened before they decided. Reported, not proved. - `content` (boolean): Opened the SKILL.md - `diff` (boolean): Opened the diff from the last approved version - `librarySkillId` (string): Once approved: the library skill (`skl_…`) this is a version of - `libraryVersion` (integer): Once approved: the library version [min 1] - `withdrawnBy` (string) - `withdrawnAt` (string (date-time)) - `withdrawnReason` (string) [max length 500] - `403` The matrix refuses a module key (`module_key`), a service account or an agent link (`role_required`) and an operator (`operator_scope`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` `promotion_not_found`: no such promotion in your reach (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | `promotion_not_found`: no such promotion in your reach | | 404 | `promotion_not_found` | Anyone else, in any state, gets 404 `promotion_not_found` | | 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/skill-promotions/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fskill-promotions%2F%7Bid%7D) ## Decide skill promotion `POST /v1/skill-promotions/{id}/decision` Approve or refuse a held promotion. An owner or admin decides for the organization; a lead of the team or of a team above it, an owner or an admin decides for a team. Never the requester, and only from a Nexus UI session or a CLI sign-in, not an API key. An approval adds the version to the library of its scope and tells the requester; a refusal needs a `reason`. Audited as skill.promotion_approved or skill.promotion_refused. A repeat with the same `Idempotency-Key` within 24 hours gets the first answer; a repeat without one gets 409 `promotion_decided`. Permission: `skills.approve_team` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The promotion's id (`spr_…`) | | `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) - `decision` ("approved" | "refused", required) - `reason` (string): Required to refuse, so the author knows what to change [max length 500] - `reviewed` (SkillPromotionReviewed): What the approver's client says they opened before they decided. Reported, not proved. - `content` (boolean): Opened the SKILL.md - `diff` (boolean): Opened the diff from the last approved version ### Responses - `200` Decided (application/json, SkillPromotion) - `id` (string, required): `spr_…` - `state` ("held" | "approved" | "refused" | "withdrawn", required) - `scope` ("org" | "team", required) - `teamId` (string): The target team's id, for scope `team` - `name` (string, required): The snapshot's name: what the version said when it was requested - `description` (string, required): The snapshot's description - `contentSha256` (string, required): The snapshot's SHA-256, lowercase hex - `bytes` (integer, required): The snapshot's size in bytes (UTF-8) - `sourceSkillId` (string, required): The author's skill (`skl_…`) the snapshot was taken from - `sourceVersion` (integer, required) [min 1] - `sourceWrittenVia` ("web" | "cli" | "api", required): How that version was written - `sourceWrittenAt` (string (date-time), required) - `requestedBy` (string, required): The requester's user id - `requestedVia` ("web" | "cli" | "api", required) - `requestedAt` (string (date-time), required) - `note` (string) [max length 500] - `decidedBy` (string): The approver's user id, once it is approved or refused - `decidedAt` (string (date-time)) - `decisionReason` (string) [max length 500] - `selfApproved` (boolean, required): Whether the approver was the requester. Always false: nobody approves their own request - `reviewed` (SkillPromotionReviewed): What the approver's client says they opened before they decided. Reported, not proved. - `content` (boolean): Opened the SKILL.md - `diff` (boolean): Opened the diff from the last approved version - `librarySkillId` (string): Once approved: the library skill (`skl_…`) this is a version of - `libraryVersion` (integer): Once approved: the library version [min 1] - `withdrawnBy` (string) - `withdrawnAt` (string (date-time)) - `withdrawnReason` (string) [max length 500] - `400` `invalid_promotion`: a field is missing, unknown or out of bounds, or a refusal has no `reason` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` `role_required`: only an owner, an admin or a team lead decides; `person_session_required`: an API key cannot decide, run `nexus auth login`; `self_approval`: nobody approves their own request; the matrix refuses a module key (`module_key`), a service account or an agent link (`role_required`) and an operator (`operator_scope`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` `promotion_not_found`: no such promotion in your reach (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` `promotion_decided`: the promotion is no longer held (`details` names its state); `requester_left`: the requester is no longer a member; `team_deleted`: the target team no longer exists; `name_taken`: an approval would give people two library skills of one name (`details` names the scope and team); `library_limit`: the library holds its most skills, or the skill its most versions (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `invalid_promotion`: a field is missing, unknown or out of bounds, or a refusal has no `reason` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | `promotion_not_found`: no such promotion in your reach | | 409 | | `promotion_decided`: the promotion is no longer held (`details` names its state); `requester_left`: the requester is no longer a member; `team_deleted`: the target team no longer exists; `name_taken`: an approval would give people two library skills of one name (`details` names the scope and team); `library_limit`: the library holds its most skills, or the skill its most versions | | 409 | `promotion_decided` | A repeat with the same `Idempotency-Key` within 24 hours gets the first answer; a repeat without one gets 409 `promotion_decided` | | 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/skill-promotions/<id>/decision" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "decision": "approved" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fskill-promotions%2F%7Bid%7D%2Fdecision) ## Withdraw skill promotion `POST /v1/skill-promotions/{id}/withdraw` Withdraw a promotion. The requester withdraws their own held request; an approver who reaches it withdraws a held one, or an approved version (from a Nexus UI session or a CLI sign-in). The version leaves its library; text a model already read stays read. With `allVersions`, every approved version of that library skill is withdrawn in one transaction, each with its own event. The answer names the promotion and, in `withdrawnIds`, every promotion withdrawn. Audited as skill.promotion_withdrawn. The requester is told, unless they withdrew it themselves. Permission: `skills.promote` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The promotion's id (`spr_…`) | | `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) - `reason` (string) [max length 500] - `allVersions` (boolean): Withdraw every approved version of the promotion's library skill. Name an approved version [default false] ### Responses - `200` Withdrawn (application/json, SkillPromotionWithdrawn) - `id` (string, required): `spr_…` - `state` ("held" | "approved" | "refused" | "withdrawn", required) - `scope` ("org" | "team", required) - `teamId` (string): The target team's id, for scope `team` - `name` (string, required): The snapshot's name: what the version said when it was requested - `description` (string, required): The snapshot's description - `contentSha256` (string, required): The snapshot's SHA-256, lowercase hex - `bytes` (integer, required): The snapshot's size in bytes (UTF-8) - `sourceSkillId` (string, required): The author's skill (`skl_…`) the snapshot was taken from - `sourceVersion` (integer, required) [min 1] - `sourceWrittenVia` ("web" | "cli" | "api", required): How that version was written - `sourceWrittenAt` (string (date-time), required) - `requestedBy` (string, required): The requester's user id - `requestedVia` ("web" | "cli" | "api", required) - `requestedAt` (string (date-time), required) - `note` (string) [max length 500] - `decidedBy` (string): The approver's user id, once it is approved or refused - `decidedAt` (string (date-time)) - `decisionReason` (string) [max length 500] - `selfApproved` (boolean, required): Whether the approver was the requester. Always false: nobody approves their own request - `reviewed` (SkillPromotionReviewed): What the approver's client says they opened before they decided. Reported, not proved. - `content` (boolean): Opened the SKILL.md - `diff` (boolean): Opened the diff from the last approved version - `librarySkillId` (string): Once approved: the library skill (`skl_…`) this is a version of - `libraryVersion` (integer): Once approved: the library version [min 1] - `withdrawnBy` (string) - `withdrawnAt` (string (date-time)) - `withdrawnReason` (string) [max length 500] - `400` `invalid_promotion`: a field is unknown or out of bounds, or `allVersions` names a held request (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` `person_session_required`: withdrawing an approved version needs a Nexus UI session or a CLI sign-in; `role_required`: the caller asks to withdraw an approved version and is not an approver of it (its requester gets this); the matrix refuses a module key (`module_key`), a service account or an agent link (`role_required`) and an operator (`operator_scope`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` `promotion_not_found`: no such promotion in your reach (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` `promotion_decided`: the promotion was refused or is already withdrawn (`details` names its state) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `invalid_promotion`: a field is unknown or out of bounds, or `allVersions` names a held request | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | `promotion_not_found`: no such promotion in your reach | | 409 | | `promotion_decided`: the promotion was refused or is already withdrawn (`details` names its state) | | 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/skill-promotions/<id>/withdraw" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "reason": "<reason>", "allVersions": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fskill-promotions%2F%7Bid%7D%2Fwithdraw) --- <!-- /docs/api/slack --> # Slack > The Nexus Slack app: an owner or admin binds a Slack workspace to the organization through Slack's OAuth install, and confirms it. A workspace binds to one organization at a time. The bot token is sealed in the vault and never shown. ## Start slack install `POST /v1/slack/installs` Start a Slack install: Slack's authorize URL and the install's id. The URL's `state` names this organization, you, the install and an expiry an hour away, and Gateway accepts it for one completion only. (GitHub's install `state` names only the organization and an expiry, and works again within the hour.) Open the URL in the browser where you are signed in to Nexus UI and approve the app in Slack. Nexus UI then completes the install (`completeSlackInstall`) and you confirm it (`confirmSlackInstall`). People only: an agent link, a service account or a module key answers 403 `person_required`. Writes nothing. Permission: `chat_apps.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `201` Created (application/json, SlackInstallStarted) - `installId` (string, required): `chw_…`: the binding's id once the install completes. - `authorizeUrl` (string (uri), required): Slack's authorize URL, with the install's `state`. - `expiresAt` (string (date-time), required): When the `state` stops working. - `403` No owner or admin (`role_required`), or no person (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The Slack app is not configured on this Gateway: `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET` and `NEXUS_PUBLIC_URL` (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `person_required` | An agent link, a service account or a module key answers 403 `person_required` | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | The Slack app is not configured on this Gateway: `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET` and `NEXUS_PUBLIC_URL` (`not_configured`) | ### Example ```sh curl -X POST "$NEXUS_URL/v1/slack/installs" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fslack%2Finstalls) ## Get slack install `GET /v1/slack/installs/{id}` An install of this organization, once it completed: its binding (`pending`, `active` or `revoked`) and workspace. Before that it is a 404 `install_not_found`, as another organization's install is. Permission: `chat_apps.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The install's id (`chw_…`) | ### Responses - `200` OK (application/json, SlackInstall) - `installId` (string, required) - `status` ("pending" | "active" | "revoked", required) - `workspace` (ChatWorkspace): A chat workspace bound to the organization. Never a token. - `id` (string, required): `chw_…`, also the install's id. - `platform` ("slack", required) - `teamId` (string, required): Slack's workspace id (`T0…`). - `teamName` (string) - `enterpriseId` (string) - `botUserId` (string) - `approvedBySlackUser` (string): The Slack user who approved the app (`authed_user.id`). - `scopes` (array of string, required): The bot scopes Slack granted. - `state` ("pending" | "active" | "revoked", required) - `installedBy` (string, required): The user id of the person who started the install. - `confirmedBy` (string) - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required): When the install's `state` expires: a pending binding confirms only before this, and is undone after it. - `confirmedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `403` No owner or admin (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such install here yet: not completed, or another organization's (`install_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such install here yet: not completed, or another organization's (`install_not_found`) | | 404 | `install_not_found` | Before that it is a 404 `install_not_found`, as another organization's install is | | 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/slack/installs/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fslack%2Finstalls%2F%7Bid%7D) ## Complete slack install `POST /v1/slack/installs/{id}/complete` Finish an install from Slack's redirect, as the signed-in person: Nexus UI's install page sends the `code` and `state` it received. The `state` must verify, name this install, and name your organization and you; otherwise 403 (`invalid_state`, `not_installer`) and Gateway calls Slack for nothing, keeps no token and writes no binding. This is the login-CSRF guard: Slack's redirect lands in the browser of whoever approved the app, so someone else's install link approved by you lands in your session, not theirs. Then Gateway exchanges the code with Slack's `oauth.v2.access`, seals the bot token in the vault and writes the binding as `pending`, with the Slack user who approved (`approvedBySlackUser`). Audited as `chat_workspace.installed`. Confirm it next (`confirmSlackInstall`); a pending install declined or left past its `state`'s expiry is uninstalled from Slack and its token deleted. Permission: `chat_apps.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The install's id (`chw_…`) | | `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) - `code` (string, required): Slack's one-time code; it expires after ten minutes. - `state` (string, required): The `state` of the install's authorize URL, as Slack sent it back. ### Responses - `201` Created: the pending binding (application/json, SlackInstall) - `installId` (string, required) - `status` ("pending" | "active" | "revoked", required) - `workspace` (ChatWorkspace): A chat workspace bound to the organization. Never a token. - `id` (string, required): `chw_…`, also the install's id. - `platform` ("slack", required) - `teamId` (string, required): Slack's workspace id (`T0…`). - `teamName` (string) - `enterpriseId` (string) - `botUserId` (string) - `approvedBySlackUser` (string): The Slack user who approved the app (`authed_user.id`). - `scopes` (array of string, required): The bot scopes Slack granted. - `state` ("pending" | "active" | "revoked", required) - `installedBy` (string, required): The user id of the person who started the install. - `confirmedBy` (string) - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required): When the install's `state` expires: a pending binding confirms only before this, and is undone after it. - `confirmedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `400` No `state` (`missing_state`), no usable code (`invalid_code`), a `state` Nexus did not sign (`invalid_state`), or an org-wide Enterprise Grid install (`enterprise_install_refused`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` No owner or admin (`role_required`), no person (`person_required`), or someone else's install (`not_installer`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The install link expired (`invalid_state`), the install completed already (`state_used`), or the workspace is bound to another organization (`installation_taken`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Slack did not answer or refused the call (`slack_unavailable`, `slack_refused`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The Slack app is not configured on this Gateway: `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET` and `NEXUS_PUBLIC_URL` (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | No `state` (`missing_state`), no usable code (`invalid_code`), a `state` Nexus did not sign (`invalid_state`), or an org-wide Enterprise Grid install (`enterprise_install_refused`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 403 | `invalid_state` | The `state` must verify, name this install, and name your organization and you; otherwise 403 (`invalid_state`, `not_installer`) and Gateway calls Slack for nothing, keeps no token and writes no binding | | 404 | `not_found` | Nothing matches the path in your organization | | 409 | | The install link expired (`invalid_state`), the install completed already (`state_used`), or the workspace is bound to another organization (`installation_taken`) | | 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 | | 502 | | Slack did not answer or refused the call (`slack_unavailable`, `slack_refused`) | | 503 | | The Slack app is not configured on this Gateway: `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET` and `NEXUS_PUBLIC_URL` (`not_configured`) | ### Example ```sh curl -X POST "$NEXUS_URL/v1/slack/installs/<id>/complete" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "code": "<code>", "state": "…" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fslack%2Finstalls%2F%7Bid%7D%2Fcomplete) ## Confirm slack install `POST /v1/slack/installs/{id}/confirm` Confirm a pending install: the workspace is bound to this organization. Only the person who started and completed the install confirms it, before its `state` expires. A confirmed install answers as it is. A workspace bound to another organization is a 409 `installation_taken`, and this install is revoked with its token. An older binding of the same workspace here is replaced, and its bound channels move to this binding with their teams (`chat_channel.moved`). Audited as `chat_workspace.confirmed`. Permission: `chat_apps.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The install's id (`chw_…`) | | `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, SlackInstall) - `installId` (string, required) - `status` ("pending" | "active" | "revoked", required) - `workspace` (ChatWorkspace): A chat workspace bound to the organization. Never a token. - `id` (string, required): `chw_…`, also the install's id. - `platform` ("slack", required) - `teamId` (string, required): Slack's workspace id (`T0…`). - `teamName` (string) - `enterpriseId` (string) - `botUserId` (string) - `approvedBySlackUser` (string): The Slack user who approved the app (`authed_user.id`). - `scopes` (array of string, required): The bot scopes Slack granted. - `state` ("pending" | "active" | "revoked", required) - `installedBy` (string, required): The user id of the person who started the install. - `confirmedBy` (string) - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required): When the install's `state` expires: a pending binding confirms only before this, and is undone after it. - `confirmedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `403` No owner or admin (`role_required`), or another person started the install (`not_installer`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such install in this organization (`install_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The workspace is bound to another organization (`installation_taken`), or this install was revoked (`install_revoked`) (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. - `410` The install's `state` expired before its confirm (`install_expired`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such install in this organization (`install_not_found`) | | 409 | | The workspace is bound to another organization (`installation_taken`), or this install was revoked (`install_revoked`) | | 409 | `installation_taken` | A workspace bound to another organization is a 409 `installation_taken`, and this install is revoked with its token | | 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 | | 410 | | The install's `state` expired before its confirm (`install_expired`) | | 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/slack/installs/<id>/confirm" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fslack%2Finstalls%2F%7Bid%7D%2Fconfirm) ## Slack oauth callback `GET /v1/slack/oauth/callback` Slack's redirect after an admin approves the app (`redirect_uri`). It checks the `state`'s signature and expiry, then answers 303 to Nexus UI's install page (`NEXUS_UI_URL`, which ends in `/app`, + `/settings/slack/installed`) with `code` and `state`. It exchanges nothing and writes nothing: it has no session, so it cannot tell who approved in Slack. Nexus UI finishes the install with `completeSlackInstall`, as the signed-in person. A missing, forged or expired `state` is 403 `invalid_state`; a cancel in Slack is 400 `install_denied`; without `NEXUS_UI_URL` it is 503 `ui_not_configured`, because an install completes only in a signed-in browser. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `code` | query | string | no | Slack's temporary code; it expires after ten minutes. | | `state` | query | string | no | The `state` of `startSlackInstall`'s URL. | | `error` | query | string | no | Slack's reason when the admin cancelled (`access_denied`): a 400 `install_denied`. | ### Responses - `303` To Nexus UI's install page, with `code` and `state` - `400` Cancelled in Slack (`install_denied`), no `state`, as for an install started in Slack (`missing_state`), no code (`invalid_code`), or a `state` Nexus did not sign (`invalid_state`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The install link expired (`invalid_state`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The Slack app is not configured (`not_configured`), or this Gateway has no `NEXUS_UI_URL` (`ui_not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Cancelled in Slack (`install_denied`), no `state`, as for an install started in Slack (`missing_state`), no code (`invalid_code`), or a `state` Nexus did not sign (`invalid_state`) | | 400 | `install_denied` | A missing, forged or expired `state` is 403 `invalid_state`; a cancel in Slack is 400 `install_denied`; without `NEXUS_UI_URL` it is 503 `ui_not_configured`, because an install completes only in a signed-in browser | | 403 | `invalid_state` | A missing, forged or expired `state` is 403 `invalid_state`; a cancel in Slack is 400 `install_denied`; without `NEXUS_UI_URL` it is 503 `ui_not_configured`, because an install completes only in a signed-in browser | | 409 | | The install link expired (`invalid_state`) | | 503 | | The Slack app is not configured (`not_configured`), or this Gateway has no `NEXUS_UI_URL` (`ui_not_configured`) | | 503 | `ui_not_configured` | A missing, forged or expired `state` is 403 `invalid_state`; a cancel in Slack is 400 `install_denied`; without `NEXUS_UI_URL` it is 503 `ui_not_configured`, because an install completes only in a signed-in browser | ### Example ```sh curl "$NEXUS_URL/v1/slack/oauth/callback" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fslack%2Foauth%2Fcallback) ## List slack workspaces `GET /v1/slack/workspaces` The organization's Slack workspace bindings, pending and active, newest first. Never a token. Permission: `chat_apps.manage` (Owner, Admin). ### Responses - `200` OK (application/json, ChatWorkspaceList) - `workspaces` (array of ChatWorkspace, required) - `id` (string, required): `chw_…`, also the install's id. - `platform` ("slack", required) - `teamId` (string, required): Slack's workspace id (`T0…`). - `teamName` (string) - `enterpriseId` (string) - `botUserId` (string) - `approvedBySlackUser` (string): The Slack user who approved the app (`authed_user.id`). - `scopes` (array of string, required): The bot scopes Slack granted. - `state` ("pending" | "active" | "revoked", required) - `installedBy` (string, required): The user id of the person who started the install. - `confirmedBy` (string) - `createdAt` (string (date-time), required) - `expiresAt` (string (date-time), required): When the install's `state` expires: a pending binding confirms only before this, and is undone after it. - `confirmedAt` (string (date-time)) - `revokedAt` (string (date-time)) - `403` No owner or admin (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 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/slack/workspaces" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fslack%2Fworkspaces) ## Disconnect slack workspace `DELETE /v1/slack/workspaces/{id}` Unbind a workspace, or decline a pending install. Gateway first uninstalls the app with Slack's `apps.uninstall`, which revokes every token of that install; if Slack fails, nothing changes (502). (A pending install whose workspace is also active here shares that binding's token, so it is revoked without the uninstall.) Then the binding is revoked, with any pending install of the same workspace here, and the bot token leaves the vault. Audited as `chat_workspace.revoked` (`reason`: `unbound` or `declined`) and `connector_credential.revoked`. Permission: `chat_apps.manage` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The binding's id (`chw_…`) | | `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, ChatWorkspaceRemoved) - `removed` (boolean, required) - `uninstalled` (boolean, required): Whether Gateway uninstalled the app from the workspace (`apps.uninstall`). - `credentialRevoked` (boolean, required): Whether the bot token left the vault. False while another binding here uses it. - `403` No owner or admin (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No live binding with this id in this organization (`workspace_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Slack did not answer or refused the call (`slack_unavailable`, `slack_refused`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The Slack app is not configured on this Gateway: `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET` and `NEXUS_PUBLIC_URL` (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No live binding with this id in this organization (`workspace_not_found`) | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | Slack did not answer or refused the call (`slack_unavailable`, `slack_refused`) | | 503 | | The Slack app is not configured on this Gateway: `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET` and `NEXUS_PUBLIC_URL` (`not_configured`) | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/slack/workspaces/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fslack%2Fworkspaces%2F%7Bid%7D) ## List slack channels `GET /v1/slack/workspaces/{id}/channels` The workspace's channels bound to a team. Owners and admins see every one; a team lead sees those bound to the teams they lead and those under them. `nexus slack channel list` reads it. Permission: `chat_apps.manage_team` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The workspace binding's id (`chw_…`) | ### Responses - `200` OK (application/json, ChatChannelList) - `channels` (array of ChatChannelBinding, required) - `workspaceId` (string, required): The workspace binding (`chw_…`). - `channelId` (string, required) - `teamId` (string, required) - `teamSlug` (string): The team's slug; absent when the team was deleted since. - `createdBy` (string, required): The person who bound it. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `403` Not an owner, an admin or a team lead (`role_required`), or a lead and the channel's team is not one they lead (`outside_led_teams`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No live workspace binding with this id in this organization (`workspace_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The workspace binding waits for its confirm (`workspace_not_active`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No live workspace binding with this id in this organization (`workspace_not_found`) | | 409 | | The workspace binding waits for its confirm (`workspace_not_active`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/slack/workspaces/<id>/channels" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fslack%2Fworkspaces%2F%7Bid%7D%2Fchannels) ## Bind slack channel `POST /v1/slack/workspaces/{id}/channels` Bind a channel of an active workspace binding to a team: in that channel the chat app attributes each call to the team, so its members, policy and caps apply. Owners and admins bind any team; a team lead binds a team they lead or one under it. A channel binds to one team: a channel bound to this team answers 200 as it is, bound to another a 409 `channel_bound` (unbind it first). Audited as `chat_channel.bound`, under the team. Ids only: no channel name is stored. Permission: `chat_apps.manage_team` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The workspace binding's id (`chw_…`) | | `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) - `channelId` (string, required): Slack's channel id (`C…`, or `G…` for an older private channel). - `team` (string, required): The team the channel's calls are attributed to, by slug or id. ### Responses - `200` The channel was bound to this team already (application/json, ChatChannelBinding) - `workspaceId` (string, required): The workspace binding (`chw_…`). - `channelId` (string, required) - `teamId` (string, required) - `teamSlug` (string): The team's slug; absent when the team was deleted since. - `createdBy` (string, required): The person who bound it. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `201` Created (application/json, ChatChannelBinding) - `workspaceId` (string, required): The workspace binding (`chw_…`). - `channelId` (string, required) - `teamId` (string, required) - `teamSlug` (string): The team's slug; absent when the team was deleted since. - `createdBy` (string, required): The person who bound it. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `400` Not a channel id (`invalid_channel`: a direct message never binds), or the body lacks `channelId` or `team` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not an owner, an admin or a team lead (`role_required`), or a lead and the named team, or the team the channel is bound to, is not one they lead (`outside_led_teams`), or no person (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No live workspace binding with this id in this organization (`workspace_not_found`), or no such team (`unknown_team`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The workspace binding waits for its confirm (`workspace_not_active`), or the channel is bound to another team (`channel_bound`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Not a channel id (`invalid_channel`: a direct message never binds), or the body lacks `channelId` or `team` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No live workspace binding with this id in this organization (`workspace_not_found`), or no such team (`unknown_team`) | | 409 | | The workspace binding waits for its confirm (`workspace_not_active`), or the channel is bound to another team (`channel_bound`) | | 409 | `channel_bound` | A channel bound to this team answers 200 as it is, bound to another a 409 `channel_bound` (unbind it first) | | 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/slack/workspaces/<id>/channels" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "channelId": "<channelId>", "team": "platform" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fslack%2Fworkspaces%2F%7Bid%7D%2Fchannels) ## Unbind slack channel `DELETE /v1/slack/workspaces/{id}/channels/{channel}` Unbind a channel from its team: the binding goes, and `chat_channel.unbound` keeps what it was. Owners and admins unbind any channel; a team lead one bound to a team they lead or one under it. Permission: `chat_apps.manage_team` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The workspace binding's id (`chw_…`) | | `channel` | path | string | yes | Slack's channel id (`C…`, or `G…` for an older private channel) | | `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, ChatChannelUnbound) - `workspaceId` (string, required) - `channelId` (string, required) - `teamId` (string, required): The team it was bound to. - `removed` (boolean, required) - `403` Not an owner, an admin or a team lead (`role_required`), or a lead and the channel's team is not one they lead (`outside_led_teams`), or no person (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No live workspace binding with this id in this organization (`workspace_not_found`), or the channel is not bound (`channel_not_bound`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The workspace binding waits for its confirm (`workspace_not_active`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No live workspace binding with this id in this organization (`workspace_not_found`), or the channel is not bound (`channel_not_bound`) | | 409 | | The workspace binding waits for its confirm (`workspace_not_active`) | | 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/slack/workspaces/<id>/channels/<channel>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fslack%2Fworkspaces%2F%7Bid%7D%2Fchannels%2F%7Bchannel%7D) ## Get slack channel settings `GET /v1/slack/workspaces/{id}/channels/{channel}/settings` A bound channel's effective settings, each with the level that set it: the team (set by the channel's binding), the open team caps on that team's path (each cap's limit for owners and admins only; a lead sees what they leave), and the model policy levels that apply with the default chat model. The settings tree is not built, so a channel holds no setting of its own yet, and the organization's budget is not read here. Owners and admins read any channel; a team lead one bound to a team they lead or one under it. Permission: `chat_apps.manage_team` (Owner, Admin, Team lead). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The workspace binding's id (`chw_…`) | | `channel` | path | string | yes | Slack's channel id (`C…`, or `G…` for an older private channel) | ### Responses - `200` OK (application/json, ChatChannelSettings) - `workspaceId` (string, required) - `channelId` (string, required) - `team` (object, required) - `id` (string, required) - `slug` (string, required) - `source` (SettingSource, required): The level that set a value: `channel` (the channel's binding), `team` (a team on the bound team's path, named by `subject`), `organization`, `deployment` (the Gateway's own rule) or `catalog` (the catalog's default). - `level` ("channel" | "team" | "organization" | "deployment" | "agent" | "catalog" | "none", required) - `subject` (string): The team's slug at the `team` level. - `spendScope` ("caps" | "own", required): `caps` for an owner or admin, who sees each cap; `own` for a team lead, who sees only `spendLeft`, as `GET /v1/teams/{slug}/budget` shows a member. - `spendCaps` (array of object, required): The open team caps on the bound team's path, top level first: owners and admins only, as only they read a cap's limit. Empty for a lead, and when none caps it. - `limitUsd` (string, required): The cap in USD, a decimal string. - `period` ("month" | "week" | "day", required) - `mode` ("hard_stop", required) - `source` (SettingSource, required): The level that set a value: `channel` (the channel's binding), `team` (a team on the bound team's path, named by `subject`), `organization`, `deployment` (the Gateway's own rule) or `catalog` (the catalog's default). - `level` ("channel" | "team" | "organization" | "deployment" | "agent" | "catalog" | "none", required) - `subject` (string): The team's slug at the `team` level. - `spendLeft` (object): What the team caps on the bound team's path leave for the channel's calls: the tightest cap's room and period. It names no cap and no level. Absent when none caps it. - `remainingUsd` (string, required): What the tightest cap has left, in USD, a decimal string; never below zero. - `period` ("month" | "week" | "day", required) - `resetsAt` (string, required): When that period starts over. - `modelPolicy` (object, required) - `levels` (array of SettingSource, required): Every level that holds a model rule for the bound team, widest first. Each one narrows the levels above it. - `level` ("channel" | "team" | "organization" | "deployment" | "agent" | "catalog" | "none", required) - `subject` (string): The team's slug at the `team` level. - `defaultChatModel` (string): The default chat model; absent when no level and no catalog entry names one. - `defaultChatModelSource` (SettingSource, required): The level that set a value: `channel` (the channel's binding), `team` (a team on the bound team's path, named by `subject`), `organization`, `deployment` (the Gateway's own rule) or `catalog` (the catalog's default). - `level` ("channel" | "team" | "organization" | "deployment" | "agent" | "catalog" | "none", required) - `subject` (string): The team's slug at the `team` level. - `403` Not an owner, an admin or a team lead (`role_required`), or a lead and the channel's team is not one they lead (`outside_led_teams`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No live workspace binding with this id in this organization (`workspace_not_found`), the channel is not bound (`channel_not_bound`), or its team was deleted (`unknown_team`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The workspace binding waits for its confirm (`workspace_not_active`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No live workspace binding with this id in this organization (`workspace_not_found`), the channel is not bound (`channel_not_bound`), or its team was deleted (`unknown_team`) | | 409 | | The workspace binding waits for its confirm (`workspace_not_active`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/slack/workspaces/<id>/channels/<channel>/settings" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fslack%2Fworkspaces%2F%7Bid%7D%2Fchannels%2F%7Bchannel%7D%2Fsettings) ## Read slack workspace runtime `GET /v1/slack/workspaces/{id}/runtime` The agents service only, with its platform secret in `x-nexus-agents-secret`. The active binding of a Slack workspace, in whichever organization holds it: the binding's ids and state, the organization, the bot token (refreshed first when it rotates) and the enabled channels (empty until channel bindings land). Answered with `Cache-Control: no-store`. Each answer writes `chat_workspace.runtime_read` in the binding's organization, with the secret's slot (`current` or `previous`) and the client address, never the token. Every other route refuses the platform secret with a 403. Permission: `chat_apps.runtime` (). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | Slack's workspace id (`T0…`), not the binding's id. The path keeps the name `id` because `/v1/slack/workspaces/{id}` has it. | ### Responses - `200` OK (application/json, SlackWorkspaceRuntime) - `workspace` (object, required) - `id` (string, required): The binding's id (`chw_…`). - `teamId` (string, required): Slack's workspace id (`T0…`). - `state` ("active", required) - `botUserId` (string) - `tenantId` (string, required): The organization the workspace is bound to. - `botToken` (string, required): The workspace's bot token. Never logged or audited. - `channels` (array of object, required): The bound channels whose team still exists. `teamId` is the Nexus team's id, not Slack's workspace id. - `channelId` (string, required) - `teamId` (string, required) - `400` The platform secret came with another credential, or twice (`credential_conflict`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential, or a wrong platform secret (`missing_credential`, `invalid_credential`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Any other credential: a person's token, an agent link, a service account key, a module key or Nexus UI's secret (`agents_only`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No active binding of this workspace: pending, revoked and unknown ids get the same answer (`workspace_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Slack did not answer or refused the call, or the vault holds no bot token (`slack_unavailable`, `slack_refused`, `slack_token_refresh_failed`, `bot_token_missing`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `NEXUS_AGENTS_SECRET`, or the Slack app's variables, are not set on this Gateway (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | The platform secret came with another credential, or twice (`credential_conflict`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No active binding of this workspace: pending, revoked and unknown ids get the same answer (`workspace_not_found`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | Slack did not answer or refused the call, or the vault holds no bot token (`slack_unavailable`, `slack_refused`, `slack_token_refresh_failed`, `bot_token_missing`) | | 503 | | `NEXUS_AGENTS_SECRET`, or the Slack app's variables, are not set on this Gateway (`not_configured`) | ### Example ```sh curl "$NEXUS_URL/v1/slack/workspaces/<id>/runtime" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fslack%2Fworkspaces%2F%7Bid%7D%2Fruntime) ## Report slack workspace revoked `POST /v1/slack/workspaces/{id}/revoked` The agents service only, with its platform secret (D2 option A): Slack says the app was uninstalled from this workspace. Gateway first asks Slack with `auth.test` on the bot token. Only when Slack answers `invalid_auth`, `token_revoked`, `account_inactive` or `not_authed` does it revoke every live binding of the workspace, in every organization, with its bot token (`chat_workspace.revoked`, `reason: uninstalled`). A token that still works, one Slack calls `token_expired`, or none to ask with, changes nothing and writes `chat_workspace.revoke_refused`. A Slack failure is a 502 and changes nothing. Permission: `chat_apps.runtime` (). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | Slack's workspace id (`T0…`), not the binding's id. The path keeps the name `id` because `/v1/slack/workspaces/{id}` has it. | ### Responses - `200` OK (application/json, SlackRevokeReport) - `revoked` (boolean, required): True when Slack said the token is gone and Gateway revoked the workspace. False when the token still works: nothing changed. - `400` The platform secret came with another credential, or twice (`credential_conflict`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential, or a wrong platform secret (`missing_credential`, `invalid_credential`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Any other credential: a person's token, an agent link, a service account key, a module key or Nexus UI's secret (`agents_only`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No active binding of this workspace: pending, revoked and unknown ids get the same answer (`workspace_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Slack did not answer or refused the call, or the vault holds no bot token (`slack_unavailable`, `slack_refused`, `slack_token_refresh_failed`, `bot_token_missing`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` `NEXUS_AGENTS_SECRET`, or the Slack app's variables, are not set on this Gateway (`not_configured`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | The platform secret came with another credential, or twice (`credential_conflict`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No active binding of this workspace: pending, revoked and unknown ids get the same answer (`workspace_not_found`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | Slack did not answer or refused the call, or the vault holds no bot token (`slack_unavailable`, `slack_refused`, `slack_token_refresh_failed`, `bot_token_missing`) | | 503 | | `NEXUS_AGENTS_SECRET`, or the Slack app's variables, are not set on this Gateway (`not_configured`) | ### Example ```sh curl -X POST "$NEXUS_URL/v1/slack/workspaces/<id>/revoked" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fslack%2Fworkspaces%2F%7Bid%7D%2Frevoked) --- <!-- /docs/api/explorer --> # Explorer > The Explorer's data: every model's LMArena, Vals AI and Hugging Face numbers, the catalog's status and list prices, the boards, each model's rating history and the market series, polled once a day. Public, read-only and cacheable: each answer carries an ETag (a request with `If-None-Match` gets a 304) and `Cache-Control: public, max-age=3600`. Only cleared sources' numbers are served. Without `NEXUS_EXPLORER_DIR`, 503 `not_configured`; before the first poll, 503 `no_data`. ## Explorer meta `GET /v1/explorer/meta` Each source's name, links, licence, `asOf` date, `cleared` switch, `fetchedAt` and last `error`, with the dataset's `updated` day and `polledAt` time. Permission: `public` (Anyone, signed in or not). ### Responses - `200` OK (application/json, object) - `schema` (integer, required) - `updated` (string, required) - `polledAt` (string | null) - `sources` (object, required) - `304` Not modified: the `If-None-Match` ETag is the current dataset's. ### Errors | Status | Code | When | | --- | --- | --- | ### Example ```sh curl "$NEXUS_URL/v1/explorer/meta" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fexplorer%2Fmeta) ## Explorer models `GET /v1/explorer/models` Every model's row without history, in the shape of the Explorer's `snapshot.json`: `updated`, `sources`, `arenaCategories`, `vals`, `models` and `hfTop`. Permission: `public` (Anyone, signed in or not). ### Responses - `200` OK (application/json, object) - `304` Not modified: the `If-None-Match` ETag is the current dataset's. ### Errors | Status | Code | When | | --- | --- | --- | ### Example ```sh curl "$NEXUS_URL/v1/explorer/models" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fexplorer%2Fmodels) ## Explorer model `GET /v1/explorer/models/{slug}` One model's row with its LMArena text rating at each update (`history`: `[date, rating]` pairs). 404 for no such model. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | A model's slug (`claude-opus-5-5`) | ### Responses - `200` OK (application/json, object) - `304` Not modified: the `If-None-Match` ETag is the current dataset's. ### Errors | Status | Code | When | | --- | --- | --- | | 404 | `not_found` | Nothing matches the path in your organization | ### Example ```sh curl "$NEXUS_URL/v1/explorer/models/platform" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fexplorer%2Fmodels%2F%7Bslug%7D) ## Explorer boards `GET /v1/explorer/boards` Every LMArena and Vals AI board with a model on it, each with its top 10 entries in the source's rank order. Permission: `public` (Anyone, signed in or not). ### Responses - `200` OK (application/json, object) - `304` Not modified: the `If-None-Match` ETag is the current dataset's. ### Errors | Status | Code | When | | --- | --- | --- | ### Example ```sh curl "$NEXUS_URL/v1/explorer/boards" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fexplorer%2Fboards) ## Explorer board `GET /v1/explorer/boards/{slug}` One board with every entry. 404 for no such board. Permission: `public` (Anyone, signed in or not). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `slug` | path | string | yes | A board's slug (`lmarena-text`, `swe-bench`) | ### Responses - `200` OK (application/json, object) - `304` Not modified: the `If-None-Match` ETag is the current dataset's. ### Errors | Status | Code | When | | --- | --- | --- | | 404 | `not_found` | Nothing matches the path in your organization | ### Example ```sh curl "$NEXUS_URL/v1/explorer/boards/platform" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fexplorer%2Fboards%2F%7Bslug%7D) ## Explorer market `GET /v1/explorer/market` The Data tab's series: each month's top 20 on LMArena's text board, and the best open-weight and proprietary rating at each update. Permission: `public` (Anyone, signed in or not). ### Responses - `200` OK (application/json, object) - `304` Not modified: the `If-None-Match` ETag is the current dataset's. ### Errors | Status | Code | When | | --- | --- | --- | ### Example ```sh curl "$NEXUS_URL/v1/explorer/market" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fexplorer%2Fmarket) ## Explorer index `GET /v1/explorer/index` `[slug, name, lab, logo]` for every model, for search. Permission: `public` (Anyone, signed in or not). ### Responses - `200` OK (application/json, array of array of string) - `304` Not modified: the `If-None-Match` ETag is the current dataset's. ### Errors | Status | Code | When | | --- | --- | --- | ### Example ```sh curl "$NEXUS_URL/v1/explorer/index" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fexplorer%2Findex) ## Explorer dataset `GET /v1/explorer.json` The open dataset: the whole document, cleared sources only. Permission: `public` (Anyone, signed in or not). ### Responses - `200` OK (application/json, object) - `304` Not modified: the `If-None-Match` ETag is the current dataset's. ### Errors | Status | Code | When | | --- | --- | --- | ### Example ```sh curl "$NEXUS_URL/v1/explorer.json" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fexplorer.json) --- <!-- /docs/api/routines --> # Routines > Routines: work your agent does for you without being asked, such as a morning brief. A routine has an owner, a trigger, an action, proactivity and caps. It runs as its owner only, reads and notifies only, and owns one Runtime schedule whose slots each start one job. It is its owner's, and its organization's owners' and admins' to read, pause and delete; to anyone else it does not exist. ## List routines `GET /v1/routines` Your routines, newest first, at most 200. With `all=true`, the organization's: its owners and admins only. Each carries its schedule's next run. Permission: `routines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `all` | query | "true" \| "false" | no | `true`: every member's routines (owners and admins) | ### Responses - `200` OK (application/json, RoutineList) - `routines` (array of Routine, required) - `id` (string, required): `rtn_` and 32 hex characters - `title` (string, required) - `ownerId` (string, required): The person it runs as. - `teamId` (string): The team its model calls go to; absent when its owner is in none. - `executor` ("gateway", required): `gateway`: each slot is a Runtime job. Desktop routines come with W4 step 2. - `trigger` (RoutineTrigger, required) - `kind` ("schedule" | "watch", required): `schedule` runs on a time; `watch` checks `watch` every `everySeconds`. `event`, `webhook` and `manual` come later. - `everySeconds` (integer): Every N seconds from the routine's creation. Not with `at`. A watch needs it: it checks at most every 10 minutes. [min 600; max 604800] - `watch` (RoutineWatch): What a `watch` trigger checks. The agent reads it as you, and tells you once it is met. - `source` ("github_pull" | "github_issue" | "spend_today", required): `github_pull`: the pull request `target` is merged or closed. `github_issue`: the issue `target` changes state. `spend_today`: your own AI spend today passes `overUsd`. Today is the UTC day, whatever the routine's `timezone`. - `target` (string): A repository and a number, `owner/repo#N`. With `github_pull` and `github_issue` only. [pattern ^[A-Za-z0-9_.-]{1,100}/[A-Za-z0-9_.-]{1,100}#[1-9][0-9]{0,9}$] - `overUsd` (string): An amount above zero in US dollars, as a decimal string with at most six decimals (root rule 9). With `spend_today` only. - `at` (string): A local time, `HH:MM`, 24-hour. Not with `everySeconds`. [pattern ^([01][0-9]|2[0-3]):[0-5][0-9]$] - `days` (array of "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun"): The days `at` runs on, in week order; every day when absent. - `timezone` (string): An IANA name; `UTC` when absent. - `catchUp` ("latest" | "none"): After downtime: `latest` runs the newest missed slot (the default), `none` runs none. - `action` (RoutineAction, required) - `kind` ("brief" | "notify", required): `brief`: what changed in your open pull requests, your assigned issues and the channels you follow, read through your own connectors. `notify`, a watch's action: you are told its condition is met. Both read only. - `proactivity` (RoutineProactivity, required) - `notify` ("always" | "on_change" | "digest"): When a run speaks up; `always` by default. - `writes` ("never"): A routine reads and notifies only. `ask_first` waits for Policy PO1. - `caps` (RoutineCaps, required) - `maxRunsPerDay` (integer): Runs a day, counted in the trigger's time zone. A slot past it is skipped. [min 1; max 144] - `reportTo` ("slack", required) - `state` ("active" | "paused", required) - `pausedReason` ("owner" | "admin") - `scheduleId` (string): Its Runtime schedule (`sch_…`). - `nextRunAt` (string (date-time)): Its schedule's next slot; absent while paused. - `lastRunAt` (string (date-time)): Its schedule's last slot. - `delivery` (RoutineDelivery, required) - `available` (boolean, required): Whether this Gateway can deliver the routine's action now. - `code` (string): Why not: `routine_brief_unavailable` or `routine_watch_unavailable`. - `reason` (string) - `createdVia` ("api" | "cli" | "ui" | "slack" | "desktop" | "agent", required) - `version` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `400` `all` is not `true` or `false`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `products.use` (`role_required`), it is not a person's (`routine_agent_refused`), or a member who is not an owner or admin asked for `all`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Routines are off on this Gateway (`routines_disabled`): they need `NEXUS_ROUTINES` and `NEXUS_SCHEDULER`. The route still mounts. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `all` is not `true` or `false`. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Routines are off on this Gateway (`routines_disabled`): they need `NEXUS_ROUTINES` and `NEXUS_SCHEDULER`. The route still mounts. | ### Example ```sh curl "$NEXUS_URL/v1/routines" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Froutines) ## Create routine `POST /v1/routines` Create a routine for yourself: a `schedule` trigger and the `brief` action. It runs as you and no one else, reads and notifies only (`writes: never`), and reports to your Slack direct messages. Gateway records it and its Runtime schedule (`source: routine:<id>`), whose slots each start one job. The brief is not available yet: `delivery.available` is `false` with `routine_brief_unavailable`, and each slot's job ends without reading or sending anything. A person owns at most 50 routines in an organization. `team` (or `x-nexus-team`) names the team its model calls go to. Permission: `routines.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) - `title` (string): `Morning brief` when absent; `Watch` for a watch. [min length 1; max length 200] - `trigger` (RoutineTrigger, required) - `kind` ("schedule" | "watch", required): `schedule` runs on a time; `watch` checks `watch` every `everySeconds`. `event`, `webhook` and `manual` come later. - `everySeconds` (integer): Every N seconds from the routine's creation. Not with `at`. A watch needs it: it checks at most every 10 minutes. [min 600; max 604800] - `watch` (RoutineWatch): What a `watch` trigger checks. The agent reads it as you, and tells you once it is met. - `source` ("github_pull" | "github_issue" | "spend_today", required): `github_pull`: the pull request `target` is merged or closed. `github_issue`: the issue `target` changes state. `spend_today`: your own AI spend today passes `overUsd`. Today is the UTC day, whatever the routine's `timezone`. - `target` (string): A repository and a number, `owner/repo#N`. With `github_pull` and `github_issue` only. [pattern ^[A-Za-z0-9_.-]{1,100}/[A-Za-z0-9_.-]{1,100}#[1-9][0-9]{0,9}$] - `overUsd` (string): An amount above zero in US dollars, as a decimal string with at most six decimals (root rule 9). With `spend_today` only. - `at` (string): A local time, `HH:MM`, 24-hour. Not with `everySeconds`. [pattern ^([01][0-9]|2[0-3]):[0-5][0-9]$] - `days` (array of "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun"): The days `at` runs on, in week order; every day when absent. - `timezone` (string): An IANA name; `UTC` when absent. - `catchUp` ("latest" | "none"): After downtime: `latest` runs the newest missed slot (the default), `none` runs none. - `action` (RoutineAction, required) - `kind` ("brief" | "notify", required): `brief`: what changed in your open pull requests, your assigned issues and the channels you follow, read through your own connectors. `notify`, a watch's action: you are told its condition is met. Both read only. - `proactivity` (RoutineProactivity) - `notify` ("always" | "on_change" | "digest"): When a run speaks up; `always` by default. - `writes` ("never"): A routine reads and notifies only. `ask_first` waits for Policy PO1. - `caps` (RoutineCaps) - `maxRunsPerDay` (integer): Runs a day, counted in the trigger's time zone. A slot past it is skipped. [min 1; max 144] - `reportTo` ("slack"): Your Slack direct messages; the default. - `team` (string): The team its model calls go to, by slug or id; your default team when absent. ### Responses - `201` Created: the routine and its schedule (application/json, Routine) - `id` (string, required): `rtn_` and 32 hex characters - `title` (string, required) - `ownerId` (string, required): The person it runs as. - `teamId` (string): The team its model calls go to; absent when its owner is in none. - `executor` ("gateway", required): `gateway`: each slot is a Runtime job. Desktop routines come with W4 step 2. - `trigger` (RoutineTrigger, required) - `kind` ("schedule" | "watch", required): `schedule` runs on a time; `watch` checks `watch` every `everySeconds`. `event`, `webhook` and `manual` come later. - `everySeconds` (integer): Every N seconds from the routine's creation. Not with `at`. A watch needs it: it checks at most every 10 minutes. [min 600; max 604800] - `watch` (RoutineWatch): What a `watch` trigger checks. The agent reads it as you, and tells you once it is met. - `source` ("github_pull" | "github_issue" | "spend_today", required): `github_pull`: the pull request `target` is merged or closed. `github_issue`: the issue `target` changes state. `spend_today`: your own AI spend today passes `overUsd`. Today is the UTC day, whatever the routine's `timezone`. - `target` (string): A repository and a number, `owner/repo#N`. With `github_pull` and `github_issue` only. [pattern ^[A-Za-z0-9_.-]{1,100}/[A-Za-z0-9_.-]{1,100}#[1-9][0-9]{0,9}$] - `overUsd` (string): An amount above zero in US dollars, as a decimal string with at most six decimals (root rule 9). With `spend_today` only. - `at` (string): A local time, `HH:MM`, 24-hour. Not with `everySeconds`. [pattern ^([01][0-9]|2[0-3]):[0-5][0-9]$] - `days` (array of "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun"): The days `at` runs on, in week order; every day when absent. - `timezone` (string): An IANA name; `UTC` when absent. - `catchUp` ("latest" | "none"): After downtime: `latest` runs the newest missed slot (the default), `none` runs none. - `action` (RoutineAction, required) - `kind` ("brief" | "notify", required): `brief`: what changed in your open pull requests, your assigned issues and the channels you follow, read through your own connectors. `notify`, a watch's action: you are told its condition is met. Both read only. - `proactivity` (RoutineProactivity, required) - `notify` ("always" | "on_change" | "digest"): When a run speaks up; `always` by default. - `writes` ("never"): A routine reads and notifies only. `ask_first` waits for Policy PO1. - `caps` (RoutineCaps, required) - `maxRunsPerDay` (integer): Runs a day, counted in the trigger's time zone. A slot past it is skipped. [min 1; max 144] - `reportTo` ("slack", required) - `state` ("active" | "paused", required) - `pausedReason` ("owner" | "admin") - `scheduleId` (string): Its Runtime schedule (`sch_…`). - `nextRunAt` (string (date-time)): Its schedule's next slot; absent while paused. - `lastRunAt` (string (date-time)): Its schedule's last slot. - `delivery` (RoutineDelivery, required) - `available` (boolean, required): Whether this Gateway can deliver the routine's action now. - `code` (string): Why not: `routine_brief_unavailable` or `routine_watch_unavailable`. - `reason` (string) - `createdVia` ("api" | "cli" | "ui" | "slack" | "desktop" | "agent", required) - `version` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `400` A body that is not a routine, or a malformed `Idempotency-Key`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `routines.use` (`role_required`), or it is not a person's own key, Nexus UI or an agent link its person granted `routines.use` (`routine_agent_refused`). A module's scoped key, a service account and a sandbox are refused the same way. An agent link's routine writes nothing: any `proactivity.writes` but `never` is `routine_agent_writes_refused`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` You own 50 routines in this organization (`routine_limit`), or the `Idempotency-Key`'s first request still runs. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `422` A routine Gateway does not build yet or cannot run (`invalid_routine`): a trigger other than `schedule`, both or neither of `everySeconds` and `at`, an interval under 600 s, an unknown time zone or day, an action other than `brief`, a `reportTo` other than `slack`. `writes: ask_first` is `routine_writes_unavailable`: it waits for Policy's approval records (PO1). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Routines are off on this Gateway (`routines_disabled`): they need `NEXUS_ROUTINES` and `NEXUS_SCHEDULER`. The route still mounts. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A body that is not a routine, or a malformed `Idempotency-Key`. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | You own 50 routines in this organization (`routine_limit`), or the `Idempotency-Key`'s first request still runs. | | 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 | | A routine Gateway does not build yet or cannot run (`invalid_routine`): a trigger other than `schedule`, both or neither of `everySeconds` and `at`, an interval under 600 s, an unknown time zone or day, an action other than `brief`, a `reportTo` other than `slack`. `writes: ask_first` is `routine_writes_unavailable`: it waits for Policy's approval records (PO1). | | 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 | | 503 | | Routines are off on this Gateway (`routines_disabled`): they need `NEXUS_ROUTINES` and `NEXUS_SCHEDULER`. The route still mounts. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/routines" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "trigger": { "kind": "schedule" }, "action": { "kind": "brief" } }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Froutines) ## Get routine `GET /v1/routines/{id}` A routine, with its schedule's next run and its last slot. Permission: `routines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The routine's id (`rtn_…`), as POST /v1/routines answered it | ### Responses - `200` OK (application/json, Routine) - `id` (string, required): `rtn_` and 32 hex characters - `title` (string, required) - `ownerId` (string, required): The person it runs as. - `teamId` (string): The team its model calls go to; absent when its owner is in none. - `executor` ("gateway", required): `gateway`: each slot is a Runtime job. Desktop routines come with W4 step 2. - `trigger` (RoutineTrigger, required) - `kind` ("schedule" | "watch", required): `schedule` runs on a time; `watch` checks `watch` every `everySeconds`. `event`, `webhook` and `manual` come later. - `everySeconds` (integer): Every N seconds from the routine's creation. Not with `at`. A watch needs it: it checks at most every 10 minutes. [min 600; max 604800] - `watch` (RoutineWatch): What a `watch` trigger checks. The agent reads it as you, and tells you once it is met. - `source` ("github_pull" | "github_issue" | "spend_today", required): `github_pull`: the pull request `target` is merged or closed. `github_issue`: the issue `target` changes state. `spend_today`: your own AI spend today passes `overUsd`. Today is the UTC day, whatever the routine's `timezone`. - `target` (string): A repository and a number, `owner/repo#N`. With `github_pull` and `github_issue` only. [pattern ^[A-Za-z0-9_.-]{1,100}/[A-Za-z0-9_.-]{1,100}#[1-9][0-9]{0,9}$] - `overUsd` (string): An amount above zero in US dollars, as a decimal string with at most six decimals (root rule 9). With `spend_today` only. - `at` (string): A local time, `HH:MM`, 24-hour. Not with `everySeconds`. [pattern ^([01][0-9]|2[0-3]):[0-5][0-9]$] - `days` (array of "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun"): The days `at` runs on, in week order; every day when absent. - `timezone` (string): An IANA name; `UTC` when absent. - `catchUp` ("latest" | "none"): After downtime: `latest` runs the newest missed slot (the default), `none` runs none. - `action` (RoutineAction, required) - `kind` ("brief" | "notify", required): `brief`: what changed in your open pull requests, your assigned issues and the channels you follow, read through your own connectors. `notify`, a watch's action: you are told its condition is met. Both read only. - `proactivity` (RoutineProactivity, required) - `notify` ("always" | "on_change" | "digest"): When a run speaks up; `always` by default. - `writes` ("never"): A routine reads and notifies only. `ask_first` waits for Policy PO1. - `caps` (RoutineCaps, required) - `maxRunsPerDay` (integer): Runs a day, counted in the trigger's time zone. A slot past it is skipped. [min 1; max 144] - `reportTo` ("slack", required) - `state` ("active" | "paused", required) - `pausedReason` ("owner" | "admin") - `scheduleId` (string): Its Runtime schedule (`sch_…`). - `nextRunAt` (string (date-time)): Its schedule's next slot; absent while paused. - `lastRunAt` (string (date-time)): Its schedule's last slot. - `delivery` (RoutineDelivery, required) - `available` (boolean, required): Whether this Gateway can deliver the routine's action now. - `code` (string): Why not: `routine_brief_unavailable` or `routine_watch_unavailable`. - `reason` (string) - `createdVia` ("api" | "cli" | "ui" | "slack" | "desktop" | "agent", required) - `version` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `products.use` (`role_required`), or it is not a person's own key or Nexus UI (`routine_agent_refused`): an agent link creates a routine only after the person's confirm card, which is not built yet. A module's scoped key, a service account and a sandbox are refused the same way. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such routine you may see (`not_found`). A routine is its owner's, and its organization's owners' and admins' to read, pause and delete. Another member's routine, and another organization's, is as absent as a missing one. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Routines are off on this Gateway (`routines_disabled`): they need `NEXUS_ROUTINES` and `NEXUS_SCHEDULER`. The route still mounts. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such routine you may see (`not_found`). A routine is its owner's, and its organization's owners' and admins' to read, pause and delete. Another member's routine, and another organization's, is as absent as a missing one. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Routines are off on this Gateway (`routines_disabled`): they need `NEXUS_ROUTINES` and `NEXUS_SCHEDULER`. The route still mounts. | ### Example ```sh curl "$NEXUS_URL/v1/routines/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Froutines%2F%7Bid%7D) ## Update routine `PATCH /v1/routines/{id}` Pause (`state: paused`) or resume (`state: active`) a routine. A pause stops its schedule first, so no slot after it starts a job. A resume runs from the next slot after now and replays nothing. The owner does both. An owner or admin of the organization may pause someone else's routine, and may not resume it. Pausing twice is the same as once. Permission: `routines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The routine's id (`rtn_…`), as POST /v1/routines answered it | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `state` ("paused" | "active", required) ### Responses - `200` OK (application/json, Routine) - `id` (string, required): `rtn_` and 32 hex characters - `title` (string, required) - `ownerId` (string, required): The person it runs as. - `teamId` (string): The team its model calls go to; absent when its owner is in none. - `executor` ("gateway", required): `gateway`: each slot is a Runtime job. Desktop routines come with W4 step 2. - `trigger` (RoutineTrigger, required) - `kind` ("schedule" | "watch", required): `schedule` runs on a time; `watch` checks `watch` every `everySeconds`. `event`, `webhook` and `manual` come later. - `everySeconds` (integer): Every N seconds from the routine's creation. Not with `at`. A watch needs it: it checks at most every 10 minutes. [min 600; max 604800] - `watch` (RoutineWatch): What a `watch` trigger checks. The agent reads it as you, and tells you once it is met. - `source` ("github_pull" | "github_issue" | "spend_today", required): `github_pull`: the pull request `target` is merged or closed. `github_issue`: the issue `target` changes state. `spend_today`: your own AI spend today passes `overUsd`. Today is the UTC day, whatever the routine's `timezone`. - `target` (string): A repository and a number, `owner/repo#N`. With `github_pull` and `github_issue` only. [pattern ^[A-Za-z0-9_.-]{1,100}/[A-Za-z0-9_.-]{1,100}#[1-9][0-9]{0,9}$] - `overUsd` (string): An amount above zero in US dollars, as a decimal string with at most six decimals (root rule 9). With `spend_today` only. - `at` (string): A local time, `HH:MM`, 24-hour. Not with `everySeconds`. [pattern ^([01][0-9]|2[0-3]):[0-5][0-9]$] - `days` (array of "mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun"): The days `at` runs on, in week order; every day when absent. - `timezone` (string): An IANA name; `UTC` when absent. - `catchUp` ("latest" | "none"): After downtime: `latest` runs the newest missed slot (the default), `none` runs none. - `action` (RoutineAction, required) - `kind` ("brief" | "notify", required): `brief`: what changed in your open pull requests, your assigned issues and the channels you follow, read through your own connectors. `notify`, a watch's action: you are told its condition is met. Both read only. - `proactivity` (RoutineProactivity, required) - `notify` ("always" | "on_change" | "digest"): When a run speaks up; `always` by default. - `writes` ("never"): A routine reads and notifies only. `ask_first` waits for Policy PO1. - `caps` (RoutineCaps, required) - `maxRunsPerDay` (integer): Runs a day, counted in the trigger's time zone. A slot past it is skipped. [min 1; max 144] - `reportTo` ("slack", required) - `state` ("active" | "paused", required) - `pausedReason` ("owner" | "admin") - `scheduleId` (string): Its Runtime schedule (`sch_…`). - `nextRunAt` (string (date-time)): Its schedule's next slot; absent while paused. - `lastRunAt` (string (date-time)): Its schedule's last slot. - `delivery` (RoutineDelivery, required) - `available` (boolean, required): Whether this Gateway can deliver the routine's action now. - `code` (string): Why not: `routine_brief_unavailable` or `routine_watch_unavailable`. - `reason` (string) - `createdVia` ("api" | "cli" | "ui" | "slack" | "desktop" | "agent", required) - `version` (integer, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `400` `state` is not `paused` or `active`. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person's key (`routine_agent_refused`), or an admin resuming someone else's routine (`routine_resume_refused`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such routine you may see (`not_found`). A routine is its owner's, and its organization's owners' and admins' to read, pause and delete. Another member's routine, and another organization's, is as absent as a missing one. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Routines are off on this Gateway (`routines_disabled`): they need `NEXUS_ROUTINES` and `NEXUS_SCHEDULER`. The route still mounts. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `state` is not `paused` or `active`. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such routine you may see (`not_found`). A routine is its owner's, and its organization's owners' and admins' to read, pause and delete. Another member's routine, and another organization's, is as absent as a missing one. | | 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 | | 503 | | Routines are off on this Gateway (`routines_disabled`): they need `NEXUS_ROUTINES` and `NEXUS_SCHEDULER`. The route still mounts. | ### Example ```sh curl -X PATCH "$NEXUS_URL/v1/routines/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "state": "paused" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Froutines%2F%7Bid%7D) ## Delete routine `DELETE /v1/routines/{id}` Delete a routine and its schedule: its owner, or an owner or admin of the organization. The schedule goes first, so no slot after it starts a job. A job already started runs to its end. Permission: `routines.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The routine's id (`rtn_…`), as POST /v1/routines answered it | | `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, RoutineDeleted) - `id` (string, required) - `deleted` (boolean, required) - `401` No credential (`missing_credential`), or a credential Gateway does not accept (`invalid_credential`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The key does not hold `products.use` (`role_required`), or it is not a person's own key or Nexus UI (`routine_agent_refused`): an agent link creates a routine only after the person's confirm card, which is not built yet. A module's scoped key, a service account and a sandbox are refused the same way. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such routine you may see (`not_found`). A routine is its owner's, and its organization's owners' and admins' to read, pause and delete. Another member's routine, and another organization's, is as absent as a missing one. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Routines are off on this Gateway (`routines_disabled`): they need `NEXUS_ROUTINES` and `NEXUS_SCHEDULER`. The route still mounts. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such routine you may see (`not_found`). A routine is its owner's, and its organization's owners' and admins' to read, pause and delete. Another member's routine, and another organization's, is as absent as a missing one. | | 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 | | 503 | | Routines are off on this Gateway (`routines_disabled`): they need `NEXUS_ROUTINES` and `NEXUS_SCHEDULER`. The route still mounts. | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/routines/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Froutines%2F%7Bid%7D) --- <!-- /docs/api/sessions --> # Sessions ## List session pins `GET /v1/session-pins` List the caller's saved session pins, including unpinned revisions for offline reconciliation. Permission: `chat.use` (Every member). ### Responses - `200` The caller's pin settings in this organization. (application/json, SessionPinList) - `pins` (array of SessionPin, required) - `source` ("chat" | "synced", required) - `sessionId` (string, required) - `pinned` (boolean, required) - `version` (integer, required) - `updatedAt` (string (date-time) | null, required) - `chats` (array of ChatSession, required) - `id` (string, required) - `title` (string, required): The first question until you rename it - `mode` ("chat" | "ask", required): `chat` with any model you may use; `ask` (Ask your code) answers from your organization's Nexus Wiki, citing its pages - `model` (string, required): The model asked for: nexus/auto by default - `lastModel` (string): The model that ran last - `team` (string): The team its spend is attributed to - `archived` (boolean, required) - `webSearch` (boolean): Whether the model may search the web in this session (default false) - `messageCount` (integer, required) - `costUsd` (number, required): The sum of its model calls and of the web searches that returned results, settled in the ledger; a search that fails after the provider billed it is in the ledger, not in this sum - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `visibility` ("private" | "shared"): Private (the default) or shared: at least one active artifact - `sharing` (ChatSessionSharing): How a shared session is shared: its newest active artifact - `artifactId` (string, required) - `version` (integer, required) - `audience` (ArtifactAudience, required): Who may read an artifact, besides its author: inside the organization, the whole organization, chosen teams (their members and the members of the teams under them) or chosen people; outside it, named people by email (`external`) or anyone with the link (`public`). Readers outside the organization see the kind only. - `kind` ("org" | "teams" | "people" | "external" | "public", required) - `teams` (array of string, required): Team slugs (kind teams) - `people` (array of string, required): Members' emails (kind people); the outsiders with access (kind external). Empty for readers outside the organization. - `allowContinue` (boolean, required) - `url` (string, required): The link to hand out: a public link (kind public), the fast viewer (kind external), else the artifact in Nexus UI; absolute when the Gateway knows Nexus UI's URL (NEXUS_UI_URL), else a path - `path` (string, required): /app/<org>/artifacts/<id> - `viewerUrl` (string): The fast viewer: <origin>/a/<id> - `publicUrl` (string): Kind public: <origin>/a/<token> - `expiresAt` (string (date-time)): Kind public: when the link stops opening - `artifacts` (array of ArtifactLink): Every version shared from this session, newest first (revoked ones included) - `id` (string, required) - `version` (integer, required) [min 1] - `status` ("active" | "revoked", required) - `audience` ("org" | "teams" | "people" | "external" | "public", required) - `createdAt` (string (date-time), required) - `revokedAt` (string (date-time)) - `author` (ArtifactAuthor): You (listed and read sessions) - `email` (string) - `name` (string) - `forkedFrom` (object): The artifact this session continues (POST /v1/artifacts/{id}/continue) - `artifactId` (string, required) - `version` (integer, required) - `title` (string) - `threads` (array of SyncedThread, required) - `threadId` (string, required) - `personId` (string, required): The thread's person (`users.id`): you, unless an auditor or a teammate reads it. - `agent` (string | null, required): The latest event's agent: `claude`, `codex` or `nexus`; null before the first event. - `model` (string | null, required) - `status` ("running" | "completed" | "interrupted" | "error" | null, required) - `totals` (SyncedTotals, required): A thread's usage totals. - `inputTokens` (integer, required) - `outputTokens` (integer, required) - `cacheReadTokens` (integer, required) - `cacheWriteTokens` (integer, required) - `costUsd` (string, required): A decimal string. - `lastSeq` (integer | null, required): The highest event number stored; null before the first event. - `keyVersion` (integer | null, required): The newest content key version of a sealed event. - `private` (boolean, required): Whether its owner keeps it from their teammates (setSyncedThreadPrivate). Otherwise it is team-visible: any member reads it while the organization's `multiplayerSessions` is on. - `followers` (array of string, required): Who follows it: members' ids (`users.id`), in the order they followed it (followSyncedThread). - `lastEventAt` (string (date-time) | null, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/session-pins" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fsession-pins) ## Set session pin `PUT /v1/session-pins/{source}/{id}` Set a personal session pin if the caller's revision matches. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `source` | path | "chat" \| "synced" | yes | | | `id` | path | string | yes | | ### Request body (application/json, required) - `pinned` (boolean, required) - `expectedVersion` (integer, required) ### Responses - `200` The matching pin, also returned on a retry when the requested state already holds. (application/json, SessionPin) - `source` ("chat" | "synced", required) - `sessionId` (string, required) - `pinned` (boolean, required) - `version` (integer, required) - `updatedAt` (string (date-time) | null, required) - `404` The caller cannot pin this session. - `409` Another device changed this pin (`session_pin_changed`). Read the current list before retrying. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The caller cannot pin this session. | | 409 | | Another device changed this pin (`session_pin_changed`). Read the current list before retrying. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/session-pins/<source>/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "pinned": false, "expectedVersion": 1 }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fsession-pins%2F%7Bsource%7D%2F%7Bid%7D) --- <!-- /docs/api/session-store --> # Session store > The session store: end-to-end encrypted session sync. A runner (the desktop app, `nexus-host`) seals each event of a thread with the thread's content key and uploads it in order; the person's other trusted devices read the events back and open them on the device. Gateway stores bytes it cannot open, plus the usage numbers budgets need: agent, model, tokens, cost, status and times. The title and the repository are inside the sealed events. A thread belongs to the person and the organization of its first upload; anyone else's is a 404. Its locked content keys are under Devices. ## List synced threads `GET /v1/threads` Your synced threads in this organization, newest first, with their readable summaries; for an auditor, one member's or every member's; for a teammate, the team-visible ones. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `scope` | query | "org" \| "team" \| "following" | no | `org`: every member's threads (`synced_sessions.audit`). `team`: the team-visible threads, to any member while `multiplayerSessions` is on; with `person`, one member's. `following`: the team-visible threads you follow (creation order only) | | `person` | query | string | no | One member's threads (`users.id`): yours without a permission, another's with `synced_sessions.audit`, or with `scope=team` another's team-visible ones | | `before` | query | string | no | The `nextBefore` of the previous page | | `limit` | query | integer | no | At most this many threads, 1 to 200; 50 when absent | | `order` | query | "creation" \| "activity" | no | Creation order by default. Activity order uses server updated_at DESC and thread_id DESC. | | `cursor` | query | string | no | Opaque precise nextCursor; only with order=activity and the same verified read scope. Cannot combine with before. | ### Responses - `200` OK (application/json, SyncedThreadList | SyncedThreadActivityList) - `400` A malformed `before`, `limit` or `scope`, or both `scope=org` and `person` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person (`person_required`), or another member's threads without `synced_sessions.audit` (`role_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed `before`, `limit` or `scope`, or both `scope=org` and `person` | | 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/threads" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads) ## Get synced thread `GET /v1/threads/{threadId}` One of your synced threads: its readable summary and the last event number stored. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | ### Responses - `200` OK (application/json, SyncedThread) - `threadId` (string, required) - `personId` (string, required): The thread's person (`users.id`): you, unless an auditor or a teammate reads it. - `agent` (string | null, required): The latest event's agent: `claude`, `codex` or `nexus`; null before the first event. - `model` (string | null, required) - `status` ("running" | "completed" | "interrupted" | "error" | null, required) - `totals` (SyncedTotals, required): A thread's usage totals. - `inputTokens` (integer, required) - `outputTokens` (integer, required) - `cacheReadTokens` (integer, required) - `cacheWriteTokens` (integer, required) - `costUsd` (string, required): A decimal string. - `lastSeq` (integer | null, required): The highest event number stored; null before the first event. - `keyVersion` (integer | null, required): The newest content key version of a sealed event. - `private` (boolean, required): Whether its owner keeps it from their teammates (setSyncedThreadPrivate). Otherwise it is team-visible: any member reads it while the organization's `multiplayerSessions` is on. - `followers` (array of string, required): Who follows it: members' ids (`users.id`), in the order they followed it (followSyncedThread). - `lastEventAt` (string (date-time) | null, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `403` Not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such thread, or not yours in this organization (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `410` The thread was deleted (`thread_deleted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such thread, or not yours in this organization (`thread_not_found`) | | 410 | | The thread was deleted (`thread_deleted`) | | 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/threads/<threadId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D) ## Delete synced thread `DELETE /v1/threads/{threadId}` Delete one of your synced threads: its events and every locked copy of its content key. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | ### Responses - `200` Deleted (application/json, SyncedThreadDeleted) - `threadId` (string, required) - `deleted` (boolean, required) - `eventsDeleted` (integer, required): The events this deletion removed. - `keysDeleted` (integer, required): The locked key copies this deletion removed, those for the organization's recovery key included. - `403` Not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such thread, or not yours in this organization (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such thread, or not yours in this organization (`thread_not_found`) | | 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/threads/<threadId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fthreads%2F%7BthreadId%7D) ## Set synced thread private `PUT /v1/threads/{threadId}/private` Keep one of your synced threads from your teammates, or share it with them again. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | ### Request body (application/json, required) - `private` (boolean, required): True keeps the thread from your teammates; false shares it again ### Responses - `200` OK (application/json, SyncedThread) - `threadId` (string, required) - `personId` (string, required): The thread's person (`users.id`): you, unless an auditor or a teammate reads it. - `agent` (string | null, required): The latest event's agent: `claude`, `codex` or `nexus`; null before the first event. - `model` (string | null, required) - `status` ("running" | "completed" | "interrupted" | "error" | null, required) - `totals` (SyncedTotals, required): A thread's usage totals. - `inputTokens` (integer, required) - `outputTokens` (integer, required) - `cacheReadTokens` (integer, required) - `cacheWriteTokens` (integer, required) - `costUsd` (string, required): A decimal string. - `lastSeq` (integer | null, required): The highest event number stored; null before the first event. - `keyVersion` (integer | null, required): The newest content key version of a sealed event. - `private` (boolean, required): Whether its owner keeps it from their teammates (setSyncedThreadPrivate). Otherwise it is team-visible: any member reads it while the organization's `multiplayerSessions` is on. - `followers` (array of string, required): Who follows it: members' ids (`users.id`), in the order they followed it (followSyncedThread). - `lastEventAt` (string (date-time) | null, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `400` The body is not `{"private": true|false}` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such thread, or not yours in this organization (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `410` The thread was deleted (`thread_deleted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not `{"private": true|false}` | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such thread, or not yours in this organization (`thread_not_found`) | | 410 | | The thread was deleted (`thread_deleted`) | | 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/threads/<threadId>/private" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "private": false }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fprivate) ## Follow synced thread `PUT /v1/threads/{threadId}/follow` Follow a teammate's session: it shows under Following, and its followers name you. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | ### Responses - `200` The thread, with its followers (application/json, SyncedThread) - `threadId` (string, required) - `personId` (string, required): The thread's person (`users.id`): you, unless an auditor or a teammate reads it. - `agent` (string | null, required): The latest event's agent: `claude`, `codex` or `nexus`; null before the first event. - `model` (string | null, required) - `status` ("running" | "completed" | "interrupted" | "error" | null, required) - `totals` (SyncedTotals, required): A thread's usage totals. - `inputTokens` (integer, required) - `outputTokens` (integer, required) - `cacheReadTokens` (integer, required) - `cacheWriteTokens` (integer, required) - `costUsd` (string, required): A decimal string. - `lastSeq` (integer | null, required): The highest event number stored; null before the first event. - `keyVersion` (integer | null, required): The newest content key version of a sealed event. - `private` (boolean, required): Whether its owner keeps it from their teammates (setSyncedThreadPrivate). Otherwise it is team-visible: any member reads it while the organization's `multiplayerSessions` is on. - `followers` (array of string, required): Who follows it: members' ids (`users.id`), in the order they followed it (followSyncedThread). - `lastEventAt` (string (date-time) | null, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `403` Not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such thread, or not a teammate's you may read: private, deleted, another organization's, or `multiplayerSessions` off (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The thread is your own: nobody follows their own (`own_thread`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such thread, or not a teammate's you may read: private, deleted, another organization's, or `multiplayerSessions` off (`thread_not_found`) | | 409 | | The thread is your own: nobody follows their own (`own_thread`) | | 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/threads/<threadId>/follow" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Ffollow) ## Unfollow synced thread `DELETE /v1/threads/{threadId}/follow` Stop following a teammate's session. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | ### Responses - `200` The thread, with its followers (application/json, SyncedThread) - `threadId` (string, required) - `personId` (string, required): The thread's person (`users.id`): you, unless an auditor or a teammate reads it. - `agent` (string | null, required): The latest event's agent: `claude`, `codex` or `nexus`; null before the first event. - `model` (string | null, required) - `status` ("running" | "completed" | "interrupted" | "error" | null, required) - `totals` (SyncedTotals, required): A thread's usage totals. - `inputTokens` (integer, required) - `outputTokens` (integer, required) - `cacheReadTokens` (integer, required) - `cacheWriteTokens` (integer, required) - `costUsd` (string, required): A decimal string. - `lastSeq` (integer | null, required): The highest event number stored; null before the first event. - `keyVersion` (integer | null, required): The newest content key version of a sealed event. - `private` (boolean, required): Whether its owner keeps it from their teammates (setSyncedThreadPrivate). Otherwise it is team-visible: any member reads it while the organization's `multiplayerSessions` is on. - `followers` (array of string, required): Who follows it: members' ids (`users.id`), in the order they followed it (followSyncedThread). - `lastEventAt` (string (date-time) | null, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `403` Not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such thread, or not a teammate's you may read: private, deleted, another organization's, or `multiplayerSessions` off (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The thread is your own: nobody follows their own (`own_thread`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such thread, or not a teammate's you may read: private, deleted, another organization's, or `multiplayerSessions` off (`thread_not_found`) | | 409 | | The thread is your own: nobody follows their own (`own_thread`) | | 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/threads/<threadId>/follow" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Ffollow) ## List thread answer ratings `GET /v1/threads/{threadId}/answer-ratings` List your own answer ratings. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | | `before` | query | integer | no | Return ratings whose answer sequence is lower than this cursor. | ### Responses - `200` OK (application/json, ThreadAnswerRatings) - `audience` ("personal" | "organization", required) - `ratings` (array of ThreadAnswerRating, required) - `answerSeq` (integer, required) [min 0; max 9007199254740991] - `rating` ("good" | "bad" | "none", required) - `reason` ("wrong" | "instructions" | "slow" | "other" | null, required) - `detail` (string | null, required) [max length 1000] - `version` (integer, required) [min 1; max 9007199254740991] - `nextBefore` (integer | null, required) [min 0; max 9007199254740991] - `400` Invalid cursor. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller is not a person. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` The caller does not own this thread. (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. - `410` The thread was deleted. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Invalid cursor. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The caller does not own this thread. | | 410 | | The thread was deleted. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/threads/<threadId>/answer-ratings" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fanswer-ratings) ## Set thread answer rating `PUT /v1/threads/{threadId}/answer-ratings/{answerSeq}` Save or clear a rating for your own completed answer. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | | `answerSeq` | path | string | yes | The sealed event that completed the turn. A decimal sequence up to 9007199254740991. | ### Request body (application/json, required) - `audience` ("personal" | "organization", required) - `rating` ("good" | "bad" | "none", required) - `reason` ("wrong" | "instructions" | "slow" | "other" | null) - `detail` (string | null) [max length 1000] - `expectedVersion` (integer, required) [min 0; max 9007199254740991] ### Responses - `200` OK (application/json, ThreadAnswerRating) - `answerSeq` (integer, required) [min 0; max 9007199254740991] - `rating` ("good" | "bad" | "none", required) - `reason` ("wrong" | "instructions" | "slow" | "other" | null, required) - `detail` (string | null, required) [max length 1000] - `version` (integer, required) [min 1; max 9007199254740991] - `400` Invalid rating, reason, detail or version. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller is not a person. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` The caller does not own this thread, or the completed answer is unavailable. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The audience or rating changed. (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. - `410` The thread was deleted. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Invalid rating, reason, detail or version. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The caller does not own this thread, or the completed answer is unavailable. | | 409 | | The audience or rating changed. | | 410 | | The thread was deleted. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/threads/<threadId>/answer-ratings/<answerSeq>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "audience": "personal", "rating": "good", "expectedVersion": 0 }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fanswer-ratings%2F%7BanswerSeq%7D) ## List org thread answer ratings `GET /v1/threads/{threadId}/org-answer-ratings` Read ratings shared with your organization. Permission: `synced_sessions.audit` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | | `before` | query | integer | no | Return ratings whose answer sequence is lower than this cursor. | ### Responses - `200` OK (application/json, ThreadAnswerRatings) - `audience` ("personal" | "organization", required) - `ratings` (array of ThreadAnswerRating, required) - `answerSeq` (integer, required) [min 0; max 9007199254740991] - `rating` ("good" | "bad" | "none", required) - `reason` ("wrong" | "instructions" | "slow" | "other" | null, required) - `detail` (string | null, required) [max length 1000] - `version` (integer, required) [min 1; max 9007199254740991] - `nextBefore` (integer | null, required) [min 0; max 9007199254740991] - `400` Invalid cursor. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` The caller is not an authorized person. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` The company thread is unavailable. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Invalid cursor. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The company thread is unavailable. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/threads/<threadId>/org-answer-ratings" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Forg-answer-ratings) ## List synced events `GET /v1/threads/{threadId}/events` A page of one of your threads' sealed events, after an event number or just before one. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | | `after` | query | integer | no | Events numbered after this one; -1 for every event | | `before` | query | integer | no | Events numbered before this one | | `limit` | query | integer | no | At most this many events, 1 to 500; 100 when absent | ### Responses - `200` OK (application/json, SyncedEventPage) - `threadId` (string, required) - `lastSeq` (integer | null, required): The highest event number stored when the page was read. - `events` (array of SyncedEvent, required) - `seq` (integer, required): The event's number: 0 first, one more each time. [min 0] - `at` (integer, required): The runner's time of the event, in milliseconds since 1970. [min 0] - `agent` (string, required): The coding agent that wrote the event, as the runner's workbench names it: `claude`, `codex` or `nexus`. - `usage` (SyncedUsage | null) - `status` ("running" | "completed" | "interrupted" | "error" | null): The thread's state, when the event reports it. - `keyVersion` (integer | null): The content key version the body is sealed with; set with `sealed`. [min 1] - `sealed` (string | null): The sealed body, base64url without padding, at most 263168 bytes. Null when the organization's content never leaves the machine. - `more` (boolean, required): Whether more events follow in the direction read. - `400` Both `after` and `before`, or a malformed number (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: an agent link, a module or a service account (`person_required`); or Nexus UI while the organization's `webSessionViewer` is off (`web_session_viewer_off`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such thread, or not yours in this organization (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `410` The thread was deleted (`thread_deleted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Both `after` and `before`, or a malformed number | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such thread, or not yours in this organization (`thread_not_found`) | | 410 | | The thread was deleted (`thread_deleted`) | | 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/threads/<threadId>/events" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fevents) ## Append synced events `POST /v1/threads/{threadId}/events` Upload a thread's next sealed events. A retried upload changes nothing, and the answer names the last event stored. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | ### Request body (application/json, required) - `events` (array of SyncedEvent, required): Consecutive events, the first at most one past the last stored. [at most 64 items] - `seq` (integer, required): The event's number: 0 first, one more each time. [min 0] - `at` (integer, required): The runner's time of the event, in milliseconds since 1970. [min 0] - `agent` (string, required): The coding agent that wrote the event, as the runner's workbench names it: `claude`, `codex` or `nexus`. - `usage` (SyncedUsage | null) - `status` ("running" | "completed" | "interrupted" | "error" | null): The thread's state, when the event reports it. - `keyVersion` (integer | null): The content key version the body is sealed with; set with `sealed`. [min 1] - `sealed` (string | null): The sealed body, base64url without padding, at most 263168 bytes. Null when the organization's content never leaves the machine. ### Responses - `200` Stored (application/json, SyncedEventsAppended) - `threadId` (string, required) - `lastSeq` (integer, required): The highest event number stored. Every number from 0 to it is stored. - `appended` (integer, required): How many of the request's events were new. - `400` No events or more than 64, events not consecutive, or a malformed event (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` Another person's thread, or yours in another organization (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The first event is past the next number (`seq_gap`), an event already stored differs (`event_conflict`), the thread has no locked keys yet (`thread_keys_missing`), a key version has no copies (`key_version_not_stored`), or a new event is not sealed with the thread's latest key version (`key_version_behind`): re-seal it with the new key; or a new event carries a sealed body while the organization's content policy is `never` (`content_policy_never`): send usage only (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `410` The thread was deleted (`thread_deleted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `413` Your synced threads in this organization would pass 1 GiB (`session_store_full`): delete some (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | No events or more than 64, events not consecutive, or a malformed event | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Another person's thread, or yours in another organization (`thread_not_found`) | | 409 | | The first event is past the next number (`seq_gap`), an event already stored differs (`event_conflict`), the thread has no locked keys yet (`thread_keys_missing`), a key version has no copies (`key_version_not_stored`), or a new event is not sealed with the thread's latest key version (`key_version_behind`): re-seal it with the new key; or a new event carries a sealed body while the organization's content policy is `never` (`content_policy_never`): send usage only | | 410 | | The thread was deleted (`thread_deleted`) | | 413 | | Your synced threads in this organization would pass 1 GiB (`session_store_full`): delete some | | 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/threads/<threadId>/events" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "events": [ { "seq": 0, "at": 0, "agent": "claude" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fevents) ## Stream synced thread `GET /v1/threads/{threadId}/stream` One of your threads, live: its new event numbers and its deletion, as server-sent events. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | | `after` | query | integer | no | The last event number you hold; -1 (the default) when you hold none | | `commands` | query | boolean | no | Also send phone control's `commands` and `command` events, when you are the thread's person with `sessions.control`. False by default. | ### Responses - `200` The event stream (text/event-stream, SyncedThreadAdvanced) - `threadId` (string, required) - `lastSeq` (integer, required): The highest event number stored. Every number from 0 to it is stored. - `400` A malformed `after` or `commands`, or an `after` below -1 (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such thread, or not yours or your team's in this organization (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `410` The thread was deleted (`thread_deleted`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` More than 16 live thread streams of yours on this Gateway copy (`thread_events_per_person`), or the rate limit (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Too many live thread streams on this Gateway copy (`thread_events_full`), or 64 on this thread (`thread_watchers_full`): read the events after your last instead (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed `after` or `commands`, or an `after` below -1 | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such thread, or not yours or your team's in this organization (`thread_not_found`) | | 410 | | The thread was deleted (`thread_deleted`) | | 429 | | More than 16 live thread streams of yours on this Gateway copy (`thread_events_per_person`), or the rate limit | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Too many live thread streams on this Gateway copy (`thread_events_full`), or 64 on this thread (`thread_watchers_full`): read the events after your last instead | ### Example ```sh curl "$NEXUS_URL/v1/threads/<threadId>/stream" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fstream) ## Post synced thread presence `POST /v1/threads/{threadId}/presence` Tell a thread's watchers where you are on it: the event number on screen, or that you left. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | The thread's sync id, as its runner names it (a UUIDv7) | ### Request body (application/json, required) - `client` (string, required): Your window or device: a random id, the same while it shows the thread [pattern ^[A-Za-z0-9_-]{1,64}$] - `seq` (integer | null): The event number on screen; unset before any shows [min 0] - `leave` (boolean): True when you stop watching [default false] ### Responses - `204` Relayed - `400` The body is not `{"client", "seq", "leave"}`: `client` is 1 to 64 letters, digits, `-` or `_`, and `seq` 0 or more (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person: an agent link, a module or a service account (`person_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such thread, or not one you may stream (`thread_not_found`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not `{"client", "seq", "leave"}`: `client` is 1 to 64 letters, digits, `-` or `_`, and `seq` 0 or more | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such thread, or not one you may stream (`thread_not_found`) | | 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/threads/<threadId>/presence" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "client": "<client>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fpresence) --- <!-- /docs/api/design-systems --> # Design systems > Nexus Design's design systems: the tokens and notes designs are made, served and checked with. ## List design systems `GET /v1/design-systems` The organization's design systems for Nexus Design: the built-in @nexus/brand (brand v5.0) first, then its own by name, and the default new designs use. Permission: `chat.use` (Every member). ### Responses - `200` The design systems (application/json, DesignSystemList) - `designSystems` (array of DesignSystem, required) - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand` - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`) - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted - `isDefault` (boolean, required): The organization's default: new designs use it - `source` (string, required): Where it came from, in words - `variableCount` (integer, required) - `componentCount` (integer, required) - `updatedAt` (string (date-time)): Unset for the built-in - `defaultId` (string, required) ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/design-systems" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdesign-systems) ## Save design system `POST /v1/design-systems` Create the named design system, or replace its tokens, notes, components and source (what `nexus design-system sync` sends). Tokens come from `css` and from `files`: CSS custom properties (`:root`, `@theme`, `[data-theme]`, `.dark`, `.light`), a Tailwind config's literal theme, and `tokens.json`. Only custom properties are stored. 400 design_system_empty when none are found, 400 design_system_limit past 50 per organization. Audited as design_system.saved, with counts and never the tokens. Permission: `org.settings` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Request body (application/json, required) - `name` (string, required): Lowercase; `@nexus/` and `ds_` are reserved [pattern ^(@[a-z0-9][a-z0-9._-]{0,30}/)?[a-z0-9][a-z0-9._-]{0,63}$] - `css` (string): CSS custom properties - `files` (array of DesignSourceFile): At most 4 MiB together [at most 40 items] - `path` (string, required): Relative to the synced folder; the name says how it is read - `text` (string, required) - `notes` (string): Markdown for the model [max length 65536] - `components` (array of string) [at most 500 items] - `source` (string) [max length 500] - `makeDefault` (boolean): Make it the organization's default too ### Responses - `200` Replaced (application/json, DesignSystemSaved) - `designSystem` (DesignSystem, required): A design system for Nexus Design, as the organization lists it. - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand` - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`) - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted - `isDefault` (boolean, required): The organization's default: new designs use it - `source` (string, required): Where it came from, in words - `variableCount` (integer, required) - `componentCount` (integer, required) - `updatedAt` (string (date-time)): Unset for the built-in - `created` (boolean, required): False when it replaced one of the same name - `read` (array of string, required): What each file gave, in words - `201` Created (application/json, DesignSystemSaved) - `designSystem` (DesignSystem, required): A design system for Nexus Design, as the organization lists it. - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand` - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`) - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted - `isDefault` (boolean, required): The organization's default: new designs use it - `source` (string, required): Where it came from, in words - `variableCount` (integer, required) - `componentCount` (integer, required) - `updatedAt` (string (date-time)): Unset for the built-in - `created` (boolean, required): False when it replaced one of the same name - `read` (array of string, required): What each file gave, in words - `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/design-systems" \ -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%2Fdesign-systems) ## Get design system `GET /v1/design-systems/{id}` A design system: its tokens as CSS and as a map of variables, its notes and its components. 404 design_system_not_found. Permission: `chat.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The design system's id (`ds_…`; the built-in is `ds_nexus_brand`), or its name when it has no `/` | ### Responses - `200` The design system (application/json, DesignSystemDetail) - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand` - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`) - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted - `isDefault` (boolean, required): The organization's default: new designs use it - `source` (string, required): Where it came from, in words - `variableCount` (integer, required) - `componentCount` (integer, required) - `updatedAt` (string (date-time)): Unset for the built-in - `css` (string, required): The tokens as CSS: `selector { --name: value; }` blocks and nothing else - `variables` (array of DesignVariable, required) - `name` (string, required): `--nx-page` - `value` (string, required) - `selector` (string, required): `:root`, or a theme such as `[data-theme="light"]` - `kind` ("color" | "length" | "font" | "other", required) - `notes` (string, required): Markdown for the model - `components` (array of string, required) ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/design-systems/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdesign-systems%2F%7Bid%7D) ## Delete design system `DELETE /v1/design-systems/{id}` Delete a design system. When it was the default, the built-in is the default again; pages that link it are served without its tokens. 400 design_system_built_in for @nexus/brand. Audited as design_system.deleted. Permission: `org.settings` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The design system's id (`ds_…`; the built-in is `ds_nexus_brand`), or its name when it has no `/` | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` Deleted (application/json, DesignSystemDeleted) - `id` (string, required) - `deleted` (boolean, required) - `defaultId` (string, required): The default now ### 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 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/design-systems/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fdesign-systems%2F%7Bid%7D) ## Set default design system `POST /v1/design-systems/{id}/default` Make a design system the organization's default for new designs (the built-in too). Audited as design_system.default_set, with the default before and after. Permission: `org.settings` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The design system's id (`ds_…`; the built-in is `ds_nexus_brand`), or its name when it has no `/` | | `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). | ### Responses - `200` The new default (application/json, DesignSystem) - `id` (string, required): `ds_…`; the built-in is `ds_nexus_brand` - `name` (string, required): `@nexus/brand`, or the organization's own name (`acme`, `@acme/web`) - `builtIn` (boolean, required): Compiled into Gateway: it cannot be changed or deleted - `isDefault` (boolean, required): The organization's default: new designs use it - `source` (string, required): Where it came from, in words - `variableCount` (integer, required) - `componentCount` (integer, required) - `updatedAt` (string (date-time)): Unset for the built-in ### 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 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/design-systems/<id>/default" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdesign-systems%2F%7Bid%7D%2Fdefault) --- <!-- /docs/api/fix-runs --> # Fix runs > Fix runs, for `@nexus fix this`: Gateway fixes one GitHub issue in a throwaway cloud sandbox on Nexus's provider account and opens the pull request as the person's agent. The run reads the issue and the repository through the GitHub connector, runs the coding agent's turns through Gateway, and runs every command in the sandbox with no network and no credential. It opens the pull request with `github/pull_create` through the person's agents' writes, so only an agent link starts one. A run is a job: its state and its pull request are read at `GET /v1/cloud/runs/{id}`. The sandbox is charged as cloud compute. Rust only. ## Create cloud run `POST /v1/cloud/runs` Start a fix run for one issue of a GitHub repository, as the calling agent link. Gateway reads the issue and the repository at its default branch through the GitHub connector, runs the coding agent in a cloud sandbox, and opens a pull request that closes the issue with `github/pull_create`. The organization must have agent writes on with `github.pull_create` on its allowlist, and the person their own agents' writes on; otherwise the run fails with `write_not_granted`, `chat_writes_off` or `operation_not_allowed` and opens nothing. Send an `Idempotency-Key`: the run's id is derived from it, so a resend answers the run the first send started. Permission: `cloud.runs.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) - `repo` (string, required): `https://github.com/<owner>/<name>` - `issue` (integer, required): The issue's number [min 1] ### Responses - `200` The run a send with this key started (application/json, CloudRun) - `id` (string, required): The run's job id (`job_…`) - `state` ("accepted" | "running" | "done" | "failed" | "cancelled", required) - `repo` (string, required) - `issue` (integer, required) - `pullRequest` (object | null, required): The pull request the run opened, once it is `done` - `number` (integer, required) - `url` (string, required) - `error` (object | null, required): Why the run failed, once it `failed`: `write_not_granted`, `chat_writes_off` or `operation_not_allowed` (the pull request write), `no_change`, `agent_stopped`, `repo_too_large`, `link_ended`, `budget_exceeded` and others - `code` (string, required) - `message` (string, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `202` Accepted: the run waits for the job worker (application/json, CloudRun) - `id` (string, required): The run's job id (`job_…`) - `state` ("accepted" | "running" | "done" | "failed" | "cancelled", required) - `repo` (string, required) - `issue` (integer, required) - `pullRequest` (object | null, required): The pull request the run opened, once it is `done` - `number` (integer, required) - `url` (string, required) - `error` (object | null, required): Why the run failed, once it `failed`: `write_not_granted`, `chat_writes_off` or `operation_not_allowed` (the pull request write), `no_change`, `agent_stopped`, `repo_too_large`, `link_ended`, `budget_exceeded` and others - `code` (string, required) - `message` (string, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `400` The body is not `{ repo, issue }`, `repo` is not a GitHub repository's URL (`invalid_repo`), `issue` is 0 (`invalid_issue`), or the `Idempotency-Key` is missing. - `402` Nothing covers 15 minutes of the run's sandbox (`budget_exceeded`), or the organization is past due (`payment_past_due`). The refusal is recorded. - `403` The credential is not an agent link (`agent_link_required`): a person's own key reads runs but never starts one. Or the link does not hold `cloud.runs.use` (`role_required`), or the organization may not run cloud compute (`cloud_not_enabled`). - `422` This `Idempotency-Key` named another run (`idempotency_key_reused`). - `429` The person has two runs going (`fix_runs_busy`); try again after `Retry-After`. - `503` Fix runs are off on this Gateway (`fix_runs_unavailable`): they need `NEXUS_FIX_RUNS=on`, a provider account (`BOAT_API_KEY`), the job worker (`NEXUS_JOB_WORKER`) and a database. The route still mounts. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not `{ repo, issue }`, `repo` is not a GitHub repository's URL (`invalid_repo`), `issue` is 0 (`invalid_issue`), or the `Idempotency-Key` is missing. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | Nothing covers 15 minutes of the run's sandbox (`budget_exceeded`), or the organization is past due (`payment_past_due`). The refusal is recorded. | | 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 | | This `Idempotency-Key` named another run (`idempotency_key_reused`). | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | The person has two runs going (`fix_runs_busy`); try again after `Retry-After`. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Fix runs are off on this Gateway (`fix_runs_unavailable`): they need `NEXUS_FIX_RUNS=on`, a provider account (`BOAT_API_KEY`), the job worker (`NEXUS_JOB_WORKER`) and a database. The route still mounts. | ### Example ```sh curl -X POST "$NEXUS_URL/v1/cloud/runs" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "repo": "https://github.com/nexus-demo/hello-factory", "issue": 1 }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcloud%2Fruns) ## Get cloud run `GET /v1/cloud/runs/{id}` A fix run of the caller's person: its state, its pull request once it is `done`, and why it failed once it `failed`. Another person's run is a 404, as a missing one is. Permission: `cloud.runs.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The run's id (`job_…`). | ### Responses - `200` The run (application/json, CloudRun) - `id` (string, required): The run's job id (`job_…`) - `state` ("accepted" | "running" | "done" | "failed" | "cancelled", required) - `repo` (string, required) - `issue` (integer, required) - `pullRequest` (object | null, required): The pull request the run opened, once it is `done` - `number` (integer, required) - `url` (string, required) - `error` (object | null, required): Why the run failed, once it `failed`: `write_not_granted`, `chat_writes_off` or `operation_not_allowed` (the pull request write), `no_change`, `agent_stopped`, `repo_too_large`, `link_ended`, `budget_exceeded` and others - `code` (string, required) - `message` (string, required) - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `404` No such run of the caller's person (`not_found`). - `503` Fix runs are off on this Gateway (`fix_runs_unavailable`): they need `NEXUS_FIX_RUNS=on`, a provider account (`BOAT_API_KEY`), the job worker (`NEXUS_JOB_WORKER`) and a database. The route still mounts. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such run of the caller's person (`not_found`). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Fix runs are off on this Gateway (`fix_runs_unavailable`): they need `NEXUS_FIX_RUNS=on`, a provider account (`BOAT_API_KEY`), the job worker (`NEXUS_JOB_WORKER`) and a database. The route still mounts. | ### Example ```sh curl "$NEXUS_URL/v1/cloud/runs/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcloud%2Fruns%2F%7Bid%7D) --- <!-- /docs/api/synced-sessions --> # Synced sessions ## Get code control `GET /v1/threads/{threadId}/control` Read whether your Code session accepts phone control Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | | ### Responses - `200` Current control or delivery state. (application/json, CodeControl) - `runnerDeviceId` (string | null, required) - `enabled` (boolean, required) - `expiresAt` (integer | null, required) - `serverTime` (integer): Gateway's clock when it answered, in Unix milliseconds. A device seals a command's expiresAt by this clock. An older Gateway leaves it out. - `400` Malformed fields, ciphertext or expiry. - `403` Invalid signature or a caller that is not a person. - `404` The session, command or device does not belong to the caller. - `409` A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. - `410` The session was deleted. - `429` The bounded command mailbox is full. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | Malformed fields, ciphertext or expiry. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The session, command or device does not belong to the caller. | | 409 | | A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. | | 410 | | The session was deleted. | | 429 | | The bounded command mailbox is full. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/threads/<threadId>/control" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fcontrol) ## Set code control `PUT /v1/threads/{threadId}/control` Renew a signed, locally enabled Code runner lease Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | | ### Request body (application/json, required) - `runnerDeviceId` (string, required) - `enabled` (boolean, required) - `expiresAt` (integer, required) - `signature` (string, required) ### Responses - `200` Current control or delivery state. (application/json, CodeControl) - `runnerDeviceId` (string | null, required) - `enabled` (boolean, required) - `expiresAt` (integer | null, required) - `serverTime` (integer): Gateway's clock when it answered, in Unix milliseconds. A device seals a command's expiresAt by this clock. An older Gateway leaves it out. - `400` Malformed fields, ciphertext or expiry. - `403` Invalid signature or a caller that is not a person. - `404` The session, command or device does not belong to the caller. - `409` A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. - `410` The session was deleted. - `429` The bounded command mailbox is full. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed fields, ciphertext or expiry. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The session, command or device does not belong to the caller. | | 409 | | A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. | | 410 | | The session was deleted. | | 429 | | The bounded command mailbox is full. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/threads/<threadId>/control" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "runnerDeviceId": "<runnerDeviceId>", "enabled": false, "expiresAt": 1, "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fcontrol) ## List code commands `GET /v1/threads/{threadId}/commands` Read up to 20 queued commands for your trusted runner Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | | | `runnerDeviceId` | query | string | yes | | ### Responses - `200` Current control or delivery state. (application/json, CodeCommands) - `commands` (array of CodeCommand, required) [at most 20 items] - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 bytes of HPKE ciphertext, base64url without padding. - `sealed` (string, required): Encrypted action payload, base64url without padding. At most 65581 decoded bytes. - `signature` (string, required): Ed25519 signature over the domain-separated command and its routing fields, base64url without padding. - `waits` (boolean): The command may wait for a sleeping computer. Absent means false. - `threadId` (string, required) - `state` ("queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled", required) - `400` Malformed fields, ciphertext or expiry. - `403` Invalid signature or a caller that is not a person. - `404` The session, command or device does not belong to the caller. - `409` A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. - `410` The session was deleted. - `429` The bounded command mailbox is full. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed fields, ciphertext or expiry. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The session, command or device does not belong to the caller. | | 409 | | A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. | | 410 | | The session was deleted. | | 429 | | The bounded command mailbox is full. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/threads/<threadId>/commands?runnerDeviceId=%3CrunnerDeviceId%3E" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fcommands) ## Send code command `POST /v1/threads/{threadId}/commands` Queue an encrypted command for your own Code session Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | | ### Request body (application/json, required) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 bytes of HPKE ciphertext, base64url without padding. - `sealed` (string, required): Encrypted action payload, base64url without padding. At most 65581 decoded bytes. - `signature` (string, required): Ed25519 signature over the domain-separated command and its routing fields, base64url without padding. - `waits` (boolean): The person lets the command wait for a computer that is asleep or offline. Gateway then queues it without a live lease, and `expiresAt` may be up to 24 hours ahead (30 seconds more for clock skew). The sender signs `nexus-code-command-v2`, with `true` after the expiry line, so a runner that verifies only v1 never runs it. Absent means false. ### Responses - `200` Current control or delivery state. (application/json, CodeCommand) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 bytes of HPKE ciphertext, base64url without padding. - `sealed` (string, required): Encrypted action payload, base64url without padding. At most 65581 decoded bytes. - `signature` (string, required): Ed25519 signature over the domain-separated command and its routing fields, base64url without padding. - `waits` (boolean): The command may wait for a sleeping computer. Absent means false. - `threadId` (string, required) - `state` ("queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled", required) - `400` Malformed fields, ciphertext or expiry. - `403` Invalid signature or a caller that is not a person. - `404` The session, command or device does not belong to the caller. - `409` A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. - `410` The session was deleted. - `429` The bounded command mailbox is full. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed fields, ciphertext or expiry. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The session, command or device does not belong to the caller. | | 409 | | A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. | | 410 | | The session was deleted. | | 429 | | The bounded command mailbox is full. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/threads/<threadId>/commands" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "id": "<id>", "senderDeviceId": "<senderDeviceId>", "runnerDeviceId": "<runnerDeviceId>", "expiresAt": 1, "lockedKey": "<lockedKey>", "sealed": "<sealed>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fcommands) ## Get code command `GET /v1/threads/{threadId}/commands/{commandId}` Read the delivery state of your own Code command Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | | | `commandId` | path | string (uuid) | yes | | ### Responses - `200` Current control or delivery state. (application/json, CodeCommand) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 bytes of HPKE ciphertext, base64url without padding. - `sealed` (string, required): Encrypted action payload, base64url without padding. At most 65581 decoded bytes. - `signature` (string, required): Ed25519 signature over the domain-separated command and its routing fields, base64url without padding. - `waits` (boolean): The command may wait for a sleeping computer. Absent means false. - `threadId` (string, required) - `state` ("queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled", required) - `400` Malformed fields, ciphertext or expiry. - `403` Invalid signature or a caller that is not a person. - `404` The session, command or device does not belong to the caller. - `409` A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. - `410` The session was deleted. - `429` The bounded command mailbox is full. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | Malformed fields, ciphertext or expiry. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The session, command or device does not belong to the caller. | | 409 | | A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. | | 410 | | The session was deleted. | | 429 | | The bounded command mailbox is full. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/threads/<threadId>/commands/<commandId>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fcommands%2F%7BcommandId%7D) ## Claim code command `POST /v1/threads/{threadId}/commands/{commandId}/claim` Claim a Code command once before executing it Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | | | `commandId` | path | string (uuid) | yes | | ### Request body (application/json, required) - `runnerDeviceId` (string, required) - `signature` (string, required) ### Responses - `200` Current control or delivery state. (application/json, CodeCommandClaimed) - `claimed` (boolean, required) - `command` (CodeCommand, required) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 bytes of HPKE ciphertext, base64url without padding. - `sealed` (string, required): Encrypted action payload, base64url without padding. At most 65581 decoded bytes. - `signature` (string, required): Ed25519 signature over the domain-separated command and its routing fields, base64url without padding. - `waits` (boolean): The command may wait for a sleeping computer. Absent means false. - `threadId` (string, required) - `state` ("queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled", required) - `400` Malformed fields, ciphertext or expiry. - `403` Invalid signature or a caller that is not a person. - `404` The session, command or device does not belong to the caller. - `409` A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. - `410` The session was deleted. - `429` The bounded command mailbox is full. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed fields, ciphertext or expiry. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The session, command or device does not belong to the caller. | | 409 | | A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. | | 410 | | The session was deleted. | | 429 | | The bounded command mailbox is full. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/threads/<threadId>/commands/<commandId>/claim" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "runnerDeviceId": "<runnerDeviceId>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fcommands%2F%7BcommandId%7D%2Fclaim) ## Finish code command `POST /v1/threads/{threadId}/commands/{commandId}/result` Report a claimed Code command completed or rejected Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | | | `commandId` | path | string (uuid) | yes | | ### Request body (application/json, required) - `runnerDeviceId` (string, required) - `state` ("completed" | "rejected", required) - `signature` (string, required) ### Responses - `200` Current control or delivery state. (application/json, CodeCommand) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 bytes of HPKE ciphertext, base64url without padding. - `sealed` (string, required): Encrypted action payload, base64url without padding. At most 65581 decoded bytes. - `signature` (string, required): Ed25519 signature over the domain-separated command and its routing fields, base64url without padding. - `waits` (boolean): The command may wait for a sleeping computer. Absent means false. - `threadId` (string, required) - `state` ("queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled", required) - `400` Malformed fields, ciphertext or expiry. - `403` Invalid signature or a caller that is not a person. - `404` The session, command or device does not belong to the caller. - `409` A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. - `410` The session was deleted. - `429` The bounded command mailbox is full. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed fields, ciphertext or expiry. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The session, command or device does not belong to the caller. | | 409 | | A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. | | 410 | | The session was deleted. | | 429 | | The bounded command mailbox is full. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/threads/<threadId>/commands/<commandId>/result" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "runnerDeviceId": "<runnerDeviceId>", "state": "completed", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fcommands%2F%7BcommandId%7D%2Fresult) ## Cancel code command `POST /v1/threads/{threadId}/commands/{commandId}/cancel` Cancel your own Code command before a computer receives it Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `threadId` | path | string | yes | | | `commandId` | path | string (uuid) | yes | | ### Request body (application/json, required) - `senderDeviceId` (string, required) - `signature` (string, required) ### Responses - `200` The cancelled command, also when it was already cancelled. (application/json, CodeCommand) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 bytes of HPKE ciphertext, base64url without padding. - `sealed` (string, required): Encrypted action payload, base64url without padding. At most 65581 decoded bytes. - `signature` (string, required): Ed25519 signature over the domain-separated command and its routing fields, base64url without padding. - `waits` (boolean): The command may wait for a sleeping computer. Absent means false. - `threadId` (string, required) - `state` ("queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled", required) - `400` A malformed body. - `403` An invalid signature, a caller that is not a person, or a device that did not send the command (`code_command_not_sender`). - `404` The session or command does not belong to the caller, or Gateway has no such command (`code_command_not_found`). - `409` A computer already claimed the command (`code_command_not_queued`), or the device is untrusted. - `410` The session was deleted. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | A malformed body. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The session or command does not belong to the caller, or Gateway has no such command (`code_command_not_found`). | | 409 | | A computer already claimed the command (`code_command_not_queued`), or the device is untrusted. | | 410 | | The session was deleted. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/threads/<threadId>/commands/<commandId>/cancel" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "senderDeviceId": "<senderDeviceId>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fthreads%2F%7BthreadId%7D%2Fcommands%2F%7BcommandId%7D%2Fcancel) ## List runner code commands `GET /v1/devices/{runnerDeviceId}/code-commands` Read queued encrypted commands across your runner's sessions Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `runnerDeviceId` | path | string | yes | | ### Responses - `200` Current control or delivery state. (application/json, CodeCommands) - `commands` (array of CodeCommand, required) [at most 20 items] - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 bytes of HPKE ciphertext, base64url without padding. - `sealed` (string, required): Encrypted action payload, base64url without padding. At most 65581 decoded bytes. - `signature` (string, required): Ed25519 signature over the domain-separated command and its routing fields, base64url without padding. - `waits` (boolean): The command may wait for a sleeping computer. Absent means false. - `threadId` (string, required) - `state` ("queued" | "claimed" | "completed" | "rejected" | "expired" | "cancelled", required) - `400` Malformed fields, ciphertext or expiry. - `403` Invalid signature or a caller that is not a person. - `404` The session, command or device does not belong to the caller. - `409` A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. - `410` The session was deleted. - `429` The bounded command mailbox is full. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | Malformed fields, ciphertext or expiry. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | The session, command or device does not belong to the caller. | | 409 | | A device is untrusted, control is disabled or offline, the organization forbids synced content, or a command state conflicts. | | 410 | | The session was deleted. | | 429 | | The bounded command mailbox is full. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/devices/<runnerDeviceId>/code-commands" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdevices%2F%7BrunnerDeviceId%7D%2Fcode-commands) --- <!-- /docs/api/computers --> # Computers ## List computers `GET /v1/computers` List your scoped computers Permission: `sessions.control` (Every member). ### Responses - `200` Current signed state. (application/json, ComputerList) - `computers` (array of ComputerPresence, required) [at most 32 items] - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `computerId` (string (uuid), required) - `runnerDeviceId` (string, required) - `name` (string, required): At most 64 Unicode scalar values and 160 UTF-8 bytes; no control characters. [min length 1; max length 64] - `generation` (integer, required) - `issuedAt` (integer, required) - `expiresAt` (integer, required) - `enabled` (boolean, required) - `capabilities` (array of "changes" | "projects" | "settings" | "start", required) [at most 4 items] - `signature` (string, required) - `serverTime` (integer, required) - `400` Malformed scope, identifier or ciphertext. - `403` Not an owner, current member or valid signer. - `404` No such owned computer, request or device. - `409` Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | Malformed scope, identifier or ciphertext. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | | No such owned computer, request or device. | | 409 | | Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/computers" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcomputers) ## Stream computer events `GET /v1/computers/stream` Your computer requests' and Code commands' new states, live, as server-sent events. Permission: `sessions.control` (Every member). ### Responses - `200` The event stream (text/event-stream, ComputerRequestChanged | CodeCommandChanged) - `403` Not a person, not a current member, or without `sessions.control` (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` More than 8 live streams of yours on this Gateway copy (`control_events_per_person`), or the rate limit (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Too many live streams on this Gateway copy (`control_events_full`): read your receipts instead (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 | | More than 8 live streams of yours on this Gateway copy (`control_events_per_person`), or the rate limit | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Too many live streams on this Gateway copy (`control_events_full`): read your receipts instead | ### Example ```sh curl "$NEXUS_URL/v1/computers/stream" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcomputers%2Fstream) ## Publish computer presence `PUT /v1/computers/{computerId}/presence` Publish signed computer presence without a session Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `computerId` | path | string (uuid) | yes | | ### Request body (application/json, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `computerId` (string (uuid), required) - `runnerDeviceId` (string, required) - `name` (string, required): At most 64 Unicode scalar values and 160 UTF-8 bytes; no control characters. [min length 1; max length 64] - `generation` (integer, required) - `issuedAt` (integer, required) - `expiresAt` (integer, required) - `enabled` (boolean, required) - `capabilities` (array of "changes" | "projects" | "settings" | "start", required) [at most 4 items] - `signature` (string, required) ### Responses - `200` Current signed state. (application/json, ComputerPresence) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `computerId` (string (uuid), required) - `runnerDeviceId` (string, required) - `name` (string, required): At most 64 Unicode scalar values and 160 UTF-8 bytes; no control characters. [min length 1; max length 64] - `generation` (integer, required) - `issuedAt` (integer, required) - `expiresAt` (integer, required) - `enabled` (boolean, required) - `capabilities` (array of "changes" | "projects" | "settings" | "start", required) [at most 4 items] - `signature` (string, required) - `400` Malformed scope, identifier or ciphertext. - `403` Not an owner, current member or valid signer. - `404` No such owned computer, request or device. - `409` Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed scope, identifier or ciphertext. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such owned computer, request or device. | | 409 | | Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/computers/<computerId>/presence" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "version": 1, "scope": { "gateway": "<gateway>", "tenantId": "<tenantId>", "personId": "<personId>" }, "computerId": "<computerId>", "runnerDeviceId": "<runnerDeviceId>", "name": "Platform", "generation": 1, "issuedAt": 1, "expiresAt": 1, "enabled": false, "capabilities": [ "changes" ], "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fcomputers%2F%7BcomputerId%7D%2Fpresence) ## Submit computer request `POST /v1/computers/{computerId}/requests` Submit an encrypted request to your computer Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `computerId` | path | string (uuid) | yes | | ### Request body (application/json, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `computerId` (string (uuid), required) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `generation` (integer, required) - `issuedAt` (integer, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 decoded HPKE bytes; canonical unpadded base64url. - `sealed` (string, required): 29 to 65565 decoded encrypted bytes; canonical unpadded base64url. - `signature` (string, required) ### Responses - `200` Current signed state. (application/json, ComputerRequest) - `envelope` (ComputerRequestEnvelope, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `computerId` (string (uuid), required) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `generation` (integer, required) - `issuedAt` (integer, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 decoded HPKE bytes; canonical unpadded base64url. - `sealed` (string, required): 29 to 65565 decoded encrypted bytes; canonical unpadded base64url. - `signature` (string, required) - `requestHash` (string, required) - `state` ("queued" | "claimed" | "replied" | "expired", required) - `reply` (ComputerReplyEnvelope | null, required) - `serverTime` (integer, required) - `400` Malformed scope, identifier or ciphertext. - `403` Not an owner, current member or valid signer. - `404` No such owned computer, request or device. - `409` Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed scope, identifier or ciphertext. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such owned computer, request or device. | | 409 | | Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/computers/<computerId>/requests" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "version": 1, "scope": { "gateway": "<gateway>", "tenantId": "<tenantId>", "personId": "<personId>" }, "computerId": "<computerId>", "id": "<id>", "senderDeviceId": "<senderDeviceId>", "runnerDeviceId": "<runnerDeviceId>", "generation": 1, "issuedAt": 1, "expiresAt": 1, "lockedKey": "<lockedKey>", "sealed": "<sealed>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcomputers%2F%7BcomputerId%7D%2Frequests) ## List computer requests `GET /v1/computers/{computerId}/requests/inbox` Read at most 20 queued encrypted computer requests Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `computerId` | path | string (uuid) | yes | | ### Responses - `200` Current signed state. (application/json, ComputerInbox) - `requests` (array of ComputerRequest, required) [at most 20 items] - `envelope` (ComputerRequestEnvelope, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `computerId` (string (uuid), required) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `generation` (integer, required) - `issuedAt` (integer, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 decoded HPKE bytes; canonical unpadded base64url. - `sealed` (string, required): 29 to 65565 decoded encrypted bytes; canonical unpadded base64url. - `signature` (string, required) - `requestHash` (string, required) - `state` ("queued" | "claimed" | "replied" | "expired", required) - `reply` (ComputerReplyEnvelope | null, required) - `serverTime` (integer, required) - `serverTime` (integer, required) - `400` Malformed scope, identifier or ciphertext. - `403` Not an owner, current member or valid signer. - `404` No such owned computer, request or device. - `409` Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | Malformed scope, identifier or ciphertext. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such owned computer, request or device. | | 409 | | Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/computers/<computerId>/requests/inbox" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcomputers%2F%7BcomputerId%7D%2Frequests%2Finbox) ## Get computer request `GET /v1/computers/{computerId}/requests/{id}` Reconcile an encrypted computer request after expiry Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `computerId` | path | string (uuid) | yes | | | `id` | path | string (uuid) | yes | | ### Responses - `200` Current signed state. (application/json, ComputerRequest) - `envelope` (ComputerRequestEnvelope, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `computerId` (string (uuid), required) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `generation` (integer, required) - `issuedAt` (integer, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 decoded HPKE bytes; canonical unpadded base64url. - `sealed` (string, required): 29 to 65565 decoded encrypted bytes; canonical unpadded base64url. - `signature` (string, required) - `requestHash` (string, required) - `state` ("queued" | "claimed" | "replied" | "expired", required) - `reply` (ComputerReplyEnvelope | null, required) - `serverTime` (integer, required) - `400` Malformed scope, identifier or ciphertext. - `403` Not an owner, current member or valid signer. - `404` No such owned computer, request or device. - `409` Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | Malformed scope, identifier or ciphertext. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such owned computer, request or device. | | 409 | | Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/computers/<computerId>/requests/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fcomputers%2F%7BcomputerId%7D%2Frequests%2F%7Bid%7D) ## Claim computer request `POST /v1/computers/{computerId}/requests/{id}/claim` Claim a computer request once Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `computerId` | path | string (uuid) | yes | | | `id` | path | string (uuid) | yes | | ### Request body (application/json, required) - `runnerDeviceId` (string, required) - `signature` (string, required) ### Responses - `200` Current signed state. (application/json, ComputerRequestClaimed) - `claimed` (boolean, required) - `request` (ComputerRequest, required) - `envelope` (ComputerRequestEnvelope, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `computerId` (string (uuid), required) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `generation` (integer, required) - `issuedAt` (integer, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 decoded HPKE bytes; canonical unpadded base64url. - `sealed` (string, required): 29 to 65565 decoded encrypted bytes; canonical unpadded base64url. - `signature` (string, required) - `requestHash` (string, required) - `state` ("queued" | "claimed" | "replied" | "expired", required) - `reply` (ComputerReplyEnvelope | null, required) - `serverTime` (integer, required) - `400` Malformed scope, identifier or ciphertext. - `403` Not an owner, current member or valid signer. - `404` No such owned computer, request or device. - `409` Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed scope, identifier or ciphertext. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such owned computer, request or device. | | 409 | | Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/computers/<computerId>/requests/<id>/claim" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "runnerDeviceId": "<runnerDeviceId>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcomputers%2F%7BcomputerId%7D%2Frequests%2F%7Bid%7D%2Fclaim) ## Reply computer request `POST /v1/computers/{computerId}/requests/{id}/reply` Store a signed encrypted reply for the exact sender Permission: `sessions.control` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `computerId` | path | string (uuid) | yes | | | `id` | path | string (uuid) | yes | | ### Request body (application/json, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `computerId` (string (uuid), required) - `requestId` (string (uuid), required) - `requestHash` (string, required) - `runnerDeviceId` (string, required) - `recipientDeviceId` (string, required) - `lockedKey` (string, required) - `sealed` (string, required): 29 to 262173 decoded encrypted bytes; canonical unpadded base64url. - `signature` (string, required) ### Responses - `200` Current signed state. (application/json, ComputerRequest) - `envelope` (ComputerRequestEnvelope, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `computerId` (string (uuid), required) - `id` (string (uuid), required) - `senderDeviceId` (string, required) - `runnerDeviceId` (string, required) - `generation` (integer, required) - `issuedAt` (integer, required) - `expiresAt` (integer, required) - `lockedKey` (string, required): 80 decoded HPKE bytes; canonical unpadded base64url. - `sealed` (string, required): 29 to 65565 decoded encrypted bytes; canonical unpadded base64url. - `signature` (string, required) - `requestHash` (string, required) - `state` ("queued" | "claimed" | "replied" | "expired", required) - `reply` (ComputerReplyEnvelope | null, required) - `serverTime` (integer, required) - `400` Malformed scope, identifier or ciphertext. - `403` Not an owner, current member or valid signer. - `404` No such owned computer, request or device. - `409` Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed scope, identifier or ciphertext. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such owned computer, request or device. | | 409 | | Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/computers/<computerId>/requests/<id>/reply" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "version": 1, "scope": { "gateway": "<gateway>", "tenantId": "<tenantId>", "personId": "<personId>" }, "computerId": "<computerId>", "requestId": "<requestId>", "requestHash": "<requestHash>", "runnerDeviceId": "<runnerDeviceId>", "recipientDeviceId": "<recipientDeviceId>", "lockedKey": "<lockedKey>", "sealed": "<sealed>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fcomputers%2F%7BcomputerId%7D%2Frequests%2F%7Bid%7D%2Freply) ## List phone pairing requests `GET /v1/devices/{inviterDeviceId}/pairing-requests` Read your device pairing relay Permission: `keys.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `inviterDeviceId` | path | string | yes | | ### Responses - `200` Current signed state. (application/json, PhonePairingRequests) - `requests` (array of PhonePairingRequest, required) [at most 20 items] - `envelope` (PhonePairingEnvelope, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `id` (string (uuid), required) - `inviteId` (string (uuid), required) - `inviterDeviceId` (string, required) - `senderDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required) - `sealed` (string, required): 29 to 8221 decoded encrypted bytes. Raw invitation secret occurs only inside this ciphertext. - `signature` (string, required) - `state` ("pending" | "finished", required) - `decision` (PhonePairingDecision): Desktop-signed outcome for an invitation. Approval binds the winning request and sender. Cancellation applies to the entire invitation. The relay receipt can be retried for five minutes after expiry. - `400` Malformed scope, identifier or ciphertext. - `403` Not an owner, current member or valid signer. - `404` No such owned computer, request or device. - `409` Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | | Malformed scope, identifier or ciphertext. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such owned computer, request or device. | | 409 | | Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/devices/<inviterDeviceId>/pairing-requests" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fdevices%2F%7BinviterDeviceId%7D%2Fpairing-requests) ## Submit phone pairing request `POST /v1/devices/{inviterDeviceId}/pairing-requests` Relay an encrypted phone scan proof Permission: `keys.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `inviterDeviceId` | path | string | yes | | ### Request body (application/json, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `id` (string (uuid), required) - `inviteId` (string (uuid), required) - `inviterDeviceId` (string, required) - `senderDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required) - `sealed` (string, required): 29 to 8221 decoded encrypted bytes. Raw invitation secret occurs only inside this ciphertext. - `signature` (string, required) ### Responses - `200` The relay request and its signed decision, when available. (application/json, PhonePairingRequest) - `envelope` (PhonePairingEnvelope, required) - `version` (1, required) - `scope` (ComputerScope, required) - `gateway` (string, required): Normalized Gateway HTTP(S) URL, without trailing slash. - `tenantId` (string, required) - `personId` (string, required) - `id` (string (uuid), required) - `inviteId` (string (uuid), required) - `inviterDeviceId` (string, required) - `senderDeviceId` (string, required) - `expiresAt` (integer, required) - `lockedKey` (string, required) - `sealed` (string, required): 29 to 8221 decoded encrypted bytes. Raw invitation secret occurs only inside this ciphertext. - `signature` (string, required) - `state` ("pending" | "finished", required) - `decision` (PhonePairingDecision): Desktop-signed outcome for an invitation. Approval binds the winning request and sender. Cancellation applies to the entire invitation. The relay receipt can be retried for five minutes after expiry. - `400` Malformed scope, identifier or ciphertext. - `403` Not an owner, current member or valid signer. - `404` No such owned computer, request or device. - `409` The invitation expired or was already used. The request conflicts with an existing entry, or the relay is full. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed scope, identifier or ciphertext. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such owned computer, request or device. | | 409 | | The invitation expired or was already used. The request conflicts with an existing entry, or the relay is full. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/devices/<inviterDeviceId>/pairing-requests" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "version": 1, "scope": { "gateway": "<gateway>", "tenantId": "<tenantId>", "personId": "<personId>" }, "id": "<id>", "inviteId": "<inviteId>", "inviterDeviceId": "<inviterDeviceId>", "senderDeviceId": "<senderDeviceId>", "expiresAt": 1, "lockedKey": "<lockedKey>", "sealed": "<sealed>", "signature": "<signature>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdevices%2F%7BinviterDeviceId%7D%2Fpairing-requests) ## Finish phone pairing request `POST /v1/devices/{inviterDeviceId}/pairing-requests/{id}/finish` Publish the inviting computer’s signed pairing decision Permission: `keys.manage_own` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `inviterDeviceId` | path | string | yes | | | `id` | path | string (uuid) | yes | | ### Request body (application/json) - `decision` (PhonePairingDecision): Desktop-signed outcome for an invitation. Approval binds the winning request and sender. Cancellation applies to the entire invitation. The relay receipt can be retried for five minutes after expiry. ### Responses - `200` The decision or legacy delivery marker is recorded. (application/json, PhonePairingFinished) - `finished` (boolean, required) - `400` Malformed scope, identifier or ciphertext. - `403` Not an owner, current member or valid signer. - `404` No such owned computer, request or device. - `409` Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | Malformed scope, identifier or ciphertext. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such owned computer, request or device. | | 409 | | Stale generation, disabled/offline computer, expired admission, immutable body conflict, unavailable content policy or full bounded mailbox. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/devices/<inviterDeviceId>/pairing-requests/<id>/finish" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "decision": { "state": "approved", "scope": { "gateway": "<gateway>", "tenantId": "<tenantId>", "personId": "<personId>" }, "computerId": "<computerId>", "inviteId": "<inviteId>", "inviterDeviceId": "<inviterDeviceId>", "expiresAt": 1, "requestId": "<requestId>", "senderDeviceId": "<senderDeviceId>", "signature": "<signature>" } }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fdevices%2F%7BinviterDeviceId%7D%2Fpairing-requests%2F%7Bid%7D%2Ffinish) --- <!-- /docs/api/staff --> # Staff > Reads across organizations for Nexus's own people only: a person with a platform role who is marked staff or signs in with a Nexus address. Each read is audited in the caller's organization before it runs. Metadata and counts only, never content. ## List staff users `GET /v1/staff/users` Every person, newest first, with who they are, how they arrived (the sign-up's `org.created`), their organizations, when they were last seen and their figures over the window: calls, tokens, spend, sessions, failed and refused calls. Staff only; audited as `staff.list_viewed`. Permission: `staff.read` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `days` | query | integer | no | Whole UTC days ending today, 1 to 90; default 7 | | `limit` | query | integer | no | People on the page, 1 to 500; default 100 | | `cursor` | query | string | no | The last person's id on the previous page (`nextCursor`) | | `x-nexus-staff-viewer` | header | string | no | The dashboard's signed-in viewer, kept in the audit event as sent; never used for access | ### Responses - `200` OK (application/json, StaffUsersPage) - `window` (StaffWindow, required): Whole UTC days: from inclusive, until exclusive (the end of today). - `from` (string (date-time), required) - `until` (string (date-time), required) - `days` (integer, required) - `users` (array of StaffUserSummary, required) - `id` (string, required) - `email` (string | null, required): Null once erased - `name` (string | null, required) - `createdAt` (string (date-time), required) - `erased` (boolean, required) - `mark` ("staff" | "test" | "demo" | null, required) - `class` ("customer" | "nexus", required) - `signUp` (object | null, required): The personal organization's `org.created`; null for people from before it - `at` (string (date-time)) - `method` (string | null) - `emailDomain` (string | null) - `country` (string | null) - `utmSource` (string | null) - `utmMedium` (string | null) - `utmCampaign` (string | null) - `referrer` (string | null) - `referral` (string | null) - `campaign` (string | null) - `orgs` (array of object, required) - `id` (string, required) - `kind` ("personal" | "company", required) - `name` (string | null, required): Null for a personal organization - `slug` (string | null, required) - `role` ("owner" | "admin" | "member", required) - `class` ("customer" | "nexus", required) - `mark` (string | null, required) - `lastSeenAt` (string (date-time) | null, required): The latest model call, any time, or agent session heartbeat in the window - `totals` (object, required) - `usage` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `refusedCalls` (integer, required) - `failedCalls` (integer, required) - `sessions` (integer, required) - `failedSessions` (integer, required) - `subscription` (StaffSubscriptionUsage | null, required) - `apps` (array of string, required) - `plan` (object, required) - `nexus` ("payg" | "credits" | null, required) - `creditsBoughtUsd` (string | null, required) - `connected` (array of object, required) - `provider` (string, required): The plan's provider: `claude` (Anthropic) or `chatgpt` (OpenAI) - `tier` (string | null, required): The person's latest plan with the provider, from their app (`agent_plans`): `free`, `pro`, `max`, `plus`, `team`, `enterprise` or `unknown`. Null when no session sent one, as with `NEXUS_COLLECT_AGENT_PLAN` off. - `avgSessionMinutes` (integer | null, required): The mean app session in the window from the apps' heartbeat (`timeInApp`'s minutes over its sessions), else the mean length of their agent sessions. Null with neither. - `flag` ("abuse" | "bug" | null, required) - `nextCursor` (string | null, required) - `stats` (object | null, required): The day's tiles, on the first page only; null on a page a cursor names. - `people` (integer, required) - `signedUpToday` (integer, required) - `signedUpDailyAvg7d` (string, required) - `activeToday` (integer, required) - `hitErrorToday` (integer, required) - `collection` (StaffCollection): Current Gateway collection switches. Historical rows can remain available when a switch is disabled. A flag is true only when the signal is kept for everyone; a signal kept for organizations marked staff alone is false and listed in staffOnly. - `activity` (boolean, required) - `agentPlan` (boolean, required) - `clientErrors` (boolean, required) - `signupSource` (boolean, required) - `staffOnly` (array of "activity" | "agentPlan" | "clientErrors"): The signals kept only for organizations marked as staff; omitted when none is. - `400` `days` (`invalid_days`), `limit` (`invalid_limit`) or `cursor` (`invalid_cursor`) is out of range (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `days` (`invalid_days`), `limit` (`invalid_limit`) or `cursor` (`invalid_cursor`) is out of range | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) | ### Example ```sh curl "$NEXUS_URL/v1/staff/users" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fstaff%2Fusers) ## Get staff user `GET /v1/staff/users/{id}` One person: their summary, each day of the window, the apps, models and products they used, their agent sessions by agent and route, calls that did not settle by reason, and their latest failed and refused calls with request ids. Spend counts the organizations the person has left too. Staff only; audited as `staff.person_viewed`. Permission: `staff.read` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The person's id | | `days` | query | integer | no | Whole UTC days ending today, 1 to 90; default 30 | | `x-nexus-staff-viewer` | header | string | no | The dashboard's signed-in viewer, kept in the audit event as sent; never used for access | ### Responses - `200` OK (application/json, StaffUserDetail) - `window` (StaffWindow, required): Whole UTC days: from inclusive, until exclusive (the end of today). - `from` (string (date-time), required) - `until` (string (date-time), required) - `days` (integer, required) - `user` (StaffUserSummary, required) - `id` (string, required) - `email` (string | null, required): Null once erased - `name` (string | null, required) - `createdAt` (string (date-time), required) - `erased` (boolean, required) - `mark` ("staff" | "test" | "demo" | null, required) - `class` ("customer" | "nexus", required) - `signUp` (object | null, required): The personal organization's `org.created`; null for people from before it - `at` (string (date-time)) - `method` (string | null) - `emailDomain` (string | null) - `country` (string | null) - `utmSource` (string | null) - `utmMedium` (string | null) - `utmCampaign` (string | null) - `referrer` (string | null) - `referral` (string | null) - `campaign` (string | null) - `orgs` (array of object, required) - `id` (string, required) - `kind` ("personal" | "company", required) - `name` (string | null, required): Null for a personal organization - `slug` (string | null, required) - `role` ("owner" | "admin" | "member", required) - `class` ("customer" | "nexus", required) - `mark` (string | null, required) - `lastSeenAt` (string (date-time) | null, required): The latest model call, any time, or agent session heartbeat in the window - `totals` (object, required) - `usage` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `refusedCalls` (integer, required) - `failedCalls` (integer, required) - `sessions` (integer, required) - `failedSessions` (integer, required) - `subscription` (StaffSubscriptionUsage | null, required) - `apps` (array of string, required) - `plan` (object, required) - `nexus` ("payg" | "credits" | null, required) - `creditsBoughtUsd` (string | null, required) - `connected` (array of object, required) - `provider` (string, required): The plan's provider: `claude` (Anthropic) or `chatgpt` (OpenAI) - `tier` (string | null, required): The person's latest plan with the provider, from their app (`agent_plans`): `free`, `pro`, `max`, `plus`, `team`, `enterprise` or `unknown`. Null when no session sent one, as with `NEXUS_COLLECT_AGENT_PLAN` off. - `avgSessionMinutes` (integer | null, required): The mean app session in the window from the apps' heartbeat (`timeInApp`'s minutes over its sessions), else the mean length of their agent sessions. Null with neither. - `flag` ("abuse" | "bug" | null, required) - `daily` (array of object, required) - `day` (string (date), required) - `usage` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `refusedCalls` (integer, required) - `failedCalls` (integer, required) - `sessions` (integer, required) - `subscription` (StaffSubscriptionUsage | null, required) - `apps` (array of object, required) - `app` (string, required) - `usage` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `models` (array of object, required) - `model` (string, required) - `usage` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `products` (array of object, required) - `product` (string, required) - `usage` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `agents` (array of object, required) - `agent` (string, required) - `via` (string, required) - `sessions` (integer, required) - `failed` (integer, required) - `interrupted` (integer, required) - `lost` (integer, required) - `errors` (array of object, required) - `status` ("failed" | "refused" | "released", required) - `reason` (string | null, required) - `calls` (integer, required) - `lastAt` (string (date-time), required) - `recentFailures` (array of object, required) - `id` (string, required) - `at` (string (date-time), required) - `orgId` (string, required) - `status` ("failed" | "refused", required) - `model` (string, required) - `provider` (string, required) - `product` (string, required) - `app` (string, required) - `reason` (string | null, required) - `requestId` (string | null, required) - `sessions` (array of object, required) - `id` (string, required) - `startedAt` (string (date-time), required) - `endedAt` (string (date-time) | null, required) - `lengthMinutes` (integer, required) - `app` (string, required) - `mode` ("code" | "chat", required) - `agent` (string | null, required) - `via` (string, required) - `tokens` (integer, required) - `gatewayTokens` (integer, required) - `subscriptionTokens` (integer, required) - `failedCalls` (integer, required) - `status` (string, required) - `journey` (array of object, required): Each step's first time, null until it happens. For an erased person, the steps the audit trail records are null. - `step` (string, required) - `label` (string, required) - `at` (string (date-time) | null, required) - `ok` (boolean, required) - `activation` (object | null, required): The person's Desktop sign-ins and chats, from records the Gateway already keeps; null for an erased person. - `firstDesktopAt` (string (date-time) | null, required): The first Desktop sign-in, any time, or the first Desktop model call in the window, whichever is earlier. - `desktopInstalls` (integer, required): Distinct machines signed in on Desktop, any time, by the sign-in label's host. - `firstChatAt` (string (date-time) | null, required): The first chat the person started, any time. - `chatsStarted` (integer, required): Chats started in the window. - `chatsAnswered` (integer, required): Chats with at least one answer, among those whose first call is in the window. - `exitsNotMeasured` (string, required): Why exits are not shown. - `staffViews` (object, required) - `last30Days` (integer, required) - `codeChat` (object, required) - `codeMinutes` (integer, required) - `chatMinutes` (integer, required) - `estimated` (boolean, required) - `devices` (array of object, required) - `app` (string, required) - `version` (string | null, required) - `os` (string | null, required): The OS the heartbeat names most for this app version in the window. Null with no heartbeat for it. - `minutes` (integer | null, required): Active minutes on this app version in the window, from the heartbeat. Null with none. - `calls` (integer, required): Model calls. 0 for an app version only the heartbeat names. - `signals` (array of StaffSignal, required) - `kind` (string, required) - `kindOf` ("bug" | "abuse", required) - `value` (string, required) - `threshold` (string, required) - `since` (string (date-time) | null, required): For review candidates, the observed threshold-trigger time; otherwise the first counting event in the activity window. - `baselineMultiple` (string | null, required) - `reason` (string, required) - `evidence` (StaffReviewEvidence) - `from` (string (date-time), required) - `until` (string (date-time), required) - `observedAt` (string (date-time), required) - `scope` (string, required) - `counts` (StaffReviewCounts, required) - `total` (integer, required) [min 0] - `fresh` (integer, required) [min 0] - `matured` (integer, required) [min 0] - `evaluated` (integer, required) [min 0] - `unknown` (integer, required) [min 0] - `excluded` (integer, required) [min 0] - `qualified` (integer, required) [min 0] - `accounts` (array of object, required) - `userId` (string, required) - `welcomeGrantMicros` (string, required): Exact micro-dollar integer. Never a reservation hold. [pattern ^[0-9]+$] - `welcomeSpentMicros` (string, required): Exact micro-dollar integer. Never a reservation hold. [pattern ^[0-9]+$] - `lastCall` (string (date-time), required) - `organizationCreatedAt` (string (date-time), required) - `rules` (array of StaffRule, required) - `kind` (string, required) - `kindOf` ("bug" | "abuse", required) - `subject` ("person" | "org" | "domain" | "network", required) - `firesWhen` (string, required) - `firing` (any): A count on the attention list; a boolean on a person's page - `timeInApp` (object | null, required): Active minutes and app sessions in the window, from the apps' heartbeat. Null with none, as with `NEXUS_COLLECT_ACTIVITY` off. - `minutes` (integer, required): At most one a minute per organization and app - `sessions` (integer, required): One per organization, app and UTC day with an active minute - `activityByHour` (array of object | null, required): Active minutes in each of the last 24 whole UTC hours by surface, oldest first. A day row that spans several hours is spread over them by time. Null with no heartbeat in them. - `hour` (string (date-time), required): The hour's start, UTC - `code` (integer, required) - `chat` (integer, required) - `other` (integer, required): Wiki, Review, Pages and every other screen - `clientErrors` (array of object | null, required): The newest 50 errors the apps caught since the window's start (kept 30 days), newest first. Never a message. Null with none, as with `NEXUS_COLLECT_CLIENT_ERRORS` off. - `eventId` (string, required): `cer_…` - `at` (string (date-time), required) - `app` (string, required) - `version` (string, required) - `os` (string, required) - `kind` ("crash" | "render" | "network" | "sign_in" | "update" | "agent" | "storage" | "other", required) - `component` (string, required): The app's own name for the place - `code` (string, required): The app's own error code - `fatal` (boolean, required): The app or the window ended - `httpErrors` (object | null, required): The 5xx and 429 answers the person met in the window, on any route: sign-in, Nexus UI and model calls (`http_error_days`). Null with none. The counter has no switch. - `serverErrors` (integer, required): Answers with a status from 500 to 599 - `rateLimited` (integer, required): Answers with status 429 - `byFamily` (array of object, required): By route family and status, most answers first - `family` (string, required): The route family, as the `family` label on `/metrics` - `status` (integer, required) - `count` (integer, required) - `lastDay` (string (date), required): The last UTC day with one - `collection` (StaffCollection): Current Gateway collection switches. Historical rows can remain available when a switch is disabled. A flag is true only when the signal is kept for everyone; a signal kept for organizations marked staff alone is false and listed in staffOnly. - `activity` (boolean, required) - `agentPlan` (boolean, required) - `clientErrors` (boolean, required) - `signupSource` (boolean, required) - `staffOnly` (array of "activity" | "agentPlan" | "clientErrors"): The signals kept only for organizations marked as staff; omitted when none is. - `clientErrorGroups` (StaffClientErrorGroups): Current UTC calendar day, partial at observedAt. Measured reads all retained daily counters; it does not establish client reporting coverage. Data remains readable while collection is off. Truncation is explicit. Person detail selects groups containing that person, while counts remain global. - `state` ("measured" | "unavailable", required) - `collectionEnabled` (boolean | null, required) - `window` (object, required) - `from` (string (date-time), required) - `until` (string (date-time), required) - `observedAt` (string (date-time), required) - `minimumPeople` (3, required) - `groupLimit` (50, required) - `peopleLimit` (20, required) - `groupsTruncated` (boolean, required) - `groups` (array of StaffClientErrorGroup, required) [at most 50 items] - `id` (string, required) - `app` (string, required) - `appVersion` (string, required) - `os` (string, required) - `kind` (string, required) - `component` (string, required) - `code` (string, required) - `affectedPeople` (integer, required) [min 0] - `errors` (integer, required) [min 0] - `fatalErrors` (integer, required) [min 0] - `lastAt` (string (date-time), required) - `people` (array of string, required) [at most 20 items] - `peopleTruncated` (boolean, required) - `referredBy` (object | null, required): Who referred the person, from their row in `referrals`. Ids only, never a name or an email. Null when nobody did, and for an erased person. - `kind` ("person" | "campaign", required) - `userId` (string | null, required): The referrer's user id, for a link to their staff page; null for a campaign. - `campaign` (string | null, required): The campaign's label; null for a person. - `at` (string (date-time) | null, required): When the sign-up recorded the referral; null on rows from before it was kept. - `referred` (object, required): The people the person referred: empty for an erased person. - `total` (integer, required): Everyone they referred, past the 50 listed too. [min 0] - `people` (array of object, required): The newest 50 of them, oldest first. Ids only, never a name or an email. [at most 50 items] - `userId` (string, required) - `signedUpAt` (string (date-time), required): When their sign-up recorded the referral. - `erased` (boolean, required): Erased, or no longer on record: their page shows nothing of theirs. - `firstCallAt` (string (date-time) | null, required): Their first model call in any of their organizations; null before one, and for an erased person. - `paidAt` (string (date-time) | null, required): When their personal organization first paid Nexus with a credit purchase of at least the reward's minimum; null before. - `reward` ("pending" | "rewarded" | "not_rewarded", required): The referrer's reward for them, as GET /v1/referrals shows the referrer. - `400` `days` is out of range (`invalid_days`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No such person (`unknown_person`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `days` is out of range (`invalid_days`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No such person (`unknown_person`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) | ### Example ```sh curl "$NEXUS_URL/v1/staff/users/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fstaff%2Fusers%2F%7Bid%7D) ## Get staff attention `GET /v1/staff/attention` People, organizations, sign-up domains and apps to look at now: the bug and abuse rules that fire over the last 24 hours against the 7 days before, each with its value, threshold, start and baseline multiple, every rule with how many it fires for, and what the data cannot measure yet. Staff only; audited as `staff.list_viewed`. Permission: `staff.read` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-staff-viewer` | header | string | no | The dashboard's signed-in viewer, kept in the audit event as sent; never used for access | ### Responses - `200` OK (application/json, StaffAttention) - `generatedAt` (string (date-time), required) - `window` (object, required) - `from` (string (date-time), required) - `until` (string (date-time), required) - `baseline` (object, required) - `from` (string (date-time), required) - `until` (string (date-time), required) - `abuse` (array of object, required) - `subject` (object, required) - `type` ("person" | "org" | "domain" | "app" | "network", required) - `id` (string, required) - `label` (string | null, required) - `class` ("customer" | "nexus" | null, required) - `createdAt` (string (date-time) | null, required) - `signals` (array of StaffSignal, required) - `kind` (string, required) - `kindOf` ("bug" | "abuse", required) - `value` (string, required) - `threshold` (string, required) - `since` (string (date-time) | null, required): For review candidates, the observed threshold-trigger time; otherwise the first counting event in the activity window. - `baselineMultiple` (string | null, required) - `reason` (string, required) - `evidence` (StaffReviewEvidence) - `from` (string (date-time), required) - `until` (string (date-time), required) - `observedAt` (string (date-time), required) - `scope` (string, required) - `counts` (StaffReviewCounts, required) - `total` (integer, required) [min 0] - `fresh` (integer, required) [min 0] - `matured` (integer, required) [min 0] - `evaluated` (integer, required) [min 0] - `unknown` (integer, required) [min 0] - `excluded` (integer, required) [min 0] - `qualified` (integer, required) [min 0] - `accounts` (array of object, required) - `userId` (string, required) - `welcomeGrantMicros` (string, required): Exact micro-dollar integer. Never a reservation hold. [pattern ^[0-9]+$] - `welcomeSpentMicros` (string, required): Exact micro-dollar integer. Never a reservation hold. [pattern ^[0-9]+$] - `lastCall` (string (date-time), required) - `organizationCreatedAt` (string (date-time), required) - `detail` (string | null, required) - `people` (array of string, required): Explicit affected user IDs, including referred people for personal-referrer findings. - `bugs` (array of object, required) - `subject` (object, required) - `type` ("person" | "org" | "domain" | "app" | "network", required) - `id` (string, required) - `label` (string | null, required) - `class` ("customer" | "nexus" | null, required) - `createdAt` (string (date-time) | null, required) - `signals` (array of StaffSignal, required) - `kind` (string, required) - `kindOf` ("bug" | "abuse", required) - `value` (string, required) - `threshold` (string, required) - `since` (string (date-time) | null, required): For review candidates, the observed threshold-trigger time; otherwise the first counting event in the activity window. - `baselineMultiple` (string | null, required) - `reason` (string, required) - `evidence` (StaffReviewEvidence) - `from` (string (date-time), required) - `until` (string (date-time), required) - `observedAt` (string (date-time), required) - `scope` (string, required) - `counts` (StaffReviewCounts, required) - `total` (integer, required) [min 0] - `fresh` (integer, required) [min 0] - `matured` (integer, required) [min 0] - `evaluated` (integer, required) [min 0] - `unknown` (integer, required) [min 0] - `excluded` (integer, required) [min 0] - `qualified` (integer, required) [min 0] - `accounts` (array of object, required) - `userId` (string, required) - `welcomeGrantMicros` (string, required): Exact micro-dollar integer. Never a reservation hold. [pattern ^[0-9]+$] - `welcomeSpentMicros` (string, required): Exact micro-dollar integer. Never a reservation hold. [pattern ^[0-9]+$] - `lastCall` (string (date-time), required) - `organizationCreatedAt` (string (date-time), required) - `detail` (string | null, required) - `people` (array of string, required): Explicit affected user IDs, including referred people for personal-referrer findings. - `rules` (array of StaffRule, required) - `kind` (string, required) - `kindOf` ("bug" | "abuse", required) - `subject` ("person" | "org" | "domain" | "network", required) - `firesWhen` (string, required) - `firing` (any): A count on the attention list; a boolean on a person's page - `notMeasured` (array of object, required) - `kind` (string, required) - `why` (string, required) - `clientErrorGroups` (StaffClientErrorGroups): Current UTC calendar day, partial at observedAt. Measured reads all retained daily counters; it does not establish client reporting coverage. Data remains readable while collection is off. Truncation is explicit. Person detail selects groups containing that person, while counts remain global. - `state` ("measured" | "unavailable", required) - `collectionEnabled` (boolean | null, required) - `window` (object, required) - `from` (string (date-time), required) - `until` (string (date-time), required) - `observedAt` (string (date-time), required) - `minimumPeople` (3, required) - `groupLimit` (50, required) - `peopleLimit` (20, required) - `groupsTruncated` (boolean, required) - `groups` (array of StaffClientErrorGroup, required) [at most 50 items] - `id` (string, required) - `app` (string, required) - `appVersion` (string, required) - `os` (string, required) - `kind` (string, required) - `component` (string, required) - `code` (string, required) - `affectedPeople` (integer, required) [min 0] - `errors` (integer, required) [min 0] - `fatalErrors` (integer, required) [min 0] - `lastAt` (string (date-time), required) - `people` (array of string, required) [at most 20 items] - `peopleTruncated` (boolean, required) - `reviewCoverage` (array of StaffReviewCoverage): Rule-specific evaluated, unknown, excluded and fresh cohorts. Absent on older Gateway releases. - `total` (integer, required) [min 0] - `fresh` (integer, required) [min 0] - `matured` (integer, required) [min 0] - `evaluated` (integer, required) [min 0] - `unknown` (integer, required) [min 0] - `excluded` (integer, required) [min 0] - `qualified` (integer, required) [min 0] - `kind` (string, required) - `from` (string (date-time), required) - `until` (string (date-time), required) - `note` (string, required) - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) | ### Example ```sh curl "$NEXUS_URL/v1/staff/attention" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fstaff%2Fattention) ## Get staff metrics `GET /v1/staff/metrics` Company numbers over a window, customers next to Nexus: people, daily, weekly and monthly actives, the last 7 days' sign-up funnel and activation, today's sources and sign-in methods, sign-ups per day, and usage per day, model, app and organization (the top 50 by spend, the rest summed). Counts only, no content. Staff only; audited as `staff.list_viewed`. Permission: `staff.read` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `days` | query | integer | no | Whole UTC days ending today, 1 to 90; default 30 | | `scope` | query | "all" \| "customers" | no | People included in every figure. all preserves the existing view; customers excludes Nexus people, including their activity in other organizations. | | `x-nexus-staff-viewer` | header | string | no | The dashboard's signed-in viewer, kept in the audit event as sent; never used for access | ### Responses - `200` OK (application/json, StaffMetrics) - `window` (StaffWindow, required): Whole UTC days: from inclusive, until exclusive (the end of today). - `from` (string (date-time), required) - `until` (string (date-time), required) - `days` (integer, required) - `people` (object, required) - `total` (integer, required) - `customers` (integer, required) - `nexus` (integer, required) - `active` (object, required): People with a model call or an agent session today, in the last 7 days and in the last 30. - `dau` (integer, required) - `wau` (integer, required) - `mau` (integer, required) - `activation` (object, required): The share of the last 7 days' sign-ups with a model call or an agent session within a day; null with no sign-up. - `withinOneDayShare` (number | null, required) [min 0; max 1] - `funnel` (array of object, required): The last 7 days' sign-ups, step by step. The steps are not nested. `desktop_signed_in` is a Desktop sign-in or Desktop model call, `chat_started` a chat they created and `chat_answered` a chat with at least one answer. - `step` ("signed_up" | "connected_app" | "first_session" | "first_gateway_call" | "back_day_2" | "desktop_signed_in" | "chat_started" | "chat_answered", required) - `label` (string, required) - `people` (integer, required) - `funnelDetail` (object, required): The funnel's Desktop and chat records for the same sign-ups, from records the Gateway already keeps. Exits are not counted. - `desktopInstalls` (integer, required): Distinct machines they signed in on Desktop, by the sign-in label's host. - `chatsStarted` (integer, required): Chats they started in the last 7 days. - `chatsAnswered` (integer, required): Their chats with at least one answer, among those whose first call is in the last 7 days. - `exitsNotMeasured` (string, required): Why exits are not counted. - `sources` (array of object | null, required): Today's sign-ups by referrer and campaign, a referral, or `direct`. Null when today has sign-ups and none says where it came from (`NEXUS_SIGNUP_SOURCE` off). - `source` (string, required) - `signUps` (integer, required) - `sourcesNotCollected` (integer, required): Today's sign-ups that say nothing of where they came from: no method, country, UTM value, referrer or referral. Never counted as `direct`. - `methods` (object, required): Today's sign-ups: the share by sign-in method and with a work email; null with no sign-up. The method shares are null too when no sign-up today names its method (`NEXUS_SIGNUP_SOURCE` off). - `google` (number | null, required) [min 0; max 1] - `github` (number | null, required) [min 0; max 1] - `email` (number | null, required) [min 0; max 1] - `workDomain` (number | null, required) [min 0; max 1] - `signUps` (object, required) - `daily` (array of object, required) - `day` (string (date), required) - `customers` (integer, required) - `nexus` (integer, required) - `totals` (object, required) - `customers` (integer, required) - `nexus` (integer, required) - `usage` (object, required) - `daily` (array of object, required) - `day` (string (date), required) - `customers` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `nexus` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `byModel` (array of object, required) - `model` (string, required) - `customers` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `nexus` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `byApp` (array of object, required) - `app` (string, required) - `customers` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `nexus` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `bySurface` (array of object): ByApp with Nexus for desktop's GPUI build apart (`desktop-gpui`, by the client it named). `unknown` is a record that kept no app. - `surface` (string, required) - `customers` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `nexus` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `byOrg` (array of object, required): The top 50 organizations by spend. - `orgId` (string, required) - `kind` ("personal" | "company", required) - `name` (string | null, required) - `class` ("customer" | "nexus", required) - `topModel` (string | null, required) - `people` (integer, required) - `usage` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `otherOrgs` (object, required) - `orgs` (integer, required) - `usage` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `subscription` (object | null, required): What people's own plans reported; null where the store keeps no subscription days. - `codeChat` (object, required) - `codeMinutes` (integer, required) - `chatMinutes` (integer, required) - `estimated` (boolean, required) - `timeInApp` (object | null, required): Time in the apps over the window, everyone's, from the heartbeat. Null with none, as with `NEXUS_COLLECT_ACTIVITY` off. - `avgSessionMinutes` (integer, required): Active minutes over app sessions - `minutes` (integer, required) - `sessions` (integer, required): One per person, organization, app and UTC day with an active minute - `people` (integer, required): People with an active minute - `codeShare` (number, required): Share of the minutes on Code, two decimals [min 0; max 1] - `chatShare` (number, required): Share of the minutes on Chat, two decimals [min 0; max 1] - `otherShare` (number, required): Share of the minutes on every other surface, two decimals [min 0; max 1] - `noCallYet` (integer, required): People with an active minute and no model call ever - `cliDownloads` (object | null): The native CLI's downloads through this Gateway (`GET /cli/nexus-<target>`) over the window, the same in either scope. Aggregates only: no person, address, key or user agent. Null without a database. - `total` (integer, required) - `daily` (array of object, required): Every day of the window, 0 included. - `day` (string (date), required) - `count` (integer, required) - `byTarget` (array of object, required): Most first. - `target` (string, required) - `count` (integer, required) - `byVersion` (array of object, required): Most first. - `version` (string, required) - `count` (integer, required) - `ossInstalls` (object | null): The open-source desktop app's active installs over the window, from its opt-in `daily_active`, and the live registered fork clients. The same in either scope: counts only, no install ID. Null without a database. - `daily` (array of object, required): Every day of the window, 0 included. - `day` (string (date), required) - `installs` (integer, required): Installs that sent `daily_active` for the day - `signedIn` (integer, required): Of those, the installs signed in to Nexus Cloud that day - `registeredForks` (integer, required): Registered fork clients not revoked, now - `scope` ("all" | "customers", required): The scope applied to every figure in this response. - `collection` (StaffCollection): Current Gateway collection switches. Historical rows can remain available when a switch is disabled. A flag is true only when the signal is kept for everyone; a signal kept for organizations marked staff alone is false and listed in staffOnly. - `activity` (boolean, required) - `agentPlan` (boolean, required) - `clientErrors` (boolean, required) - `signupSource` (boolean, required) - `staffOnly` (array of "activity" | "agentPlan" | "clientErrors"): The signals kept only for organizations marked as staff; omitted when none is. - `retention` (StaffRetention, required): Recorded account-creation cohorts backed by personal org.created audit evidence in the selected window, at most 90 days. Uses User.createdAt, never organization creation or guessed age. Current Company classification applies across all organizations. Erased identities stay in All; Customers reports unresolved erased classifications. Week 0 is activation during the creation week; Weeks 1–4 are later calendar weeks beginning Monday 00:00 UTC. Active means non-refused recorded model use or observed agent-session start/last heartbeat. No interpolation, app-open inference or future observations. Reuses existing bounded reads under the 20-second staff deadline. No collection watermark proves historical completeness; missing identities, dates and evidence remain explicit. - `generatedAt` (string (date-time), required) - `from` (string (date-time), required) - `until` (string (date-time), required) - `scope` ("all" | "customers", required) - `period` ("calendar_week_monday_utc", required) - `observedFrom` (string (date-time) | null, required): Earliest evidenced account-creation time in this bounded read and scope. Unresolved erased classifications do not establish Customers' boundary. Not a historical completeness watermark. - `unlinkedSignUpEvents` (integer, required): Distinct personal organizations with an audit event but no usable identity/date. Cohort and scope are unknown, so all denominators are unavailable. [min 0] - `olderAccountEvents` (integer, required): Personal-organization events for accounts created before the read; never assigned new ages. [min 0] - `cohorts` (array of StaffRetentionCohort, required) - `from` (string (date-time), required) - `until` (string (date-time), required) - `cohortComplete` (boolean, required) - `knownSignUps` (integer, required): Evidenced immutable identities in this scope, once across all organizations. [min 0] - `erasedSignUps` (integer, required): Evidenced erased identities still included in this cohort. [min 0] - `missingEvidencePeople` (integer, required): In-scope registry identities created in this week without personal audit evidence inside the read. [min 0] - `unclassifiedPeople` (integer, required): Erased identities whose Customer/Nexus classification is unavailable for Customers. [min 0] - `denominator` (integer | null, required) [min 0] - `periods` (array of StaffRetentionPeriod, required) [at most 5 items] - `week` (integer, required) [min 0; max 4] - `from` (string (date-time), required) - `until` (string (date-time), required) - `state` ("observed" | "empty" | "immature" | "unavailable", required) - `activePeople` (integer | null, required) [min 0] - `share` (number | null, required) [min 0; max 1] - `unknownCreationDatePeople` (integer, required): Eligible registry identities with an unparseable recorded creation date. No cohort is assignable, so all denominators in this scope are unavailable. [min 0] - `peopleInsights` (StaffPeopleInsights, required): Current-scope operational aggregates. Unknown and erased identities are separate from known people. Rankings carry no person identity. - `newDaily` (array of StaffPeopleDay, required) - `day` (string (date), required) - `customers` (integer, required) [min 0] - `nexus` (integer, required) [min 0] - `unknown` (integer, required) [min 0] - `activeDaily` (array of StaffPeopleDay, required) - `day` (string (date), required) - `customers` (integer, required) [min 0] - `nexus` (integer, required) [min 0] - `unknown` (integer, required) [min 0] - `activeWeekly` (array of StaffPeopleWeek, required) - `from` (string (date-time), required) - `until` (string (date-time), required) - `complete` (boolean, required) - `customers` (integer, required) [min 0] - `nexus` (integer, required) [min 0] - `unknown` (integer, required) [min 0] - `byOrg` (array of StaffOrgPeople, required) - `orgId` (string, required) - `name` (string, required) - `class` ("customer" | "nexus", required) - `members` (integer, required) [min 0] - `active` (integer, required) [min 0] - `unresolvedMembers` (integer, required) [min 0] - `otherOrgs` (integer, required) [min 0] - `personalOnly` (object, required) - `customers` (object, required) - `members` (integer, required) [min 0] - `active` (integer, required) [min 0] - `nexus` (object, required) - `members` (integer, required) [min 0] - `active` (integer, required) [min 0] - `topBySpend` (array of StaffTopPerson, required) [at most 10 items] - `rank` (integer, required) [min 1] - `class` ("customer" | "nexus", required) - `orgs` (integer, required) [min 0] - `usage` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `topByCalls` (array of StaffTopPerson, required) [at most 10 items] - `rank` (integer, required) [min 1] - `class` ("customer" | "nexus", required) - `orgs` (integer, required) [min 0] - `usage` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `unattributed` (object, required) - `customers` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `nexus` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `unknownPerson` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `erasedPerson` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `unknownCreationDatePeople` (integer, required) [min 0] - `cohortFunnel` (StaffCohortFunnel, required): Monday UTC cohorts. First accepted means a non-refused call on days 0 through 6. Day two is exactly the UTC date two days after creation, with a prior accepted call. Observed counts are lower bounds while follow-up remains open. Each stage has a final denominator only after its own calendar dates and evidence are complete. - `period` ("calendar_week_monday_utc", required) - `scope` ("all" | "customers", required) - `firstCallDays` (7, required) - `returnDay` (2, required) - `weeks` (array of StaffCohortFunnelWeek, required) - `from` (string (date-time), required) - `until` (string (date-time), required) - `evidencedSignUps` (integer, required) [min 0] - `denominator` (integer | null, required) [min 0] - `firstAcceptedCalls` (integer, required) [min 0] - `day2Returns` (integer, required) [min 0] - `state` ("observed" | "partial_week" | "immature" | "missing_evidence" | "ambiguous_call_time", required) - `day2Eligible` (integer, required) [min 0] - `day2Denominator` (integer | null, required) [min 0] - `ambiguousCallPeople` (integer, required) [min 0] - `unlinkedSignUpEvents` (integer, required) [min 0] - `unknownCreationDatePeople` (integer, required) [min 0] - `400` `days` is out of range (`invalid_days`) or `scope` is unknown (`invalid_scope`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `days` is out of range (`invalid_days`) or `scope` is unknown (`invalid_scope`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) | ### Example ```sh curl "$NEXUS_URL/v1/staff/metrics" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fstaff%2Fmetrics) ## Get staff models `GET /v1/staff/models` Tokens by model over chosen UTC days, every organization's, customers next to Nexus: calls, prompt and completion tokens and spend per model, over the range and per day. Refused calls add nothing. Counts only, no content. Staff only; audited as `staff.list_viewed`. Permission: `staff.read` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `from` | query | string (date) | yes | The first UTC day, YYYY-MM-DD, inclusive | | `to` | query | string (date) | no | The last UTC day, YYYY-MM-DD, inclusive; default today. At most 90 days after from, and not after today | | `scope` | query | "all" \| "customers" | no | People included. all counts everyone; customers excludes Nexus people, including their calls in other organizations. | | `x-nexus-staff-viewer` | header | string | no | The dashboard's signed-in viewer, kept in the audit event as sent; never used for access | ### Responses - `200` OK (application/json, StaffModels) - `window` (StaffWindow, required): Whole UTC days: from inclusive, until exclusive (the end of today). - `from` (string (date-time), required) - `until` (string (date-time), required) - `days` (integer, required) - `scope` ("all" | "customers", required) - `models` (array of object, required): Most tokens first. - `model` (string, required) - `customers` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `nexus` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `daily` (array of object, required): Every day of the window, a day with no call included. - `day` (string (date), required) - `customers` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `nexus` (StaffUsage, required): Settled, failed and released calls. Refused calls are counted apart. `spendUsd` is the ledger's cost at the provider, as a decimal string, and null when no call was made. - `calls` (integer, required) - `promptTokens` (integer, required) - `completionTokens` (integer, required) - `tokens` (integer, required) - `spendUsd` (string | null, required) [pattern ^-?[0-9]+\.[0-9]{6}$] - `400` `from` or `to` is missing, malformed, reversed, after today or more than 90 days apart (`invalid_range`), or `scope` is unknown (`invalid_scope`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | `from` or `to` is missing, malformed, reversed, after today or more than 90 days apart (`invalid_range`), or `scope` is unknown (`invalid_scope`) | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) | ### Example ```sh curl "$NEXUS_URL/v1/staff/models?from=2026-10-01" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fstaff%2Fmodels) ## Get staff live `GET /v1/staff/live` The live view: people active in the last 5 minutes and by app, people active today, running agent sessions, tokens and failed calls a minute, and today's sign-ups with how they arrived (no email, no id). Staff only; audited as `staff.list_viewed`. Permission: `staff.read` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-staff-viewer` | header | string | no | The dashboard's signed-in viewer, kept in the audit event as sent; never used for access | ### Responses - `200` OK (application/json, StaffLive) - `generatedAt` (string (date-time), required) - `activeNow` (object, required): People with a model call, or an agent session started in the last 24 hours, heard in the last 5 minutes. - `people` (integer, required) - `byApp` (array of object, required) - `app` (string, required) - `people` (integer, required) - `activeToday` (integer, required) - `sessionsRunning` (integer, required): Running agent sessions that started in the last 24 hours. - `tokensPerMinute` (integer, required) - `errorsPerMinute` (number, required): Failed model calls a minute over the last 5 minutes, one decimal. [min 0] - `signUps` (object, required) - `lastHour` (integer, required) - `today` (integer, required) - `latest` (array of object, required): Today's 10 latest sign-ups: how they arrived, and the ids that link the person and their referrer, never a name or an email. - `at` (string (date-time), required) - `userId` (string | null, required): The person who signed up, for a link to their staff page; null when the event names nobody. - `referrerUserId` (string | null, required): The person whose referral code the sign-up carried, from `referrals`; null for a campaign's code or no code. - `method` (string | null, required) - `referrer` (string | null, required) - `campaign` (string | null, required) - `country` (string | null, required) - `workDomain` (boolean, required) - `inApp` (object | null, required): People whose app counted an active minute in the last 2 minutes, from the heartbeat. Null with nobody, as with `NEXUS_COLLECT_ACTIVITY` off. - `people` (integer, required) - `byApp` (array of object, required): People per app, most first - `app` (string, required) - `people` (integer, required) - `noCallYet` (integer, required): Of them, people with no model call ever - `collection` (StaffCollection): Current Gateway collection switches. Historical rows can remain available when a switch is disabled. A flag is true only when the signal is kept for everyone; a signal kept for organizations marked staff alone is false and listed in staffOnly. - `activity` (boolean, required) - `agentPlan` (boolean, required) - `clientErrors` (boolean, required) - `signupSource` (boolean, required) - `staffOnly` (array of "activity" | "agentPlan" | "clientErrors"): The signals kept only for organizations marked as staff; omitted when none is. - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) | ### Example ```sh curl "$NEXUS_URL/v1/staff/live" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fstaff%2Flive) ## Get staff revenue `GET /v1/staff/revenue` Customer ledger fees, billed usage and credits for every closed billing day, with recurring subscriptions from Stripe. Missing sources carry errors. Staff only; audited before the read. Permission: `staff.read` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-staff-viewer` | header | string | no | The dashboard's signed-in viewer, kept in the audit event as sent; never used for access | ### Responses - `200` OK (application/json, StaffRevenue) - `scope` ("customers", required) - `billingFrom` (string (date), required) - `window` (StaffWindow, required): Whole UTC days: from inclusive, until exclusive (the end of today). - `from` (string (date-time), required) - `until` (string (date-time), required) - `days` (integer, required) - `provisional` (boolean, required) - `ledgerError` (object | null, required) - `code` (string, required) - `reason` (string, required) - `daily` (array of object, required) - `day` (string (date), required) - `feeUsd` (string | null, required): Exact USD; null on an empty or unknown financial day. [pattern ^\d+\.\d{6}$] - `billedUsd` (string | null, required): Exact USD; null on an empty or unknown financial day. [pattern ^\d+\.\d{6}$] - `creditsUsd` (string | null, required): Exact USD; null on an empty or unknown financial day. [pattern ^\d+\.\d{6}$] - `freeStartUsd` (string | null, required): Exact USD; null on an empty or unknown financial day. [pattern ^\d+\.\d{6}$] - `ledgerError` (string | null, required) - `recurring` (object, required) - `mrrUsd` (string | null, required): Exact monthly USD from mapped customer subscriptions; null when Stripe or a subscription price is unavailable. [pattern ^\d+\.\d{6}$] - `contractedArrUsd` (string | null, required): Exact annual USD from mapped customer subscriptions; null when Stripe, subscription prices, or signed contract prices are unavailable. [pattern ^\d+\.\d{6}$] - `subscriptions` (integer, required) [min 0] - `unpricedContracts` (integer, required) [min 0] - `recurringError` (string | null, required) - `400` Query windows are unsupported (`unsupported_window`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Neither financial source succeeded (`executive_sources_failed`). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Both money sources are unconfigured (`executive_not_configured`), audit failed (`staff_audit_unavailable`), or the read exceeded 20 s (`staff_read_timeout`). (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 | | Query windows are unsupported (`unsupported_window`). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | Neither financial source succeeded (`executive_sources_failed`). | | 503 | | Both money sources are unconfigured (`executive_not_configured`), audit failed (`staff_audit_unavailable`), or the read exceeded 20 s (`staff_read_timeout`). | ### Example ```sh curl "$NEXUS_URL/v1/staff/revenue" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fstaff%2Frevenue) ## Get staff executive `GET /v1/staff/executive` Customer token, signup and company history since October 2026, and observed agent adoption. Closed UTC days; staff only; audited. Permission: `staff.read` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-staff-viewer` | header | string | no | The dashboard's signed-in viewer, kept in the audit event as sent; never used for access | ### Responses - `200` OK (application/json, StaffExecutive) - `scope` ("customers", required) - `window` (StaffWindow, required): Whole UTC days: from inclusive, until exclusive (the end of today). - `from` (string (date-time), required) - `until` (string (date-time), required) - `days` (integer, required) - `models` (array of ExecutiveModelDays | null, required) - `model` (string, required) - `openWeights` (boolean | null, required) - `daily` (array of ExecutiveCountDay, required) - `day` (string (date), required) - `value` (integer, required) [min 0] - `tokensError` (ExecutiveSourceError | null, required) - `signUps` (array of ExecutiveCountDay | null, required) - `day` (string (date), required) - `value` (integer, required) [min 0] - `signUpsError` (ExecutiveSourceError | null, required) - `customersToDate` (integer, required) [min 0] - `organizations` (array of ExecutiveCountDay, required) - `day` (string (date), required) - `value` (integer, required) [min 0] - `organizationsToDate` (integer, required) [min 0] - `adoption` (ExecutiveAdoption | null, required) - `adoptionError` (ExecutiveSourceError | null, required) - `provisional` (boolean, required) - `400` Custom windows or histories longer than 3660 days are unsupported. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` The customer classification or organization history could not be read. (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) (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 | | Custom windows or histories longer than 3660 days are unsupported. | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | The customer classification or organization history could not be read. | | 503 | | The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) | ### Example ```sh curl "$NEXUS_URL/v1/staff/executive" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fstaff%2Fexecutive) ## List staff invites `GET /v1/staff/invites` Every campaign code for invite-only sign-up, by label, with its uses and link. Staff only; audited as `staff.list_viewed`. Permission: `staff.invites` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `x-nexus-staff-viewer` | header | string | no | The dashboard's signed-in viewer, kept in the audit event as sent; never used for access | ### Responses - `200` OK (application/json, CampaignCodeList) - `campaigns` (array of CampaignCode, required) - `label` (string, required): The campaign's name: lowercase letters, digits and inner hyphens - `code` (string, required): `<label>-<random tail>` - `link` (string, required): The sign-up link that carries the code: `/r/<code>` at the site's root - `maxUses` (integer, required) [min 1] - `used` (integer, required) [min 0] - `paid` (integer, required): How many of the people it brought in have paid: a credit purchase in their personal organization, of any amount. A later refund does not lower it [min 0] - `left` (integer, required): How many more people it admits now: 0 once revoked or past its end [min 0] - `expiresAt` (string (date-time) | null, required): When it stops admitting people; null with no end - `revoked` (boolean, required) - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) | ### Example ```sh curl "$NEXUS_URL/v1/staff/invites" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fstaff%2Finvites) ## Create staff invite `POST /v1/staff/invites` Make a campaign code: `<label>-<random tail>`, admitting `uses` people until `until`. It earns no referral reward. Staff only; audited as `invite.created` in the platform audit stream, with the caller as its actor. Permission: `staff.invites` (Owner, Admin). ### Request body (application/json, required) - `label` (string, required): The campaign's name, trimmed and lowercased: a DNS label of at most 40 characters [max length 40] - `uses` (integer, required): How many people it admits [min 1] - `until` (string | null): Its end: an ISO time, or a `YYYY-MM-DD` day through its end in UTC. Absent: no end ### Responses - `201` Created (application/json, CampaignCode) - `label` (string, required): The campaign's name: lowercase letters, digits and inner hyphens - `code` (string, required): `<label>-<random tail>` - `link` (string, required): The sign-up link that carries the code: `/r/<code>` at the site's root - `maxUses` (integer, required) [min 1] - `used` (integer, required) [min 0] - `paid` (integer, required): How many of the people it brought in have paid: a credit purchase in their personal organization, of any amount. A later refund does not lower it [min 0] - `left` (integer, required): How many more people it admits now: 0 once revoked or past its end [min 0] - `expiresAt` (string (date-time) | null, required): When it stops admitting people; null with no end - `revoked` (boolean, required) - `400` The body is not valid (`invalid_invite`), the label is not a lowercase DNS label of at most 40 characters, `uses` is 0, or `until` is not a time or has passed (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `409` The label has a campaign code already, revoked or not (`invite_exists`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not valid (`invalid_invite`), the label is not a lowercase DNS label of at most 40 characters, `uses` is 0, or `until` is not a time or has passed | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 409 | | The label has a campaign code already, revoked or not (`invite_exists`) | | 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/staff/invites" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "label": "CI", "uses": 1 }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fstaff%2Finvites) ## Get staff invite `GET /v1/staff/invites/{label}` One campaign code by its label, any case, with its uses and link. Staff only; audited as `staff.list_viewed` with the label. Permission: `staff.invites` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `label` | path | string | yes | | | `x-nexus-staff-viewer` | header | string | no | The dashboard's signed-in viewer, kept in the audit event as sent; never used for access | ### Responses - `200` OK (application/json, CampaignCode) - `label` (string, required): The campaign's name: lowercase letters, digits and inner hyphens - `code` (string, required): `<label>-<random tail>` - `link` (string, required): The sign-up link that carries the code: `/r/<code>` at the site's root - `maxUses` (integer, required) [min 1] - `used` (integer, required) [min 0] - `paid` (integer, required): How many of the people it brought in have paid: a credit purchase in their personal organization, of any amount. A later refund does not lower it [min 0] - `left` (integer, required): How many more people it admits now: 0 once revoked or past its end [min 0] - `expiresAt` (string (date-time) | null, required): When it stops admitting people; null with no end - `revoked` (boolean, required) - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No campaign code has this label (`unknown_invite`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No campaign code has this label (`unknown_invite`) | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | The read could not be audited (`staff_audit_unavailable`) or took longer than 20 s (`staff_read_timeout`) | ### Example ```sh curl "$NEXUS_URL/v1/staff/invites/CI" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fstaff%2Finvites%2F%7Blabel%7D) ## Revoke staff invite `DELETE /v1/staff/invites/{label}` Revoke a campaign code: it admits no one after. Revoking twice answers the same and writes one event. Staff only; audited as `invite.revoked` in the platform audit stream, with the caller as its actor. Permission: `staff.invites` (Owner, Admin). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `label` | path | string | yes | | ### Responses - `200` The code, now revoked (application/json, CampaignCode) - `label` (string, required): The campaign's name: lowercase letters, digits and inner hyphens - `code` (string, required): `<label>-<random tail>` - `link` (string, required): The sign-up link that carries the code: `/r/<code>` at the site's root - `maxUses` (integer, required) [min 1] - `used` (integer, required) [min 0] - `paid` (integer, required): How many of the people it brought in have paid: a credit purchase in their personal organization, of any amount. A later refund does not lower it [min 0] - `left` (integer, required): How many more people it admits now: 0 once revoked or past its end [min 0] - `expiresAt` (string (date-time) | null, required): When it stops admitting people; null with no end - `revoked` (boolean, required) - `403` Not a person with a platform role who is one of Nexus's own people (`staff_required`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `404` No campaign code has this label (`unknown_invite`) (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | No campaign code has this label (`unknown_invite`) | | 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/staff/invites/CI" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fstaff%2Finvites%2F%7Blabel%7D) --- <!-- /docs/api/apps --> # Apps > Nexus Apps: an app you deploy from a folder, hosted on Vercel in Nexus's own team (Vercel for Platforms, one Vercel project per app). Nobody needs a Vercel account. Nexus pays Vercel for every app on its team, so an organization holds at most `NEXUS_APPS_MAX_PER_TENANT` apps (10 by default); a claim link moves an app's project to your own Vercel account, where it stops costing Nexus. Each app shows what Vercel billed for it, from Vercel's daily charges. An app is its deployer's, and the organization's owners and admins reach every app; to anyone else it does not exist. Off unless the Gateway sets `NEXUS_APPS_ENABLED=true`: then every route answers 404 `apps_off`, and these routes are left out of GET /v1/openapi.json. On, without `VERCEL_TOKEN` and `VERCEL_TEAM_ID`, every route answers 503 `apps_unavailable`. ## List apps `GET /v1/apps` Your apps, or every app of your organization for an owner or admin, by name, each with what Vercel billed for it. Permission: `apps.use` (Every member). ### Responses - `200` OK (application/json, AppList) - `apps` (array of App, required) - `id` (string, required): `app_…` - `name` (string, required) [max length 48; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `userId` (string, required): The member who deployed it first. - `url` (string | null, required): The app's address: its production URL once Vercel assigned it, else its last deployment's own. Null before the first deployment. - `state` ("QUEUED" | "INITIALIZING" | "BUILDING" | "READY" | "ERROR" | "CANCELED" | "BLOCKED" | null, required): Vercel's state of the last deployment; null before the first. - `framework` (string | null, required): The Vercel framework preset it was deployed with; null for Vercel's own detection. - `projectName` (string, required): The Vercel project's name on Nexus's team (`nx-<8 hex>-<name>`). - `deployedAt` (string (date-time) | null, required): When the last deployment started. - `claimRequestedAt` (string (date-time) | null, required): When a member last asked for a claim link: the project may since be on their own Vercel account. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `costToDate` (string | null, required): What Vercel billed Nexus for this app in all, in USD, as a decimal string (root rule 9); null until a cost pull saw a charge for it. [pattern ^-?[0-9]+\.[0-9]{6}$] - `cost30d` (string | null, required): What Vercel billed for it over the last 30 days, in USD, as a decimal string; null until a cost pull saw a charge for it. [pattern ^-?[0-9]+\.[0-9]{6}$] - `costUpdatedAt` (string (date-time) | null, required): When the costs were last read from Vercel's charges, which come a day late; null with no cost. - `billingError` (string | null, required): An outstanding payment, paused state, or provider correction awaiting credit. Transient errors never pause hosting. - `monthlyCapUsd` (string, required): Monthly hosting cap in USD. Defaults to $10. - `monthSpendUsd` (string, required): Current UTC month ListCost plus Nexus rate, in USD. - `pauseAt` (string | null, required): The earliest cap or payment grace deadline. Null while healthy. - `pausedReason` (string | null, required): Cap, card or debt while hosting is paused. - `403` The caller is not a member of an organization (`member_required`), or the role may not use apps. - `404` Nexus Apps is off on this Gateway (`apps_off`). - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). ### 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 | | Nexus Apps is off on this Gateway (`apps_off`). | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). | ### Example ```sh curl "$NEXUS_URL/v1/apps" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fapps) ## Deploy app `POST /v1/apps` Deploy a folder as your app named `name`: a new app (201) or the next deployment of yours (200). Send every file of the folder, its path relative to the folder and its bytes as standard base64: at most 5000 files and 20 MB decoded (the body at most 30 MB). `framework` is a Vercel framework preset (`nextjs`, `vite`); absent, Vercel detects it. Gateway makes the app's Vercel project on Nexus's team the first time, then deploys the files to production; the answer's `state` is Vercel's (`QUEUED`, `BUILDING`, …) and GET /v1/apps/{id} follows it to `READY` or `ERROR`. A name is the organization's: another member's app of the same name is a 409. Permission: `apps.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): The app's name in your organization: lowercase words joined by single dashes. [max length 48; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `framework` (string | null): A Vercel framework preset, such as `nextjs` or `vite`; absent or null, Vercel detects it. [pattern ^[a-z0-9-]{1,40}$] - `files` (array of object, required) [at most 5000 items] - `path` (string, required): The file's path in the app, relative, with `/` between folders. [max length 512] - `data` (string, required): The file's bytes, standard base64. ### Responses - `200` The next deployment of your app (application/json, App) - `id` (string, required): `app_…` - `name` (string, required) [max length 48; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `userId` (string, required): The member who deployed it first. - `url` (string | null, required): The app's address: its production URL once Vercel assigned it, else its last deployment's own. Null before the first deployment. - `state` ("QUEUED" | "INITIALIZING" | "BUILDING" | "READY" | "ERROR" | "CANCELED" | "BLOCKED" | null, required): Vercel's state of the last deployment; null before the first. - `framework` (string | null, required): The Vercel framework preset it was deployed with; null for Vercel's own detection. - `projectName` (string, required): The Vercel project's name on Nexus's team (`nx-<8 hex>-<name>`). - `deployedAt` (string (date-time) | null, required): When the last deployment started. - `claimRequestedAt` (string (date-time) | null, required): When a member last asked for a claim link: the project may since be on their own Vercel account. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `costToDate` (string | null, required): What Vercel billed Nexus for this app in all, in USD, as a decimal string (root rule 9); null until a cost pull saw a charge for it. [pattern ^-?[0-9]+\.[0-9]{6}$] - `cost30d` (string | null, required): What Vercel billed for it over the last 30 days, in USD, as a decimal string; null until a cost pull saw a charge for it. [pattern ^-?[0-9]+\.[0-9]{6}$] - `costUpdatedAt` (string (date-time) | null, required): When the costs were last read from Vercel's charges, which come a day late; null with no cost. - `billingError` (string | null, required): An outstanding payment, paused state, or provider correction awaiting credit. Transient errors never pause hosting. - `monthlyCapUsd` (string, required): Monthly hosting cap in USD. Defaults to $10. - `monthSpendUsd` (string, required): Current UTC month ListCost plus Nexus rate, in USD. - `pauseAt` (string | null, required): The earliest cap or payment grace deadline. Null while healthy. - `pausedReason` (string | null, required): Cap, card or debt while hosting is paused. - `201` Created: the app's first deployment is building (application/json, App) - `id` (string, required): `app_…` - `name` (string, required) [max length 48; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `userId` (string, required): The member who deployed it first. - `url` (string | null, required): The app's address: its production URL once Vercel assigned it, else its last deployment's own. Null before the first deployment. - `state` ("QUEUED" | "INITIALIZING" | "BUILDING" | "READY" | "ERROR" | "CANCELED" | "BLOCKED" | null, required): Vercel's state of the last deployment; null before the first. - `framework` (string | null, required): The Vercel framework preset it was deployed with; null for Vercel's own detection. - `projectName` (string, required): The Vercel project's name on Nexus's team (`nx-<8 hex>-<name>`). - `deployedAt` (string (date-time) | null, required): When the last deployment started. - `claimRequestedAt` (string (date-time) | null, required): When a member last asked for a claim link: the project may since be on their own Vercel account. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `costToDate` (string | null, required): What Vercel billed Nexus for this app in all, in USD, as a decimal string (root rule 9); null until a cost pull saw a charge for it. [pattern ^-?[0-9]+\.[0-9]{6}$] - `cost30d` (string | null, required): What Vercel billed for it over the last 30 days, in USD, as a decimal string; null until a cost pull saw a charge for it. [pattern ^-?[0-9]+\.[0-9]{6}$] - `costUpdatedAt` (string (date-time) | null, required): When the costs were last read from Vercel's charges, which come a day late; null with no cost. - `billingError` (string | null, required): An outstanding payment, paused state, or provider correction awaiting credit. Transient errors never pause hosting. - `monthlyCapUsd` (string, required): Monthly hosting cap in USD. Defaults to $10. - `monthSpendUsd` (string, required): Current UTC month ListCost plus Nexus rate, in USD. - `pauseAt` (string | null, required): The earliest cap or payment grace deadline. Null while healthy. - `pausedReason` (string | null, required): Cap, card or debt while hosting is paused. - `400` The body is not a deploy: `name` (`invalid_name`), `framework` (`invalid_framework`) or `files` (`invalid_files`: none, too many, a bad or repeated path, or data that is not base64). - `402` Add a saved card, resolve unpaid hosting, repay credit debt, or raise the app cap (apps_card_required, apps_payment_pending, apps_debt_pending, app_paused). - `403` The caller is not a member of an organization (`member_required`), or the role may not use apps. - `404` Nexus Apps is off on this Gateway (`apps_off`). - `409` Another member of your organization has an app of this name (`app_name_taken`), or the app's Vercel project left Nexus's team (`app_gone`): it was claimed or deleted at Vercel. - `413` The files are more than 20 MB decoded (`app_too_large`), or the body more than 30 MB. - `422` Vercel refused the project or the deployment (`vercel_refused`), with Vercel's own message. - `429` Your organization holds its most apps (`apps_limit`, `NEXUS_APPS_MAX_PER_TENANT`): delete one first. Also the caller's rate limit. - `502` Vercel failed or did not answer (`vercel_error`); try again. - `503` Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 400 | | The body is not a deploy: `name` (`invalid_name`), `framework` (`invalid_framework`) or `files` (`invalid_files`: none, too many, a bad or repeated path, or data that is not base64). | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 402 | `budget_exceeded` | Add a saved card, resolve unpaid hosting, repay credit debt, or raise the app cap (apps_card_required, apps_payment_pending, apps_debt_pending, app_paused). | | 403 | `role_required` | Your role does not have this permission | | 404 | | Nexus Apps is off on this Gateway (`apps_off`). | | 409 | | Another member of your organization has an app of this name (`app_name_taken`), or the app's Vercel project left Nexus's team (`app_gone`): it was claimed or deleted at Vercel. | | 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running | | 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part | | 413 | | The files are more than 20 MB decoded (`app_too_large`), or the body more than 30 MB. | | 422 | | Vercel refused the project or the deployment (`vercel_refused`), with Vercel's own message. | | 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request | | 429 | | Your organization holds its most apps (`apps_limit`, `NEXUS_APPS_MAX_PER_TENANT`): delete one first. Also the caller's rate limit. | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 502 | | Vercel failed or did not answer (`vercel_error`); try again. | | 503 | | Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/apps" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "name": "Platform", "files": [ { "path": "<path>", "data": "<data>" } ] }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fapps) ## Get app `GET /v1/apps/{id}` One app, with what Vercel billed for it. While its deployment builds, Gateway reads its state from Vercel again; if Vercel does not answer, the last state stands. Permission: `apps.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The app's id (`app_…`), as POST /v1/apps answered it | ### Responses - `200` OK (application/json, App) - `id` (string, required): `app_…` - `name` (string, required) [max length 48; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `userId` (string, required): The member who deployed it first. - `url` (string | null, required): The app's address: its production URL once Vercel assigned it, else its last deployment's own. Null before the first deployment. - `state` ("QUEUED" | "INITIALIZING" | "BUILDING" | "READY" | "ERROR" | "CANCELED" | "BLOCKED" | null, required): Vercel's state of the last deployment; null before the first. - `framework` (string | null, required): The Vercel framework preset it was deployed with; null for Vercel's own detection. - `projectName` (string, required): The Vercel project's name on Nexus's team (`nx-<8 hex>-<name>`). - `deployedAt` (string (date-time) | null, required): When the last deployment started. - `claimRequestedAt` (string (date-time) | null, required): When a member last asked for a claim link: the project may since be on their own Vercel account. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `costToDate` (string | null, required): What Vercel billed Nexus for this app in all, in USD, as a decimal string (root rule 9); null until a cost pull saw a charge for it. [pattern ^-?[0-9]+\.[0-9]{6}$] - `cost30d` (string | null, required): What Vercel billed for it over the last 30 days, in USD, as a decimal string; null until a cost pull saw a charge for it. [pattern ^-?[0-9]+\.[0-9]{6}$] - `costUpdatedAt` (string (date-time) | null, required): When the costs were last read from Vercel's charges, which come a day late; null with no cost. - `billingError` (string | null, required): An outstanding payment, paused state, or provider correction awaiting credit. Transient errors never pause hosting. - `monthlyCapUsd` (string, required): Monthly hosting cap in USD. Defaults to $10. - `monthSpendUsd` (string, required): Current UTC month ListCost plus Nexus rate, in USD. - `pauseAt` (string | null, required): The earliest cap or payment grace deadline. Null while healthy. - `pausedReason` (string | null, required): Cap, card or debt while hosting is paused. - `403` The caller is not a member of an organization (`member_required`), or the role may not use apps. - `404` Nexus Apps is off on this Gateway (`apps_off`), or no such app reaches you: another member's and another organization's are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Nexus Apps is off on this Gateway (`apps_off`), or no such app reaches you: another member's and another organization's are as absent as a missing one. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). | ### Example ```sh curl "$NEXUS_URL/v1/apps/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fapps%2F%7Bid%7D) ## Delete app `DELETE /v1/apps/{id}` Delete the app and its Vercel project, with every deployment. A project Vercel no longer has, or a claimed one, is not an error. Audited as app.deleted. Permission: `apps.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The app's id (`app_…`), as POST /v1/apps answered it | | `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, AppDeleted) - `id` (string, required) - `deleted` (boolean, required) - `403` The caller is not a member of an organization (`member_required`), or the role may not use apps. - `404` Nexus Apps is off on this Gateway (`apps_off`), or no such app reaches you: another member's and another organization's are as absent as a missing one. - `422` Vercel refused the delete (`vercel_refused`). - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Vercel failed or did not answer (`vercel_error`); try again. - `503` Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Nexus Apps is off on this Gateway (`apps_off`), or no such app reaches you: another member's and another organization's are as absent as a missing one. | | 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 | | Vercel refused the delete (`vercel_refused`). | | 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 | | 502 | | Vercel failed or did not answer (`vercel_error`); try again. | | 503 | | Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/apps/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fapps%2F%7Bid%7D) ## Claim app `POST /v1/apps/{id}/claim` A claim link: whoever opens it signs in to Vercel (or signs up, free) and moves the app's project to their own Vercel account, where it stops costing Nexus. Anyone with the link can claim the app, so share it with nobody else. It works for 24 hours (`expiresAt`). Gateway records when it was asked for (`claimRequestedAt`), and audits each request as app.claim_requested. Permission: `apps.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The app's id (`app_…`), as POST /v1/apps answered it | | `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, AppClaim) - `id` (string, required) - `claimUrl` (string (uri), required): Vercel's claim page for the app's project. Anyone with it can claim the app. - `expiresAt` (string (date-time), required): When the link stops working: 24 hours after it was made. - `403` The caller is not a member of an organization (`member_required`), or the role may not use apps. - `404` Nexus Apps is off on this Gateway (`apps_off`), or no such app reaches you: another member's and another organization's are as absent as a missing one. - `409` The app has no Vercel project yet (`app_not_deployed`), or its project left Nexus's team (`app_gone`). - `422` Vercel refused the transfer request (`vercel_refused`). - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `502` Vercel failed or did not answer (`vercel_error`); try again. - `503` Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Nexus Apps is off on this Gateway (`apps_off`), or no such app reaches you: another member's and another organization's are as absent as a missing one. | | 409 | | The app has no Vercel project yet (`app_not_deployed`), or its project left Nexus's team (`app_gone`). | | 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 | | Vercel refused the transfer request (`vercel_refused`). | | 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 | | 502 | | Vercel failed or did not answer (`vercel_error`); try again. | | 503 | | Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). | ### Example ```sh curl -X POST "$NEXUS_URL/v1/apps/<id>/claim" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fapps%2F%7Bid%7D%2Fclaim) ## Set app cap `PUT /v1/apps/{id}/cap` Set the monthly hosting cap for an app you own or manage. A cap above $10, or above the cap a manager set, needs `budgets.manage` (owners and admins). Audited as app.cap_changed. The app resumes after its blocking state clears. Permission: `apps.use` (Every member). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The app's id (`app_…`), as POST /v1/apps answered it | ### Request body (application/json, required) - `monthlyCapUsd` (string, required): USD decimal string in whole cents, $0.01 to $1,000,000. ### Responses - `200` OK (application/json, App) - `id` (string, required): `app_…` - `name` (string, required) [max length 48; pattern ^[a-z0-9]+(-[a-z0-9]+)*$] - `userId` (string, required): The member who deployed it first. - `url` (string | null, required): The app's address: its production URL once Vercel assigned it, else its last deployment's own. Null before the first deployment. - `state` ("QUEUED" | "INITIALIZING" | "BUILDING" | "READY" | "ERROR" | "CANCELED" | "BLOCKED" | null, required): Vercel's state of the last deployment; null before the first. - `framework` (string | null, required): The Vercel framework preset it was deployed with; null for Vercel's own detection. - `projectName` (string, required): The Vercel project's name on Nexus's team (`nx-<8 hex>-<name>`). - `deployedAt` (string (date-time) | null, required): When the last deployment started. - `claimRequestedAt` (string (date-time) | null, required): When a member last asked for a claim link: the project may since be on their own Vercel account. - `createdAt` (string (date-time), required) - `updatedAt` (string (date-time), required) - `costToDate` (string | null, required): What Vercel billed Nexus for this app in all, in USD, as a decimal string (root rule 9); null until a cost pull saw a charge for it. [pattern ^-?[0-9]+\.[0-9]{6}$] - `cost30d` (string | null, required): What Vercel billed for it over the last 30 days, in USD, as a decimal string; null until a cost pull saw a charge for it. [pattern ^-?[0-9]+\.[0-9]{6}$] - `costUpdatedAt` (string (date-time) | null, required): When the costs were last read from Vercel's charges, which come a day late; null with no cost. - `billingError` (string | null, required): An outstanding payment, paused state, or provider correction awaiting credit. Transient errors never pause hosting. - `monthlyCapUsd` (string, required): Monthly hosting cap in USD. Defaults to $10. - `monthSpendUsd` (string, required): Current UTC month ListCost plus Nexus rate, in USD. - `pauseAt` (string | null, required): The earliest cap or payment grace deadline. Null while healthy. - `pausedReason` (string | null, required): Cap, card or debt while hosting is paused. - `403` The caller is not a member of an organization (`member_required`), the role may not use apps, or the cap needs `budgets.manage` (`role_required`). - `404` Nexus Apps is off on this Gateway (`apps_off`), or no such app reaches you: another member's and another organization's are as absent as a missing one. - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. - `503` Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 404 | | Nexus Apps is off on this Gateway (`apps_off`), or no such app reaches you: another member's and another organization's are as absent as a missing one. | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | | 503 | | Nexus Apps has no Vercel token and team on this Gateway (`apps_unavailable`). | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/apps/<id>/cap" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "monthlyCapUsd": "<monthlyCapUsd>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fapps%2F%7Bid%7D%2Fcap) --- <!-- /docs/api/projects --> # 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) --- <!-- /docs/api/agent-api --> # Agent API > Your own agent, the one `@nexus` is in Slack, through Gateway: `/v1/agent/*` forwards to the agent API with your token. Off unless the Gateway turns it on. ## Agent ask `POST /v1/agent/ask` Ask your agent, the one `@nexus` is in Slack. `stream: true`, or `Accept: text/event-stream`, streams the answer as server-sent events: `started`, `model`, `text` (each `delta`), `step`, then `done` or `error`. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) - `message` (string, required): The question [max length 8000] - `conversation` (string): The conversation to continue; a new one without it [pattern ^[A-Za-z0-9._-]{1,64}$] - `model` (string): The model to answer with; the saved one without it - `stream` (boolean): Stream the answer as server-sent events - `context` (array of object): What the ask names from the `@` menu (`GET /v1/agent/context`) [at most 8 items] - `kind` (string, required) - `id` (string, required) - `skill` (string): A skill of yours to answer with ### Responses - `200` The answer: whole as JSON, or streamed as server-sent events (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/agent/ask" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "message": "<message>" }' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Fask) ## Agent list conversations `GET /v1/agent/conversations` Your conversations from every surface, newest activity first. Page with `limit` and `before`. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `limit` | query | integer | no | At most this many (50) | | `before` | query | string | no | The cursor of the page before | ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/agent/conversations" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fconversations) ## Agent get conversation `GET /v1/agent/conversations/{id}` Your turns in one conversation, or 404. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/conversations/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fconversations%2F%7Bid%7D) ## Agent get memory `GET /v1/agent/memory` What your agent keeps about you: its notes, and whether it learns. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/memory" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fmemory) ## Agent forget memory `DELETE /v1/agent/memory` Forget every note your agent keeps about you. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/agent/memory" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fagent%2Fmemory) ## Agent add note `POST /v1/agent/memory/notes` Add a note (`{text}`) to your agent's memory. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/agent/memory/notes" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Fmemory%2Fnotes) ## Agent edit note `PATCH /v1/agent/memory/notes/{id}` Edit one note (`{text}`). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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 PATCH "$NEXUS_URL/v1/agent/memory/notes/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Fagent%2Fmemory%2Fnotes%2F%7Bid%7D) ## Agent forget note `DELETE /v1/agent/memory/notes/{id}` Forget one note. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/agent/memory/notes/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fagent%2Fmemory%2Fnotes%2F%7Bid%7D) ## Agent set learning `PUT /v1/agent/memory/learning` Pause or resume learning (`{paused}`). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/agent/memory/learning" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fagent%2Fmemory%2Flearning) ## Agent get approval settings `GET /v1/agent/approvals/settings` Your spend line, your "Always allow" rules and "Sent using Nexus". Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/approvals/settings" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fapprovals%2Fsettings) ## Agent set approval settings `PUT /v1/agent/approvals/settings` Set your spend line or "Sent using Nexus". Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/agent/approvals/settings" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fagent%2Fapprovals%2Fsettings) ## Agent revoke rules `DELETE /v1/agent/approvals/rules` Revoke every "Always allow" rule. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/agent/approvals/rules" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fagent%2Fapprovals%2Frules) ## Agent revoke rule `DELETE /v1/agent/approvals/rules/{id}` Revoke one "Always allow" rule. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/agent/approvals/rules/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fagent%2Fapprovals%2Frules%2F%7Bid%7D) ## Agent list errands `GET /v1/agent/errands` Your errands. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/errands" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Ferrands) ## Agent start errand `POST /v1/agent/errands` Start an errand (`{goal}`). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/agent/errands" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Ferrands) ## Agent get errand `GET /v1/agent/errands/{id}` One errand. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/errands/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Ferrands%2F%7Bid%7D) ## Agent act on errand `POST /v1/agent/errands/{id}` Confirm, close or cancel an errand (`{action}`: `confirm`, `done` or `cancel`). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/errands/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Ferrands%2F%7Bid%7D) ## Agent edit errand `PATCH /v1/agent/errands/{id}` Rename, pin, archive or close an errand. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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 PATCH "$NEXUS_URL/v1/agent/errands/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Fagent%2Ferrands%2F%7Bid%7D) ## Agent reply to errand `POST /v1/agent/errands/{id}/messages` Reply about an errand (`{message}`), in its own thread. Answers in one piece. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/errands/<id>/messages" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Ferrands%2F%7Bid%7D%2Fmessages) ## Agent get errand handoff `GET /v1/agent/errands/{id}/handoff` The errand as a coding session's prompt. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/errands/<id>/handoff" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Ferrands%2F%7Bid%7D%2Fhandoff) ## Agent record errand handoff `POST /v1/agent/errands/{id}/handoff` Record the step "Handed off to a session". Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Request body (application/json) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/errands/<id>/handoff" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Ferrands%2F%7Bid%7D%2Fhandoff) ## Agent list projects `GET /v1/agent/projects` Your projects. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/projects" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fprojects) ## Agent view project `GET /v1/agent/projects/view` One project's page, by `id` or `name`. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | query | string | no | The project's id | | `name` | query | string | no | A name-only project's name | ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl "$NEXUS_URL/v1/agent/projects/view" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fprojects%2Fview) ## Agent link project `POST /v1/agent/projects/link` Bind a name-only project to a Gateway project (`{name, projectId}`). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/agent/projects/link" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Fprojects%2Flink) ## Agent list watches `GET /v1/agent/watches` Your watches. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/watches" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fwatches) ## Agent keep watch `POST /v1/agent/watches` Keep a watch your agent proposed. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/agent/watches" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Fwatches) ## Agent get watch `GET /v1/agent/watches/{id}` One watch. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/watches/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fwatches%2F%7Bid%7D) ## Agent edit watch `PATCH /v1/agent/watches/{id}` Edit a watch. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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 PATCH "$NEXUS_URL/v1/agent/watches/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Fagent%2Fwatches%2F%7Bid%7D) ## Agent delete watch `DELETE /v1/agent/watches/{id}` Delete a watch. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 404 | `not_found` | Nothing matches the path in your organization | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X DELETE "$NEXUS_URL/v1/agent/watches/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fagent%2Fwatches%2F%7Bid%7D) ## Agent get brief `GET /v1/agent/brief/today` Today's morning brief, the one Slack's DM got. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/brief/today" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fbrief%2Ftoday) ## Agent get proactivity `GET /v1/agent/proactivity` Your proactivity dial, the kinds you turned off and your quiet hours. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/proactivity" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fproactivity) ## Agent set proactivity `PUT /v1/agent/proactivity` Set your proactivity dial, kinds or quiet hours. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/agent/proactivity" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fagent%2Fproactivity) ## Agent get model `GET /v1/agent/model` The model your agent answers with (the composer's Auto chip). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/model" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fmodel) ## Agent set model `PUT /v1/agent/model` Set the model your agent answers with (`{model}`). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/agent/model" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fagent%2Fmodel) ## Agent get context `GET /v1/agent/context` What an ask may name as context (the composer's `@` menu). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/context" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fcontext) ## Agent get pause `GET /v1/agent/pause` Whether your agent is paused. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/pause" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fpause) ## Agent set pause `PUT /v1/agent/pause` Pause or resume your agent (`{paused}`). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/agent/pause" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fagent%2Fpause) ## Agent get privacy `GET /v1/agent/privacy` What your agent can reach: its links and connected accounts. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/privacy" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fprivacy) ## Agent revoke all `POST /v1/agent/revoke` Revoke what your agent can reach. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/agent/revoke" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Frevoke) ## Agent get vault `GET /v1/agent/vault` Your passwords and payments: never a password or a card number. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/vault" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fvault) ## Agent get vault activity `GET /v1/agent/vault/activity` Your vault's activity. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/vault/activity" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fvault%2Factivity) ## Agent set vault login `PUT /v1/agent/vault/logins/{id}` Change how your agent may use one login. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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 PUT "$NEXUS_URL/v1/agent/vault/logins/<id>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fagent%2Fvault%2Flogins%2F%7Bid%7D) ## Agent set vault card `PUT /v1/agent/vault/card` Freeze or unfreeze your card (`{frozen}`). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/agent/vault/card" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fagent%2Fvault%2Fcard) ## Agent set vault index `PUT /v1/agent/vault/index` Your desktop's vault index: names and hosts, never a secret. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X PUT "$NEXUS_URL/v1/agent/vault/index" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fagent%2Fvault%2Findex) ## Agent ask vault `POST /v1/agent/vault/asks` Ask to use a login; you approve it on your desktop. An agent link may call it. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 400 | `invalid_request_error` | A field is missing or not valid; the message names it | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/agent/vault/asks" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Fvault%2Fasks) ## Agent approve vault ask `POST /v1/agent/vault/asks/{id}/approve` Approve an ask to use a login. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Request body (application/json) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/vault/asks/<id>/approve" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Fvault%2Fasks%2F%7Bid%7D%2Fapprove) ## Agent decline vault ask `POST /v1/agent/vault/asks/{id}/decline` Decline an ask to use a login. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `id` | path | string | yes | The agent API's id | ### Request body (application/json) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/vault/asks/<id>/decline" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Fvault%2Fasks%2F%7Bid%7D%2Fdecline) ## Agent edit write `PATCH /v1/agent/writes/{card}` Edit a write that waits for your approval. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `card` | path | string | yes | The agent API's id | ### Request body (application/json, required) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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 PATCH "$NEXUS_URL/v1/agent/writes/<card>" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#patch%3A%2Fv1%2Fagent%2Fwrites%2F%7Bcard%7D) ## Agent approve write `POST /v1/agent/writes/{card}/approve` Approve a write your agent proposed in the chat (`{always}` also allows it from now on). Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `card` | path | string | yes | The agent API's id | ### Request body (application/json) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/writes/<card>/approve" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Fwrites%2F%7Bcard%7D%2Fapprove) ## Agent decline write `POST /v1/agent/writes/{card}/decline` Decline a write your agent proposed in the chat. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `card` | path | string | yes | The agent API's id | ### Request body (application/json) AgentApiBody: the provider's own request. ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/writes/<card>/decline" \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{}' ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Fwrites%2F%7Bcard%7D%2Fdecline) ## Agent get intro `GET /v1/agent/intro` What your agent shows the first time you open it, once. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `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/agent/intro" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fagent%2Fintro) ## Agent mark intro seen `POST /v1/agent/intro/seen` Keep that you saw the first open, on every app. Gateway forwards it to the agent API with your own token, after its own authentication and rate limit; only a person's credential or their agent link may call it. Off unless the Gateway turns the agent proxy on. Permission: `models.use` (Every member, module keys). ### Responses - `200` The agent API's answer, as it sent it (application/json, AgentApiBody) - `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error) - `error` (object) - `message` (string, required) - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error. - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape. - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise. - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408. - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports. ### Errors | Status | Code | When | | --- | --- | --- | | 401 | `authentication_error` | No key, or a key Gateway does not accept | | 403 | `role_required` | Your role does not have this permission | | 429 | | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). | | 429 | `rate_limit_error` | Too many requests from this key in a minute | ### Example ```sh curl -X POST "$NEXUS_URL/v1/agent/intro/seen" \ -H "Authorization: Bearer $NEXUS_API_KEY" ``` Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fagent%2Fintro%2Fseen) --- <!-- /docs/cli --> # CLI overview > The nexus CLI does everything Nexus UI does, for people, scripts and agents. The `nexus` CLI is one client of the Nexus API, like Nexus UI. Every command takes `--json`, exits with a meaningful code and retries its writes safely, so scripts and AI agents can drive it as well as people. ## Install ```sh curl -fsSL https://api.nexus.inc/install.sh | bash ``` Needs curl. The installer downloads the CLI from Nexus Gateway, checks its SHA-256 checksum, and installs it to `~/.nexus/bin/nexus` (`NEXUS_INSTALL_DIR` changes the folder). It installs the native binary for your machine when Gateway publishes one. Otherwise it installs the JavaScript CLI, which needs Node.js 22.6 or later. Then [`nexus update`](/docs/cli/update) keeps it current, and `nexus update --rollback` goes back one version. ## Grammar ```sh nexus <command> [subcommand] [arguments] [options] nexus <product> <verb> [capability] [--input value] ``` Gateway's own commands are fixed: `auth`, `keys`, `team`, `members`, `spend`, `billing`, `chat`, `pages`, `skills`, `routines`, `agent`, `claude`, `sessions` and the others `nexus help` lists. Product commands are discovered from the products registered on your Gateway: `nexus help` lists them, and `nexus <product> --help` shows a product's capabilities, verbs and inputs. ## Output On a terminal the CLI uses color, symbols and a spinner while it waits; piped, or with `NO_COLOR` or `--no-color`, it prints plain text. With `--json`, it prints only JSON on stdout, and `nexus help --json` lists every command, flag and exit code for scripts and agents. The exit codes are below; `nexus claude` and `nexus codex` exit with the agent's own code. ## Global options | Option | Meaning | | --- | --- | | `--json` | Print only JSON on stdout; errors go to stderr as {"error": {"message", "hint"}} | | `--no-color` | Plain text on a terminal too (also NO_COLOR) | | `--help` | Help for a command (also -h) | | `--version` | The CLI's version (also -v; with --json: {"version"}) | ## Environment | Variable | Meaning | | --- | --- | | `NEXUS_URL` | The Gateway URL when none is saved (the installer's wrapper sets it; default https://api.nexus.inc) | | `NEXUS_GATEWAY` | One command against another Gateway, with its own sign-in (nexus auth login once per Gateway); the saved one stays the default | | `NEXUS_CONFIG` | The CLI config file (default ~/.nexus/factory/config.json) | | `NEXUS_UI_URL` | Where the CLI's Nexus UI links point, for the Gateway NEXUS_URL names (any Gateway when NEXUS_URL is unset) | | `NEXUS_TEAM` | The team runs and agent sessions are attributed to (--team wins) | | `NEXUS_CLAUDE_AUTH` | Gateway or subscription: the route nexus claude takes in this shell (a flag wins; unset: your saved route, nexus agents) | | `NEXUS_CODEX_AUTH` | Gateway or subscription: the route nexus codex takes in this shell (a flag wins; unset: your saved route) | | `NEXUS_ANTIGRAVITY_AUTH` | Subscription, its only route: the route nexus agy takes in this shell (Antigravity runs on your Google AI plan) | | `NEXUS_CURSOR_AUTH` | Subscription: run nexus cursor-agent on your Cursor plan | | `NEXUS_RECORDINGS_DIR` | Where nexus recordings reads screen recordings (default: Nexus for Mac's folder) | | `NEXUS_DESKTOP_BIN` | The binary nexus recordings frames runs (default: Nexus.app's nexus-desktop, else Nexus GPUI's nexus-desktop-gpui) | | `NEXUS_DESKTOP_SOCKET` | The socket nexus sessions reaches Nexus for desktop through (default: the app's, in $XDG_RUNTIME_DIR or its data folder) | | `NEXUS_NO_UPDATE_CHECK` | 1: never check for a newer CLI (also off with --json, in CI and when stdout is not a terminal) | | `NO_COLOR` | Plain output on a terminal too | | `NEXUS_DEBUG` | 1: print the stack trace with an error | ## Exit codes | Code | Meaning | | --- | --- | | 0 | Success | | 1 | Failure: Gateway refused or failed the request, a run failed, you are not signed in, or Gateway could not be reached | | 2 | Usage error: an unknown command, a missing argument or an invalid flag | --- <!-- /docs/cli/auth --> # auth > Sign in to a Nexus Gateway, check who you are, sign out, and manage your API keys. Sign in to a Nexus Gateway, check who you are, sign out, and manage your API keys. ## nexus auth login ```sh nexus auth login --url <core> nexus auth login --with-token ``` Sign in as you, in your organization: approve a one-time code in Nexus UI (--no-browser to only print the link). - `nexus auth login --with-token`: Sign in with an API key read from stdin, for CI and scripts. | Option | Meaning | | --- | --- | | `--url <core>` | The Gateway to sign in to, saved as the default (default: NEXUS_GATEWAY, else the saved one, else NEXUS_URL, else https://api.nexus.inc) | | `--no-browser` | Only print the approval link; do not open a browser | | `--with-token` | Read an API key from stdin instead of signing in through the browser | ```sh nexus auth login --url https://api.nexus.inc ``` ## nexus auth signup ```sh nexus auth signup --name <name> [--email <email>] [--dry-run] ``` Create an organization and its owner without a browser, and save the new API key (when key-only signup is enabled). | Option | Meaning | | --- | --- | | `--name <name>` | The new organization's name (1 to 80 characters) | | `--email <email>` | The owner's email address (unverified until verified through sign-in) | | `--dry-run` | Show what would change, change nothing | ## nexus auth status ```sh nexus auth status ``` Your org, user and role, the Gateway URL, your token (masked) and whether Gateway accepts it. | Exit code | Meaning | | --- | --- | | 0 | Signed in, and Gateway accepts the token | | 1 | Not signed in, or Gateway rejects the saved token | ```sh nexus auth status --json ``` ## nexus auth logout ```sh nexus auth logout ``` Revoke the saved token on Gateway and forget it. ## nexus auth delete-account ```sh nexus auth delete-account [--dry-run] [--confirm DELETE] ``` Delete your account for good: your sign-in, your personal organization and your place in every organization. | Option | Meaning | | --- | --- | | `--dry-run` | Show what would change, change nothing | | `--confirm <DELETE>` | DELETE, to confirm without a terminal (on one, you type it when asked) | ## nexus auth tokens list ```sh nexus auth tokens list [--all] ``` Your API keys and CLI sign-ins in this organization, newest first (--all: everyone's, owners and admins). | Option | Meaning | | --- | --- | | `--all` | Everyone's tokens in the organization (owners and admins) | ## nexus auth tokens create ```sh nexus auth tokens create --label <label> ``` Create a personal API key for CI and scripts: it acts as you, with your role, and it is shown once. | Option | Meaning | | --- | --- | | `--label <label>` | A name for the key (1 to 80 characters), to tell keys apart | ```sh nexus auth tokens create --label "CI deploys" ``` ## nexus auth tokens revoke ```sh nexus auth tokens revoke <id> ``` Revoke one of your tokens at once (owners and admins: anyone's). --- <!-- /docs/cli/keys --> # keys > Your organization's own provider keys (BYOK): Gateway calls each provider with its key. Your organization's own provider keys (BYOK): Gateway calls each provider with its key. ## nexus keys add ```sh nexus keys add <provider> <key> [--team <slug|id>] [--user <me|id>] ``` Bring your own provider key (owners and admins); encrypted at rest. With --team or --user, a team's or a person's key, which their calls use first. | Option | Meaning | | --- | --- | | `--team <slug|id>` | The team that holds the key: its slug or id | | `--user <me|id>` | The person who holds the key: me, or their user id | ```sh nexus keys add anthropic sk-ant-… ``` ## nexus keys list ```sh nexus keys list ``` Your provider keys, masked, with the teams' and people's keys you may read. ```sh nexus keys list --json ``` ## nexus keys history ```sh nexus keys history <provider> [--team <slug|id>] [--user <me|id>] ``` A provider key's versions: who added each, when, and its last four characters. | Option | Meaning | | --- | --- | | `--team <slug|id>` | The team that holds the key: its slug or id | | `--user <me|id>` | The person who holds the key: me, or their user id | ## nexus keys replace ```sh nexus keys replace <provider> <key> [--team <slug|id>] [--user <me|id>] [--dry-run] ``` Replace a provider key, checked against its provider first (owners and admins). | Option | Meaning | | --- | --- | | `--team <slug|id>` | The team that holds the key: its slug or id | | `--user <me|id>` | The person who holds the key: me, or their user id | | `--dry-run` | Show what would change, change nothing | ## nexus keys disable ```sh nexus keys disable <provider> [--team <slug|id>] [--user <me|id>] [--dry-run] ``` Stop calls from using a provider key; it stays sealed (owners and admins). | Option | Meaning | | --- | --- | | `--team <slug|id>` | The team that holds the key: its slug or id | | `--user <me|id>` | The person who holds the key: me, or their user id | | `--dry-run` | Show what would change, change nothing | ## nexus keys enable ```sh nexus keys enable <provider> [--team <slug|id>] [--user <me|id>] [--dry-run] ``` Use a disabled or rejected provider key again, checked against its provider first (owners and admins). | Option | Meaning | | --- | --- | | `--team <slug|id>` | The team that holds the key: its slug or id | | `--user <me|id>` | The person who holds the key: me, or their user id | | `--dry-run` | Show what would change, change nothing | ## nexus keys remove ```sh nexus keys remove <provider> [--team <slug|id>] [--user <me|id>] [--dry-run] ``` Delete a provider key; its versions stay (owners and admins). | Option | Meaning | | --- | --- | | `--team <slug|id>` | The team that holds the key: its slug or id | | `--user <me|id>` | The person who holds the key: me, or their user id | | `--dry-run` | Show what would change, change nothing | ## nexus keys revoke ```sh nexus keys revoke <scoped key id> [--dry-run] ``` Revoke a module's scoped key before it expires (owners and admins): its key id (keyId in the JSON of nexus spend, or the audit log), or its smk_… id. | Option | Meaning | | --- | --- | | `--dry-run` | Show what would change, change nothing | --- <!-- /docs/cli/models --> # models > The models you may use (--all: the whole catalog, coming soon too). The models you may use (--all: the whole catalog, coming soon too). ## nexus models ```sh nexus models [--all] [--team T] ``` The models you may use (--all: the whole catalog, coming soon too). | Option | Meaning | | --- | --- | | `--all` | The whole catalog, coming-soon models included | | `--team <T>` | The models allowed in this team | ```sh nexus models nexus models --all --json ``` --- <!-- /docs/cli/chat --> # chat > A chat session, the same as Nexus UI's home: the answer streams; a prompt continues the session you used last. A chat session, the same as Nexus UI's home: the answer streams; a prompt continues the session you used last. ## nexus chat sessions ```sh nexus chat sessions [list] [--all] [--search words] [--limit N] ``` Your chat sessions, most recent first (--all: archived ones too). | Option | Meaning | | --- | --- | | `--all` | The whole catalog, coming-soon models included | | `--search <words>` | Only sessions with these words in the title or messages | | `--limit <N>` | At most this many (1 to 100) | ```sh nexus chat sessions images chs_… --out shots ``` ## nexus chat sessions show ```sh nexus chat sessions show <id> ``` A session's messages, with the model, cost and sources of each answer. ## nexus chat sessions images ```sh nexus chat sessions images <id> [<image>…] [--out dir] [--force] ``` Save a session's images to files: every question's, or the ones named by id. | Option | Meaning | | --- | --- | | `--out <dir>` | The directory to save the images in (default: the working directory; made if it is missing) | | `--force` | Overwrite files that are already there | ```sh nexus chat sessions images chs_… --out shots ``` ## nexus chat sessions rename ```sh nexus chat sessions rename <id> <title…> ``` Give a session a title. ## nexus chat sessions archive ```sh nexus chat sessions archive <id> [--undo] ``` Hide a session from the list (--undo brings it back). | Option | Meaning | | --- | --- | | `--undo` | Undo it: restore an archived session | ## nexus chat sessions delete ```sh nexus chat sessions delete <id> ``` Delete a session and its messages. ## nexus chat share ```sh nexus chat share <session> [--org | --team T | --people a@x,b@y] [--replace] [--allow-continue] nexus chat share <session> --to a@x,b@y | --public [--expires 30d] [--include-code] nexus chat share <session> --private ``` Share a session as an artifact: a snapshot for your organization, chosen teams or chosen people (again: a new version; --replace revokes the earlier ones). - `nexus chat share <session> --to a@x,b@y | --public [--expires 30d] [--include-code]`: Share it outside your organization, as its settings allow: with named people by email (they sign in with that email to open it) or anyone with the link. - `nexus chat share <session> --private`: Stop sharing a session: revoke every version, so only you can read it. | Option | Meaning | | --- | --- | | `--org` | Share with everyone in your organization | | `--team <T>` | Share with these teams (slugs, comma-separated) and the teams under them | | `--people <a@x,b@y>` | Share with these people in your organization (emails, comma-separated) | | `--replace` | Revoke the session's earlier versions, so only this audience can open it | | `--allow-continue` | Let readers continue it in a new private chat of their own | | `--to <a@x,b@y>` | Share outside your organization with these people (emails, comma-separated); they sign in with that email to open it | | `--public` | Share with anyone who has the link (unguessable, not indexed by search engines) | | `--expires <30d>` | When a public link stops working: 30d, 12h or a number of days | | `--include-code` | Keep an old code session's sources in a share outside your organization (only if your organization allows it) | | `--private` | Stop sharing: revoke every version, so only you can read it | ## nexus chat export ```sh nexus chat export <session> [--md] [--out file] ``` A session as Markdown, to stdout or a file. | Option | Meaning | | --- | --- | | `--md` | As Markdown (the only format for now) | | `--out <file>` | Write it to this file instead of stdout | --- <!-- /docs/cli/policy --> # policy > Model access: allow and deny lists per organization, team and agent, and time-boxed operator controls; a deny always wins. Which connectors the organization's members may use. Model access: allow and deny lists per organization, team and agent, and time-boxed operator controls; a deny always wins. Which connectors the organization's members may use. ## nexus policy show ```sh nexus policy show [org|team/<slug>|agent/<claude|codex>] ``` A level's rule, what it inherits, and what it allows. ```sh nexus policy show team/web ``` ## nexus policy set ```sh nexus policy set <target> --allow a,b --deny c nexus policy set <target> --default m nexus policy set <target> --from rule.yaml | --clear ``` Replace a list (--allow all, --deny none clear it); owners and admins. - `nexus policy set <target> --default m`: The default for nexus/auto (an agent's default for agent/…). - `nexus policy set <target> --from rule.yaml | --clear`: A whole rule from a file, or remove the level's rule. | Option | Meaning | | --- | --- | | `--allow <a,b>` | Allowed model patterns, comma-separated (all clears the list) | | `--deny <c>` | Denied model patterns, comma-separated (none clears the list) | | `--default <m>` | The default model | | `--from <rule.yaml>` | A whole rule from a YAML or JSON file | | `--clear` | Remove the level's own rule | ```sh nexus policy set org --deny "anthropic/claude-fable-*" ``` ## nexus policy test ```sh nexus policy test [--model m] [--as who] [--team T] [--agent a] ``` Would it be allowed, and by which rule (exit 1 if refused). | Option | Meaning | | --- | --- | | `--model <m>` | A model (provider/model, or auto) | | `--as <who>` | Test as this person (email or user id) | | `--team <T>` | Test as a member of this team | | `--agent <a>` | Test for a coding agent (claude or codex) | | Exit code | Meaning | | --- | --- | | 0 | Allowed | | 1 | Refused | ```sh nexus policy test --agent claude --model claude-haiku-5-5 ``` ## nexus policy controls ```sh nexus policy controls [--team <slug>] ``` The operator controls in force that apply to you (all of them for owners and admins), or a team's with --team. | Option | Meaning | | --- | --- | | `--team <slug>` | Act through this team: a lead may pause or limit it, or a person or key in it or in a team under it | ## nexus policy pause ```sh nexus policy pause <org|team/<slug>|person/<id>|key/<id>> --reason r --expires 12h [--team <slug>] ``` Stop model traffic for a target until it expires; owners and admins, or a team lead with --team. | Option | Meaning | | --- | --- | | `--reason <r>` | Why the control is needed; the audit log and the people it applies to can read it | | `--expires <12h>` | How long the control stays in force: 30d, 12h or a number of days | | `--team <slug>` | Act through this team: a lead may pause or limit it, or a person or key in it or in a team under it | ```sh nexus policy pause person/usr_123 --reason "runaway spend" --expires 12h ``` ## nexus policy limit ```sh nexus policy limit <target> --models a,b --reason r --expires 12h [--team <slug>] ``` Narrow a target to these models until it expires; owners and admins, or a team lead with --team. | Option | Meaning | | --- | --- | | `--models <a,b>` | The models a limit narrows to, or an override allows, comma-separated | | `--reason <r>` | Why the control is needed; the audit log and the people it applies to can read it | | `--expires <12h>` | How long the control stays in force: 30d, 12h or a number of days | | `--team <slug>` | Act through this team: a lead may pause or limit it, or a person or key in it or in a team under it | ## nexus policy override ```sh nexus policy override <target> --models a,b --reason r --expires 12h ``` Allow these models past a deny until it expires; owners and admins. | Option | Meaning | | --- | --- | | `--models <a,b>` | The models a limit narrows to, or an override allows, comma-separated | | `--reason <r>` | Why the control is needed; the audit log and the people it applies to can read it | | `--expires <12h>` | How long the control stays in force: 30d, 12h or a number of days | ## nexus policy clear ```sh nexus policy clear <control-id> [--team <slug>] ``` Take a control out of force; owners and admins, or a team lead with --team. | Option | Meaning | | --- | --- | | `--team <slug>` | Act through this team: a lead may pause or limit it, or a person or key in it or in a team under it | ## nexus policy connectors ```sh nexus policy connectors ``` Which connectors your organization's members may use. ## nexus policy connector ```sh nexus policy connector <name> <disabled|available|enabled_for_all> [--teams a,b] ``` Choose who may use a connector; owners and admins. | Option | Meaning | | --- | --- | | `--teams <a,b>` | Only these teams' members and the teams under them, comma-separated slugs (default: everyone) | ## nexus policy grants ```sh nexus policy grants [list] nexus policy grants set <product/capability> --connector c --actions a,b nexus policy grants set robustness/review --for-mode <shadow|comment|comment_and_check> ``` The connector writes each module may make (write grants), and what may be granted. - `nexus policy grants set <product/capability> --connector c --actions a,b`: Set a module's granted writes of one connector, in full (an empty --actions revokes them); owners and admins. - `nexus policy grants set robustness/review --for-mode <shadow|comment|comment_and_check>`: Grant Nexus Review exactly what the mode needs, and revoke the rest; owners and admins. | Option | Meaning | | --- | --- | | `--connector <c>` | The connector the grants are for (github; the default with --for-mode) | | `--actions <a,b>` | The writes the module holds, in full, comma-separated (empty revokes them all) | | `--for-mode <shadow|comment|comment_and_check>` | Grant Nexus Review exactly what this mode needs: shadow none, comment pull_review, comment_and_check pull_review,check_run | ## nexus policy review-events ```sh nexus policy review-events [show] nexus policy review-events set <comment|request_changes|full> ``` Which review events a module may post on pull requests: comment, request_changes or full (the default). - `nexus policy review-events set <comment|request_changes|full>`: Choose whether modules may request changes and approve; owners and admins. ## nexus policy agent-writes ```sh nexus policy agent-writes [show] nexus policy agent-writes <on|off> ``` Whether your agents make your organization's allowed connector writes without a confirmation in Nexus. - `nexus policy agent-writes <on|off>`: Turn your agents' writes on or off; only you, from your own sign-in, never an agent link. --- <!-- /docs/cli/products --> # Products > Run the products registered on your Gateway and read their results. Product commands are discovered from each product's manifest, so `nexus help` lists the ones your Gateway has. Run the products registered on your Gateway and read their results. Product commands are discovered from each product's manifest, so `nexus help` lists the ones your Gateway has. ## nexus <product> ```sh nexus <product> <verb> [capability] [--<input> value] [--team T] [--no-wait] ``` A product's commands, discovered from the modules your Gateway registers (nexus modules): run, report and the rest. | Option | Meaning | | --- | --- | | `--team <T>` | A team's slug | | `--no-wait` | Start the run and return its id without waiting | ```sh nexus robustness run --repo https://github.com/nexus-demo/hello-factory nexus robustness status review --repo https://github.com/nexus-demo/hello-factory ``` ## nexus modules ```sh nexus modules ``` Registered products and capabilities (their commands: nexus <product> --help). ```sh nexus modules --json ``` ## nexus connectors ```sh nexus connectors ``` Connectors Gateway offers, with their read and write operations. ```sh nexus connectors --json ``` --- <!-- /docs/cli/spend --> # spend and analytics > Budget, spend and usage. Budget, spend and usage. ## nexus spend ```sh nexus spend [calls] [--by team|person|model|provider|key|product|day] [--from D] [--to D] [--team T] [--person P] [--model M] [--provider P] [--product P] [--status S] [--session S] [--limit N] [--cursor C] [--csv | --jsonl] [--out F] ``` Budget and spend by product and capability, or by team; spend calls lists each model call, and --csv or --jsonl writes them to a file. | Option | Meaning | | --- | --- | | `--by <team|person|model|provider|key|product|day>` | Show the analytics table grouped by team, person, model, provider, key, product or day | | `--from <D>` | With --by, calls, --csv or --jsonl: from this day (YYYY-MM-DD, UTC; at most 366 days in all) | | `--to <D>` | With --by, calls, --csv or --jsonl: until this day, included (YYYY-MM-DD, UTC) | | `--team <T>` | With --by, calls, --csv or --jsonl: only this team and the teams under it; with calls or a file, unassigned for calls with no team | | `--person <P>` | With calls, --csv or --jsonl: only this person's calls (a user id) | | `--model <M>` | With calls, --csv or --jsonl: only this model; - for calls with none | | `--provider <P>` | With calls, --csv or --jsonl: only this provider; - for calls with none | | `--product <P>` | With calls, --csv or --jsonl: only this product, or product/capability (Analytics' key) | | `--status <S>` | With calls, --csv or --jsonl: only these statuses, comma-separated: settled, failed, refused, released | | `--session <S>` | With calls, --csv or --jsonl: only this agent or chat session's calls (its id) | | `--limit <N>` | With calls: at most this many calls on a page (1 to 500, default 50) | | `--cursor <C>` | With calls, --csv or --jsonl: the next page of calls, or where a stopped file continues (its manifest's nextCursor) | | `--csv` | Write the matching calls as CSV, at most 100,000 rows a file; its manifest (rows, nextCursor for the rest) is in the audit log | | `--jsonl` | Write the matching calls as JSON Lines, at most 100,000 rows a file; its last line is the manifest | | `--out <F>` | With --csv or --jsonl: write the file here instead of stdout | ```sh nexus spend nexus spend --by team --json nexus spend calls --team web --status failed nexus spend --csv --from 2026-10-01 > calls.csv nexus spend --jsonl --out calls.jsonl ``` ## nexus analytics ```sh nexus analytics [--by team|person|model|provider|key|product|day] [--days N] [--from D] [--to D] [--team T] [--depth N] [--under T] [--person P] [--model M] [--provider P] [--product P] [--csv | --jsonl] [--cursor C] [--out F] ``` Usage by team, person, model, provider, key, product or day, with a daily series. | Option | Meaning | | --- | --- | | `--by <team|person|model|provider|key|product|day>` | Group by team, person, model, provider, key, product or day | | `--days <N>` | The last N days (1 to 366) | | `--from <D>` | From this day (YYYY-MM-DD) | | `--to <D>` | Until this day (YYYY-MM-DD) | | `--team <T>` | Only this team's usage | | `--depth <N>` | How many levels of teams to show or roll up | | `--under <T>` | Only teams under this one | | `--person <P>` | With --csv or --jsonl: only this person's usage (a user id) | | `--model <M>` | With --csv or --jsonl: only this model; - for calls with none | | `--provider <P>` | With --csv or --jsonl: only this provider; - for calls with none | | `--product <P>` | With --csv or --jsonl: only this product, or product/capability | | `--csv` | Write the usage file as CSV, one row per day, team, person, model, provider and product; its manifest is in the audit log | | `--jsonl` | Write the usage file as JSON Lines; its last line is the manifest | | `--cursor <C>` | With --csv or --jsonl: continue a file the row limit stopped, from its manifest's nextCursor | | `--out <F>` | With --csv or --jsonl: write the file here instead of stdout | ```sh nexus analytics --by team --days 7 nexus analytics --by model --json nexus analytics --csv --days 30 > usage.csv nexus analytics --jsonl --team web --out usage.jsonl ``` --- <!-- /docs/cli/team --> # team > Teams in your organization, nested; owners and admins manage them. Teams in your organization, nested; owners and admins manage them. ## nexus team list ```sh nexus team list ``` Teams in your organization, with yours marked. ## nexus team tree ```sh nexus team tree [--depth N] ``` Teams nested under their parents, with levels, leads and headcount. | Option | Meaning | | --- | --- | | `--depth <N>` | How many levels of teams to show or roll up | ## nexus team show ```sh nexus team show <slug> ``` A team: its path, child teams, members and pending members. ## nexus team create ```sh nexus team create <slug> [--parent P] [--level L] [--name N] ``` Create a team, optionally under a parent (owners and admins). | Option | Meaning | | --- | --- | | `--parent <P>` | The parent team's slug | | `--level <L>` | Your own label for the team's level (e.g. department) | | `--name <N>` | A display name | ```sh nexus team create web --name "Web" ``` ## nexus team move ```sh nexus team move <slug> --parent P | --root ``` Put a team under another one, or at the top (owners and admins). | Option | Meaning | | --- | --- | | `--parent <P>` | The parent team's slug | | `--root` | Put the team at the top, under no parent | ## nexus team rename ```sh nexus team rename <slug> <new-slug> [--name N] ``` Change a team's slug, name, --level or --description (owners and admins). | Option | Meaning | | --- | --- | | `--name <N>` | A display name | | `--level <L>` | Your own label for the team's level (e.g. department) | | `--description <text>` | A description | ## nexus team delete ```sh nexus team delete <slug> --yes [--cascade] ``` Delete a team (--cascade: and every team under it); spend stays. | Option | Meaning | | --- | --- | | `--yes` | Confirm a change that deletes or sends more than one thing | | `--cascade` | Also delete every team under it | ## nexus team add ```sh nexus team add <slug> <email|userId> [--lead] [--home] ``` Add someone; an email not in the organization yet is pending until they join. | Option | Meaning | | --- | --- | | `--lead` | Add the person as a lead | | `--home` | Make it the person's default team | ```sh nexus team add web bo@acme.example ``` ## nexus team remove ```sh nexus team remove <slug> <email|userId> ``` Take someone out of a team (owners and admins). ## nexus team pending ```sh nexus team pending [--team T] [--cancel <email|id>] ``` People added by email who have not joined yet (owners and admins). | Option | Meaning | | --- | --- | | `--team <T>` | Only people pending in this team | | `--cancel <email|id>` | Cancel a pending member (email or id) | ## nexus team import ```sh nexus team import <file> [--dry-run] [--plan P] [--prune [--yes]] nexus team import <file> --invite [--dry-run] [--yes] ``` Load teams, leads and members from a YAML or JSON file; --dry-run shows the changes and a plan to apply exactly them (owners and admins). - `nexus team import <file> --invite [--dry-run] [--yes]`: Also invite the file's people who are not in the organization yet (the sign-in provider emails them; never without --invite). | Option | Meaning | | --- | --- | | `--dry-run` | Show what would change, change nothing | | `--plan <P>` | Apply exactly the plan a dry run printed | | `--prune` | Also remove teams and memberships missing from the file | | `--yes` | Confirm a change that deletes or sends more than one thing | | `--invite` | Also invite the file's people who are not in the organization yet | ```sh nexus team import teams.yaml --dry-run ``` ## nexus team use ```sh nexus team use <slug> ``` Make it your default team: where your spend goes when you name none. --- <!-- /docs/cli/members --> # members > Everyone in your organization, who has not joined yet, and invitations. Everyone in your organization, who has not joined yet, and invitations. ## nexus members list ```sh nexus members list ``` Everyone in your organization, by role. ## nexus members pending ```sh nexus members pending [--team T] ``` People in teams by email who have not joined yet (owners and admins). | Option | Meaning | | --- | --- | | `--team <T>` | Only people pending in this team | ## nexus members invite ```sh nexus members invite <email…> [--role admin] [--dry-run] [--yes] nexus members invite --pending [--dry-run] [--yes] ``` Invite people by email; the sign-in provider sends each one (owners and admins). - `nexus members invite --pending [--dry-run] [--yes]`: Invite everyone in a team by email who has not joined yet. | Option | Meaning | | --- | --- | | `--role <admin>` | The role to invite as (member or admin) | | `--dry-run` | Show what would change, change nothing | | `--yes` | Confirm a change that deletes or sends more than one thing | | `--pending` | Everyone added to a team by email who has not joined yet | ```sh nexus members invite ada@acme.example --dry-run nexus members invite --pending --yes ``` ## nexus members remove ```sh nexus members remove <email|userId> [--dry-run] [--yes] ``` Remove someone from the organization; recoverable for 30 days (owners and admins). | Option | Meaning | | --- | --- | | `--dry-run` | Show what would change, change nothing | | `--yes` | Confirm a change that deletes or sends more than one thing | ## nexus members removed ```sh nexus members removed ``` Removed members, and until when each can be recovered (owners and admins). ## nexus members recover ```sh nexus members recover <userId> [--dry-run] ``` Bring back a removed member with their teams, inside 30 days (owners and admins). | Option | Meaning | | --- | --- | | `--dry-run` | Show what would change, change nothing | --- <!-- /docs/cli/audit --> # audit > Who changed what in your organization, from where, newest first. Who changed what in your organization, from where, newest first. ## nexus audit ```sh nexus audit [options] ``` Who changed what in your organization, from where, newest first. | Option | Meaning | | --- | --- | | `--since <7d>` | From this long ago (30m, 24h, 7d, 2w) or an ISO time; default 7d | | `--until <time>` | Up to this time | | `--action <a>` | An action (team.moved), a list (a,b) or a prefix (team.*) | | `--actor <email>` | Changes made by this person (email or user id) | | `--team <slug>` | Changes to this team and the teams under it | | `--target <id>` | Changes to this target (id or slug) | | `--limit <n>` | Events per page (1 to 500, default 50); --cursor <c> for the next page | | `--csv` | Every matching event as CSV on stdout (owners, admins and team leads) | ```sh nexus audit --since 24h nexus audit --action 'team.*' --json nexus audit --csv > audit.csv ``` --- <!-- /docs/cli/agents --> # claude, codex, agy and agents > Run Claude Code and Codex with every model call through Nexus Gateway: metered, checked against your policies and attributed to you. `nexus agy` runs Antigravity on your own Google AI plan. `nexus agents` shows each agent's setup on this machine. Run Claude Code and Codex with every model call through Nexus Gateway: metered, checked against your policies and attributed to you. `nexus agy` runs Antigravity on your own Google AI plan. `nexus agents` shows each agent's setup on this machine. ## nexus claude ```sh nexus claude [--json] [--subscription | --api | --via <route>] [--team <slug>] [--recording [<id>|latest]] [--no-skills] [--] [claude args…] ``` Claude Code on the route you chose (nexus agents): through Nexus Gateway, metered, checked against your policies and attributed to you, or on your own Claude plan. | Option | Meaning | | --- | --- | | `--json` | A JSON summary on stdout when the agent exits | | `--subscription` | Use your Claude subscription (claude auth login), not Gateway: model calls are not metered or checked (also NEXUS_CLAUDE_AUTH=subscription) | | `--api` | Through Gateway for this run, whatever route you saved (also NEXUS_CLAUDE_AUTH=gateway) | | `--via <route>` | The route for this run: gateway or subscription; default: your saved route (nexus agents) | | `--team <slug>` | The team this session's spend goes to (also NEXUS_TEAM) | | `--recording <id>` | Start on a screen recording from Nexus for Mac (⌥⇧S): its id, or latest (the default); Claude Code is told how to read it | | `--model <auto>` | Claude Code's own flag, read by Nexus: auto runs on the model Gateway chooses | | Exit code | Meaning | | --- | --- | | 0 | The agent's own exit code is passed through | ```sh nexus claude -p "hello" nexus claude --team web nexus claude --subscription nexus claude --recording latest ``` ## nexus codex ```sh nexus codex [--json] [--subscription | --api | --via <route>] [--team <slug>] [--recording [<id>|latest]] [--no-skills] [--] [codex args…] ``` Codex on the route you chose (nexus agents): through Nexus Gateway, metered, checked against your policies and attributed to you, or on your own ChatGPT plan. | Option | Meaning | | --- | --- | | `--json` | A JSON summary on stdout when the agent exits | | `--subscription` | Use your ChatGPT plan (codex login), not Gateway: model calls are not metered or checked (also NEXUS_CODEX_AUTH=subscription) | | `--api` | Through Gateway for this run, whatever route you saved (also NEXUS_CODEX_AUTH=gateway) | | `--via <route>` | The route for this run: gateway or subscription; default: your saved route (nexus agents) | | `--team <slug>` | The team this session's spend goes to (also NEXUS_TEAM) | | `--recording <id>` | Start on a screen recording from Nexus for Mac (⌥⇧S): its id, or latest (the default); Codex gets its contact sheet | | `--model <auto>` | Codex's own flag, read by Nexus: auto runs on the model Gateway chooses | | Exit code | Meaning | | --- | --- | | 0 | The agent's own exit code is passed through | ```sh nexus codex exec "hello" nexus codex --team web nexus codex --subscription nexus codex --recording latest ``` ## nexus agy ```sh nexus agy [--json] [--subscription] [--team <slug>] [--] [agy args…] ``` Antigravity on your own Google AI plan: its calls go straight to Google, and Nexus records the session. | Option | Meaning | | --- | --- | | `--json` | A JSON summary on stdout when the agent exits | | `--subscription` | Run on your Google AI plan, the default (also NEXUS_ANTIGRAVITY_AUTH=subscription) | | `--team <slug>` | The team this session is attributed to (also NEXUS_TEAM) | | `--model <id>` | Agy's own flag: the model it runs, by its id (auto is not available) | | Exit code | Meaning | | --- | --- | | 0 | The agent's own exit code is passed through | | 2 | --api, --via gateway, --model auto or --recording: not available, and the agent does not start | ```sh nexus agy -p "hello" nexus agy --team web nexus agy -- --conversation <id> ``` ## nexus agents list ```sh nexus agents list ``` Each local launcher (also plain nexus agents): install, sign-in, route, payer, and setup steps. ## nexus agents use ```sh nexus agents use <claude|codex|agy|cursor-agent> <gateway|subscription|default> ``` The route an agent takes when you name none, in every Nexus app you sign in to. ```sh nexus agents use claude subscription nexus agents use codex default ``` ## nexus agents setup ```sh nexus agents setup <claude|codex> ``` How to run an agent through Gateway, from its recipe: the limits first, then each step. Writes nothing. ```sh nexus agents setup claude ``` ## nexus agents share ```sh nexus agents share <session|latest> [--org | --team T | --people a@x,b@y] [--include-thinking] nexus agents share <session|latest> --to a@x,b@y | --public [--expires 30d] nexus agents share <session|latest> --private ``` Share a Claude Code session (nexus claude) as an artifact, from its transcript on this machine: latest is this folder's newest. Again: a new version, and the earlier ones revoked. - `nexus agents share <session|latest> --to a@x,b@y | --public [--expires 30d]`: Share it outside your organization, as its settings allow. - `nexus agents share <session|latest> --private`: Stop sharing a session: revoke every version, so only you can read it. | Option | Meaning | | --- | --- | | `--org` | Share with everyone in your organization | | `--team <T>` | Share with these teams (slugs, comma-separated) and the teams under them | | `--people <a@x,b@y>` | Share with these people in your organization (emails, comma-separated) | | `--include-thinking` | Keep the agent's thinking in the shared session (left out by default) | | `--to <a@x,b@y>` | Share outside your organization with these people (emails, comma-separated); they sign in with that email to open it | | `--public` | Share with anyone who has the link (unguessable, not indexed by search engines) | | `--expires <30d>` | When a public link stops working: 30d, 12h or a number of days | | `--private` | Stop sharing: revoke every version, so only you can read it | ```sh nexus agents share latest --org ``` --- <!-- /docs/cli/budgets --> # budgets > Monthly spend limits per person (UTC calendar month): the organization's default and each person's override; a call that would go over is refused. Monthly spend limits per person (UTC calendar month): the organization's default and each person's override; a call that would go over is refused. ## nexus budgets list ```sh nexus budgets list ``` This month's spend limits: the organization's default per person, and each person's limit, spend, what is left and who is at their limit. ## nexus budgets show ```sh nexus budgets show <email|userId|me> ``` One person's month: their limit and where it comes from, spend and what is left. ```sh nexus budgets show me --json ``` ## nexus budgets default ```sh nexus budgets default <amount|none> ``` Set the organization's default monthly limit per person, in USD; none clears it (owners). ```sh nexus budgets default 50 ``` ## nexus budgets set ```sh nexus budgets set <email|userId> <amount|default> ``` Set one person's monthly limit, above or below the default; default removes it (owners, and admins an owner allows; an owner's limit: owners). ```sh nexus budgets set ada@acme.example 100 nexus budgets set ada@acme.example default ``` ## nexus budgets managers ```sh nexus budgets managers [list] nexus budgets managers add <email|userId> nexus budgets managers remove <email|userId> ``` Who may set person limits: every owner, and each admin an owner allowed. - `nexus budgets managers add <email|userId>`: Allow an admin to set person limits (owners). - `nexus budgets managers remove <email|userId>`: Stop an admin from setting person limits (owners). ```sh nexus budgets managers add bo@acme.example ``` --- <!-- /docs/cli/budget --> # budget > The organization's or a team's spend cap per day, week or month: owners and admins set it; a member sees what is left for them. --mode and --warn-at are for teams. Person limits: nexus budgets. The organization's or a team's spend cap per day, week or month: owners and admins set it; a member sees what is left for them. --mode and --warn-at are for teams. Person limits: nexus budgets. ## nexus budget ```sh nexus budget set org|team/<slug> <amount>/<day|week|month> [--mode hard_stop] [--warn-at 80] [--dry-run] ``` The organization's or a team's spend cap per day, week or month: owners and admins set it; a member sees what is left for them. --mode and --warn-at are for teams. Person limits: nexus budgets. | Option | Meaning | | --- | --- | | `--mode <hard_stop>` | Hard_stop (warn and approval are not available yet) | | `--warn-at <80>` | For mode warn, which is not available yet | | `--dry-run` | Show what would change, change nothing | ```sh nexus budget set org 2000/month nexus budget set org 50/week --dry-run nexus budget show org nexus budget set team/web 500/month nexus budget set team/web 500/month --dry-run nexus budget show team/web ``` --- <!-- /docs/cli/update --> # update > Update this CLI to the version your Gateway publishes (GET /cli/version). Update this CLI to the version your Gateway publishes (GET /cli/version). ## nexus update ```sh nexus update [--check] [--rollback] [--json] ``` Update this CLI to the version your Gateway publishes (GET /cli/version). | Option | Meaning | | --- | --- | | `--check` | Only check; change nothing | | `--rollback` | Restore the version before the last update | | `--json` | Print only JSON on stdout | | Exit code | Meaning | | --- | --- | | 0 | Updated, already up to date, rolled back, or (--check) checked | | 1 | Nothing changed: Gateway unreachable, a checksum mismatch, or this CLI was not installed by Nexus's installer | ```sh nexus update nexus update --check --json nexus update --rollback ``` --- <!-- /docs/cli/help --> # help and version > What the CLI and your Gateway can do, and which version you run. What the CLI and your Gateway can do, and which version you run. ## nexus help ```sh nexus help [--json] ``` Every command; --json: this list, for scripts and the docs. ```sh nexus help --json ``` ## nexus version ```sh nexus --version [--json] ``` The CLI's version: semver and build, e.g. 0.2.0+abc1234. ```sh nexus --version nexus --version --json ``` --- <!-- /docs/cli/artifacts --> # artifacts > Chats shared as snapshots (Nexus Artifacts): inside your organization (everyone, chosen teams or chosen people) or outside it (named people by email, or anyone with the link), as its settings allow. Chats shared as snapshots (Nexus Artifacts): inside your organization (everyone, chosen teams or chosen people) or outside it (named people by email, or anyone with the link), as its settings allow. ## nexus artifacts list ```sh nexus artifacts list [--mine | --shared-with-me] [--revoked | --all] nexus artifacts list --external [--audience A] [--author A] [--team T] ``` Artifacts shared with you and by you, newest first (--revoked: yours you revoked; --all: both); shared with you includes other organizations' shares to your email. - `nexus artifacts list --external [--audience A] [--author A] [--team T]`: Everything shared outside your organization, with opens, readers, requests and reports (owners and admins); --search narrows by title. | Option | Meaning | | --- | --- | | `--mine` | Only the artifacts you shared | | `--shared-with-me` | Only the artifacts others shared with you | | `--revoked` | Only your revoked artifacts | | `--all` | Active and revoked artifacts | | `--external` | Everything shared outside your organization (owners and admins) | | `--audience <A>` | External (named people) or public (anyone with the link) | | `--author <A>` | Only what this person shared (email or user id) | | `--team <T>` | Only artifacts shared from this team's sessions and the teams under it | | `--search <words>` | Only artifacts with these words in the title | ```sh nexus artifacts list --external --audience public ``` ## nexus artifacts show ```sh nexus artifacts show <id> ``` An artifact: who shared it with whom, its models and cost, and the conversation. ## nexus artifacts export ```sh nexus artifacts export <id> [--md] [--out file] ``` An artifact as Markdown, to stdout or a file. | Option | Meaning | | --- | --- | | `--md` | As Markdown (the only format for now) | | `--out <file>` | Write it to this file instead of stdout | ```sh nexus artifacts export art_… --md --out answer.md ``` ## nexus artifacts images ```sh nexus artifacts images <id|token|link> [<image>…] [--out dir] [--force] ``` Save an artifact's images to files: every question's, or the ones named by id; a public link's token or the link works too. | Option | Meaning | | --- | --- | | `--out <dir>` | The directory to save the images in (default: the working directory; made if it is missing) | | `--force` | Overwrite files that are already there | ```sh nexus artifacts images art_… --out shots ``` ## nexus artifacts continue ```sh nexus artifacts continue <id> ``` Continue an artifact in a new private chat session of your own (when its author allows). ```sh nexus artifacts continue art_… ``` ## nexus artifacts access ```sh nexus artifacts access <id> [--grant E] [--deny E] [--remove E] ``` Who has an artifact shared outside, who asked for it and how often each opened it; grant, deny or remove people by email (its author, owners and admins). | Option | Meaning | | --- | --- | | `--grant <E>` | Give these people access (emails, comma-separated) | | `--deny <E>` | Refuse these people's requests (emails, comma-separated) | | `--remove <E>` | Take access away from these people (emails, comma-separated) | ```sh nexus artifacts access art_… --grant bo@partner.example ``` ## nexus artifacts request ```sh nexus artifacts request <id> [--message text] ``` Ask the author of an artifact shared outside their organization for access. | Option | Meaning | | --- | --- | | `--message <text>` | A note for the author | ## nexus artifacts revoke ```sh nexus artifacts revoke <id> [<id>…] ``` Stop sharing an artifact at once (yours; owners and admins: any they can read); several ids revoke in bulk. --- <!-- /docs/cli/pages --> # pages > Standalone HTML or Markdown pages, in versions that never change; share one with your organization, teams, people or a public link. Standalone HTML or Markdown pages, in versions that never change; share one with your organization, teams, people or a public link. ## nexus pages publish ```sh nexus pages publish <file> [--title T] [--format html|md|jsx|board] ``` Publish an HTML, Markdown, React (.jsx, .tsx) or board (.board.json) file as a new page (version 1); the title defaults to its <title> or first heading. | Option | Meaning | | --- | --- | | `--title <T>` | The page's title (default: its <title> or first # heading, else the file name) | | `--format <html|md|jsx|board>` | Html, md, jsx, sheet or board (default: from the file name; .md and .markdown are Markdown, .jsx and .tsx are React, .sheet.json is a sheet, .board.json is a board) | ```sh nexus pages publish report.html ``` ## nexus pages list ```sh nexus pages list ``` Your pages, most recently written first. ## nexus pages get ```sh nexus pages get <id> [<version>] [--source] [--out file] ``` A page's latest version, or the one named; --source prints or saves its source as written. | Option | Meaning | | --- | --- | | `--source` | The source as written, not the version's details | | `--out <file>` | Write the source to this file instead of stdout | ```sh nexus pages get pag_… --source --out report.html ``` ## nexus pages update ```sh nexus pages update <id> <file> [--base N] [--title T] ``` Write the next version from a file; --base refuses it if someone wrote a newer version since. | Option | Meaning | | --- | --- | | `--base <N>` | The version this was built on: refused if someone wrote a newer version since | | `--title <T>` | The page's title (default: its <title> or first # heading, else the file name) | ```sh nexus pages update pag_… report.html --base 2 ``` ## nexus pages versions ```sh nexus pages versions <id> ``` A page's versions, newest first: title, size and how each was written. ## nexus pages restore ```sh nexus pages restore <id> <version> [--base N] ``` Make a new version with an old version's title and content. | Option | Meaning | | --- | --- | | `--base <N>` | The version this was built on: refused if someone wrote a newer version since | ```sh nexus pages restore pag_… 1 ``` ## nexus pages delete ```sh nexus pages delete <id> --yes ``` Delete a page, every version and its content, for good. | Option | Meaning | | --- | --- | | `--yes` | Confirm a change that deletes or sends more than one thing | ```sh nexus pages delete pag_… --yes ``` ## nexus pages share ```sh nexus pages share <id> [--org | --team T | --people a@x,b@y | --to a@x,b@y | --public [--expires 30d]] [--pin N] ``` Share a page with your organization, teams, people, named outsiders or anyone with the link; --pin N pins that version, else readers see the latest. | Option | Meaning | | --- | --- | | `--org` | Share with everyone in your organization | | `--team <T>` | Share with these teams (slugs, comma-separated) and the teams under them | | `--people <a@x,b@y>` | Share with these people in your organization (emails, comma-separated) | | `--to <a@x,b@y>` | Share outside your organization with these people (emails, comma-separated); they sign in with that email to open it | | `--public` | Share with anyone who has the link (unguessable, not indexed by search engines) | | `--expires <30d>` | When a public link stops working: 30d, 12h or a number of days | | `--pin <N>` | Share this version of the page; without it, readers see the latest version | ```sh nexus pages share pag_… --team web --pin 2 ``` ## nexus pages open ```sh nexus pages open <id|art_id> [<version>] [--no-browser] ``` Open a page (or a version of it) or a shared page (its art_ id) in Nexus UI's viewer. | Option | Meaning | | --- | --- | | `--no-browser` | Only print the approval link; do not open a browser | ## nexus pages frame ```sh nexus pages frame <id|art_id> [<version>] ``` Print a signed URL that renders the page (the latest version, or the one named) with no sign-in, for five minutes. ## nexus pages export ```sh nexus pages export <id> [<version>] --format png|svg|pdf|pptx|html|zip [--board B] [--scale 1|2] [--out file] ``` Write the page as a file: one board as PNG or SVG, every board as PDF, PPTX or zip, or the page as standalone HTML; --board picks one board, or a deck's slide by its title or number. | Option | Meaning | | --- | --- | | `--format <png|svg|pdf|pptx|html|zip>` | Png or svg (one board), pdf (one page per board), pptx (one slide per board), html (the page, opens offline) or zip | | `--board <B>` | One board or slide, by its data-id, its name or its number from 1; a PNG or SVG of a design or a deck with several needs one | | `--scale <1|2>` | 1 or 2: the pixel ratio the boards render at (default: 2 for pdf and pptx, else 1) | | `--out <file>` | Write the file here (default: <id>[-<board>].<format> in the working directory) | ## nexus pages check ```sh nexus pages check <id> [<version>] ``` Check a design against its design system: colours, font sizes and spacing off its tokens, and text below WCAG AA contrast; it changes nothing. --- <!-- /docs/cli/design-system --> # design-system > Nexus Design's design systems: the tokens and notes designs are made with, served with and checked against. The built-in @nexus/brand is the default until you pick another. Nexus Design's design systems: the tokens and notes designs are made with, served with and checked against. The built-in @nexus/brand is the default until you pick another. ## nexus design-system list ```sh nexus design-system list ``` The organization's design systems: the built-in @nexus/brand first, and which one new designs use. ## nexus design-system show ```sh nexus design-system show [<name>] ``` A design system's link tag, tokens (CSS custom properties) and notes; the default without a name. ```sh nexus design-system show ``` ## nexus design-system sync ```sh nexus design-system sync <path> [--name N] [--default] ``` Read a repository's tokens (CSS variables, a Tailwind config, tokens.json), its DESIGN.md and its component names into a design system (owners and admins). | Option | Meaning | | --- | --- | | `--name <N>` | The design system's name (default: the folder's package.json name, else the folder's own) | | `--default` | Make it the default for new designs too | ```sh nexus design-system sync ./web --default ``` ## nexus design-system use ```sh nexus design-system use <name> ``` Make a design system the default for new designs (owners and admins). ```sh nexus design-system use acme ``` --- <!-- /docs/cli/skills --> # skills > Your own skills: SKILL.md files, kept in versions that never change; import one, export it unchanged, delete it. Promote one to your organization or a team. It is held until an approver who is not you approves it. Your own skills: SKILL.md files, kept in versions that never change; import one, export it unchanged, delete it. Promote one to your organization or a team. It is held until an approver who is not you approves it. ## nexus skills list ```sh nexus skills list ``` Your skills, most recently written first: name, latest version and description. ## nexus skills create ```sh nexus skills create <name> ``` Write a new skill in your editor ($VISUAL or $EDITOR), from a SKILL.md skeleton. ```sh nexus skills create release-notes ``` ## nexus skills import ```sh nexus skills import <path> [--update] ``` Add a SKILL.md, or a folder that holds one, as a new skill (version 1); only SKILL.md is sent, and the other files are named; --update writes a new version if you already have a skill of that name, unless the file is already its latest version. | Option | Meaning | | --- | --- | | `--update` | Write a new version if you already have a skill of that name, unless the file is already its latest version | ```sh nexus skills import ./pdf-processing nexus skills import ./pdf-processing --update ``` ## nexus skills export ```sh nexus skills export <name|id> [<version>] [--out dir] ``` Write a skill's SKILL.md, unchanged, to <dir>/<name>/SKILL.md. The version is a number or latest. A name that a library skill has exports that skill, at an approved version. | Option | Meaning | | --- | --- | | `--out <dir>` | The folder to write <name>/SKILL.md in (default: the working directory; made if it is missing) | ```sh nexus skills export pdf-processing --out skills ``` ## nexus skills delete ```sh nexus skills delete <name|id> --yes ``` Delete a skill, every version and its content, for good. | Option | Meaning | | --- | --- | | `--yes` | Confirm a change that deletes or sends more than one thing | ```sh nexus skills delete pdf-processing --yes ``` ## nexus skills promote ```sh nexus skills promote <name|id> [<version>] --to org|team/<slug> [--note TEXT] ``` Ask to promote a version of your skill (default: the latest) to the organization or a team you are in. The request is held until an owner, admin or team lead who is not you approves it. | Option | Meaning | | --- | --- | | `--to <org|team/<slug>>` | Where to promote it: org, or team/<slug> for a team you are in | | `--note <TEXT>` | Why you ask, for the approvers (at most 500 characters) | ```sh nexus skills promote pdf-processing --to org --note "For the whole team" nexus skills promote pdf-processing 2 --to team/web ``` ## nexus skills promotions ```sh nexus skills promotions [--state STATE] [--to TARGET] [--mine] [--limit N] [--cursor C] nexus skills promotions <id> ``` The promotion requests you can see, newest first: your own, and those you may approve. STATE is held, approved, refused or withdrawn. - `nexus skills promotions <id>`: One promotion request: who asked and from which version, a diff from the last approved version, and the full text. | Option | Meaning | | --- | --- | | `--state <STATE>` | Only requests in this state: held, approved, refused or withdrawn | | `--to <TARGET>` | Only requests to this target: org or team/<slug> | | `--mine` | Only the promotion requests you made | | `--limit <N>` | Requests per page (1 to 200, default 50) | | `--cursor <C>` | The next page: the cursor the last page printed | ```sh nexus skills promotions --state held nexus skills promotions spr_… ``` ## nexus skills approve ```sh nexus skills approve <id> [--reason TEXT] ``` Approve a held promotion request, so its version joins the library. Your sign-in decides; an API key cannot. | Option | Meaning | | --- | --- | | `--reason <TEXT>` | Why you approve it, for the author (optional, at most 500 characters) | ```sh nexus skills approve spr_… ``` ## nexus skills refuse ```sh nexus skills refuse <id> --reason TEXT ``` Refuse a held promotion request; the reason is required, and the author reads it. | Option | Meaning | | --- | --- | | `--reason <TEXT>` | Why you refuse it, for the author (required, at most 500 characters) | ```sh nexus skills refuse spr_… --reason "Say when to use it in the description" ``` ## nexus skills withdraw ```sh nexus skills withdraw <id> [--reason TEXT] [--all-versions] ``` Withdraw your held request, or (as an owner, admin or team lead) an approved version. --all-versions withdraws every approved version of that skill. | Option | Meaning | | --- | --- | | `--reason <TEXT>` | Why you withdraw it, for the author and the audit log (optional, at most 500 characters) | | `--all-versions` | Withdraw every approved version of that library skill, not only this one | ```sh nexus skills withdraw spr_… --all-versions ``` ## nexus skills library ```sh nexus skills library [--to TARGET] ``` The skills your organization and teams approved for you to load, with scope and approved version. A name that two skills share is marked duplicate_name. | Option | Meaning | | --- | --- | | `--to <TARGET>` | Only skills promoted to this target: org or team/<slug> | ```sh nexus skills library ``` --- <!-- /docs/cli/org --> # org > Your organizations (Personal first, then your companies; switch without signing in again) and the organization's settings: how long chat messages are kept and how artifacts may be shared outside it; owners and admins change them. `nexus orgs` is the same command. Your organizations (Personal first, then your companies; switch without signing in again) and the organization's settings: how long chat messages are kept and how artifacts may be shared outside it; owners and admins change them. `nexus orgs` is the same command. ## nexus org list ```sh nexus org list ``` Your organizations: Personal first, then your companies; the one you are signed in to is marked. ## nexus org waiting ```sh nexus org waiting ``` Your pending Gateway approvals and waiting cloud sessions, by organization. ## nexus org switch ```sh nexus org switch <org> ``` Sign in to another of your organizations (its slug, or personal): a new token, saved in your config. ```sh nexus org switch personal nexus org switch acme --json ``` ## nexus org settings ```sh nexus org settings [list] nexus org settings get <key> nexus org settings set <key> <value> ``` Your organization's settings: each value and its default. - `nexus org settings get <key>`: One setting's value. - `nexus org settings set <key> <value>`: Change a setting (owners and admins): a JSON value or a word; null restores the default. ```sh nexus org settings nexus org settings set artifacts.external named nexus org settings set artifacts.external.domains '{"allow":["partner.example"],"deny":[]}' nexus org settings set chatRetentionDays null nexus org settings set agentSubscriptions false nexus org settings set webSearch.engine borrowed ``` ## nexus org domains ```sh nexus org domains [list] nexus org domains add <domain> [--enrollment M] [--dry-run] nexus org domains remove <domain> [--dry-run] ``` Your organization's verified email domains and how people on them join (owners and admins). - `nexus org domains add <domain> [--enrollment M] [--dry-run]`: Add a domain you have a verified email on; the sign-in provider invites everyone with a verified email there. - `nexus org domains remove <domain> [--dry-run]`: Remove a domain (its name or id); the sign-in provider stops inviting people on it, and who joined stays. | Option | Meaning | | --- | --- | | `--enrollment <M>` | How people with a verified email on the domain join: automatic_invitation (the default), automatic_suggestion or manual_invitation | | `--dry-run` | Show what would change, change nothing | ## nexus org subscription ```sh nexus org subscription [show] nexus org subscription set [--payer U] [--billing-contact U] [--effective-at T] [--dry-run] ``` Your organization's subscription: plan, status, payer, billing contact and paid term. - `nexus org subscription set [--payer U] [--billing-contact U] [--effective-at T] [--dry-run]`: Name the payer and the billing contact (owners): a member's id or email, none clears it; Billing sets the plan, term and status. | Option | Meaning | | --- | --- | | `--payer <U>` | The member who pays: their email or user id (none clears it) | | `--billing-contact <U>` | The member who receives billing mail: their email or user id (none clears it) | | `--effective-at <T>` | When the change took effect, an ISO 8601 time (default now; never in the future) | | `--dry-run` | Show what would change, change nothing | ```sh nexus org subscription nexus org subscription set --payer ada@acme.example --dry-run ``` --- <!-- /docs/cli/search --> # search > Search what your role may read, grouped and ranked: your own chats (titles and messages), artifacts shared with or by you, people, teams, models and model policies. Search what your role may read, grouped and ranked: your own chats (titles and messages), artifacts shared with or by you, people, teams, models and model policies. ## nexus search ```sh nexus search "<query>" [--type chats|artifacts|people|teams|models] [--limit N] [--json] ``` Search what your role may read, grouped and ranked: your own chats (titles and messages), artifacts shared with or by you, people, teams, models and model policies. | Option | Meaning | | --- | --- | | `--type <chats|artifacts|people|teams|models>` | Chats, artifacts, people, teams or models; comma-separated for several (default: all) | | `--limit <N>` | Results per type, 1 to 20 (default 5) | | `--json` | Print only JSON on stdout | ```sh nexus search "deploy checklist" nexus search ada --type people nexus search fly --type chats --limit 10 --json ``` --- <!-- /docs/cli/billing --> # billing > Your organization's billing (owners): the card on file through Stripe Checkout, the free start, Nexus credits and their auto top-up, paying after the fact up to a monthly usage limit, the receipts, an unpaid month and when model calls stop for it, the monthly statements and Stripe's billing portal. Your organization's billing (owners): the card on file through Stripe Checkout, the free start, Nexus credits and their auto top-up, paying after the fact up to a monthly usage limit, the receipts, an unpaid month and when model calls stop for it, the monthly statements and Stripe's billing portal. ## nexus billing show ```sh nexus billing show ``` The Stripe mode, the card on file, the free start left, Nexus credits, paying after the fact, Nexus's rate, and an unpaid month with the time model calls stop. ## nexus billing card ```sh nexus billing card add [--no-browser] [--no-wait] ``` Add or replace the card through Stripe Checkout, then wait until Stripe saves it (up to 10 minutes). | Option | Meaning | | --- | --- | | `--no-browser` | Only print the Stripe Checkout link; do not open a browser | | `--no-wait` | Print the link and return without waiting for the card | ```sh nexus billing card add ``` ## nexus billing statement ```sh nexus billing statement [--period YYYY-MM] ``` One month's bill: each charge, the total and what is charged (default: this month so far). | Option | Meaning | | --- | --- | | `--period <YYYY-MM>` | The month, as YYYY-MM in UTC (default: this month so far) | ```sh nexus billing statement --period 2026-09 nexus billing statements --json ``` ## nexus billing statements ```sh nexus billing statements ``` The closed months, newest first: the total, the invoice's state and its page on Stripe. ```sh nexus billing statements --json ``` ## nexus billing receipts ```sh nexus billing receipts nexus billing receipts open <paymentId> [--no-browser] ``` Every payment, newest first: its date, what it paid for, its amount, its status and its id. - `nexus billing receipts open <paymentId> [--no-browser]`: Open Stripe's receipt of one payment. | Option | Meaning | | --- | --- | | `--no-browser` | Only print the receipt link; do not open a browser | ## nexus billing portal ```sh nexus billing portal [--no-browser] ``` Open Stripe's billing portal: cards, invoices and tax ids. | Option | Meaning | | --- | --- | | `--no-browser` | Only print the portal link; do not open a browser | ```sh nexus billing portal ``` ## nexus billing confirm ```sh nexus billing confirm [--no-browser] ``` Confirm a charge the bank wants the cardholder to confirm (3-D Secure) on the bank's page: the same charge, not a new one. | Option | Meaning | | --- | --- | | `--no-browser` | Only print the bank's page; do not open a browser | ## nexus billing credits ```sh nexus billing credits nexus billing credits buy <usd> [--payment-token-stdin] [--dry-run] [--no-browser] [--no-wait] ``` Nexus credits: what is left, bought, spent and held. Nexus-run AI spends them after the free start. - `nexus billing credits buy <usd> [--payment-token-stdin] [--dry-run] [--no-browser] [--no-wait]`: Buy Nexus credits (from $25): a delegated Stripe payment token from stdin, the payment method on file, or Stripe Checkout. | Option | Meaning | | --- | --- | | `--payment-token-stdin` | Read the agent wallet's Stripe shared payment token (spt_) from stdin; no browser or saved card needed | | `--dry-run` | Say what `credits buy` would charge, and charge nothing | | `--no-browser` | Only print the Stripe Checkout link; do not open a browser | | `--no-wait` | Return without waiting for Stripe to take the payment | ```sh nexus billing credits buy 10 ``` ## nexus billing auto-topup ```sh nexus billing auto-topup nexus billing auto-topup set --below <usd> --add <usd> [--dry-run] nexus billing auto-topup off [--dry-run] ``` Auto top-up of Nexus credits: on or off, its line, its amount and today's top-ups. - `nexus billing auto-topup set --below <usd> --add <usd> [--dry-run]`: Turn it on: when credits fall below --below, Nexus adds --add ($25 to $500) with the payment method on file. - `nexus billing auto-topup off [--dry-run]`: Turn auto top-up off. | Option | Meaning | | --- | --- | | `--below <usd>` | Top up when the credits left fall below this many dollars | | `--add <usd>` | Dollars one top-up buys, from 10 to 500 | | `--dry-run` | Say what would change, and change nothing | ```sh nexus billing auto-topup set --below 10 --add 50 ``` ## nexus billing after-the-fact ```sh nexus billing after-the-fact nexus billing after-the-fact on [--limit <usd>] [--dry-run] nexus billing after-the-fact off [--dry-run] nexus billing after-the-fact limit <usd> [--dry-run] ``` Paying after the fact: on or off, the monthly usage limit, what the card was used for this month, what is owed and a failed charge. - `nexus billing after-the-fact on [--limit <usd>] [--dry-run]`: Turn it on: the card on file pays for Nexus-run AI after the free start and the credits, charged each $25 of unpaid usage, up to the limit a month (default $25). - `nexus billing after-the-fact off [--dry-run]`: Turn paying after the fact off. - `nexus billing after-the-fact limit <usd> [--dry-run]`: Set the monthly usage limit; paying after the fact stays on or off as it is. | Option | Meaning | | --- | --- | | `--limit <usd>` | The monthly usage limit in dollars (default 25) | | `--dry-run` | Say what would change, and change nothing | ```sh nexus billing after-the-fact on --limit 50 ``` --- <!-- /docs/cli/service-accounts --> # service-accounts > Service accounts (owners and admins): callers for CI and scripts that are no member and hold no seat. Each holds keys (nxsa_…) that you issue, rotate and revoke; a token is shown once. Service accounts (owners and admins): callers for CI and scripts that are no member and hold no seat. Each holds keys (nxsa_…) that you issue, rotate and revoke; a token is shown once. ## nexus service-accounts list ```sh nexus service-accounts list ``` The organization's service accounts and their keys (owners and admins). ## nexus service-accounts create ```sh nexus service-accounts create --name <name> --team <slug> [--owner <user-id>] --expires <YYYY-MM-DD|30d> [--dry-run] ``` Create a service account: a caller for CI and scripts that is no member and holds no seat (owners and admins). | Option | Meaning | | --- | --- | | `--name <name>` | The service account's name (1 to 64 characters) | | `--team <slug>` | The team that owns it, by slug or id: its keys stop when the team is deleted | | `--owner <user-id>` | The member who answers for it, by user id (default: you): its keys stop when they leave the organization | | `--expires <YYYY-MM-DD|30d>` | When it stops working: a day (YYYY-MM-DD, UTC, the whole day) or a duration (30d, 12h or a number of days); at most 365 days from now | | `--dry-run` | Show what would change, change nothing | ```sh nexus service-accounts create --name ci --team web --expires 90d --dry-run nexus service-accounts create --name ci --team web --expires 2027-01-31 ``` ## nexus service-accounts revoke ```sh nexus service-accounts revoke <id> [--dry-run] ``` Revoke a service account and stop every live key it holds (owners and admins). | Option | Meaning | | --- | --- | | `--dry-run` | Show what would change, change nothing | ```sh nexus service-accounts revoke sva_… --dry-run ``` ## nexus service-accounts keys create ```sh nexus service-accounts keys create <account id> --label <label> [--expires <YYYY-MM-DD|30d>] ``` Issue a key for a service account: its token (nxsa_…) is shown once. | Option | Meaning | | --- | --- | | `--label <label>` | A name for the key (1 to 80 characters), to tell keys apart | | `--expires <YYYY-MM-DD|30d>` | When the key stops working: a day or a duration, as for the account, and not past the account's own (default: 90 days from now) | ```sh nexus service-accounts keys create sva_… --label github-actions ``` ## nexus service-accounts keys rotate ```sh nexus service-accounts keys rotate <account id> <key id> [--label <label>] [--expires <YYYY-MM-DD|30d>] ``` Issue a new key in place of one and stop the old one at once: it keeps the label and lifetime unless you set them; the new token is shown once. | Option | Meaning | | --- | --- | | `--label <label>` | A name for the new key (1 to 80 characters); the old key's name by default | | `--expires <YYYY-MM-DD|30d>` | When the new key stops working: a day or a duration, as for the account, and not past the account's own (default: as long as the old key lived) | ```sh nexus service-accounts keys rotate sva_… sak_… ``` ## nexus service-accounts keys revoke ```sh nexus service-accounts keys revoke <account id> <key id> ``` Revoke one key at once. --- <!-- /docs/cli/slack --> # slack > The Nexus Slack app (owners and admins): bind a Slack workspace to your organization through Slack's install. Only the person who started an install confirms it, and a workspace binds to one organization at a time. A channel binds to a team: in a bound channel, @nexus attributes each call to that team, under its policy and caps; a team lead binds a channel to a team they lead. The Nexus Slack app (owners and admins): bind a Slack workspace to your organization through Slack's install. Only the person who started an install confirms it, and a workspace binds to one organization at a time. A channel binds to a team: in a bound channel, @nexus attributes each call to that team, under its policy and caps; a team lead binds a channel to a team they lead. ## nexus slack connect ```sh nexus slack connect [--confirm <install-id>] [--dry-run] ``` Connect a Slack workspace: print Slack's install link; approve the app in the browser where you are signed in to Nexus UI, which completes the install; then --confirm binds that workspace to this organization (owners and admins). | Option | Meaning | | --- | --- | | `--confirm <install-id>` | The install id (chw_…) that nexus slack connect printed: binds its workspace once you approved the app in Slack | | `--dry-run` | Show what would change, change nothing | ```sh nexus slack connect nexus slack connect --confirm chw_… --dry-run nexus slack connect --confirm chw_… ``` ## nexus slack status ```sh nexus slack status ``` The organization's Slack workspaces, pending and active (owners and admins). ```sh nexus slack status --json ``` ## nexus slack disconnect ```sh nexus slack disconnect <id> [--dry-run] ``` Unbind a workspace: Gateway uninstalls the app from it and deletes its bot token, unless another binding of the organization still uses it (owners and admins). | Option | Meaning | | --- | --- | | `--dry-run` | Show what would change, change nothing | ```sh nexus slack disconnect chw_… --dry-run ``` ## nexus slack channel list ```sh nexus slack channel list <workspace id> ``` The workspace's channels bound to a team (owners and admins: every one; a lead: those of the teams they lead). ```sh nexus slack channel list chw_… ``` ## nexus slack channel bind ```sh nexus slack channel bind <workspace id> <channel id> --team <slug> ``` Bind a channel to a team: its calls go to that team, under its policy and caps (owners and admins: any team; a lead: a team they lead). | Option | Meaning | | --- | --- | | `--team <slug>` | The team the channel's calls go to, by slug or id (a lead: a team they lead or one under it) | ```sh nexus slack channel bind chw_… C0123ABCD --team web ``` ## nexus slack channel unbind ```sh nexus slack channel unbind <workspace id> <channel id> ``` Unbind a channel from its team. ```sh nexus slack channel unbind chw_… C0123ABCD --json ``` --- <!-- /docs/cli/connections --> # connections > Your accounts at a connector's vendor, and the organization's: who it says you are there, and whether it needs a reconnect. Your accounts at a connector's vendor, and the organization's: who it says you are there, and whether it needs a reconnect. ## nexus connections ```sh nexus connections ``` Your accounts at a connector's vendor, and the organization's: who it says you are there, and whether it needs a reconnect. ```sh nexus connections nexus connections --json ``` --- <!-- /docs/cli/connect --> # connect > Connect an account at a connector's vendor: the fields its form takes (a value of - reads stdin for one field, and @<file> reads a file only you can read, so a secret stays out of your shell history), or with none, the OAuth link to open. --org connects the organization's (owners and admins); --write asks for the write access a write refused with write_consent_required needs. Connect an account at a connector's vendor: the fields its form takes (a value of - reads stdin for one field, and @<file> reads a file only you can read, so a secret stays out of your shell history), or with none, the OAuth link to open. --org connects the organization's (owners and admins); --write asks for the write access a write refused with write_consent_required needs. ## nexus connect ```sh nexus connect <connector> [--org] [--write] [field=value ...] ``` Connect an account at a connector's vendor: the fields its form takes (a value of - reads stdin for one field, and @<file> reads a file only you can read, so a secret stays out of your shell history), or with none, the OAuth link to open. --org connects the organization's (owners and admins); --write asks for the write access a write refused with write_consent_required needs. | Option | Meaning | | --- | --- | | `--org` | The organization's account, not your own (owners and admins) | | `--write` | Allow writes: the OAuth link asks the vendor for the write scopes, not only the reads | ```sh echo "$JIRA_TOKEN" | nexus connect jira site=acme.atlassian.net email=ada@acme.example token=- nexus connect notion nexus connect microsoft-todo --write nexus connect jira --org site=acme.atlassian.net email=ada@acme.example token=- echo "$DD_API_KEY" | nexus connect datadog --org site=datadoghq.com api_key=- application_key=@dd-app.key ``` --- <!-- /docs/cli/disconnect --> # disconnect > Disconnect an account by its id, name or host. --org disconnects the organization's (owners and admins). Disconnect an account by its id, name or host. --org disconnects the organization's (owners and admins). ## nexus disconnect ```sh nexus disconnect <connector> <account> [--org] ``` Disconnect an account by its id, name or host. --org disconnects the organization's (owners and admins). | Option | Meaning | | --- | --- | | `--org` | The organization's account, not your own (owners and admins) | ```sh nexus disconnect jira acme.atlassian.net nexus disconnect notion Acme --org ``` --- <!-- /docs/cli/triage --> # triage > Nexus staff: start an agent that reads this computer's Nexus files, diagnoses a Nexus defect and drafts a report. Send the report you approved to the Nexus team, with your name and email. Nexus staff: start an agent that reads this computer's Nexus files, diagnoses a Nexus defect and drafts a report. Send the report you approved to the Nexus team, with your name and email. ## nexus triage send ```sh nexus triage send <file> --yes ``` Post an approved report to the Nexus team, with your name and email. | Option | Meaning | | --- | --- | | `--yes` | Confirm a change that deletes or sends more than one thing | ```sh nexus triage send report.md --yes ``` --- <!-- /docs/cli/machines --> # machines > Your cloud machines in this organization, one per cloud session: their state, size and why one sleeps. Put one to sleep; the app wakes it when you use the session. Your cloud machines in this organization, one per cloud session: their state, size and why one sleeps. Put one to sleep; the app wakes it when you use the session. ## nexus machines list ```sh nexus machines list ``` Your live cloud machines, one per cloud session, newest first (also plain nexus machines). ## nexus machines show ```sh nexus machines show <id> ``` One machine: its session, state, size and why it sleeps. ```sh nexus machines show cm_… ``` ## nexus machines sleep ```sh nexus machines sleep <id> ``` Put a machine to sleep: its disk is kept and its running time stops; the app wakes it when you use the session. ```sh nexus machines sleep cm_… ``` --- <!-- /docs/cli/notifications --> # notifications > Your inbox in this organization, as Nexus UI's notifications page shows it: the items not yet done, newest first. Mark an item read, or done to clear it. Your inbox in this organization, as Nexus UI's notifications page shows it: the items not yet done, newest first. Mark an item read, or done to clear it. ## nexus notifications list ```sh nexus notifications list [--unread] [--group G] [--cursor C] ``` Your items not yet done, newest first (also plain nexus notifications); --unread: only those not yet read. | Option | Meaning | | --- | --- | | `--unread` | Only items not yet read | | `--group <G>` | Only this group's items: my_sessions, usage_and_billing, requests_and_approvals, automations_and_integrations or account_and_security | | `--cursor <C>` | The next page: the cursor the list printed last | ```sh nexus notifications list --unread --group usage_and_billing ``` ## nexus notifications read ```sh nexus notifications read <id> ``` Mark an item read. ## nexus notifications done ```sh nexus notifications done <id> ``` Mark an item done, and read: it leaves your inbox. ```sh nexus notifications done ntf_… ``` ## nexus notifications kinds ```sh nexus notifications kinds ``` The catalogue: each kind of notification, its group, whether it is required, and its default channels. ```sh nexus notifications kinds --json ``` --- <!-- /docs/cli/jobs --> # jobs > Jobs: a module's verb with its input, run in the background for the person who submits it. A job is accepted, then running, then done, failed or cancelled. You, and your organization's owners and admins, read and cancel it. Jobs: a module's verb with its input, run in the background for the person who submits it. A job is accepted, then running, then done, failed or cancelled. You, and your organization's owners and admins, read and cancel it. ## nexus jobs submit ```sh nexus jobs submit <product>/<capability> <verb> [--input <json>] [--team <slug>] ``` Submit a job: a module's verb with its input, run in the background for you; prints the job's id. The module is <product>/<capability>, such as robustness/review. | Option | Meaning | | --- | --- | | `--input <json>` | The verb's input, a JSON object (default: {}) | | `--team <slug>` | The team the job's model calls go to, by slug or id (default: yours) | ```sh nexus jobs submit robustness/review run --input '{"repo":"https://github.com/nexus-demo/hello-factory"}' ``` ## nexus jobs get ```sh nexus jobs get <id> ``` A job's state: accepted, running, done, failed or cancelled. ```sh nexus jobs get job_… ``` ## nexus jobs cancel ```sh nexus jobs cancel <id> ``` Cancel a job no worker has taken yet; a running or finished job stays as it is. ```sh nexus jobs cancel job_… ``` ## nexus jobs result ```sh nexus jobs result <id> ``` A job's result, once it is done or failed. ```sh nexus jobs result job_… --json ``` --- <!-- /docs/cli/routines --> # routines > Routines: work Nexus does for you without being asked, such as a morning brief on a schedule. A routine runs as you only, reads and notifies only, and reports to your Slack direct messages. You manage your own; your organization's owners and admins may read, pause and delete them. Routines: work Nexus does for you without being asked, such as a morning brief on a schedule. A routine runs as you only, reads and notifies only, and reports to your Slack direct messages. You manage your own; your organization's owners and admins may read, pause and delete them. ## nexus routines list ```sh nexus routines list [--all] ``` Your routines, newest first, with each one's next run; --all lists the organization's (owners and admins). | Option | Meaning | | --- | --- | | `--all` | Every member's routines (owners and admins) | ```sh nexus routines list ``` ## nexus routines show ```sh nexus routines show <id> ``` A routine: its trigger, action, proactivity, caps, state and next run. ## nexus routines create ```sh nexus routines create --at <HH:MM> [--days mon-fri] | --every <interval> [--timezone <zone>] [--title <title>] [--max-runs-per-day <n>] [--team <slug>] ``` Create a morning brief on a schedule, for you only; prints its id and next run. The brief reads only, and reports to your Slack direct messages. | Option | Meaning | | --- | --- | | `--at <HH:MM>` | A local time, HH:MM, 24-hour | | `--days <mon-fri>` | The days --at runs on, such as mon-fri or mon,wed,fri (default: every day) | | `--every <interval>` | An interval of 10 minutes or more, such as 30m, 2h or 1d; not with --at | | `--timezone <zone>` | An IANA time zone, such as America/Costa_Rica (default: UTC) | | `--title <title>` | A name for the routine (default: Morning brief) | | `--max-runs-per-day <n>` | The most runs a day; a slot past it is skipped | | `--team <slug>` | The team its model calls go to, by slug or id (default: yours) | ```sh nexus routines create --at 08:00 --days mon-fri --timezone America/Costa_Rica ``` ## nexus routines pause ```sh nexus routines pause <id> ``` Pause a routine: its schedule stops before its next slot. ```sh nexus routines pause rtn_… ``` ## nexus routines resume ```sh nexus routines resume <id> ``` Resume your routine from its next slot after now; nothing missed is replayed. ```sh nexus routines resume rtn_… ``` ## nexus routines delete ```sh nexus routines delete <id> ``` Delete a routine and its schedule. --- <!-- /docs/cli/apps --> # apps > Deploy and manage Apps on Nexus. Hosting costs Vercel list price plus 8%. Each app starts with a $10 monthly cap. Deploy and manage Apps on Nexus. Hosting costs Vercel list price plus 8%. Each app starts with a $10 monthly cap. ## nexus apps deploy ```sh nexus apps deploy [dir] [--name N] [--framework F] ``` Deploy a folder (default: this one) to Vercel; deploying the same name again ships its next version. Prints its URL. | Option | Meaning | | --- | --- | | `--name <N>` | The app's name: lowercase words joined by dashes (default: the folder's name) | | `--framework <F>` | A Vercel framework preset, such as nextjs or vite (default: Vercel detects it) | ```sh nexus apps deploy ./my-site nexus apps deploy --name docs --framework vite ``` ## nexus apps list ```sh nexus apps list ``` Your apps (owners and admins: the organization's), with what each cost Nexus. ## nexus apps cap ```sh nexus apps cap <id> <usd> ``` Set this app's monthly hosting cap in USD. ## nexus apps get ```sh nexus apps get <id> ``` An app: its URL, its deployment's state and its cost. ## nexus apps delete ```sh nexus apps delete <id> --yes ``` Delete an app and its Vercel project. | Option | Meaning | | --- | --- | | `--yes` | Confirm a change that deletes or sends more than one thing | ```sh nexus apps delete app_… --yes ``` ## nexus apps claim ```sh nexus apps claim <id> ``` A link that moves the app to your own Vercel account, where it stops costing Nexus; it works for 24 hours. ```sh nexus apps claim app_… ``` --- <!-- /docs/cli/cursor-agent --> # cursor-agent > Cursor on your own Cursor plan: its calls go straight to Cursor, and Nexus records the session. Cursor on your own Cursor plan: its calls go straight to Cursor, and Nexus records the session. ## nexus cursor-agent ```sh nexus cursor-agent [--json] [--subscription] [--team <slug>] [--] [cursor-agent args…] ``` Cursor on your own Cursor plan: its calls go straight to Cursor, and Nexus records the session. | Option | Meaning | | --- | --- | | `--json` | A JSON summary on stdout when Cursor exits | | `--subscription` | Run on your Cursor plan | | `--team <slug>` | The team this session is attributed to (also NEXUS_TEAM) | | `--model <id>` | Cursor's own model flag | | Exit code | Meaning | | --- | --- | | 0 | The agent's own exit code is passed through | | 2 | --api, --via gateway, --model auto or --recording: not available, and the agent does not start | ```sh nexus cursor-agent -p "hello" nexus cursor-agent --team web nexus cursor-agent -- --resume <id> ``` --- <!-- /docs/cli/agent --> # agent > Nexus, the same one as @nexus in Slack, with its memory and saved model. It never runs a write: it prints the Nexus UI page where you approve one. Needs NEXUS_AGENTS_API_URL, the agent API's address. Any other nexus agent command is nexus agents. Nexus, the same one as @nexus in Slack, with its memory and saved model. It never runs a write: it prints the Nexus UI page where you approve one. Needs NEXUS_AGENTS_API_URL, the agent API's address. Any other nexus agent command is nexus agents. ## nexus agent ask ```sh nexus agent ask "<question>" [--conversation <id>] [--model <id>] ``` Ask Nexus, the same one as @nexus in Slack, with its memory and saved model; the answer streams, then its sources. | Option | Meaning | | --- | --- | | `--conversation <id>` | Continue this conversation: the id the last answer printed (default: a new one) | | `--model <id>` | A catalog model id for this answer (default: your saved model) | ```sh nexus agent ask "What did I decide about the launch?" nexus agent ask --conversation <id> "And the date?" nexus agent ask "Summarize my week" --json ``` ## nexus agent chat ```sh nexus agent chat [--conversation <id>] [--model <id>] ``` Talk with Nexus in one conversation; type exit or press Ctrl-D to end. | Option | Meaning | | --- | --- | | `--conversation <id>` | Continue this conversation: the id the last answer printed (default: a new one) | | `--model <id>` | A catalog model id for this answer (default: your saved model) | ```sh nexus agent chat ``` --- <!-- /docs/cli/recordings --> # recordings > Screen recordings Nexus for Mac makes for agents (⌥⇧S), on this computer: what an agent reads, and more frames for a closer look. Screen recordings Nexus for Mac makes for agents (⌥⇧S), on this computer: what an agent reads, and more frames for a closer look. ## nexus recordings list ```sh nexus recordings list [--json] ``` Your screen recordings from Nexus for Mac (⌥⇧S), newest first: when, how long, keyframes and the first words said. | Option | Meaning | | --- | --- | | `--json` | Print only JSON on stdout | ## nexus recordings show ```sh nexus recordings show [<id>|latest] [--json] ``` A recording's summary.md, what an agent reads first (--json: its capture.json). | Option | Meaning | | --- | --- | | `--json` | Print only JSON on stdout | ```sh nexus recordings show latest ``` ## nexus recordings path ```sh nexus recordings path [<id>|latest] ``` A recording's folder, for scripts and agents. ## nexus recordings frames ```sh nexus recordings frames [<id>|latest] --from <time> --to <time> [--count N] ``` More frames from its video, at full resolution, for a closer look (Nexus for Mac draws them). | Option | Meaning | | --- | --- | | `--from <time>` | From this moment of the recording (0:12 as summary.md writes it, or seconds) | | `--to <time>` | Until this moment | | `--count <N>` | How many frames, evenly spread (default 8, at most 60) | ```sh nexus recordings frames latest --from 0:10 --to 0:14 ``` --- <!-- /docs/cli/memory --> # memory > Manage the local shared memory that coding agents use across sessions and worktrees. Manage the local shared memory that coding agents use across sessions and worktrees. ## nexus memory status ```sh nexus memory status [--json] ``` Show whether shared memory is on. | Option | Meaning | | --- | --- | | `--json` | Print only JSON on stdout | ## nexus memory enable ```sh nexus memory enable [--json] ``` Turn on shared memory on this computer. | Option | Meaning | | --- | --- | | `--json` | Print only JSON on stdout | ```sh nexus memory enable ``` ## nexus memory disable ```sh nexus memory disable [--export <path>] [--skip-export] [--repo <path>] ``` Turn off shared memory with a Markdown export or an explicit choice to skip it. | Option | Meaning | | --- | --- | | `--export <path>` | Save a Markdown copy to this path before turning off shared memory | | `--skip-export` | Turn off shared memory without exporting | | `--repo <path>` | Choose the repository whose notes to use | ## nexus memory list ```sh nexus memory list [--repo <path>] [--json] ``` List personal and repository entries. | Option | Meaning | | --- | --- | | `--repo <path>` | Choose the repository whose notes to use | | `--json` | Print only JSON on stdout | ```sh nexus memory list --json ``` ## nexus memory add ```sh nexus memory add <text> ``` Save a personal note. ## nexus memory edit ```sh nexus memory edit <id> <text> [--repo <path>] ``` Replace the text of an entry. | Option | Meaning | | --- | --- | | `--repo <path>` | Choose the repository whose notes to use | ## nexus memory forget ```sh nexus memory forget <id> [--repo <path>] ``` Delete an entry. | Option | Meaning | | --- | --- | | `--repo <path>` | Choose the repository whose notes to use | ## nexus memory import ```sh nexus memory import <claude|codex> [--repo <path>] ``` Import memory from the selected agent's local profiles. | Option | Meaning | | --- | --- | | `--repo <path>` | Choose the repository whose notes to use | ```sh nexus memory import claude ``` ## nexus memory export ```sh nexus memory export <claude|codex|markdown> [--output <path>] [--repo <path>] ``` Export to an agent profile or Markdown. Codex loads every repository block in every session on that profile. | Option | Meaning | | --- | --- | | `--output <path>` | Write a Markdown export to this path | | `--repo <path>` | Choose the repository whose notes to use | --- <!-- /docs/cli/sessions --> # sessions > Code sessions in Nexus for desktop, on this computer: list, read, start, name, message and stop them from a script or another agent. Turn on Outside access in the app first; each client asks you once. Code sessions in Nexus for desktop, on this computer: list, read, start, name, message and stop them from a script or another agent. Turn on Outside access in the app first; each client asks you once. ## nexus sessions list ```sh nexus sessions list [--project P] [--archived] [--limit N] [--json] ``` Code sessions in Nexus for desktop, newest first: id, status, name, title and project. | Option | Meaning | | --- | --- | | `--project <P>` | The project: its folder (. is the current one), its id, or GitHub owner/repo | | `--archived` | Archived sessions too | | `--limit <N>` | At most this many sessions (1 to 200, default 50) | | `--json` | Print only JSON on stdout | ```sh nexus sessions list ``` ## nexus sessions show ```sh nexus sessions show <id|name|title> [--turns N] [--json] ``` A session's status and its latest turns: each prompt, the agent's last answer and how the turn ended. Name a session by its id (a word starting with t_), or by its name or exact title among the newest 200; a name past those goes to the app's own lookup. | Option | Meaning | | --- | --- | | `--turns <N>` | How many of the latest turns (1 to 20, default 3) | | `--json` | Print only JSON on stdout | ```sh nexus sessions show <id> ``` ## nexus sessions start ```sh nexus sessions start "<prompt>" [--project P] [--agent A] [--model M] [--mode M] [--worktree] [--folder] [--name N] [--json] ``` Start a session with its project's defaults (the current folder's project when --project is left out; - reads the prompt from stdin). | Option | Meaning | | --- | --- | | `--project <P>` | The project: its folder (. is the current one), its id, or GitHub owner/repo | | `--agent <A>` | Claude or codex or nexus or antigravity or cursor; default: the project's | | `--model <M>` | The model; default: the project's | | `--mode <M>` | The permission mode: plan, default, acceptEdits, auto or bypassPermissions; never above the project's default | | `--worktree` | Work in a new worktree; default: the project's choice | | `--folder` | Work in the project's folder; default: the project's choice | | `--name <N>` | The session's unique name, which Claude Code's ListAgents and SendMessage reach it by | | `--json` | Print only JSON on stdout | ```sh nexus sessions start --project . "Find why the tests are slow" ``` ## nexus sessions send ```sh nexus sessions send <id|name|title> "<message>" ``` Message a session; a busy one gets it after its current turn (- reads stdin). Name a session by its id (a word starting with t_), or by its name or exact title among the newest 200; a name past those goes to the app's own lookup. ```sh nexus sessions send <id> "Now fix it" ``` ## nexus sessions stop ```sh nexus sessions stop <id|name|title> ``` Stop a session's current turn. Name a session by its id (a word starting with t_), or by its name or exact title among the newest 200; a name past those goes to the app's own lookup. ## nexus sessions name ```sh nexus sessions name <id|name|title> [<new-name>] [--clear] [--json] ``` Give a session a unique name, which Claude Code's ListAgents and SendMessage reach it by; --clear removes it. A name is 1 to 40 letters, digits, dots, dashes or underscores, and never starts with t_. | Option | Meaning | | --- | --- | | `--clear` | Remove the session's name | | `--json` | Print only JSON on stdout | ## nexus sessions connect ```sh nexus sessions connect [--read-only] ``` Ask Nexus for desktop for access now (the other commands ask by themselves); you approve it in the app. | Option | Meaning | | --- | --- | | `--read-only` | Ask only to read sessions | ## nexus sessions disconnect ```sh nexus sessions disconnect ``` Forget this CLI's access on this computer (revoke it in the app: Settings, MCP servers, Outside access). ## nexus sessions mcp ```sh nexus sessions mcp [--name N] ``` The same tools as an MCP server on stdin and stdout, for another agent: claude mcp add nexus-sessions -- nexus sessions mcp. | Option | Meaning | | --- | --- | | `--name <N>` | The name the app shows for this client (default: nexus CLI) | ```sh nexus sessions mcp --name "Claude Code" ``` --- <!-- /docs/cli/devices --> # devices > Your devices for end-to-end encrypted session sync: pair this computer so its nexus claude and nexus codex sessions show in Nexus UI, and revoke a device. Your devices for end-to-end encrypted session sync: pair this computer so its nexus claude and nexus codex sessions show in Nexus UI, and revoke a device. ## nexus devices list ```sh nexus devices list [--json] ``` Your devices for encrypted session sync, oldest first: this computer, each one's state and pairing code. | Option | Meaning | | --- | --- | | `--json` | Print only JSON on stdout | ## nexus devices pair ```sh nexus devices pair [--name N] [--new] [--no-wait] [--approver-code C] [--json] ``` Make this computer a trusted device: it shows a code and a QR code, and you approve it from a trusted device (Settings › Devices in Nexus UI or the desktop app). Then confirm the approver's code: sync starts only after that. | Option | Meaning | | --- | --- | | `--name <N>` | This computer's name in your devices (default: nexus CLI on <hostname>) | | `--new` | Forget this computer's key and pair a new one | | `--no-wait` | Show the code and return without waiting for the approval | | `--approver-code <C>` | Confirm the approver without a prompt: the code its own screen shows | | `--json` | Print only JSON on stdout | ```sh nexus devices pair ``` ## nexus devices revoke ```sh nexus devices revoke <device-id> [--yes] ``` Revoke a device with this computer's key: it gets no key for anything new. Revoking this computer also deletes its key. | Option | Meaning | | --- | --- | | `--yes` | Revoke without asking | ```sh nexus devices revoke dev_… ``` ## nexus devices org-key ```sh nexus devices org-key [--fingerprint F] [--vault-public-key FILE] [--json] ``` Your org's recovery key: compare its fingerprint with the one computed from your vault, then confirm it here. Your synced sessions are also locked for it when your org chooses so. | Option | Meaning | | --- | --- | | `--fingerprint <F>` | Confirm your org's recovery key without a prompt: the fingerprint computed from your vault | | `--vault-public-key <FILE>` | Compute a fingerprint offline from your vault's X25519 public-key export, raw 32 bytes or base64url | | `--json` | Print only JSON on stdout | ## nexus devices control ```sh nexus devices control [on|off] [--json] ``` Phone control for this computer's `nexus claude` and `nexus codex` sessions: off until you turn it on. With no setting, says where it stands. | Option | Meaning | | --- | --- | | `--json` | Print only JSON on stdout | --- <!-- /docs/cli/mcp --> # mcp > A local MCP server on stdin and stdout: your spend, budgets, usage, models, teams and agent sessions as tools, under your own sign-in and permissions. Owners and admins also read and change members, teams, budgets, policies and keys; the agent asks before each change. An agent starts it: claude mcp add nexus -- nexus mcp, or codex mcp add nexus -- nexus mcp. A local MCP server on stdin and stdout: your spend, budgets, usage, models, teams and agent sessions as tools, under your own sign-in and permissions. Owners and admins also read and change members, teams, budgets, policies and keys; the agent asks before each change. An agent starts it: claude mcp add nexus -- nexus mcp, or codex mcp add nexus -- nexus mcp. ## nexus mcp ```sh nexus mcp ``` A local MCP server on stdin and stdout: your spend, budgets, usage, models, teams and agent sessions as tools, under your own sign-in and permissions. Owners and admins also read and change members, teams, budgets, policies and keys; the agent asks before each change. An agent starts it: claude mcp add nexus -- nexus mcp, or codex mcp add nexus -- nexus mcp. --- <!-- /docs/cli/completion --> # completion > Tab-completion for commands, subcommands and flags: install turns it on, a shell prints its script to source. Tab-completion for commands, subcommands and flags: install turns it on, a shell prints its script to source. ## nexus completion ```sh nexus completion <bash|zsh|fish|install> ``` Tab-completion for commands, subcommands and flags: install turns it on, a shell prints its script to source. ```sh nexus completion install nexus completion bash nexus completion zsh nexus completion fish ``` --- <!-- /blog/auto-router-v2-0 --> # Auto Router v2.0 > Auto now keeps a conversation on its model while the provider's prompt cache is warm, and switches only when the switch pays for itself. The Nexus team, 2026-11-17 Set `model` to `nexus/auto`, and Auto picks a model for each request. Auto Router v2.0 is live. It keeps an agent's conversation on one model while that model's prompt cache is warm. It switches only when the switch saves more than it costs. ```sh curl -i https://api.nexus.inc/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "nexus/auto", "messages": [{"role": "system", "content": "You are a coding agent."}, {"role": "user", "content": "Fix the failing test"}]}' ``` The `x-nexus-model` header names the model that ran. The `x-nexus-router` header names the Auto version that picked it. ## What's new - **A conversation keeps its model.** Auto remembers the model each conversation last ran on, for 5 minutes. A conversation is your organization, your API key, your tools, the system message and the first user message. Auto stores a hash of them, not the text. - **A switch must pay for itself.** A provider caches the start of a prompt it has already read, and bills a cached read at a fraction of the input price. Another model starts cold and reads the whole prompt at the full price. Auto now counts that cost before it switches. It counts a cached read only when the new prompt starts with the last one, and only on a provider that caches API calls without a request to do so. - **Harder requests still move up.** When a request needs a stronger model, Auto moves it up. A tool result in an agent's loop is the usual case. ## Why An agent sends many calls in one conversation, often seconds apart, and its prompt grows with each call. In one week of our own traffic, Auto switched models within the same conversation 11 times in 37 follow-on calls. Each switch read the whole prompt again with no cache. An illustration, not a measurement: take a 150,000-token prompt. On a model that bills $3 per million input tokens, a warm read costs about $0.045. A switch to a model that bills $0.50 costs about $0.075 for its first, cold read. The cheaper model costs more until its own cache is warm. ## How Auto picks a model in v2.0 1. **It starts from the models you allow.** Auto considers only the models your organization's policy allows and can pay for. 2. **It sorts the request.** Auto puts the request in one of three classes: light, standard or heavy. 3. **It prices each model for this call.** The model the conversation is on reads its cached prompt at the cache price. Every other model reads the whole prompt at the input price. 4. **It picks the lowest-priced model for the class.** Each class has a minimum model tier, as in v1.6. A first call has nothing to keep, so v2.0 picks as v1.6 does. Our benchmark replays single calls, so its pass rates and costs are the same as v1.6's. ## Limits - **A chat in Nexus already kept its model.** v2.0 adds the same behavior to API calls, such as an agent or a script. - **Claude models are not held yet.** Anthropic caches only the parts of a prompt that a request marks, and an API call through Auto marks none today. So Auto counts no cached read for Claude models, and a Claude pick switches as in v1.6. - **The reasoning effort does not change yet.** A later version will try a lower or higher reasoning effort on the same model before it switches models. - **5 minutes.** A conversation that pauses for longer than 5 minutes starts fresh, as the provider's cache does. ## Get started - Set `model` to `nexus/auto` in an API call, or pick Auto in the model picker. - Keep the system message and the first user message the same across an agent's calls. Auto then sees one conversation. - See every Auto version in the [Auto Router changelog](/auto-router/changelog). --- <!-- /blog/auto-router-v1-6 --> # Auto Router v1.6 > Auto sends more requests to GPT-6 Luna. On our benchmark, v1.6 passes 91.4% of prompts, up from 82.9%, at the same cost. The Nexus team, 2026-11-16 Set `model` to `nexus/auto`, and Auto picks a model for each request. Auto Router v1.6 is live. It sends more requests to GPT-6 Luna. On our benchmark, it passes 91.4% of the prompts, up from 82.9% with v1.5, at the same cost per answer. ```sh curl -i https://api.nexus.inc/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "nexus/auto", "messages": [{"role": "user", "content": "Summarize this changelog in three bullets"}]}' ``` The `x-nexus-model` header names the model that ran. The `x-nexus-router` header names the Auto version that picked it. ## What's new - **Prices based on more answers.** Auto prices each model by how much it writes per answer. v1.5 measured GPT-6 Luna and GLM 5.3 Flash on light prompts only. v1.6 measures them on light and standard prompts. GPT-6 Luna writes shorter answers than v1.5 assumed, and GLM 5.3 Flash writes longer ones. - **More requests go to GPT-6 Luna.** With the new prices, GPT-6 Luna is the lowest-priced model for most light requests. In v1.5, GLM 5.3 Flash on Baseten took many of them. ## Benchmark We replayed v1.6's picks on the same 222 light and standard prompts as the [v1.5 post](/blog/auto-router-v1-5). Each answer was already graded. Costs are what the Gateway billed, weighted by our own traffic: 85% light, 15% standard. | Model | Light prompts passed | Standard prompts passed | Cost per 1,000 answers | | --- | --- | --- | --- | | Claude Sonnet 5.5 on every request | 94 of 110 | 98 of 112 | $2.33 | | Auto v1.5 | 92 of 110 | 88 of 112 | $0.28 | | Auto v1.6 | 101 of 110 | 100 of 112 | $0.27 | Against v1.5, v1.6 passes nine more light prompts and twelve more standard prompts. The gain is larger than chance on both classes. The cost per answer stays about the same. Against Claude Sonnet 5.5 on every request, v1.6 bills 88% less and passes more prompts of both classes. ![Pass rate against cost per 1,000 answers for Auto v1.5, Auto v1.6 and five models on every request. GPT-6 Luna sits alone on the frontier. Auto v1.6 sits above every point except GPT-6 Luna.](/blog-images/auto-router-v1-6-pareto.svg) Up and to the left is better. A point is on the frontier when no lower-cost point passes more prompts. Auto v1.6 is closer to the frontier, but it is not on it. On every request, GPT-6 Luna passed 93.7% of the prompts at $0.07 per 1,000 answers. Auto sends the requests it classes as standard to a stronger tier, and GPT-6 Luna is not in that tier. The next version tests GPT-6 Luna in that tier. ## Limits - **Same prompts.** We measured the new prices on the same prompts that this benchmark replays. Part of the gain can be a fit to these prompts. A run on new prompts will measure it again. - **No heavy prompts.** The benchmark has no heavy prompts. On our synthetic heavy requests, v1.6 moves four picks from GLM 5.3 Flash to GPT-6 Luna. We did not grade answers to them. - **One provider.** Most light requests now go to one model on one provider, OpenAI. v1.5 sent many of them to Baseten. ## Get started - Set `model` to `nexus/auto` in an API call, or pick Auto in the model picker. - Block a model in your model policy, and Auto stops picking it. Block GPT-6 Luna, and Auto picks among the rest. - See every Auto version in the [Auto Router changelog](/auto-router/changelog). --- <!-- /blog/auto-router-v1-5 --> # Auto Router v1.5 > Auto sends more everyday requests to lower-cost models. On our benchmark, v1.5 bills 68% less per answer than v1.4. The Nexus team, 2026-11-12 Set `model` to `nexus/auto`, and Auto picks a model for each request. Auto Router v1.5 is live. It sends more everyday requests to lower-cost models, and on our benchmark it bills 68% less per answer than v1.4. ```sh curl -i https://api.nexus.inc/v1/chat/completions \ -H "Authorization: Bearer $NEXUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "nexus/auto", "messages": [{"role": "user", "content": "Rename getUserName to snake_case"}]}' ``` The `x-nexus-model` header names the model that ran. The `x-nexus-router` header names the Auto version that picked it. ## What's new - **Lower-cost models for coding questions (v1.5).** A code block no longer sends a request to a stronger model by itself. The request's size and shape decide. Requests with tool results, like an agent's loop, still go to a stronger model. - **Prices based on real answers (v1.3.1 and v1.4).** Some models write longer answers than others, and reasoning is billed as output. Auto now prices each model by how much it writes per answer, measured on our benchmark. - **Open-weight models for light requests (v1.3).** gpt-oss-120b and GLM 5.3 Flash on Baseten can now take light requests. ## How Auto picks a model 1. **It starts from the models you allow.** Auto considers only the models your organization's policy allows and can pay for. 2. **It sorts the request.** Auto scores the request's size, turns, tools, tool results, code and images. Then it puts the request in one of three classes: light, standard or heavy. Most short questions are light. A request with tool results is standard or heavy. 3. **It picks the lowest-priced model for the class.** Each class has a minimum model tier. Auto prices each model at or above that tier by how much it writes per answer, and sends the request to the lowest-priced one. 4. **It records the pick.** Every pick is recorded with its version and its class. If Auto cannot pick, the call runs your organization's default model. ## Benchmark We sent 222 light and standard prompts through the Gateway to five models: Claude Haiku 5.5, Claude Sonnet 5.5, GPT-6 Luna, gpt-oss-120b and GLM 5.3 Flash. We graded every answer. Then we replayed each Auto version's picks on those answers. Costs are what the Gateway billed, weighted by our own traffic: 85% light, 15% standard. | Model | Light prompts passed | Standard prompts passed | Cost per 1,000 answers | | --- | --- | --- | --- | | Claude Sonnet 5.5 on every request | 94 of 110 | 98 of 112 | $2.33 | | Auto v1.4 | 90 of 110 | 90 of 112 | $0.86 | | Auto v1.5 | 92 of 110 | 88 of 112 | $0.28 | Against v1.4, v1.5 bills 68% less per answer. Its pass rates moved by no more than chance: two more light passes, two fewer standard passes. Against Claude Sonnet 5.5 on every request, v1.5 bills 88% less. It passes two fewer light prompts and ten fewer standard prompts. If your standard requests need Sonnet-level answers, name the model in those calls. ![Pass rate against cost per 1,000 answers for Auto v1.4, Auto v1.5 and five models on every request. GPT-6 Luna sits alone on the frontier, above and to the left of every other point.](/blog-images/auto-router-v1-5-pareto.svg) The chart puts each Auto version next to five models used on every request. Up and to the left is better. A point is on the frontier when no lower-cost point passes more prompts. Auto v1.5 is not on the frontier. GPT-6 Luna on every request passed 93.7% of the prompts at $0.07 per 1,000 answers. Auto v1.5 passed 82.9% at $0.28. Two things explain most of the gap: - Auto sends standard requests only to models in a stronger tier, and GPT-6 Luna is not in it. On this benchmark, GPT-6 Luna passed 94 of 112 standard prompts. Auto v1.5 passed 88. - Most of these prompts are light, and GPT-6 Luna passed 105 of 110 of them. A set this easy does not show where a stronger model is worth its price. Closing this gap is the next step for Auto: a fuller benchmark, with heavy prompts, and tiers set from its results. We will publish the same chart with each new version. The benchmark has no heavy prompts, and it is one run on our own prompts. So these numbers say nothing about heavy requests. ## Get started - Set `model` to `nexus/auto` in an API call, or pick Auto in the model picker. - Block a model in your model policy, and Auto stops picking it. - See every Auto version in the [Auto Router changelog](/auto-router/changelog).