Error shape
REST answers with the HTTP status from the table below and a JSON body {error, msg, details?, hint?}. error is the stable code to branch on; msg is one readable line; details holds what the next step needs (a checkout link, a wait time, a missing scope); hint appears on the few errors whose message does not already say what to do.
Over MCP an op error is a tool result with isError: true whose text is the same JSON. A bad_request also carries args, the op's argument signature, so the agent can correct its call without asking tl_help. These are the real responses:
tl_create {"op":"create","args":{"title":"x","text":"y"}}
// isError: true
{
"error": "bad_request",
"msg": "signers: Invalid input: expected array, received undefined",
"args": "{title:str,text?:str,pdf?:str,doc?:str,message?:str,signers:[{name:str,email:str,order?:int,role?:str}],fields?:[{kind:signature|initials|date|text|checkbox,signer:int,page:int,x:0..1,y:0..1,w:num,h:num,required?:bool,label?:str}],redirect?:str|{url:str,label?:str},approval?:bool,send?:bool,expiresInDays?:int,remindEveryDays?:int}"
}tl_create {"op":"send","args":{"id":"env_..."}}
// isError: true, nothing ran
{"error":"bad_request","msg":"send is a send op: use tl_send"}HTTP/1.1 402 Payment Required (REST; over MCP the same JSON is a tool error)
{
"error": "plan_required",
"msg": "Sending needs a plan: this account has no plan yet. Start a 14-day trial to send. Open https://trustline.app/app/settings?upgrade=solo to start it (a person signs in and adds a card; an agent can't pay).",
"details": {
"checkoutUrl": "https://trustline.app/app/settings?upgrade=solo",
"plan": "solo",
"status": null,
"trialDays": 14
}
}{
"error": "plan_limit",
"msg": "sending signers to your invoice needs the Team plan",
"details": {
"upgradeTo": "team"
},
"hint": "only a person can change plans: give them https://trustline.app/pricing (details.upgradeTo)"
}Error codes
The same codes come from REST, MCP and the dashboard, because all three run the same operations. Statuses are fixed per code.
| error | HTTP | Meaning | Next step | Carries |
|---|---|---|---|---|
| bad_request | 400 | The arguments failed validation (unknown keys are rejected, required ones missing, wrong types) or a value does not fit (a field off the page, a signer index that does not exist, a webhook URL that is not public https). | Read msg: it names the path and the problem, for example signers: expected array. Over MCP the error also carries args, the op's signature, so fix and retry without calling tl_help. | args (MCP, the op's signature); details.problems on some send checks |
| unauthorized | 401 | No credential, or the API key or token is unknown, expired or revoked. | Send Authorization: Bearer with a tlk_ API key or an OAuth access token. To get one, see /docs/agents#connect. | hint |
| forbidden | 403 | The credential lacks the op's scope (details.scope), or the action is one only a person may take (approving an envelope, changing the plan). | Missing scope: reconnect asking for it; a person approves the new grant. Person-only action: tell the person what to do; do not retry. | details.scope and hint when a scope is missing |
| not_found | 404 | No such envelope, template, webhook, document or op for this account. Another account's ids also read as not found, never as forbidden. | Check the id. list, tpls and hooks show what this account has. For an unknown op, msg lists the valid ones. | |
| conflict | 409 | Another call is changing the same envelope (envelope is busy; retry), or a stored file failed its integrity check. | Busy: retry after a moment. An integrity failure is not fixed by retrying: report it at /contact. | |
| invalid_state | 409 | The envelope's status does not allow this: editing after it was sent, downloading the signed PDF before completion, sending after the expiry date. | msg says the current status and what was expected. Read tl_read status and do what that status allows; for an expired draft, set update {expiresInDays}. | |
| not_your_turn | 409 | Signing order: an earlier signer has not signed yet. Raised on the signing page, not by agent ops. | Wait. In status, the signer whose turn it is has turn: true. | |
| missing_fields | 422 | A signer submitted without filling required fields. Raised on the signing page, not by agent ops. | The signer fills the fields listed in details.fields. | details.fields |
| plan_limit | 402 | The plan does not include this: an invoice link (redirect) needs the Team plan; adding a sender over the plan's limit. | Only a person can change the plan: give them the pricing page; details.upgradeTo names the plan. Or retry without the feature (for example without redirect). | details.upgradeTo, hint |
| plan_required | 402 | Sending needs a trial or a subscription, and this account has neither (or it ended). create with send: true stores nothing, so no draft is left behind; send leaves the draft as it was. | Give details.checkoutUrl to the person. After they start the 14-day trial, retry the same call. Drafts, reads and downloads keep working meanwhile. | details.checkoutUrl, details.plan, details.status, details.trialDays |
| rate_limited | 429 | The per-account burst limiter tripped (far above normal use), or a sign-up limit was reached. | Wait details.retryAfter seconds (60 when absent), then retry. REST also sends a Retry-After header. | details.retryAfter (seconds), when known |
| unsupported | 400 | Reserved for requests the server does not support. No current op returns it. | Not expected; if seen, read msg. | |
| billing_unavailable | 409 | A billing action from the dashboard cannot run on this server (no billing provider, or test-mode billing has no portal). | Not an agent path: plans are changed by a person in the dashboard. | |
| unavailable | 503 | A dependency could not be reached (email or payments). Nothing was sent or charged. | Retry in a minute. |
Retrying safely
- Retry after waiting:
rate_limited(waitdetails.retryAfterseconds),conflictwith "envelope is busy", andunavailable. - Retry after a person acts:
plan_required(they start the trial atdetails.checkoutUrl),plan_limit(they upgrade),forbiddenfor a missing scope (they approve a new grant). - Fix the call first:
bad_request,not_found,invalid_state.
There is no idempotency key on ops. create is not idempotent: if a call times out and you cannot tell whether it ran, read tl_read {"op":"list"} (newest first, with titles) before creating again, or you may send the document twice. send on an envelope that is already sent fails with invalid_state rather than emailing again. Account webhook deliveries carry an idempotency-key header (the event id) so your endpoint can drop repeats.
JSON-RPC errors
The MCP endpoint answers protocol problems with JSON-RPC errors before any op runs. Authorization errors also set WWW-Authenticate, which is how OAuth clients know to sign in again or ask for more scope:
HTTP/1.1 403 Forbidden
WWW-Authenticate: Bearer error="insufficient_scope", error_description="needs tl:send", resource_metadata="...", scope="tl:read tl:send"
{"jsonrpc":"2.0","id":1,"error":{"code":-32024,"message":"Forbidden: this credential lacks scope tl:send","data":{"scope":"tl:send"}}}| code | Name | HTTP | When |
|---|---|---|---|
| -32700 | Parse error | 400 | The body is not JSON. |
| -32600 | Invalid Request | 400 (403 for a disallowed Origin, 413 over 30 MB) | Not a JSON-RPC 2.0 message, a browser Origin that is not https or localhost, or a body over 30 MB. |
| -32001 | Unauthorized | 401 | No credential, or an invalid one. WWW-Authenticate points to the OAuth metadata; the message explains how to connect. |
| -32601 | Method not found | 404 on 2026-07-28, 200 before | Unknown method, or an events/* method from a client older than 2026-07-28. |
| -32602 | Invalid params | 200 | Unknown tool, bad event arguments or cursor, or (2026-07-28) a resource that does not exist or is not yours. |
| -32002 | Resource not found | 200 | resources/read of a missing resource on revisions before 2026-07-28. |
| -32603 | Internal error | 500 | An unexpected server error. |
| -32020 | Header mismatch | 400 | A 2026-07-28 request whose MCP-Protocol-Version, Mcp-Method or Mcp-Name header is missing or does not match the body. |
| -32022 | Unsupported protocol version | 400 | An unknown protocol version; data lists supported and requested. |
| -32023 | NotFound | 200 | Unknown event name, or events/unsubscribe of a subscription that does not exist. |
| -32024 | Forbidden | 403 with WWW-Authenticate insufficient_scope (200 inside events) | The credential lacks the scope the method needs (data.scope); events need tl:read. |
| -32025 | ResourceExhausted | 429 with Retry-After | The per-account burst limit on methods other than tools/call; data.retryAfter in seconds. tools/call reports rate_limited as a tool error instead. |
| -32026 | Unsupported | 200 | events/subscribe with a delivery mode other than webhook. |
| -32027 | CallbackEndpointError | 200 | events/subscribe: the endpoint did not echo the verification challenge; data.reason is connection_refused, timeout, tls_error, http_4xx, http_5xx or challenge_failed. |
The event codes -32023 to -32027 come from the MCP Events extension; see the events reference.