Spring til indhold
Menu

Reference

API

.md

This page is the reference for calling a workspace from your own program: the key, the HTTP calls, the tools of the MCP endpoint, the hooks' address, and what a refusal says.

Everything a client does over MCP, your own program can do over HTTP. The address is https://api.duplex.matterspace.ai; every request and answer is JSON.

Keys

A request carries a key of your organization in one of three headers; they mean the same:

http
X-API-Key: <your Duplex key>
x-duplex-key: <your Duplex key>
Authorization: Bearer <your Duplex key>

Make a key on API keys in the console. A key for your own program is a service key: it is made for some of your workspaces and for what it may do there, it is shown once, and it can be revoked at any time. The service does not keep the key itself, so it cannot show it to you again. Your sign-in to the console is not a key.

A key can be given extra permissions when it is made; the form names each with what it opens. One is tools:run: the key's agents run the service's standard tools — number_stats, unit_convert, time_convert, json_summary, csv_summary, text_checksum and public_https_get — through duplex_tool over MCP. A key without it is not offered the tool.

Ask who a key is:

bash
curl -sS https://api.duplex.matterspace.ai/v1/whoami -H "X-API-Key: $DUPLEX_API_KEY"
json
{"tenant_id": "org_…", "role": "tenant", "key_id": "k_…", "auth_mode": "keyed", "member_of": ["default"], "scope": "default", "permissions": []}

Workspaces

What your agents learn is kept in a workspace, each apart from the others. A request names its workspace in scope; without one it is the key's own (default for your first). Workspaces in the console lists them. A key reaches only the workspaces it was made for, and never another organization's.

Operations

A workspace is worked through named operations, called verbs. List the ones your key may run:

bash
curl -sS https://api.duplex.matterspace.ai/v1/verbs -H "X-API-Key: $DUPLEX_API_KEY"

Run one with POST /v1/verb/<name>, giving the workspace and the operation's arguments. Keep a memory:

bash
curl -sS https://api.duplex.matterspace.ai/v1/verb/agent_memory_ingest \
  -H "X-API-Key: $DUPLEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scope": "default", "args": {"text": "The rehearsal build ships on Fridays."}}'

Ask the workspace what it remembers that bears on a question:

bash
curl -sS https://api.duplex.matterspace.ai/v1/verb/agent_memory_search \
  -H "X-API-Key: $DUPLEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scope": "default", "args": {"query": "When does the rehearsal build ship?", "top_k": 5}}'

Every answer has the same frame: the verb, its result, and who ran it. A hit carries its text, a score (a higher score is a closer match), and where it came from:

json
{"verb": "agent_memory_search", "result": {"hits": [{"record_id": "5469…", "text": "The rehearsal build ships on Fridays.", "score": 0.89, "trust": "operator", "source": "api"}]}, "provenance": {"tenant": "org_…", "user": "k_…"}}

The console's Try it screen runs this same call and gives it as code for curl, Python and Node.

Keep a value under a name, and read it back:

bash
curl -sS https://api.duplex.matterspace.ai/v1/verb/state_set \
  -H "X-API-Key: $DUPLEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scope": "default", "args": {"key": "release-day", "value": "Friday"}}'
bash
curl -sS https://api.duplex.matterspace.ai/v1/verb/state_get \
  -H "X-API-Key: $DUPLEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scope": "default", "args": {"key": "release-day"}}'

Sending a request again

A request that changes something may carry an Idempotency-Key header with a value of your own. Sent again with the same key and the same body, it is answered with the first answer and is not done twice; the same key with another body is refused (422). Every answer carries an X-Request-ID header; send your own to follow a request through your logs.

The MCP endpoint

https://api.duplex.matterspace.ai/mcp is the same service for AI clients: Streamable HTTP, JSON-RPC messages POSTed with the same key headers. Connect a client has each client's line.

It offers eleven tools. Which of them a key is offered depends on what the key may do, and the tool listing your client receives when it connects names every argument a tool takes for your key.

ToolWhat it is for
duplex_contextCalled at the start of a turn with the person's message (message). The answer carries the workspace's rules that apply, what the workspace keeps that bears on the message, and the task the message belongs to
duplex_observeCalled at the end of a turn with how it went (turn, answer, and optionally tools, outcome, remember). This is what the workspace learns from
duplex_learnTeaches the workspace something when the person asks (what says what)
duplex_rulesThe workspace's rules: lists them, and changes one when the person asks and agrees (op)
duplex_taskWork that spans sessions, kept as a task (op)
duplex_planAsks the workspace for a prediction from what it has learned (op)
duplex_skillThe skills the workspace keeps: lists, reads and runs them (op)
duplex_shareWork carried over from other sessions; shares it only when the person asks (op)
duplex_forgetTakes back something the workspace learned, by the id the service gave it, when the person asks (what, id)
duplex_statusWhat the service did on a call and why, and how the workspace is set (show)
duplex_report_feedbackSends the person's feedback or problem report to their organization, once they confirm (text, confirm)

A key with the tools:run permission is also offered duplex_tool (tool, input, args), which runs one of the standard tools named under Keys.

A turn is two calls: duplex_context at its start and duplex_observe at its end. The server tells the client to make both, and the turn counts as one query of your plan however many calls it makes.

An agent can also report how a piece of work ended: duplex_learn with what: outcome and the steps it took, each with how it went. The workspace learns from the report at once and answers with the outcome's id; duplex_forget with what: outcome and that id takes it back.

Hooks

A client's hooks post its events — a prompt submitted, a tool about to run, a tool's result, a session's end — to:

http
POST https://api.duplex.matterspace.ai/v1/hook/{client}/{event}

{client} is claude_code, codex, cursor or copilot; {event} is the client's own name for the event. The same key headers apply. The answer says whether a checked tool call may run. Use your client's package rather than calling this yourself: it handles time limits and what to do when no answer comes. See The client packages.

When a request is refused

A refusal is a sentence, its kind, whether anything was done, and whether trying again helps:

json
{"detail": "missing or invalid API key", "kind": "not_permitted", "applied": false, "retry": "no"}

retry is safe (send it again as it is), after (wait retry_after_s seconds; the Retry-After header says the same) or no.

StatusWhat it meansWhat to do
400The arguments do not fit the operationCorrect the arguments
401No key, or a key the service does not knowMake a key on API keys and send it in X-API-Key
402A monthly limit of your plan is reached. When the month's queries are used, error is decisions_per_month_exceededWait for the next month, or change plan on Billing. Your agent keeps working without Duplex, and nothing it learned is lost. See Plans and limits
403The key may not do this, or one of your organization's rules refused it; the answer carries the rule's wordsUse a key that may, or have an admin change the rule on Rules
404No such operation or route; the answer names the nearestCorrect the name
409The operation's own refusal, named in error; or a write that met another at the same momentFor a write that met another, send it again
413The request is too largeSend less
422The body does not fit the route, or an Idempotency-Key was used again with another bodyCorrect the body, or use a new Idempotency-Key
429Your plan's calls a minute, or calls at once, are used; error is calls_per_minute_exceeded or calls_in_flight_exceededWait the seconds the answer names and send it again
500A fault of the service; the answer carries an incident idQuote the incident id to support
503The service cannot take the call this moment. With error: over_capacity the service is momentarily full, and nothing was doneSend it again after the seconds Retry-After names

On the MCP endpoint a refusal is a JSON-RPC error that carries the same sentence: -32001 for a missing or unknown key, -32005 for a plan's calls a minute or calls at once, -32007 for over_capacity.