Skip to content
undertext developers
Skip to Content
undertext developers
REST API

Agent requests

Approve or deny an agent from your consent page, so Undertext can issue it tokens.

An agent request is one agent asking to act for one of your users. When someone adds your MCP address to their agent, the agent registers with Undertext and opens the person's browser at Undertext's authorize page. Undertext has no sign-in, so it sends the browser on to the consent URL you set in the console or with PATCH /v1/platform, with the request's id:

https://acme.com/undertext/connect?request=areq_7Tc1Pz9M

Your page signs the person in if they aren't already, shows them which agent is asking, lets them name it, and on Allow or Deny calls one of the endpoints below from your server. Each returns a redirect_url; send the browser there, and Undertext finishes the OAuth flow with the agent directly. You approve; Undertext issues the agent's tokens; you never see them. See Connect agents for the whole flow.

A request lasts 10 minutes and can be answered once.

The agent request object

AttributeTypeDescription
idstringThe request's id, starting areq_.
statusstringpending, approved, denied or expired.
clientobjectThe agent asking. name: the name it registered with. host: the domain its registration is published from, checked by Undertext, so it can't claim someone else's. local: whether it's an app on the person's own device, coming back to a loopback address or its own scheme, whose host says nothing people can check. logo_url: its logo, or null.
agentobject or nullRetrieved for a user: their agent that approving would update, because they approved the same client before, with its id and the name they gave it. null otherwise.
expires_attimestampWhen the request lapses if it isn't answered.
{
  "id": "areq_7Tc1Pz9M",
  "status": "pending",
  "client": {
    "name": "Claude Code",
    "host": "claude.ai",
    "local": false,
    "logo_url": "https://claude.ai/images/claude-code-icon.png"
  },
  "agent": null,
  "expires_at": "2026-10-30T18:30:00Z"
}

Show client.name and client.host together on your consent page. The name is whatever the client chose; the host is the part people can trust. For a local client, say it's an app on their computer instead of showing its local address. Offer a field for what the person will call the agent, filled in with agent.name when they're connecting the same client again, and client.name otherwise.

Retrieve an agent request

GET /v1/agent-requests/{request_id}

ParameterTypeDescription
request_idstring, path, requiredThe request value from your consent URL.
userstring, queryThe Undertext id of the person signed in to your consent page, to learn which of their agents approving would update.
curl "https://api.undertext.sh/v1/agent-requests/areq_7Tc1Pz9M?user=usr_5Kq2Lm8R" \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY"

Returns the agent request, or 404 request_not_found for an id that isn't one of yours, or a user that isn't.

Approve an agent request

POST /v1/agent-requests/{request_id}/approve

Approves the agent for one of your users and creates the agent. Call it only after your own sign-in has confirmed who the person is, and only from a deliberate action such as a form post, never from a page load.

If the user has already connected this same client, Undertext keeps the existing agent and replaces its access with what you pass here, and its name if you pass one.

ParameterTypeDescription
request_idstring, path, requiredThe request's id.
userstring, requiredThe Undertext id of the person approving: the one signed in to your product, never a value from the form.
accessstring, requiredall for every document they can open, editing at most, or chosen for only the documents in documents.
namestringWhat the person calls the agent: 1 to 48 characters, trimmed, without control or invisible characters. Without it, a new agent is called what its client calls itself, and an existing one keeps its name.
documentsobjectWith chosen: a map from document id to role, editor, suggester or viewer.
curl https://api.undertext.sh/v1/agent-requests/areq_7Tc1Pz9M/approve \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user": "usr_5Kq2Lm8R",
    "access": "chosen",
    "name": "Research",
    "documents": { "doc_8Hq2Lm4R": "suggester" }
  }'
{
  "redirect_url": "https://mcp.undertext.sh/acme/authorize/continue?state=pz9Kq2Vn8Lr4",
  "agent": {
    "id": "agt_6Bw4Ys7J",
    "user": "usr_5Kq2Lm8R",
    "name": "Codex",
    "host": "openai.com",
    "access": "chosen",
    "connected_at": "2026-10-30T18:21:40Z",
    "last_used_at": null
  }
}

For an agent that's new, Undertext also sends agent.connected to your webhook endpoints.

ErrorWhen
400 missing_parameter on documentsaccess is chosen and documents is empty or missing.
400 invalid_parameter on documentsA role is owner or not a role.
404 user_not_foundThe user doesn't exist.
404 document_not_foundA document in documents doesn't exist.
409 request_expiredMore than 10 minutes have passed. The person starts again from their agent.
409 request_already_answeredThe request was approved or denied already.

Deny an agent request

POST /v1/agent-requests/{request_id}/deny

Turns the agent away. Send the browser to redirect_url so the agent hears the answer instead of waiting.

ParameterTypeDescription
request_idstring, path, requiredThe request's id.
curl https://api.undertext.sh/v1/agent-requests/areq_7Tc1Pz9M/deny \
  -X POST \
  -H "Authorization: Bearer $UNDERTEXT_SECRET_KEY"
{
  "redirect_url": "https://mcp.undertext.sh/acme/authorize/continue?state=pz9Kq2Vn8Lr4"
}
ErrorWhen
409 request_expiredMore than 10 minutes have passed.
409 request_already_answeredThe request was approved or denied already.

On this page