Skip to content

Agent ergonomics

Trustline's API was built for agents first: few tools, one call to send, input checked strictly with messages a model can act on, and answers that carry the next step. Each principle below links to how it is implemented.

Tools split by effect, with honest annotations

The MCP server has six tools. Five group the ops by what they do to the world, so a read can never run through a write tool and a client can ask you before anything that sends email or deletes. Every tool carries a title and annotations; only tl_read and tl_help are read-only.

MCP tools and annotations
ToolOpsRead-onlyDestructiveIdempotentOpen world
tl_readstatus, list, download, audit, tpls, hooks, accountyesnoyesno
tl_createsignup, create, upload, tpl_save, tpl_send, hook_addnononoyes
tl_updateupdatenoyesyesno
tl_sendsend, approval, remind, hook_testnononoyes
tl_deletevoid, hook_delnoyesyesyes
tl_helpop?yesnoyesno

Each tool takes {op, args}. An op sent to the wrong tool is refused before it runs, with the right tool named:

wrong tool
{"error":"bad_request","msg":"send is a send op: use tl_send"}

One call to send

create with send: true creates the envelope and emails the signers in the same call. Give it text (plain text) and Trustline lays out the PDF and adds a signature and a date field for each signer, so there are no coordinates to compute. A PDF works too: pass pdf as base64, and fields are proposed from the document when you give none; or upload it first, review the proposals, and pass doc and fields.

send a contract in one call (real result)
tl_create {
  "op": "create",
  "args": {
    "title": "Consulting agreement",
    "text": "Ada will advise on the analytical engine for 3 months. Fee: 4,000 USD per month, invoiced monthly.",
    "signers": [
      {
        "name": "Ada Lovelace",
        "email": "ada@example.com"
      }
    ],
    "send": true
  }
}

// result (and a resource_link to trustline://envelopes/env_...)
{"id":"env_0012","status":"sent","signers":[{"id":"sgn_0009","email":"ada@example.com","order":1,"status":"notified","turn":true}]}

Minimal required input

create needs a title, exactly one of text, pdf or doc, and signers with a name and email each. Everything else is optional with a working default: signing order follows the list, approval is off, fields come from the document. A test envelope whose only signer is your own account email sends even before the 14-day trial starts.

Strict input, readable errors

Every op's input is checked against a strict schema at the boundary: unknown keys are refused rather than ignored, so a misspelt signer does not silently drop your signers. The first problem comes back as one line with its path, and a bad_request carries the op's signature so the agent can fix the call without another lookup:

create without signers (real result)
{"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}"}

Errors whose message does not already say what to do carry a short hint. Every code, its HTTP status and the recovery step: errors reference.

Compact results

Results hold ids and statuses, not echoes of what the agent sent. turn: true marks whose turn it is to sign. A completed envelope adds the SHA-256 of the signed PDF; download returns one-hour URLs instead of file bytes. Measured sizes: token efficiency.

What needs a person, said in the answer

An agent cannot pay or approve its own sends, so the answers say when a person is needed and hand over the link. A send on an account without a plan fails with HTTP 402 plan_required and details.checkoutUrl; with create it fails before anything is stored, so there is no orphan draft to clean up. Reads, drafts and downloads keep working.

plan_required (real result)
{
  "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
  }
}

The same holds before connecting: an unauthenticated server/discover answers with instructions that start with how to connect, and every other unauthenticated call gets 401 with a WWW-Authenticate header that OAuth clients follow and a message that explains the headless device flow.

discovery without a credential
curl -s https://trustline.app/api/mcp -H "Content-Type: application/json" \
  -H "MCP-Protocol-Version: 2026-07-28" -H "Mcp-Method: server/discover" \
  -d '{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28"}}}'
# no credential needed: the instructions start with how to connect

Waiting without polling

Clients on MCP 2026-07-28 get envelope lifecycle events: poll a cursor that tells you when to come back (nextPollMs), hold an SSE stream, or have Trustline POST signed webhooks. Older clients poll tl_read status, as the server instructions tell them. See the events reference.

Resources

Every envelope is a resource at trustline://envelopes/{id} (and /audit for its trail), and op results that name an envelope include a resource_link to it, so a client can attach the envelope to the conversation without another tool call. Another account's envelope reads as not found.

resources/read (real result)
{
  "resultType": "complete",
  "contents": [
    {
      "uri": "trustline://envelopes/env_0012",
      "mimeType": "application/json",
      "text": "{\"id\":\"env_0012\",\"status\":\"sent\",\"signers\":[{\"id\":\"sgn_0009\",\"email\":\"ada@example.com\",\"order\":1,\"status\":\"notified\",\"turn\":true}],\"title\":\"Consulting agreement\",\"createdAt\":\"2026-03-02T15:00:00.000Z\",\"original\":\"https://trustline.app/api/dl/env_0012/original?t=...kfa6c57.d7c4e0466e0561e1c1336a56e690f5074f3c33572cd5d533\"}"
    }
  ],
  "ttlMs": 10000,
  "cacheScope": "private"
}

Help on demand

The tool list names the ops but carries no per-op schemas. tl_help lists every op in one line each, and tl_help {"op":"create"} returns that op's arguments as a short signature. The same text is at GET /api/v1/help and in /llms-full.txt.

Approval is opt-in

Sends go straight to the signers by default. Set approval: true on an envelope, or turn on approval for every agent send in Settings, and a send emails a person instead; the envelope waits in awaiting_approval. No API key or OAuth token can approve, so an agent cannot approve its own envelope. See optional human approval.

Same ops everywhere

MCP, REST (POST /api/v1/ops/{op} and resource-style aliases) and the dashboard run the same operations with the same validation and the same errors, so what an agent learns over one transport holds on the other. Scopes map one to one to tools: tl:read, tl:create, tl:update, tl:send, tl:delete.

What it does not do

  • No idempotency keys: a retried create makes a second envelope. After a timeout, check list before retrying.
  • No pagination cursor on list: it returns the newest envelopes, up to limit (default 50, at most 200), optionally filtered by status.
  • No field selection: results are already compact.
  • No tool moves money. An envelope can link to your own invoice; the signer pays you there.
  • Events need a 2026-07-28 client; older clients poll status or use account webhooks.

Connect your agent and send a test envelope

Every plan includes the REST API and the MCP server, unlimited, with a 14-day free trial.