Your agents, from your own code
Run your Nagent agents from a script, a backend, Claude Code, Cursor or any MCP client. A run from outside is governed exactly as one inside Nagent: the same knowledge, tools, autonomy level and approvals, and spend through your budget.
These are the developer docs. Setting up and running your AI teams in the workspace itself is covered in the platform docs.
Quickstart
- Create an API key in Nagent at Settings, API & MCP (steps below).
- Run an agent:
curl -X POST https://nagent.ai/api/v1/agents/nora/runs \
-H "Authorization: Bearer $NAGENT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"input": "Research retail-1.example and draft a first email"}'The response is the finished run: its output, the actions it took, and any it is waiting on a person to approve.
Create an API key
- Sign in to Nagent and open
https://nagent.ai/admin/settings/api(Settings, API & MCP). Viewing it needssettings:read; creating a key needssettings:write. - Choose Create key. Name it after what will use it, for example Zapier production or Cursor, Priya.
- Pick live or test. A test key runs agents without tools, so it never sends or writes anything: use it while you build.
- Give it scopes (
agents:runandruns:readto run agents) and the agents it may reach. Choose personal if it should act as you, which deciding approvals needs. - Optionally set an expiry, an IP allowlist (Business) or a lower rate limit.
- Copy the key. It is shown once, with every snippet on this page filled in. Store it as
NAGENT_API_KEYin your secret manager or shell.
Rotate makes a successor with the same access and keeps the old key working for 24 hours. Revoke stops it at once. Keys start on the Team plan.
From any language
The API is plain HTTPS and JSON with a bearer key, so any stack can call it. Official SDKs exist for Python and TypeScript. For anything else, generate a client from the OpenAPI document at /api/v1/openapi.json, or import that URL into Postman, Insomnia or Bruno to try every call with your key.
Python
# pip install nagent
import os
from nagent import Nagent
nagent = Nagent(api_key=os.environ["NAGENT_API_KEY"], base_url="https://nagent.ai")
run = nagent.runs.create("nora", input="Research retail-1.example and draft a first email")
print(run["status"], run["output"])TypeScript
// npm install @nagent/sdk
import { Nagent } from '@nagent/sdk';
const nagent = new Nagent({ apiKey: process.env.NAGENT_API_KEY!, baseUrl: 'https://nagent.ai' });
const run = await nagent.runs.create('nora', { input: 'Research retail-1.example and draft a first email' });
console.log(run.status, run.output);Go, Java, C#, Ruby, PHP and the rest
# Any language: generate a client from the OpenAPI document
npx @openapitools/openapi-generator-cli generate \
-i https://nagent.ai/api/v1/openapi.json -g go -o ./nagent-go
# -g java | csharp | ruby | php | kotlin | swift5 | rust | …Keys and scopes
A key belongs to your workspace and is made by a member. It can hold no scope its maker lacks, reaches only the agents it is given, and is checked on every call against the plan the workspace is on that day. Keys start nag_live_ or nag_test_; a test key runs agents without tools, so it never sends or writes anything. Rotate makes a successor and keeps the old key working for 24 hours; revoke stops it at once.
| Scope | What it allows | From |
|---|---|---|
agents:read | List the agents the key reaches and read their agent.md. | Team |
agents:run | Start a governed run. Actions below the autonomy floor wait for a person. | Team |
runs:read | Read a run’s status, output and the actions it took or is waiting on. | Team |
approvals:read | List the actions waiting for a person. | Business |
approvals:decide | Approve or reject a waiting action, as the member the key belongs to. Personal keys only. | Business |
webhooks:manage | Add and remove the endpoints Nagent posts events to. | Business |
knowledge:read | List, search and read the Knowledge Hub documents the key’s member may read. | Team |
knowledge:write | Add a document to the Knowledge Hub from text or a web address. | Team |
leads:read | List and read leads, with contact fields as the member’s role shows them. | Team |
leads:write | Create leads and change their stage, owner and details. | Team |
ops:triggers | List the triggers of the agents the key reaches, fire one now, or subscribe an agent to an event. | Team |
tools:write | Register a code tool service as a connector, read its review state, and disable it. | Business |
assist:run | Send a live call’s transcript and read back assist cards and the after-call draft. Read only: assist never acts on an account. | Business |
collections:field | The bank’s field app records visits: GPS trail, live photos and the customer’s visit code, as the field officer named on each call. | Business |
conversions:write | Send conversion events to your connected ad accounts. | Team |
convexa:manage | Read the Convexa snippet, add or remove allowed origins, and check an install. | Team |
convexa:sessions | From your backend, start a chat session for a signed-in app user. The app chats with the token it gets back. | Team |
Plans and limits
| Plan | API and MCP | Requests a minute | Webhook endpoints |
|---|---|---|---|
| Solo | The settings page and snippets; keys start on Team | None | None |
| Team | Live keys, agents and runs scopes | 60 | 1 |
| Business | Every scope, personal keys that decide approvals, IP allowlists | 600 | 5 |
| Enterprise | Every scope, personal keys, IP allowlists, unlimited call log | 6,000 | 25 |
See pricing for the plans themselves.
REST reference
Base URL https://nagent.ai/api/v1. JSON in and out; errors are RFC 9457 problem documents; every response carries X-Request-Id, Nagent-Api-Version and RateLimit-*. The machine-readable reference is /api/v1/openapi.json.
| Call | What it does | Scope |
|---|---|---|
GET /agents | List the agents this key reaches | agents:read |
GET /agents/{key} | Read one agent | agents:read |
GET /agents/{key}/agent.md | The agent as a markdown specification | agents:read |
POST /agents/{key}/runs | Run an agent | agents:run |
POST /agents/{key}/messages | Message an agent as yourself | agents:run |
POST /n/messages | Message N as yourself | agents:run |
GET /runs/{id} | Read a run, with its output once it has one | runs:read |
GET /runs/{id}/events | A run as server-sent events | runs:read |
GET /approvals | Actions waiting for a person | approvals:read |
POST /approvals/{id}/decide | Approve or reject a waiting action | approvals:decide |
GET /webhooks | List webhook endpoints | webhooks:manage |
POST /webhooks | Add a webhook endpoint | webhooks:manage |
DELETE /webhooks/{id} | Remove a webhook endpoint | webhooks:manage |
GET /knowledge | Knowledge Hub documents the key’s member may read | knowledge:read |
POST /knowledge | Add a document | knowledge:write |
GET /knowledge/{id} | Read a document with its text | knowledge:read |
GET /leads | Leads, newest first | leads:read |
POST /leads | Create a lead | leads:write |
GET /leads/{id} | Read a lead | leads:read |
PATCH /leads/{id} | Change a lead | leads:write |
GET /triggers | Triggers of the agents this key reaches | ops:triggers |
POST /triggers/{id}/fire | Fire a trigger now | ops:triggers |
POST /tool-connectors | Register a deployed code tool service | tools:write |
GET /tool-connectors/{id} | A code tool connector and the review state of each operation | tools:write |
DELETE /tool-connectors/{id} | Disable a code tool connector | tools:write |
POST /conversions | Send conversion events to the workspace’s ChatGPT ad account | conversions:write |
GET /convexa/snippet | The website chat bot snippet and status | convexa:manage |
GET /convexa/origins | The websites allowed to show the chat bot | convexa:manage |
POST /convexa/origins | Allow a website to show the chat bot | convexa:manage |
DELETE /convexa/origins | Stop allowing a website | convexa:manage |
POST /convexa/install-check | Check that a page carries the snippet | convexa:manage |
POST /convexa/sessions | Start a website bot chat for a signed-in app user | convexa:sessions |
GET /assist/calls/{id} | A contact-centre call: state, cards, summary and masked transcript | assist:run |
POST /assist/calls/{id}/turns | Send turns of a live call’s transcript, get assist cards | assist:run |
POST /assist/calls/{id}/summary | Close the call and draft its summary and disposition | assist:run |
Runs, sessions and async
POST /agents/{key}/runs takes input (up to 20000 characters) and optionally:
- A run’s
outputis returned to the key that started it; another key reads the run without it. sessionId: continue a conversation. The same id sends the agent the last turns this key ran in it, so a chat in your product keeps its thread. Sessions belong to the key.metadata: up to 16 string labels of up to 500 characters, returned on the run and on its webhook events, for your own ticket or user ids.- Header
Idempotency-Key: a retry within 24 hours is refused with 409 rather than run twice. - Header
Prefer: respond-async: answer 202 at once with the runrunningand aLocation; with the same key, pollGET /runs/{id}, followGET /runs/{id}/events, or wait for therun.completedwebhook. Use it for long runs and from serverless functions with short timeouts.
curl -X POST https://nagent.ai/api/v1/agents/nora/runs \
-H "Authorization: Bearer $NAGENT_API_KEY" \
-H "Content-Type: application/json" \
-H "Prefer: respond-async" \
-d '{"input": "Audit retail-1.example", "sessionId": "crm-4711", "metadata": {"ticket": "T-88"}}'
# 202 Accepted, Location: /api/v1/runs/<id>, status "running". Then:
curl https://nagent.ai/api/v1/runs/<id> -H "Authorization: Bearer $NAGENT_API_KEY"Lists page with a cursor: pass nextCursor back as cursor until hasMore is false.
curl "https://nagent.ai/api/v1/approvals?status=pending&limit=50" -H "Authorization: Bearer $NAGENT_API_KEY"
# { "object": "list", "data": [...], "hasMore": true, "nextCursor": "MTc2…" }
curl "https://nagent.ai/api/v1/approvals?status=pending&limit=50&cursor=MTc2…" -H "Authorization: Bearer $NAGENT_API_KEY"Knowledge, leads and triggers (Beta)
These scopes start on the Team plan, and the key acts as its member: it reads and writes what that person may in Nagent, no more.
knowledge:readlists and reads the Knowledge Hub documents the member may read, matched on title and topics, or by meaning withmode=semantic, which draws a little from the workspace’s credits. A document they may not read answers 404.knowledge:writeadds a document fromtitleandtext, or from aurlNagent reads. A full Knowledge Hub answers 402.leads:readlists and reads leads, with contact fields as the member’s role shows them in the CRM.leads:writecreates a lead from an email, phone or LinkedIn URL, owned by the member, and updates one through the CRM’s own update. A lead that already exists answers 409 with its address inLocation, so a sync can retry safely. A lead made here is not sent outreach on its own; run an agent for that, and its sends wait for approval as usual.ops:triggerslists the triggers of the agents the key reaches and fires one now. A trigger that is off or paused answers 409, one past its hourly limit 429, and the fire is governed as when it fires on schedule: the outcome isfired, orqueuedwhen its action waits for a person.
Tool connectors (Beta)
A code tool is a small service an admin builds from a description in Nagent. These calls register its deployed service as a connector, read the review state of each of its operations, and disable it. An operation reaches no agent until an admin confirms it on Integrations, Connectors. Scope: tools:write (from Business).
| Call | What it does |
|---|---|
POST /tool-connectors | Register a deployed code tool service. The service becomes a connector whose calls Nagent signs. A new project answers 201, in review, with the signing secret, shown once; it reaches no agent until an admin confirms each operation. The same project again answers 200: its status is kept, and changes names the operations that now need confirming again. Only manifest and deployment are read. |
GET /tool-connectors/{id} | A code tool connector and the review state of each operation. |
DELETE /tool-connectors/{id} | Disable a code tool connector. Agents stop reaching it at once. Only an admin turns it back on. |
Conversions (Beta)
Send conversion events from your own systems, such as a checkout or a sign-up, to the workspace’s ChatGPT ad account. Set conversions up first on Integrations, ChatGPT Ads. Scope: conversions:write (from Team).
| Call | What it does |
|---|---|
POST /conversions | Send conversion events to the workspace’s ChatGPT ad account. For your own systems: a shop checkout, a kiosk sign-up. Emails, phones and ids are hashed here before they go to OpenAI and are never stored. Needs conversions set up on the ChatGPT Ads page. Send up to 1000 events; a repeated id is deduplicated by OpenAI. validateOnly checks the batch without recording it. If a later batch of a large send fails, the problem carries sent, the events already accepted. |
Website chat bot (Beta)
The workspace’s website chat bot, set up on its own page in Nagent. Manage its snippet and the websites allowed to show it, check an install, and start a chat for a user signed in to your own app. Scopes: convexa:manage (from Team) and convexa:sessions (from Team).
| Call | What it does |
|---|---|
GET /convexa/snippet | The website chat bot snippet and status. The public site key, the script tag to put before </body>, and the bot’s status. The test token is never returned here. |
GET /convexa/origins | The websites allowed to show the chat bot. |
POST /convexa/origins | Allow a website to show the chat bot. https only; http://localhost and http://127.0.0.1 are accepted until the bot is live. An origin already listed is not added twice. At most 20 origins (409). |
DELETE /convexa/origins | Stop allowing a website. |
POST /convexa/install-check | Check that a page carries the snippet. The page must be on an allowed origin. It is fetched once from here, with no redirect to another host, within 10 seconds and 2 MB. Only the four fields below come back, never the page. |
POST /convexa/sessions | Start a website bot chat for a signed-in app user. Call this from your backend, never from the app. The reply carries a token (one hour) the app sends to POST /api/convexa/v1/chat with { token, text }, and to /api/convexa/v1/lead for a lead. The same userId always reaches the same visitor memory, on every device. userId is never stored or logged, only a one-way id derived from it. A conversation from the last 24 hours is resumed. The bot must be live, unless test is true, which opens a test conversation that writes no CRM lead. |
Contact-centre assist (Beta)
Send a live call’s transcript as text and get cards back for the person on the call, then a draft summary and disposition for them to confirm. Read only: assist never acts on an account. An admin turns it on in Settings, Contact centre. Scope: assist:run (from Business).
| Call | What it does |
|---|---|
GET /assist/calls/{id} | A contact-centre call: state, cards, summary and masked transcript. The transcript is null once the workspace’s retention setting has removed it. |
POST /assist/calls/{id}/turns | Send turns of a live call’s transcript, get assist cards. Text only, never audio. The first post opens the call; a repeated seq is ignored, so a retry is safe. Card and account numbers are masked to their last four digits and SSNs, PINs and passcodes removed before anything is stored. Refused with 409 assist-off until an admin turns assist on. Read only: assist never acts on an account. |
POST /assist/calls/{id}/summary | Close the call and draft its summary and disposition. A draft for the human agent to confirm before it goes to the CRM. Asking again answers the same draft. With retention 0 the transcript is deleted now. |
MCP for coding agents
The server is https://nagent.ai/api/mcp/nagent over Streamable HTTP, with the same key as a bearer header. It works with Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Devin and any client that speaks MCP; a client that only starts local servers reaches it through mcp-remote. Each agent the key reaches is a <agent>_run tool (with optional sessionId and metadata), and nagent_run_agent runs any of them by agentKey; nagent_list_agents, nagent_get_run, nagent_wait_run and, on a personal key, nagent_decide_approval follow the key’s scopes, as do nagent_search_knowledge, nagent_read_knowledge, nagent_add_knowledge, nagent_list_leads, nagent_get_lead, nagent_create_lead, nagent_update_lead, nagent_list_triggers and nagent_fire_trigger. On a personal key that answers as you, nagent_ask_n messages N in your own conversation with it (name an agent and N asks that agent for you), and, for workspace admins, nagent_ask_agent messages one agent directly; both need agents:run (Beta). nagent_read_smriti reads what an agent the key reaches remembers, read only, and nagent_list_proposals lists the SEO and AEO proposals waiting for a person; both need agents:read. nagent_subscribe_event, with ops:triggers, creates an event trigger: when the named event arrives, the agent runs the named action. Each agent’s agent.md and card are resources. Discovery: /.well-known/mcp.json. Set NAGENT_API_KEY in the environment the client starts from, or paste the key where the snippet names it.
Claude Code plugin
The quickest way in from Claude Code. The plugin adds this MCP server with sign-in through your browser, so there is no key to paste, a /nagent:setup command that connects, lists your agents and can wire the SDK and a webhook receiver into the project you are in, and a skill that teaches Claude this API. Source: github.com/PWIN-Technologies-Pvt-Ltd/nagent-claude-plugin.
/plugin marketplace add PWIN-Technologies-Pvt-Ltd/nagent-claude-plugin
/plugin install nagent@nagent
/nagent:setupOr connect any client with a key:
Claude Code
claude mcp add --transport http nagent https://nagent.ai/api/mcp/nagent --header "Authorization: Bearer $NAGENT_API_KEY"Codex in ~/.codex/config.toml
# Set NAGENT_API_KEY in the environment Codex starts from.
[mcp_servers.nagent]
url = "https://nagent.ai/api/mcp/nagent"
bearer_token_env_var = "NAGENT_API_KEY"Cursor in .cursor/mcp.json
{
"mcpServers": {
"nagent": {
"url": "https://nagent.ai/api/mcp/nagent",
"headers": {
"Authorization": "Bearer ${env:NAGENT_API_KEY}"
}
}
}
}VS Code in .vscode/mcp.json
{
"inputs": [
{
"type": "promptString",
"id": "nagent-api-key",
"description": "Nagent API key",
"password": true
}
],
"servers": {
"nagent": {
"type": "http",
"url": "https://nagent.ai/api/mcp/nagent",
"headers": {
"Authorization": "Bearer ${input:nagent-api-key}"
}
}
}
}Windsurf in ~/.codeium/windsurf/mcp_config.json
{
"mcpServers": {
"nagent": {
"serverUrl": "https://nagent.ai/api/mcp/nagent",
"headers": {
"Authorization": "Bearer ${env:NAGENT_API_KEY}"
}
}
}
}Gemini CLI in ~/.gemini/settings.json
{
"mcpServers": {
"nagent": {
"httpUrl": "https://nagent.ai/api/mcp/nagent",
"headers": {
"Authorization": "Bearer $NAGENT_API_KEY"
}
}
}
}Claude Desktop in claude_desktop_config.json
{
"mcpServers": {
"nagent": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://nagent.ai/api/mcp/nagent",
"--header",
"Authorization:${NAGENT_AUTH}"
],
"env": {
"NAGENT_AUTH": "Bearer <your key>"
}
}
}
}Devin and others in the client’s MCP settings
Transport: Streamable HTTP
URL: https://nagent.ai/api/mcp/nagent
Header: Authorization: Bearer <your key>
A client that only runs local (stdio) servers can use:
npx -y mcp-remote https://nagent.ai/api/mcp/nagent --header "Authorization:Bearer <your key>"Sign in with OAuth instead of a key
An MCP client can connect without a key: the person signs in to Nagent in a browser and approves what the client may do. The Claude Code plugin connects this way, and so can any MCP client that supports OAuth sign-in. Nagent is its own authorization server (OAuth 2.1 with PKCE), and the MCP server is the only thing a token from it opens.
- The client calls
https://nagent.ai/api/mcp/nagentwith no token. The 401 carries aWWW-Authenticateheader naminghttps://nagent.ai/.well-known/oauth-protected-resource/api/mcp/nagentand the scopes to ask for first:agents:read,agents:run,runs:read. - It reads
https://nagent.ai/.well-known/oauth-authorization-serverand registers itself at/api/oauth/register(dynamic client registration): 1 to 10 redirect addresses, each https, or http on a loopback host. Registration allows 20 an hour from one address, and a client that never completes a sign-in is removed after 7 days. - It opens
https://nagent.ai/oauth/authorizein the browser. The person signs in, picks the workspace, the scopes and the agents, and approves. They can grant only what they could put on a personal key: scopes their role holds, on a plan that includes MCP (from Team). - The client trades the code, which lasts 60 seconds, at
/api/oauth/tokenwith its PKCE verifier (S256 only). It gets an access token that lasts 1 hour and a refresh token that lasts 30 days; each refresh replaces both. A spent refresh token or code used again ends the whole grant. - The access token acts as the person who approved it, with every check a personal key gets. It works on the MCP server only: the REST API refuses it with
oauth-token-mcp-only.
The client ends a grant at /api/oauth/revoke. In Nagent, Settings, API & MCP lists each signed-in app under Connected apps (Beta), with who approved it and what it holds; an admin with settings:write presses Disconnect to stop it at once.
MCP client tokens (retired)
Before keys, an admin could issue an MCP client token on Settings, Triggers for four tools: fire a trigger, create an event trigger, read agent memory and list SEO and AEO proposals. No new tokens are issued. A token already issued still works for now, as the member who issued it, while that member is active and may still manage tools; it calls only the tools it was issued for, and a token with no named issuer is refused. An admin who may manage tools revokes a token on the same page.
Move to an API key: with ops:triggers the MCP server offers nagent_fire_trigger and nagent_subscribe_event, and with agents:read nagent_read_smriti and nagent_list_proposals.
Webhooks
Add an https endpoint in Settings, API & MCP. Nagent signs every delivery in the Standard Webhooks scheme. A delivery that fails is retried after 1 minute, 5, 30, then 2, 5 and 10 hours; after 24 hours the endpoint pauses and its maker is emailed. De-duplicate on webhook-id, which is the same on every retry.
| Event | When |
|---|---|
run.started | A run started through the API or MCP began. Carries the run id, agent, session and metadata. |
run.completed | A run started through the API or MCP finished. Carries the run without its output. |
run.failed | A run started through the API or MCP did not finish, and why. |
approval.requested | A run is waiting for a person to approve one or more actions, by approval id. |
approval.decided | A waiting action was approved or rejected over the API. |
whatsapp.action.confirmed | A customer confirmed, with a WhatsApp button, a protective action the bank granted for chat (never money or a commitment). Carries the product, end user, proposal, action and args for your backend to carry out. |
Verifying a delivery: TypeScript
import crypto from 'node:crypto';
// secret: the whsec_… shown when you added the endpoint
export function verify(secret: string, headers: Headers, body: string): boolean {
const id = headers.get('webhook-id') ?? '';
const ts = Number(headers.get('webhook-timestamp'));
if (!id || Math.abs(Date.now() / 1000 - ts) > 300) return false;
const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
const expected = crypto.createHmac('sha256', key).update(`${id}.${ts}.${body}`).digest();
return (headers.get('webhook-signature') ?? '').split(' ').some(entry => {
const [v, sig] = entry.split(',');
const got = Buffer.from(sig ?? '', 'base64');
return v === 'v1' && got.length === expected.length && crypto.timingSafeEqual(got, expected);
});
}Verifying a delivery: Python
import base64, hashlib, hmac, time
# secret: the whsec_… shown when you added the endpoint
def verify(secret: str, headers: dict, body: bytes) -> bool:
msg_id = headers.get("webhook-id", "")
ts = int(headers.get("webhook-timestamp", "0"))
if not msg_id or abs(time.time() - ts) > 300:
return False
key = base64.b64decode(secret.removeprefix("whsec_"))
expected = hmac.new(key, f"{msg_id}.{ts}.".encode() + body, hashlib.sha256).digest()
for entry in headers.get("webhook-signature", "").split(" "):
version, _, sig = entry.partition(",")
if version == "v1" and hmac.compare_digest(base64.b64decode(sig), expected):
return True
return FalseAny Standard Webhooks library verifies these too; the SDKs include the check.
Verify a signed request
When you add a connector with Signed requests, Nagent shows a signing secret once and then signs every call it makes to your service. Check the signature before you act on a call. The signed string is the timestamp, the method, the path and query, and the SHA-256 of the body, joined by dots; the signature is its HMAC-SHA256 under the secret. Reject a timestamp more than 300 seconds from your clock.
const crypto = require('node:crypto');
const MAX_SKEW_SECONDS = 300;
// secret: the 64 character value shown once when you saved the connector.
// ts, signature: the X-Nagent-Timestamp and X-Nagent-Signature headers.
// pathAndQuery: the request target as received, such as /v2/items?x=1.
// body: the raw request body as a string ('' for a GET).
function verify({ secret, ts, method, pathAndQuery, body, signature, now }) {
if (!secret) return false;
if (!/^\d{1,12}$/.test(String(ts))) return false;
if (Math.abs(now - Number(ts)) > MAX_SKEW_SECONDS) return false;
const bodyHash = crypto.createHash('sha256').update(body, 'utf8').digest('hex');
const canonical = `${ts}.${method.toUpperCase()}.${pathAndQuery}.${bodyHash}`;
const expected = crypto.createHmac('sha256', secret).update(canonical).digest('hex');
const a = Buffer.from(expected, 'utf8');
const b = Buffer.from(String(signature), 'utf8');
return a.length === b.length && crypto.timingSafeEqual(a, b);
}
// Express: read the raw body (express.raw) and answer 401 when verify is false.
// verify({
// secret: process.env.NAGENT_SIGNING_SECRET,
// ts: req.get('X-Nagent-Timestamp'),
// method: req.method,
// pathAndQuery: req.originalUrl,
// body: req.body.toString('utf8'),
// signature: req.get('X-Nagent-Signature'),
// now: Math.floor(Date.now() / 1000),
// });
A code tool, one an admin builds from a description in Nagent, is signed the same way and you verify it the same way, with nothing to install: Nagent runs it for you and holds its signing secret.
Approvals
A run is one governed pass of an agent over your input. Each agent works at an autonomy level, L1 Observe to L5 Lead; an action below its level does not run on its own but waits for a person, and the run comes back waiting_for_approval naming the approvals. A member decides them in Nagent, or a personal key with approvals:decide decides them as that member. Every run is checked against the workspace budget first.
Versioning
This is version 1, named in the path and in the Nagent-Api-Version header. Within v1, fields and operations are only added, so ignore fields you do not know. A breaking change ships as /api/v2. An operation being retired answers with Deprecation, a Sunset date at least six months out, and a Link to what replaces it. The older /api/public/agent/run is the website widget’s endpoint, not this API; called with a key it answers Deprecation and points here.
Errors
| Status | Type | Meaning |
|---|---|---|
| 400 | #invalid-input | The request is missing a required field, or a field is malformed. |
| 400 | #invalid-cursor | The cursor was not one a previous page returned. |
| 400 | #invalid-decision | An approval decision is approve or reject. |
| 400 | #invalid-webhook | The endpoint URL or its events could not be accepted. |
| 400 | #invalid-events | A conversions batch has an event that could not be read. |
| 400 | #connection-required | The workspace has several ChatGPT Ads connections, so the call must name one. |
| 400 | #provider-rejected | OpenAI rejected the conversions batch; the detail carries its reason. |
| 400 | #manifest-too-large | A tool connector manifest is larger than 512 KB. |
| 400 | #manifest-invalid | A tool connector manifest is not a JSON object, does not validate, or is larger than 512 KB. |
| 400 | #deployment-invalid | A tool connector deployment is missing its project, service address or revision. |
| 400 | #service-url-mismatch | The service address does not belong to that code tool build. |
| 400 | #project-mismatch | The build result is for a different project than the one named. |
| 400 | #sandbox-host-refused | The service address is not on a sandbox host. |
| 400 | #server-url-mismatch | The manifest’s first server URL is not the deployment’s service address. |
| 400 | #connector-invalid | The tool connector could not be saved as sent. |
| 401 | #missing-key | No `Authorization: Bearer` header, or not a key. |
| 401 | #invalid-key | No workspace has this key. |
| 401 | #key-revoked | The key was revoked. |
| 401 | #key-expired | The key passed its expiry. |
| 401 | #key-rotated | The key was rotated and its 24 hours of grace are over. |
| 401 | #key-owner-inactive | The member the key acts as is no longer active in the workspace. |
| 401 | #key-member-inactive | The member the key acts as is no longer active in this workspace. |
| 401 | #token-expired | An MCP sign-in token expired. Refresh it, or sign in again. |
| 401 | #oauth-token-mcp-only | An MCP sign-in token was used on the REST API. Use an API key there. |
| 401 | #product-key-wrong-door | A launched product’s key was used here. It works only on its product API. |
| 401 | #a2a-key-wrong-door | A key issued to an external agent was used here. It works only on the A2A endpoints. |
| 402 | #credits_exhausted | The workspace has used its credits for the month. |
| 402 | #tenant_budget_exceeded | The workspace reached its daily spend cap. |
| 402 | #billing_hold | The workspace is on a billing hold, so nothing that costs money runs. |
| 402 | #budget-refused | A call summary needs budget the workspace does not have. |
| 402 | #credits-exhausted | Semantic search needs credits the workspace does not have; keyword search still works. |
| 402 | #knowledge-full | The Knowledge Hub is full. |
| 403 | #plan | The workspace plan does not include the API, MCP or webhooks, or holds no more endpoints. |
| 403 | #ip-not-allowed | The call came from outside the key’s allowlist. |
| 403 | #scope-missing | The key was not given the scope this call needs. |
| 403 | #scope-withheld | The key holds the scope, but the plan no longer includes it. |
| 403 | #scope-not-held | The member the key acts as no longer holds the permission behind the scope. |
| 403 | #scope-not-held-at-seat | The member does not hold the permission behind the scope at that agent’s team. |
| 403 | #agent-not-allowed | The key was not given this agent. |
| 403 | #key-owner-staff | The key acts as platform staff and cannot be used inside a customer workspace. |
| 403 | #personal-key-required | Only a personal key, one that acts as a member, can decide an approval. |
| 403 | #member-gone | The member the key acts as is no longer in the workspace. |
| 403 | #not-allowed | The member may not decide this approval. |
| 403 | #test-key | A test key cannot fire triggers, because their actions are real. |
| 403 | #service_key | A service key answers for an integration; messaging N or an agent needs a personal key that answers as you. |
| 403 | #not_admin | Only a workspace admin may message an agent directly; message N with `agent` set instead. |
| 403 | #workspace-off | The team workspace is not on for this account. |
| 403 | #entitlement_required | The workspace plan does not include connectors. |
| 404 | #agent-not-found | No agent with that key in the workspace. |
| 404 | #run-not-found | No run with that id for an agent this key reaches. |
| 404 | #approval-not-found | No approval with that id that this key may see. |
| 404 | #lead-not-found | No lead with that id. |
| 404 | #not-found | No Knowledge Hub document or trigger with that id that this key reaches. |
| 404 | #webhook-not-found | No webhook endpoint with that id. |
| 404 | #tool-connector-not-found | No code tool connector with that id. |
| 404 | #tool-build-not-found | No code tool build with that project in the workspace. |
| 404 | #connection-not-found | No ChatGPT Ads connection with that id in the workspace. |
| 404 | #no-site | The workspace has no website chat bot yet. |
| 404 | #call-not-found | No assist call with that id in the workspace, or its retention has passed. |
| 409 | #agent-paused | The agent is paused in the workspace. |
| 409 | #duplicate-request | The Idempotency-Key was used in the last 24 hours. |
| 409 | #lead-exists | A lead with that email, phone or LinkedIn URL exists; `Location` names it. |
| 409 | #trigger-off | The trigger is switched off. |
| 409 | #trigger-paused | The trigger is paused. |
| 409 | #client-not-allowed | The trigger names the clients that may fire it, and this key is not one. |
| 409 | #tool-build-not-ready | The code tool build has not finished. |
| 409 | #connector-conflict | A connector with that slug or project already exists in the workspace. |
| 409 | #no-conversions-setup | Conversions are not set up on the ChatGPT Ads page yet. |
| 409 | #origin-limit | The chat bot already allows as many origins as it can. |
| 409 | #test-after-live | Test sessions are only for a chat bot that is not live yet. |
| 409 | #setting-up | The chat bot is still being set up. |
| 409 | #setup-failed | The chat bot could not finish setting up. |
| 409 | #not-live | The chat bot is not live yet. |
| 409 | #assist-off | Contact-centre assist is off for the workspace. An admin turns it on in Settings, Contact centre. |
| 409 | #call-closed | The call has its summary and takes no more turns. |
| 409 | #sandbox-host-not-configured | No sandbox host is set up, so a tool connector cannot be registered. |
| 409 | #tool-build-no-secret | The code tool build holds no signing secret. |
| 409 or 429 | #busy | Assist: other posts for the same call arrived at the same moment, send the turns again (409). Chat bot: it is busy right now (429). |
| 400, 404 or 409 | #refused | The approval could not be decided, for example its inputs changed since it was read. |
| 402, 410 or 423 | #gated | The workspace refused the decision for now, for example it is suspended or over its cap. |
| 410 | #tenant_soft_deleted | The workspace has been deleted. |
| 413 | #call-too-long | The call already holds the most turns one call may. |
| 422 | #message-refused | The message was empty, too long, or the workspace’s rules held it. |
| 422 | #not-ingested | The document could not be added to the Knowledge Hub. |
| 422 | #no-transcript | The call has no turns to summarise. |
| 423 | #tenant_suspended | The workspace is suspended: reads work, writes do not. |
| 423 | #paused | The chat bot is paused. |
| 429 | #rate-limited | Over the key’s requests a minute. Retry after the Retry-After seconds. |
| 429 | #message-rate-limited | The person sent more messages in the last minute than the app allows. |
| 429 | #trigger-rate-limited | The trigger already fired its hourly limit. |
| 429 | #provider-rate-limited | OpenAI is rate limiting conversions for the workspace. |
| 429 | #cap-reached | The chat bot is at its limit for today. |
| 500 | #internal | Nagent could not finish the call. Quote the request id if you write to us. |
| 500 | #ask-failed | N or the agent could not answer the message; the reason says why in plain words. |
| 502 | #conversions-key-refused | OpenAI refused the workspace’s Conversions API key. Run conversions setup again. |
| 502 | #provider-unavailable | OpenAI could not take the conversions batch right now. |
| 503 | #search-unavailable | Semantic search is unavailable right now; keyword search still works. |
| 503 | #convexa-not-configured | Chat is not available right now. |
| 503 | #model-unavailable | The model did not give a call summary; send the request again. |
SDKs
Both are thin clients over the REST API with no dependencies. Tests hold each to the OpenAPI document, so a method is one operation. Errors raise the problem document with its request id. @nagent/sdk 1.3.0 is on npm, an ES module you load with import, and nagent 1.2.0 is on PyPI. The REST API and its OpenAPI document above work from any other stack.
Python: pip install nagent
# pip install nagent
import os
from nagent import Nagent
nagent = Nagent(api_key=os.environ["NAGENT_API_KEY"])
accepted = nagent.runs.create("nora", input="Research retail-1.example", session_id="crm-4711", wait=False)
run = nagent.runs.wait(accepted["id"])
print(run["status"], run["output"])
for approval in nagent.approvals.iter():
print(approval["id"], approval["action"])TypeScript and JavaScript: npm install @nagent/sdk
// npm install @nagent/sdk
import { Nagent } from '@nagent/sdk';
const nagent = new Nagent({ apiKey: process.env.NAGENT_API_KEY! });
const accepted = await nagent.runs.create('nora', { input: 'Research retail-1.example', sessionId: 'crm-4711' }, { async: true });
const run = await nagent.runs.wait(accepted.id!);
if (run.status === 'waiting_for_approval') console.log('Waiting on', run.waitingOn);
else console.log(run.output);
for await (const approval of nagent.approvals.all()) console.log(approval.id, approval.action);Every method
Each client is nagent below, made with new Nagent(...) in TypeScript and Nagent(...) in Python. TypeScript also exports verifyWebhook and Python verify_webhook, which check a webhook delivery’s signature.
| TypeScript | Python | Call |
|---|---|---|
| Agents | ||
agents.list | agents.list | GET /agents List the agents this key reaches. |
agents.get | agents.get | GET /agents/{key} Read one agent. |
agents.markdown | agents.markdown | GET /agents/{key}/agent.md The agent as a markdown specification. |
| Runs | ||
runs.create | runs.create | POST /agents/{key}/runs Run an agent. |
runs.get | runs.get | GET /runs/{id} Read a run, with its output once it has one. |
runs.events | runs.events | GET /runs/{id}/events A run as server-sent events. |
runs.wait | runs.wait | Reads the run until it is no longer running, or the timeout passes. |
| Messages (Beta) | ||
messages.toN | messages.to_n | POST /n/messages Message N as yourself. |
messages.toAgent | messages.to_agent | POST /agents/{key}/messages Message an agent as yourself. |
| Approvals | ||
approvals.list | approvals.list | GET /approvals Actions waiting for a person. |
approvals.all | approvals.iter | Every approval, page after page, from the list call. |
approvals.decide | approvals.decide | POST /approvals/{id}/decide Approve or reject a waiting action. |
| Webhooks | ||
webhooks.list | webhooks.list | GET /webhooks List webhook endpoints. |
webhooks.create | webhooks.create | POST /webhooks Add a webhook endpoint. |
webhooks.delete | webhooks.delete | DELETE /webhooks/{id} Remove a webhook endpoint. |
| Knowledge | ||
knowledge.list | knowledge.list | GET /knowledge Knowledge Hub documents the key’s member may read. |
knowledge.get | knowledge.get | GET /knowledge/{id} Read a document with its text. |
knowledge.create | knowledge.create | POST /knowledge Add a document. |
| Leads | ||
leads.list | leads.list | GET /leads Leads, newest first. |
leads.get | leads.get | GET /leads/{id} Read a lead. |
leads.create | leads.create | POST /leads Create a lead. |
leads.update | leads.update | PATCH /leads/{id} Change a lead. |
| Triggers | ||
triggers.list | triggers.list | GET /triggers Triggers of the agents this key reaches. |
triggers.fire | triggers.fire | POST /triggers/{id}/fire Fire a trigger now. |
| Conversions | ||
conversions.send | conversions.send | POST /conversions Send conversion events to the workspace’s ChatGPT ad account. |
| Website chat bot | ||
convexa.snippet | convexa.snippet | GET /convexa/snippet The website chat bot snippet and status. |
convexa.listOrigins | convexa.list_origins | GET /convexa/origins The websites allowed to show the chat bot. |
convexa.addOrigin | convexa.add_origin | POST /convexa/origins Allow a website to show the chat bot. |
convexa.removeOrigin | convexa.remove_origin | DELETE /convexa/origins Stop allowing a website. |
convexa.checkInstall | convexa.check_install | POST /convexa/install-check Check that a page carries the snippet. |
convexa.createSession | convexa.create_session | POST /convexa/sessions Start a website bot chat for a signed-in app user. |
| Tool connectors | ||
toolConnectors.register | register_tool_connector | POST /tool-connectors Register a deployed code tool service. |
toolConnectors.get | get_tool_connector | GET /tool-connectors/{id} A code tool connector and the review state of each operation. |
toolConnectors.disable | disable_tool_connector | DELETE /tool-connectors/{id} Disable a code tool connector. |
| Contact-centre assist | ||
assist.postTurns | assist.post_turns | POST /assist/calls/{id}/turns Send turns of a live call’s transcript, get assist cards. |
assist.summarise | assist.summarise | POST /assist/calls/{id}/summary Close the call and draft its summary and disposition. |
assist.get | assist.get | GET /assist/calls/{id} A contact-centre call: state, cards, summary and masked transcript. |
Product API
On the Launch page an admin packages chosen agents as a product for the workspace’s own customers. The product’s app calls the Product API from its backend, with the product’s key, on behalf of its signed-in end users. Every message is a governed run of the product’s agents, and the reply comes back finished. This is a separate API from /api/v1: a different key and a different audience.
Get a product key
- Launch is on the Business plan and above. Opening it needs
aiteam:read; making a product and everything that changes one (publish, pause, rotate the key) needsaiteam:write. - Press New product and Create product. Its key, starting
nag_live_, is shown once. Keep it on your server, never in the app or a browser. - Rotate key on the product’s page makes a new key, shown once; the old one keeps working for 24 hours. If that answer is lost, the admin who rotated can show the new key once more within ten minutes.
- The app’s calls are answered while the product is in preview or live. A draft answers 409
product-not-published; a paused product or one taken offline answers 423. Going live is not open on every workspace yet; until it is, a product works in preview.
A product key works only here, and nothing else works here: a workspace API key is refused with product-surface-needs-product-key, and the product key anywhere else with product-key-wrong-door. The in-store calls tagged Retail take a store’s kiosk key instead, starting rk_, made on the Stores screen and shown once; it reaches that one store only.
Base URL https://nagent.ai/api/launch/v1. The machine-readable reference, with every request and response schema, is /api/launch/v1/openapi.json, public like the REST one.
| Call | What it does | Key |
|---|---|---|
| End users | ||
POST /users | Register or refresh an end user | Product key |
| Sessions | ||
POST /sessions | Open a conversation | Product key |
GET /sessions/{id} | Read a session’s turns | Product key |
POST /sessions/{id}/messages | Send a message and get the reply | Product key |
| Model | ||
POST /model | Ask the workspace’s default model (text only) | Product key |
| Audit | ||
POST /audit | Record the assistant’s per-action audit events | Product key |
| Servicing | ||
GET /servicing/requests | List a customer’s servicing requests | Product key |
GET /servicing/requests/{id} | Read one servicing request | Product key |
POST /servicing/requests/{id}/confirm | Confirm a servicing request the customer approved in the app | Product key |
POST /servicing/requests/{id}/outcome | Report the card block the app carried out | Product key |
POST /servicing/requests/{id}/cancel | Decline or withdraw a servicing request | Product key |
| Integrations | ||
POST /integrations | Report the integrations the app runs on | Product key |
| Agents | ||
POST /agents | Report the agents the app runs | Product key |
| Conformance | ||
POST /conformance/{runId}/claim | Take a requested conformance run | Product key |
POST /conformance/{runId}/result | Post the nine checks of a claimed run | Product key |
| Retail | ||
GET /retail/feed | Read a store’s live catalogue (kiosk) | Kiosk key |
GET /retail/appointments/slots | Free appointment slots at this store (kiosk) | Kiosk key |
POST /retail/appointments | Book an appointment (kiosk) | Kiosk key |
GET /retail/appointments | This store’s appointments on a day (kiosk) | Kiosk key |
DELETE /retail/appointments/{id} | Cancel an appointment (kiosk) | Kiosk key |
POST /retail/events | Report what happened in a store (kiosk) | Kiosk key |
POST /retail/handoffs | Hand a purchase off (kiosk) | Kiosk key |
GET /retail/handoffs | List this store’s hand-offs (kiosk) | Kiosk key |
GET /retail/handoffs/{id} | Read a hand-off (kiosk) | Kiosk key |
POST /retail/handoffs/{id}/paid | Mark paid at the counter (kiosk) | Kiosk key |
POST /retail/handoffs/{id}/cancel | Cancel a hand-off (kiosk) | Kiosk key |
POST /retail/shoppers | Opt a shopper in to follow-ups (kiosk) | Kiosk key |
POST /retail/shoppers/{id}/confirm | Confirm a channel with its code (kiosk) | Kiosk key |
GET /retail/shoppers/{id} | Read a shopper profile (kiosk) | Kiosk key |
PATCH /retail/shoppers/{id} | Change preferences, language or channels (kiosk) | Kiosk key |
DELETE /retail/shoppers/{id} | Delete a shopper profile (kiosk) | Kiosk key |
POST /retail/shoppers/{id}/visits | Save a visit summary (kiosk) | Kiosk key |
The NagentProduct client
@nagent/sdk includes NagentProduct, a client for the Product API built on the same transport as Nagent: https only, the bearer key, and a NagentError carrying the problem document on any refusal. It is TypeScript only; the Python package has no product client, so from Python call the API over HTTPS as above.
// npm install @nagent/sdk (on your server, never in the app)
import { NagentProduct } from '@nagent/sdk';
const product = new NagentProduct({ productKey: process.env.NAGENT_PRODUCT_KEY! });
// On sign-up or sign-in: keep the returned id on your own user.
const user = await product.users.upsert({ externalId: 'user-4711', displayName: 'Priya' });
const session = await product.sessions.open({ endUserId: user.id });
const message = await product.sessions.send(session.id, { endUserId: user.id, text: 'Where is my order?' });
if (message.status === 'completed') console.log(message.reply);
else console.log(message.status, message.waitingOn);| Method | Call |
|---|---|
users.upsert | POST /users Register or refresh an end user. |
sessions.open | POST /sessions Open a conversation. |
sessions.send | POST /sessions/{id}/messages Send a message and get the reply. |
sessions.history | GET /sessions/{id} Read a session’s turns. |
model.call | POST /model Ask the workspace’s default model (text only). |
audit.post | POST /audit Record the assistant’s per-action audit events. |
integrations.post | POST /integrations Report the integrations the app runs on. |
agents.post | POST /agents Report the agents the app runs. |
servicing.list | GET /servicing/requests List a customer’s servicing requests. |
servicing.get | GET /servicing/requests/{id} Read one servicing request. |
servicing.confirm | POST /servicing/requests/{id}/confirm Confirm a servicing request the customer approved in the app. |
servicing.outcome | POST /servicing/requests/{id}/outcome Report the card block the app carried out. |
servicing.cancel | POST /servicing/requests/{id}/cancel Decline or withdraw a servicing request. |
conformance.claim | POST /conformance/{runId}/claim Take a requested conformance run. |
conformance.result | POST /conformance/{runId}/result Post the nine checks of a claimed run. |