Skip to content
NagentNagent
Log inSign upHire your AI Growth Team
NagentNagent
Log inSign up

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

  1. Create an API key in Nagent at Settings, API & MCP (steps below).
  2. 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

  1. Sign in to Nagent and open https://nagent.ai/admin/settings/api (Settings, API & MCP). Viewing it needs settings:read; creating a key needs settings:write.
  2. Choose Create key. Name it after what will use it, for example Zapier production or Cursor, Priya.
  3. Pick live or test. A test key runs agents without tools, so it never sends or writes anything: use it while you build.
  4. Give it scopes (agents:run and runs:read to run agents) and the agents it may reach. Choose personal if it should act as you, which deciding approvals needs.
  5. Optionally set an expiry, an IP allowlist (Business) or a lower rate limit.
  6. Copy the key. It is shown once, with every snippet on this page filled in. Store it as NAGENT_API_KEY in 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.

ScopeWhat it allowsFrom
agents:readList the agents the key reaches and read their agent.md.Team
agents:runStart a governed run. Actions below the autonomy floor wait for a person.Team
runs:readRead a run’s status, output and the actions it took or is waiting on.Team
approvals:readList the actions waiting for a person.Business
approvals:decideApprove or reject a waiting action, as the member the key belongs to. Personal keys only.Business
webhooks:manageAdd and remove the endpoints Nagent posts events to.Business
knowledge:readList, search and read the Knowledge Hub documents the key’s member may read.Team
knowledge:writeAdd a document to the Knowledge Hub from text or a web address.Team
leads:readList and read leads, with contact fields as the member’s role shows them.Team
leads:writeCreate leads and change their stage, owner and details.Team
ops:triggersList the triggers of the agents the key reaches, fire one now, or subscribe an agent to an event.Team
tools:writeRegister a code tool service as a connector, read its review state, and disable it.Business
assist:runSend 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:fieldThe 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:writeSend conversion events to your connected ad accounts.Team
convexa:manageRead the Convexa snippet, add or remove allowed origins, and check an install.Team
convexa:sessionsFrom 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

PlanAPI and MCPRequests a minuteWebhook endpoints
SoloThe settings page and snippets; keys start on TeamNoneNone
TeamLive keys, agents and runs scopes601
BusinessEvery scope, personal keys that decide approvals, IP allowlists6005
EnterpriseEvery scope, personal keys, IP allowlists, unlimited call log6,00025

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.

CallWhat it doesScope
GET /agentsList the agents this key reachesagents:read
GET /agents/{key}Read one agentagents:read
GET /agents/{key}/agent.mdThe agent as a markdown specificationagents:read
POST /agents/{key}/runsRun an agentagents:run
POST /agents/{key}/messagesMessage an agent as yourselfagents:run
POST /n/messagesMessage N as yourselfagents:run
GET /runs/{id}Read a run, with its output once it has oneruns:read
GET /runs/{id}/eventsA run as server-sent eventsruns:read
GET /approvalsActions waiting for a personapprovals:read
POST /approvals/{id}/decideApprove or reject a waiting actionapprovals:decide
GET /webhooksList webhook endpointswebhooks:manage
POST /webhooksAdd a webhook endpointwebhooks:manage
DELETE /webhooks/{id}Remove a webhook endpointwebhooks:manage
GET /knowledgeKnowledge Hub documents the key’s member may readknowledge:read
POST /knowledgeAdd a documentknowledge:write
GET /knowledge/{id}Read a document with its textknowledge:read
GET /leadsLeads, newest firstleads:read
POST /leadsCreate a leadleads:write
GET /leads/{id}Read a leadleads:read
PATCH /leads/{id}Change a leadleads:write
GET /triggersTriggers of the agents this key reachesops:triggers
POST /triggers/{id}/fireFire a trigger nowops:triggers
POST /tool-connectorsRegister a deployed code tool servicetools:write
GET /tool-connectors/{id}A code tool connector and the review state of each operationtools:write
DELETE /tool-connectors/{id}Disable a code tool connectortools:write
POST /conversionsSend conversion events to the workspace’s ChatGPT ad accountconversions:write
GET /convexa/snippetThe website chat bot snippet and statusconvexa:manage
GET /convexa/originsThe websites allowed to show the chat botconvexa:manage
POST /convexa/originsAllow a website to show the chat botconvexa:manage
DELETE /convexa/originsStop allowing a websiteconvexa:manage
POST /convexa/install-checkCheck that a page carries the snippetconvexa:manage
POST /convexa/sessionsStart a website bot chat for a signed-in app userconvexa:sessions
GET /assist/calls/{id}A contact-centre call: state, cards, summary and masked transcriptassist:run
POST /assist/calls/{id}/turnsSend turns of a live call’s transcript, get assist cardsassist:run
POST /assist/calls/{id}/summaryClose the call and draft its summary and dispositionassist:run

Runs, sessions and async

POST /agents/{key}/runs takes input (up to 20000 characters) and optionally:

  • A run’s output is 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 run running and a Location; with the same key, poll GET /runs/{id}, follow GET /runs/{id}/events, or wait for the run.completed webhook. 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:read lists and reads the Knowledge Hub documents the member may read, matched on title and topics, or by meaning with mode=semantic, which draws a little from the workspace’s credits. A document they may not read answers 404.
  • knowledge:write adds a document from title and text, or from a url Nagent reads. A full Knowledge Hub answers 402.
  • leads:read lists and reads leads, with contact fields as the member’s role shows them in the CRM.
  • leads:write creates 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 in Location, 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:triggers lists 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 is fired, or queued when 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).

CallWhat it does
POST /tool-connectorsRegister 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).

CallWhat it does
POST /conversionsSend 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).

CallWhat it does
GET /convexa/snippetThe 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/originsThe websites allowed to show the chat bot.
POST /convexa/originsAllow 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/originsStop allowing a website.
POST /convexa/install-checkCheck 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/sessionsStart 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).

CallWhat 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}/turnsSend 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}/summaryClose 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:setup

Or 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.

  1. The client calls https://nagent.ai/api/mcp/nagent with no token. The 401 carries a WWW-Authenticate header naming https://nagent.ai/.well-known/oauth-protected-resource/api/mcp/nagent and the scopes to ask for first: agents:read, agents:run, runs:read.
  2. It reads https://nagent.ai/.well-known/oauth-authorization-server and 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.
  3. It opens https://nagent.ai/oauth/authorize in 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).
  4. The client trades the code, which lasts 60 seconds, at /api/oauth/token with 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.
  5. 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.

EventWhen
run.startedA run started through the API or MCP began. Carries the run id, agent, session and metadata.
run.completedA run started through the API or MCP finished. Carries the run without its output.
run.failedA run started through the API or MCP did not finish, and why.
approval.requestedA run is waiting for a person to approve one or more actions, by approval id.
approval.decidedA waiting action was approved or rejected over the API.
whatsapp.action.confirmedA 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 False

Any 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

StatusTypeMeaning
400#invalid-inputThe request is missing a required field, or a field is malformed.
400#invalid-cursorThe cursor was not one a previous page returned.
400#invalid-decisionAn approval decision is approve or reject.
400#invalid-webhookThe endpoint URL or its events could not be accepted.
400#invalid-eventsA conversions batch has an event that could not be read.
400#connection-requiredThe workspace has several ChatGPT Ads connections, so the call must name one.
400#provider-rejectedOpenAI rejected the conversions batch; the detail carries its reason.
400#manifest-too-largeA tool connector manifest is larger than 512 KB.
400#manifest-invalidA tool connector manifest is not a JSON object, does not validate, or is larger than 512 KB.
400#deployment-invalidA tool connector deployment is missing its project, service address or revision.
400#service-url-mismatchThe service address does not belong to that code tool build.
400#project-mismatchThe build result is for a different project than the one named.
400#sandbox-host-refusedThe service address is not on a sandbox host.
400#server-url-mismatchThe manifest’s first server URL is not the deployment’s service address.
400#connector-invalidThe tool connector could not be saved as sent.
401#missing-keyNo `Authorization: Bearer` header, or not a key.
401#invalid-keyNo workspace has this key.
401#key-revokedThe key was revoked.
401#key-expiredThe key passed its expiry.
401#key-rotatedThe key was rotated and its 24 hours of grace are over.
401#key-owner-inactiveThe member the key acts as is no longer active in the workspace.
401#key-member-inactiveThe member the key acts as is no longer active in this workspace.
401#token-expiredAn MCP sign-in token expired. Refresh it, or sign in again.
401#oauth-token-mcp-onlyAn MCP sign-in token was used on the REST API. Use an API key there.
401#product-key-wrong-doorA launched product’s key was used here. It works only on its product API.
401#a2a-key-wrong-doorA key issued to an external agent was used here. It works only on the A2A endpoints.
402#credits_exhaustedThe workspace has used its credits for the month.
402#tenant_budget_exceededThe workspace reached its daily spend cap.
402#billing_holdThe workspace is on a billing hold, so nothing that costs money runs.
402#budget-refusedA call summary needs budget the workspace does not have.
402#credits-exhaustedSemantic search needs credits the workspace does not have; keyword search still works.
402#knowledge-fullThe Knowledge Hub is full.
403#planThe workspace plan does not include the API, MCP or webhooks, or holds no more endpoints.
403#ip-not-allowedThe call came from outside the key’s allowlist.
403#scope-missingThe key was not given the scope this call needs.
403#scope-withheldThe key holds the scope, but the plan no longer includes it.
403#scope-not-heldThe member the key acts as no longer holds the permission behind the scope.
403#scope-not-held-at-seatThe member does not hold the permission behind the scope at that agent’s team.
403#agent-not-allowedThe key was not given this agent.
403#key-owner-staffThe key acts as platform staff and cannot be used inside a customer workspace.
403#personal-key-requiredOnly a personal key, one that acts as a member, can decide an approval.
403#member-goneThe member the key acts as is no longer in the workspace.
403#not-allowedThe member may not decide this approval.
403#test-keyA test key cannot fire triggers, because their actions are real.
403#service_keyA service key answers for an integration; messaging N or an agent needs a personal key that answers as you.
403#not_adminOnly a workspace admin may message an agent directly; message N with `agent` set instead.
403#workspace-offThe team workspace is not on for this account.
403#entitlement_requiredThe workspace plan does not include connectors.
404#agent-not-foundNo agent with that key in the workspace.
404#run-not-foundNo run with that id for an agent this key reaches.
404#approval-not-foundNo approval with that id that this key may see.
404#lead-not-foundNo lead with that id.
404#not-foundNo Knowledge Hub document or trigger with that id that this key reaches.
404#webhook-not-foundNo webhook endpoint with that id.
404#tool-connector-not-foundNo code tool connector with that id.
404#tool-build-not-foundNo code tool build with that project in the workspace.
404#connection-not-foundNo ChatGPT Ads connection with that id in the workspace.
404#no-siteThe workspace has no website chat bot yet.
404#call-not-foundNo assist call with that id in the workspace, or its retention has passed.
409#agent-pausedThe agent is paused in the workspace.
409#duplicate-requestThe Idempotency-Key was used in the last 24 hours.
409#lead-existsA lead with that email, phone or LinkedIn URL exists; `Location` names it.
409#trigger-offThe trigger is switched off.
409#trigger-pausedThe trigger is paused.
409#client-not-allowedThe trigger names the clients that may fire it, and this key is not one.
409#tool-build-not-readyThe code tool build has not finished.
409#connector-conflictA connector with that slug or project already exists in the workspace.
409#no-conversions-setupConversions are not set up on the ChatGPT Ads page yet.
409#origin-limitThe chat bot already allows as many origins as it can.
409#test-after-liveTest sessions are only for a chat bot that is not live yet.
409#setting-upThe chat bot is still being set up.
409#setup-failedThe chat bot could not finish setting up.
409#not-liveThe chat bot is not live yet.
409#assist-offContact-centre assist is off for the workspace. An admin turns it on in Settings, Contact centre.
409#call-closedThe call has its summary and takes no more turns.
409#sandbox-host-not-configuredNo sandbox host is set up, so a tool connector cannot be registered.
409#tool-build-no-secretThe code tool build holds no signing secret.
409 or 429#busyAssist: 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#refusedThe approval could not be decided, for example its inputs changed since it was read.
402, 410 or 423#gatedThe workspace refused the decision for now, for example it is suspended or over its cap.
410#tenant_soft_deletedThe workspace has been deleted.
413#call-too-longThe call already holds the most turns one call may.
422#message-refusedThe message was empty, too long, or the workspace’s rules held it.
422#not-ingestedThe document could not be added to the Knowledge Hub.
422#no-transcriptThe call has no turns to summarise.
423#tenant_suspendedThe workspace is suspended: reads work, writes do not.
423#pausedThe chat bot is paused.
429#rate-limitedOver the key’s requests a minute. Retry after the Retry-After seconds.
429#message-rate-limitedThe person sent more messages in the last minute than the app allows.
429#trigger-rate-limitedThe trigger already fired its hourly limit.
429#provider-rate-limitedOpenAI is rate limiting conversions for the workspace.
429#cap-reachedThe chat bot is at its limit for today.
500#internalNagent could not finish the call. Quote the request id if you write to us.
500#ask-failedN or the agent could not answer the message; the reason says why in plain words.
502#conversions-key-refusedOpenAI refused the workspace’s Conversions API key. Run conversions setup again.
502#provider-unavailableOpenAI could not take the conversions batch right now.
503#search-unavailableSemantic search is unavailable right now; keyword search still works.
503#convexa-not-configuredChat is not available right now.
503#model-unavailableThe 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.

TypeScriptPythonCall
Agents
agents.listagents.listGET /agents List the agents this key reaches.
agents.getagents.getGET /agents/{key} Read one agent.
agents.markdownagents.markdownGET /agents/{key}/agent.md The agent as a markdown specification.
Runs
runs.createruns.createPOST /agents/{key}/runs Run an agent.
runs.getruns.getGET /runs/{id} Read a run, with its output once it has one.
runs.eventsruns.eventsGET /runs/{id}/events A run as server-sent events.
runs.waitruns.waitReads the run until it is no longer running, or the timeout passes.
Messages (Beta)
messages.toNmessages.to_nPOST /n/messages Message N as yourself.
messages.toAgentmessages.to_agentPOST /agents/{key}/messages Message an agent as yourself.
Approvals
approvals.listapprovals.listGET /approvals Actions waiting for a person.
approvals.allapprovals.iterEvery approval, page after page, from the list call.
approvals.decideapprovals.decidePOST /approvals/{id}/decide Approve or reject a waiting action.
Webhooks
webhooks.listwebhooks.listGET /webhooks List webhook endpoints.
webhooks.createwebhooks.createPOST /webhooks Add a webhook endpoint.
webhooks.deletewebhooks.deleteDELETE /webhooks/{id} Remove a webhook endpoint.
Knowledge
knowledge.listknowledge.listGET /knowledge Knowledge Hub documents the key’s member may read.
knowledge.getknowledge.getGET /knowledge/{id} Read a document with its text.
knowledge.createknowledge.createPOST /knowledge Add a document.
Leads
leads.listleads.listGET /leads Leads, newest first.
leads.getleads.getGET /leads/{id} Read a lead.
leads.createleads.createPOST /leads Create a lead.
leads.updateleads.updatePATCH /leads/{id} Change a lead.
Triggers
triggers.listtriggers.listGET /triggers Triggers of the agents this key reaches.
triggers.firetriggers.firePOST /triggers/{id}/fire Fire a trigger now.
Conversions
conversions.sendconversions.sendPOST /conversions Send conversion events to the workspace’s ChatGPT ad account.
Website chat bot
convexa.snippetconvexa.snippetGET /convexa/snippet The website chat bot snippet and status.
convexa.listOriginsconvexa.list_originsGET /convexa/origins The websites allowed to show the chat bot.
convexa.addOriginconvexa.add_originPOST /convexa/origins Allow a website to show the chat bot.
convexa.removeOriginconvexa.remove_originDELETE /convexa/origins Stop allowing a website.
convexa.checkInstallconvexa.check_installPOST /convexa/install-check Check that a page carries the snippet.
convexa.createSessionconvexa.create_sessionPOST /convexa/sessions Start a website bot chat for a signed-in app user.
Tool connectors
toolConnectors.registerregister_tool_connectorPOST /tool-connectors Register a deployed code tool service.
toolConnectors.getget_tool_connectorGET /tool-connectors/{id} A code tool connector and the review state of each operation.
toolConnectors.disabledisable_tool_connectorDELETE /tool-connectors/{id} Disable a code tool connector.
Contact-centre assist
assist.postTurnsassist.post_turnsPOST /assist/calls/{id}/turns Send turns of a live call’s transcript, get assist cards.
assist.summariseassist.summarisePOST /assist/calls/{id}/summary Close the call and draft its summary and disposition.
assist.getassist.getGET /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

  1. 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) needs aiteam:write.
  2. 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.
  3. 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.
  4. 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.

CallWhat it doesKey
End users
POST /usersRegister or refresh an end userProduct key
Sessions
POST /sessionsOpen a conversationProduct key
GET /sessions/{id}Read a session’s turnsProduct key
POST /sessions/{id}/messagesSend a message and get the replyProduct key
Model
POST /modelAsk the workspace’s default model (text only)Product key
Audit
POST /auditRecord the assistant’s per-action audit eventsProduct key
Servicing
GET /servicing/requestsList a customer’s servicing requestsProduct key
GET /servicing/requests/{id}Read one servicing requestProduct key
POST /servicing/requests/{id}/confirmConfirm a servicing request the customer approved in the appProduct key
POST /servicing/requests/{id}/outcomeReport the card block the app carried outProduct key
POST /servicing/requests/{id}/cancelDecline or withdraw a servicing requestProduct key
Integrations
POST /integrationsReport the integrations the app runs onProduct key
Agents
POST /agentsReport the agents the app runsProduct key
Conformance
POST /conformance/{runId}/claimTake a requested conformance runProduct key
POST /conformance/{runId}/resultPost the nine checks of a claimed runProduct key
Retail
GET /retail/feedRead a store’s live catalogue (kiosk)Kiosk key
GET /retail/appointments/slotsFree appointment slots at this store (kiosk)Kiosk key
POST /retail/appointmentsBook an appointment (kiosk)Kiosk key
GET /retail/appointmentsThis store’s appointments on a day (kiosk)Kiosk key
DELETE /retail/appointments/{id}Cancel an appointment (kiosk)Kiosk key
POST /retail/eventsReport what happened in a store (kiosk)Kiosk key
POST /retail/handoffsHand a purchase off (kiosk)Kiosk key
GET /retail/handoffsList this store’s hand-offs (kiosk)Kiosk key
GET /retail/handoffs/{id}Read a hand-off (kiosk)Kiosk key
POST /retail/handoffs/{id}/paidMark paid at the counter (kiosk)Kiosk key
POST /retail/handoffs/{id}/cancelCancel a hand-off (kiosk)Kiosk key
POST /retail/shoppersOpt a shopper in to follow-ups (kiosk)Kiosk key
POST /retail/shoppers/{id}/confirmConfirm 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}/visitsSave 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);
MethodCall
users.upsertPOST /users Register or refresh an end user.
sessions.openPOST /sessions Open a conversation.
sessions.sendPOST /sessions/{id}/messages Send a message and get the reply.
sessions.historyGET /sessions/{id} Read a session’s turns.
model.callPOST /model Ask the workspace’s default model (text only).
audit.postPOST /audit Record the assistant’s per-action audit events.
integrations.postPOST /integrations Report the integrations the app runs on.
agents.postPOST /agents Report the agents the app runs.
servicing.listGET /servicing/requests List a customer’s servicing requests.
servicing.getGET /servicing/requests/{id} Read one servicing request.
servicing.confirmPOST /servicing/requests/{id}/confirm Confirm a servicing request the customer approved in the app.
servicing.outcomePOST /servicing/requests/{id}/outcome Report the card block the app carried out.
servicing.cancelPOST /servicing/requests/{id}/cancel Decline or withdraw a servicing request.
conformance.claimPOST /conformance/{runId}/claim Take a requested conformance run.
conformance.resultPOST /conformance/{runId}/result Post the nine checks of a claimed run.