Skip to content

Events reference

Instead of asking for an envelope's status over and over, an agent can receive its lifecycle as events: by polling a cursor, over a push stream, or as signed webhooks. This page covers the MCP Events extension and Trustline's account webhooks.

Events are part of the MCP Events extension (io.modelcontextprotocol/events), served to clients on protocol 2026-07-28. They come from the envelope's append-only audit log, so every mode can replay from a cursor and every event has a stable id. All three delivery modes are offered for every event type.

Event types

events/list returns these types with their input and payload schemas. Pick one type, or envelope.lifecycle for all of them.

Event types
nameWhenArguments
envelope.sentAn envelope was sent to its signers (directly or after a person approved it).envelopeId
envelope.viewedA signer opened the envelope for the first time.envelopeId
envelope.signedA signer signed. The envelope completes when the last signer signs.envelopeId
envelope.completedEveryone signed; the signed PDF and audit certificate are ready.envelopeId
envelope.voidedThe sender voided the envelope, or it expired.envelopeId
envelope.declinedA signer declined to sign.envelopeId
envelope.lifecycleAny of envelope.sent, viewed, signed, completed, voided, declined (filter with `events`).envelopeId, events

Every argument is optional. envelopeId (env_...) limits events to one envelope; events (on envelope.lifecycle only) lists the types to keep. Unknown arguments are refused with -32602.

Payload

Each event is {eventId, name, timestamp, data}. eventId is <envelope id>.<seq>, the same id the account webhooks use, so it is safe to deduplicate on. data stays minimal: no IP addresses, no document content.

Event payload fields
fieldTypeNotes
eventstringenvelope.lifecycle only: which of envelope.sent, envelope.viewed, envelope.signed, envelope.completed, envelope.voided, envelope.declined
envelopeIdstringenv_...
titlestringthe envelope title
statusstringthe envelope's status right after this event: draft, awaiting_approval, sent, completed, voided or declined
atdate-timewhen it happened
signer{email, name}on viewed and signed: who did it

Poll

events/poll is stateless. Start with cursor: null, which means "from now": the first answer has no events and a cursor. Pass back the cursor from each answer and wait nextPollMs before the next call (5 s after events, 15 s when idle). maxEvents is 1 to 200 (default 50); when more are waiting, hasMore is true and you can call again at once. Requests on 2026-07-28 carry _meta and these headers, which must match the body:

events/poll request
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          (the event name; for events/subscribe and events/unsubscribe too)

{"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":{}}}}
result: nothing new
{
  "resultType": "complete",
  "events": [],
  "cursor": "c1.WzY5MixudWxsLDBd",
  "truncated": false,
  "hasMore": false,
  "nextPollMs": 15000
}
result: the signer viewed, signed, and the envelope completed
{
  "resultType": "complete",
  "events": [
    {
      "eventId": "env_0012.4",
      "name": "envelope.lifecycle",
      "timestamp": "2026-03-02T15:00:00.000Z",
      "data": {
        "event": "envelope.viewed",
        "envelopeId": "env_0012",
        "title": "Consulting agreement",
        "status": "sent",
        "at": "2026-03-02T15:00:00.000Z",
        "signer": {
          "email": "ada@example.com",
          "name": "Ada Lovelace"
        }
      }
    },
    {
      "eventId": "env_0012.6",
      "name": "envelope.lifecycle",
      "timestamp": "2026-03-02T15:00:00.000Z",
      "data": {
        "event": "envelope.signed",
        "envelopeId": "env_0012",
        "title": "Consulting agreement",
        "status": "sent",
        "at": "2026-03-02T15:00:00.000Z",
        "signer": {
          "email": "ada@example.com",
          "name": "Ada Lovelace"
        }
      }
    },
    {
      "eventId": "env_0012.7",
      "name": "envelope.lifecycle",
      "timestamp": "2026-03-02T15:00:00.000Z",
      "data": {
        "event": "envelope.completed",
        "envelopeId": "env_0012",
        "title": "Consulting agreement",
        "status": "completed",
        "at": "2026-03-02T15:00:00.000Z"
      }
    }
  ],
  "cursor": "c1.WzcwNCxudWxsLDBd",
  "truncated": false,
  "hasMore": false,
  "nextPollMs": 5000
}

Cursors and replay

  • A cursor (c1....) is opaque: store it and send it back. A cursor this server did not issue is refused with -32602.
  • The cursor is a position in the audit log. A poll only returns events from transactions that have finished, so a slow write is never skipped. Following the returned cursors, you see each event once, in log order.
  • Replay reaches back 30 days at most. When events older than that (or older than your maxAgeMs) were skipped, the answer says truncated: true; read tl_read status to resynchronize.
  • The cursor advances even when no event matched your filter, so a quiet subscription does not rescan the log.

Push (SSE)

events/stream takes the same name, arguments, cursor and maxAgeMs, plus heartbeatMs (5 to 30 seconds, default 15), and answers with a Server-Sent Events stream. It starts with notifications/events/active, then sends notifications/events/event as events happen and notifications/events/heartbeat with the current cursor when it is quiet. The server checks the credential on every tick: if it is revoked the stream ends with notifications/events/terminated. Streams are bounded: the server closes one after about 45 seconds with a final result, and the client reconnects with its last cursor.

events/stream (abridged)
data: {"jsonrpc":"2.0","method":"notifications/events/active","params":{"cursor":"c1...","truncated":false,"heartbeatMs":15000,"_meta":{...}}}
data: {"jsonrpc":"2.0","method":"notifications/events/event","params":{"eventId":"env_....7","name":"envelope.lifecycle","timestamp":"...","data":{...},"cursor":"c1...","_meta":{...}}}
data: {"jsonrpc":"2.0","method":"notifications/events/heartbeat","params":{"cursor":"c1...","_meta":{...}}}
data: {"jsonrpc":"2.0","id":7,"result":{"resultType":"complete","_meta":{...}}}      (the server ends the stream)

Webhook delivery

events/subscribe asks Trustline to POST each event to your endpoint. delivery.url must be https (no credentials, no fragment) and delivery.secret is whsec_ followed by base64 of random bytes: use 32 or more (24 to 64 are accepted). A subscription is keyed by credential, URL, event name and arguments, so subscribing again with the same values refreshes it instead of creating a second one (with a new secret, the old one keeps signing for 5 minutes while you switch).

  • TTL: ttlMs defaults to 1 h, between 1 min and 24 h (null gets the maximum). Subscribe again before refreshBefore to keep it.
  • Verification: before the first delivery to a URL, Trustline POSTs a signed {"type":"verification","challenge"}; answer 2xx with {"challenge"}. Otherwise subscribe fails with -32027 and a reason.
  • Retries: up to 4 attempts, waiting 30 s, 2 min, 10 min between them. HTTP 410 and 413 are final.
  • Cursor: each delivery carries a cursor; pass the last one to events/subscribe or events/poll to catch up after downtime.
  • Revocation: when the credential loses tl:read, the endpoint gets a signed {"type":"terminated"} and the subscription is removed. events/unsubscribe takes the same name, arguments and delivery.url.
events/subscribe
{"jsonrpc":"2.0","id":2,"method":"events/subscribe","params":{
  "name":"envelope.completed","arguments":{},
  "delivery":{"mode":"webhook","url":"https://agent.example.com/mcp-events","secret":"whsec_<base64 of 32 random bytes>"},
  "ttlMs":3600000,
  "_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{}}}}

// result
{
  "resultType": "complete",
  "id": "sub_629427f4734713c24ac1e601",
  "refreshBefore": "2026-03-02T16:00:00.000Z",
  "cursor": "c1.WzY3NCxudWxsLDBd",
  "truncated": false
}
verification request (real)
POST https://agent.example.com/mcp-events
content-type: application/json
webhook-id: msg_verification_27NbzikOgGXiocA-TRQIsMMz
webhook-timestamp: 1772463600
webhook-signature: v1,Fz7OlXuuu9sHm0qI9HmiNMHhkjx/73Xh1hyXy++rYRY=
x-mcp-subscription-id: sub_629427f4734713c24ac1e601
user-agent: Trustline-MCP-Events/1

{"challenge":"y1LsEBPrehVcqXfSKLU-WhNAzwrK0Qbm","type":"verification"}

// answer 2xx with the same challenge:
{"challenge":"y1LsEBPrehVcqXfSKLU-WhNAzwrK0Qbm"}
a delivery (real)
POST https://agent.example.com/mcp-events
content-type: application/json
webhook-id: msg_CpALOO0uRdVG0z2uyXfYIReu
webhook-timestamp: 1772463600
webhook-signature: v1,Wuzr7viz1bn5D9H7k+x1gfCeyVyZac2vdNV73a4Mnxg=
x-mcp-subscription-id: sub_629427f4734713c24ac1e601
user-agent: Trustline-MCP-Events/1

{
  "eventId": "env_0012.7",
  "name": "envelope.completed",
  "timestamp": "2026-03-02T15:00:00.000Z",
  "data": {
    "envelopeId": "env_0012",
    "title": "Consulting agreement",
    "status": "completed",
    "at": "2026-03-02T15:00:00.000Z"
  },
  "cursor": "c1.WzY5OSwiZW52XzAwMTIiLDdd"
}

Deliveries follow Standard Webhooks: webhook-signature is v1, plus the base64 HMAC-SHA256 of webhook-id.webhook-timestamp.body, keyed with the bytes your secret encodes. Verify before trusting the payload:

verify-event.mjs (Node)
import { createHmac, timingSafeEqual } from "node:crypto";

// secret: the whsec_... you sent in events/subscribe; headers: lower-case names; rawBody: the exact bytes received
export function verifyTrustlineEvent(rawBody, headers, secret, nowSec = Date.now() / 1000) {
  const id = headers["webhook-id"] ?? "";
  const ts = Number(headers["webhook-timestamp"]);
  if (!Number.isSafeInteger(ts) || Math.abs(nowSec - ts) > 300) return false;
  const key = Buffer.from(secret.slice("whsec_".length), "base64");
  const expected = Buffer.from(createHmac("sha256", key).update(`${id}.${ts}.${rawBody}`).digest("base64"));
  // space-separated during a secret rotation: any one match is enough
  return (headers["webhook-signature"] ?? "").split(" ").some((part) => {
    const got = Buffer.from(part.startsWith("v1,") ? part.slice(3) : "");
    return got.length === expected.length && timingSafeEqual(got, expected);
  });
}

Scopes and errors

Every events method needs the tl:read scope. Without it the request fails with HTTP 403 and WWW-Authenticate: Bearer error="insufficient_scope". Event errors:

Event error codes
codeNameWhen
-32023NotFoundUnknown event name, or events/unsubscribe of a subscription that does not exist.
-32024ForbiddenThe credential lacks the scope the method needs (data.scope); events need tl:read.
-32025ResourceExhaustedThe per-account burst limit on methods other than tools/call; data.retryAfter in seconds. tools/call reports rate_limited as a tool error instead.
-32026Unsupportedevents/subscribe with a delivery mode other than webhook.
-32027CallbackEndpointErrorevents/subscribe: the endpoint did not echo the verification challenge; data.reason is connection_refused, timeout, tls_error, http_4xx, http_5xx or challenge_failed.

Older clients

Clients that connect with an initialize handshake (protocol 2025-11-25 and earlier) get -32601 for events methods. The server instructions tell them to poll tl_read {"op":"status","args":{"id":"env_..."}} instead, or register an account webhook below. A status check costs about the same tokens as an empty poll; see token efficiency.

Account webhooks

Separate from MCP events, an account can register HTTPS endpoints with hook_add (any client, REST too). They receive every audit event type below, not only the lifecycle, filtered by the optional events list (default: all). hook_test sends a signed ping now; hooks lists endpoints and hook_del removes one. A delivery that does not get a 2xx is tried up to 7 times over about 31 hours.

register
tl_create {"op":"hook_add","args":{"url":"https://example.com/hooks/trustline","events":["signer.signed","envelope.completed"]}}
// -> {"id":"whk_0007","secret":"whsec_..."}   store the secret: it is shown once
a delivery (real)
POST https://example.com/hooks/trustline
content-type: application/json
user-agent: Trustline-Webhooks/1
trustline-signature: t=1772463600,v1=190ddc1ae7daca98dbaf422944ab7ffe4ba202943f553e58f86b1772e3c558a6
trustline-event-id: env_0012.6
idempotency-key: env_0012.6

{
  "created": "2026-03-02T15:00:00.000Z",
  "data": {
    "adoptedName": "Pat Signer",
    "date": "Mar 2, 2026",
    "fields": 0,
    "intentHash": "bb1130b9f017b771aae2482022322b625410e776ee50e6a25f0561003211ecbe",
    "method": "typed",
    "signatureSha256": "5647802942c8632930ca029189b7a50f1d0a828e9519da03affb8b720835b111",
    "signer": "sgn_0009",
    "timeZone": "UTC"
  },
  "envelope": {
    "id": "env_0012",
    "status": "sent"
  },
  "id": "env_0012.6",
  "type": "signer.signed"
}

The body is {id, type, created, envelope: {id, status}, data}, where id is the same <envelope id>.<seq> as eventId above and is repeated in trustline-event-id and idempotency-key. Signer IP addresses and user agents are never in webhooks; they are on the audit certificate.

Account webhook event types
typedata
envelope.createdtitle, originalSha256, pages, via, redirect?
envelope.updatedsigners (count), fields (count), redirect (url or null)
envelope.approval_requested{}
envelope.approved{}
envelope.approval_rejectedreason
envelope.sentsigners (count)
envelope.remindedsigners (ids reminded)
envelope.completedsignedSha256
envelope.voidedreason
envelope.declinedby (signer id)
signer.notifiedsigner, email
signer.viewedsigner
signer.consentedsigner, consentHash
signer.signedsigner, method, adoptedName, signatureSha256, intentHash, fields (count), timeZone?, date?
signer.declinedsigner, reason
signer.redirect_shownsigner, url
signer.redirect_followedsigner, url
pingwebhook (from hook_test)

The signature header is trustline-signature: t=<unix seconds>,v1=<hex>, HMAC-SHA256 of t.body keyed with the secret string as returned:

verify-hook.mjs (Node)
import { createHmac, timingSafeEqual } from "node:crypto";

// secret: the secret hook_add returned (used as is); header: trustline-signature; rawBody: the exact bytes received
export function verifyTrustlineHook(rawBody, header, secret, nowSec = Date.now() / 1000) {
  const parts = Object.fromEntries(header.split(",").map((kv) => kv.split("=")));
  const t = Number(parts.t);
  if (!Number.isSafeInteger(t) || Math.abs(nowSec - t) > 300) 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);
}

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.