Connect
Trustline's MCP server runs over Streamable HTTP (stateless) at https://trustline.app/api/mcp. There is nothing to install. Every request carries Authorization: Bearer <token>, where the token is an OAuth access token or a Trustline API key. Without it the server answers 401 with a WWW-Authenticate header that points to its OAuth metadata.
OAuth: Claude, ChatGPT, Grok
Clients with OAuth need only the URL. Add https://trustline.app/api/mcp as a custom connector (Claude: Settings, Connectors), sign in to Trustline, tick the permissions to grant and press Allow. Step-by-step guides: ChatGPT and Grok.
Claude Code can sign in the same way:
claude mcp add --transport http trustline https://trustline.app/api/mcp
# then run /mcp in Claude Code and sign in to TrustlineTrustline is an OAuth 2.1 authorization server (issuer https://trustline.app) with protected resource and authorization server metadata under /.well-known/, Dynamic Client Registration, Client ID Metadata Documents, PKCE S256 and the resource indicator https://trustline.app/api/mcp. Clients are public: there are no client secrets. Access tokens (tlo_...) last 1 hour; refresh tokens (tlr_...) last 30 days and rotate on use.
API key header
Clients without OAuth send an API key as Authorization: Bearer tlk_.... Create a key in the dashboard under API & Agents, or let the agent get one with self-onboarding below. Claude Code:
claude mcp add --transport http trustline https://trustline.app/api/mcp \
--header "Authorization: Bearer tlk_..."Cursor (.cursor/mcp.json), Windsurf and most clients that take an mcpServers file accept a URL with headers:
{
"mcpServers": {
"trustline": {
"url": "https://trustline.app/api/mcp",
"headers": { "Authorization": "Bearer tlk_..." }
}
}
}VS Code uses its own file, .vscode/mcp.json:
{
"servers": {
"trustline": {
"type": "http",
"url": "https://trustline.app/api/mcp",
"headers": { "Authorization": "Bearer tlk_..." }
}
}
}Self-onboarding (device flow)
A headless agent can get its own credential. It sends the person's email; Trustline emails them a link that signs them in (creating a free account only then, if they have none) and shows the agent name, an 8-letter code and the permissions. The person checks the code matches the one the agent showed and presses Approve or Deny. With credential=api_key the agent gets a scoped API key named after agent_name, returned once and revocable under API & Agents. Without it, it gets OAuth access and refresh tokens.
# 1. ask for a code (form-encoded or JSON)
curl -s https://trustline.app/oauth/device_authorization \
-d email=<person's email> -d agent_name="My agent" \
-d scope="tl:read tl:create tl:send" -d credential=api_key
# -> {"device_code":"...","user_code":"BCDF-GHJK","verification_uri":"https://trustline.app/connect",
# "verification_uri_complete":"...","expires_in":900,"interval":5}
# 2. the person opens the emailed link, checks the code matches, presses Approve
# 3. poll every interval seconds
curl -s https://trustline.app/oauth/token \
-d grant_type=urn:ietf:params:oauth:grant-type:device_code -d device_code=<device_code>
# authorization_pending: wait slow_down: add 5 s access_denied / expired_token: stop
# -> {"access_token":"tlk_...","token_type":"Bearer","scope":"tl:read tl:create tl:send","credential":"api_key"}Limits: 3 pending and 5 per hour per email, 10 per hour per IP address.
Tools
Reads and writes are separate tools, each with a title, annotations and an output schema: tl_read (status, lists, downloads, audit), tl_create, tl_update, tl_send and tl_delete. Only tl_read and tl_help are read-only. tl_help lists ops or returns one op's args on demand. No tool moves money, and Trustline never collects payments: an agent can attach a link to your own invoice, and the signer pays you there.
tl_help {} // list ops
tl_help { "op": "create" } // one op's args
tl_create {
"op": "create",
"args": {
"title": "Consulting agreement",
"text": "# Consulting agreement\n\nAda will ...",
"signers": [{ "name": "Ada Lovelace", "email": "ada@example.com" }],
"redirect": { "url": "https://invoice.stripe.com/i/acct_...", "label": "Pay invoice" },
"send": true
}
}REST
REST lives under /api/v1. Authenticate with Authorization: Bearer tlk_.... Every op is also available at POST /api/v1/ops/{op}.
# 1. get an API key: self-onboard (see Connect), the dashboard, or the older signup endpoint
curl -X POST https://trustline.app/api/v1/signup \
-H "content-type: application/json" \
-d '{"email":"you@example.com"}'
# -> {"key":"tlk_...","plan":"free"}
# 2. create and send an envelope
curl -X POST https://trustline.app/api/v1/envelopes \
-H "authorization: Bearer $TRUSTLINE_API_KEY" \
-H "content-type: application/json" \
-d '{
"title": "Consulting agreement",
"text": "# Consulting agreement\n\nAda will ...",
"signers": [{"name":"Ada Lovelace","email":"ada@example.com"}],
"redirect": {"url": "https://invoice.stripe.com/i/acct_..."},
"send": true
}'
# 3. status and downloads
curl https://trustline.app/api/v1/envelopes/env_... -H "authorization: Bearer $TRUSTLINE_API_KEY"
curl https://trustline.app/api/v1/envelopes/env_.../download -H "authorization: Bearer $TRUSTLINE_API_KEY"
# any op, generically
curl -X POST https://trustline.app/api/v1/ops/status \
-H "authorization: Bearer $TRUSTLINE_API_KEY" -H "content-type: application/json" \
-d '{"id":"env_..."}'Protocol versions
The server answers both eras of MCP on the same URL.
| Version | Notes |
|---|---|
| 2026-07-28 | Per-request _meta, server/discover, resources, events |
| 2025-11-25 | initialize handshake (legacy) |
| 2025-06-18 | initialize handshake (legacy) |
| 2025-03-26 | initialize handshake (legacy) |
| 2024-11-05 | initialize handshake (legacy) |
Scopes
Each tool needs one scope. tl_help needs only a valid token. A call without the scope fails with 403 insufficient_scope. Tokens and keys can never approve a send that requires a person's approval.
| Scope | Allows |
|---|---|
| tl:read | tl_read, resources, events |
| tl:create | tl_create |
| tl:update | tl_update |
| tl:send | tl_send |
| tl:delete | tl_delete |
Resources
trustline://envelopes/{id} returns an envelope's status, signers and download links; trustline://envelopes/{id}/audit returns its audit trail. Use resources/list, resources/templates/list and resources/read; results cover only the caller's account. The results of create, send and status include a resource_link to the envelope.
Events
Clients on MCP 2026-07-28 can use the Events extension (io.modelcontextprotocol/events). events/list returns the types: envelope.sent, envelope.viewed (a signer first opened it), envelope.signed (a signer signed), envelope.completed, envelope.voided, envelope.declined, and envelope.lifecycle (all of them; arguments {envelopeId?, events?}). Every type accepts {envelopeId?}.
Poll: start with cursor: null (from now) and pass back the returned cursor. maxEvents is at most 200. Modern requests send the MCP-Protocol-Version, Mcp-Method and Mcp-Name headers and _meta in params:
POST https://trustline.app/api/mcp
Authorization: Bearer <token>
Content-Type: application/json
Accept: application/json, text/event-stream
MCP-Protocol-Version: 2026-07-28
Mcp-Method: events/poll
Mcp-Name: envelope.lifecycle
{"jsonrpc":"2.0","id":1,"method":"events/poll","params":{
"name":"envelope.lifecycle","arguments":{"envelopeId":"env_..."},"cursor":null,
"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{}}}}
// -> {"events":[{"eventId":"env_....2","name":"envelope.lifecycle","timestamp":"...",
// "data":{"envelopeId":"env_...","title":"...","status":"sent","at":"...","event":"envelope.sent"}}],
// "cursor":"c1...","truncated":false,"hasMore":false,"nextPollMs":5000}
// Call again with the returned cursor after nextPollMs.- Push:
events/streamis an SSE stream ofnotifications/events/eventwith heartbeats. The server closes it after about 45 seconds; reconnect with the last cursor. - Webhook:
events/subscribewithdelivery: {url, secret}(https URL, secretwhsec_plus base64 of 24 to 64 random bytes). The endpoint must echo a verification challenge. Deliveries are signed with Standard Webhooks headers. Subscriptions last up to 24 hours; subscribe again to refresh. - Older clients (initialize handshake) cannot use events: poll
tl_read {op:"status"}or register an account webhook withhook_add(below).
Details for agents: /skill/events.md.
Optional human approval
Set approval: true and an envelope does not go to any signer when your agent calls send. Instead, Trustline emails a person on your account, the status becomes awaiting_approval, and signers are notified only after that person approves from the emailed link or the dashboard. An API key or OAuth token can never approve, so an agent cannot approve its own envelope. A rejection returns it to draft for the agent to fix.
Approval is off by default on every channel: with send: true an envelope goes straight to its signers and the status becomes sent. Turn it on per envelope when you want a person to read a contract first.
Invoice link after signing
Trustline does not collect money on your behalf. Instead, add redirect: { url, label } on create, update or tpl_send. The URL must be https: your own Stripe invoice, QuickBooks, Square or any payment page. The label is optional and defaults to "Pay invoice".
After the signer signs, the finished screen shows a button with that label. It opens your page in a new tab, and the signed PDF and audit certificate stay on screen. The audit trail records signer.redirect_shown and, if they click it, signer.redirect_followed; both appear on the certificate.
The invoice link is on the Team and Operator plans.
Webhooks
Register an HTTPS endpoint with hook_add. Each event (for example signer.signed, signer.redirect_followed, envelope.completed) is delivered as JSON. If your endpoint does not answer with a 2xx, the delivery is retried with backoff over roughly 31 hours.
tl_create { "op": "hook_add", "args": { "url": "https://example.com/hooks/trustline" } }
// -> { "id": "whk_...", "secret": "..." } store the secret; it is shown onceEvery delivery is signed with the header trustline-signature: t=<unix>,v1=<hex>, where v1 is HMAC-SHA256 of t + "." + body with your secret. Verify it before trusting the payload:
import { createHmac, timingSafeEqual } from "node:crypto";
// header: trustline-signature: t=<unix seconds>,v1=<hex HMAC-SHA256(secret, "t.body")>
export function verifyTrustline(rawBody, header, secret, toleranceSec = 300) {
const parts = Object.fromEntries(header.split(",").map((kv) => kv.split("=")));
const t = Number(parts.t);
if (!Number.isSafeInteger(t) || Math.abs(Date.now() / 1000 - t) > toleranceSec) return false;
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
const given = Buffer.from(parts.v1 ?? "", "hex");
return given.length === expected.length && timingSafeEqual(given, expected);
}
// Use the raw request body, before any JSON parsing:
// verifyTrustline(await req.text(), req.headers.get("trustline-signature") ?? "", process.env.TRUSTLINE_WEBHOOK_SECRET)All ops
The same ops power MCP and REST. Amounts are in cents. Ask tl_help or GET /api/v1/help?op=<op> for an op's full schema.
| Op | Usage |
|---|---|
| signup | signup {email,name?} -> {key}. No auth. |
| create | create {title, text|pdf(base64)|doc, signers:[{name,email,order?}], fields?, redirect?:https|{url,label?}, approval?, send?} -> envelope. text -> PDF with signature+date per signer. |
| upload | upload {pdf|images:[b64],maybe?} -> {doc,p:[{k,p,b,s,c}],needs_review,signed?:[{p,b}],warnings?}; then create {doc,fields} |
| update | update {id, title?, signers?, fields?, redirect?|null, approval?} (draft only) |
| send | send {id}. If approval is required: emails a human -> awaiting_approval. |
| approval | approval {id}: ask a human to approve before sending |
| status | status {id} -> envelope |
| list | list {status?,limit?} -> [{id,status,title}] |
| remind | remind {id}: re-email signers whose turn it is |
| void | void {id, reason?} |
| download | download {id} -> {pdf,cert} 1h URLs (completed) or {original} |
| audit | audit {id} -> {ok,events,head,last} |
| tpl_save | tpl_save {id(envelope), name, roles?:[per signer]} -> {id, roles} |
| tpl_send | tpl_send {template, signers:[{role,name,email}], title?, redirect?, approval?, send?} -> envelope |
| tpls | tpls -> [{id,name,roles}] |
| hook_add | hook_add {url, events?} -> {id, secret}. HMAC header trustline-signature: t=..,v1=hex(hmac(secret,t.body)) |
| hooks | hooks -> [{id,url,events}] |
| hook_del | hook_del {id} |
| hook_test | hook_test {id} -> {ok,status}: signed ping now |
| account | account -> {plan, used, limit} |