Skip to content

REST API

Everything the web UI does goes through the same REST API, and a Service Token is all your own code needs to reach it. A CI job that opens a workspace, a script that bulk-loads prompts, a local agent handing a long task to a hosted one — all the same surface.

The interactive reference is on your instance

Section titled “The interactive reference is on your instance”

Your own NAP serves it:

https://<your-nap-host>/api/docs

Signed in, ⌘KAPI Docs goes straight there. The machine-readable document sits beside it at /api/docs/openapi.json.

It isn’t mirrored here on purpose: what your instance serves is generated from the control plane you are actually running, so it matches your version rather than ours.

Create a token in the UI — ⌘KService Tokens (route /integration/tokens) → Create Service Token. It is shown once, so copy it then.

Every request carries it:

Authorization: Bearer <token>

Paths are relative to your host, so GET $NAP_BASE_URL/api/workspaces lists workspaces.

One convention worth knowing before it bites: URL-encode query parameters that carry a path. Encode the whole value — slashes inside it are literal, not separators. A raw CJK or slashed value gets a 400 or lands somewhere else.

There is deliberately no exec endpoint for service tokens. Work goes to the agent as a prompt, and the agent has its full toolset behind it — bash, file editing, everything it has in the UI:

Terminal window
BASE="${NAP_BASE_URL:?}"
NAP_WS="<workspace-id>"
# Start the turn. async returns 202 immediately with a session id.
SID=$(curl -s -X POST "$BASE/api/workspaces/$NAP_WS/chat" \
-H "Authorization: Bearer $NAP_TOKEN" -H "Content-Type: application/json" \
-d '{"message":"List the files in the repo and summarize the README","mode":"async","source":"api"}' \
| jq -r .session_id)
# Then poll the session until the agent stops running, and read the transcript.

Turns can also stream, if you’d rather watch it work than wait for it.

Where things are when they aren’t where you’d look first:

You want toGo to
Have the agent do something — run a task, edit files, answer about its workPOST /api/workspaces/{id}/chat
Read, write or list files in the workspacethe agent-files resource
Reach the shared /mnt/afs volumethe agent-afs-files resource — a different mount
Create and configure a workspacePOST /api/workspaces, then PUT /api/workspaces/{id}/config
Bulk-manage prompts, templates or skillsthe prompts, templates, skills resources

Rather than reading operation lists yourself, hand them to an agent: the nap-api skill is generated from this same spec, and it’s what lets a local agent drive NAP.