docs
Quickstart
From an empty project to a signed test document. Every endpoint is in the API reference, and agents can start from llms.txt. Errors always have the form {"error":{"code","message","request_id"}}. To see every call before you write one, try the live demo.
Building an agent? Two paths for your user
- No account: if they only need to sign a PDF themselves, send them to /sign-pdf. Nothing is stored and they sign it themselves.
- With an account: they sign in at /login, create an API key under Developers and give it to the agent. The agent uploads the PDF, places the fields (Placing fields), sends and hands out the signing links. With the “Agent: prepare only” key the user approves before anything is sent.
Free workspaces have storage and upload limits: limits. The full agent guide is llms.txt.
Run locally
Needs Node 22+ and pnpm 10. Sign-in emails go to /dev/mailbox; nothing is sent. The source repository is not public yet, so this works from the day it opens. Until then, use a test key on this site.
git clone https://github.com/typesign-dev/typesign.git typesign && cd typesign
pnpm install
pnpm setup:local
pnpm dev- 1
Get an API key
Sign in to the dashboard (a workspace with free envelopes is created for you), open Developers and create an API key. Switch on Test mode first to get a test key (osk_test_): it works on the same URL, emails nobody, returns signing links in the send response and uses free test credits. A live key (osk_live_) sends real invitations. The standalone server (typesign serve) is test mode only and has no dashboard: its first start creates a key and saves it to local-api-key in its data directory, and prints the path.
export OSK=osk_test_xxxxxxxx export BASE=https://<your-host>/api/v1 # or, with typesign serve (default port and data directory): export OSK=$(cat ~/.local/share/typesign/local-api-key) export BASE=http://localhost:8080/api/v1 - 2
Upload a PDF
The server validates the file (type, size, encryption, existing signatures, scripts and attachments) and stores an immutable version with its SHA-256. The response has the version_id you pass to the envelope and each page's size in points.
curl -X POST $BASE/documents \ -H "Authorization: Bearer $OSK" \ -F file=@test-agreement.pdf - 3
Create a draft envelope
Each field gives a page (1-based) and a box as fractions 0 to 1 of the page, measured from the top-left corner of the page as displayed. Every recipient needs at least one signature field. Placing fields explains the coordinates, converting from PDF points, rotated pages, field types, limits and metadata.
curl -X POST $BASE/envelopes \ -H "Authorization: Bearer $OSK" -H "Content-Type: application/json" \ -d '{"document_version_id":"ver_…","title":"Consulting agreement", "recipients":[{"role":"customer","name":"Test Customer","email":"customer@example.com"}], "fields":[{"recipient_role":"customer","type":"signature","page":1,"x":0.1,"y":0.8,"width":0.3,"height":0.06}]}' - 4
Request approval (agents)
If the workspace requires approval for API sends, request it. A person approves in the dashboard; the approval binds to the payload hash and is single-use.
curl -X POST $BASE/envelopes/env_…/approval-requests -H "Authorization: Bearer $OSK" # → { "approval_id": "apr_…", "approval_url": "…", "payload_hash": "…" } - 5
Send
Sending locks the document, recipients, fields and the credit quote, and reserves 1 credit (charged on completion, released on decline, cancel or expiry; 402 insufficient_credits if none are available). An Idempotency-Key is required; retries with the same key return the same result. In test mode, signing links are returned and emails go to the test inbox.
curl -X POST $BASE/envelopes/env_…/send \ -H "Authorization: Bearer $OSK" -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" -d '{}' # with an approval from step 4: -d '{"approval_id":"apr_…"}' - 6
Register a webhook endpoint
Webhooks tell your app when an envelope is signed, declined or expired. The secret (whsec_…) is returned once, in this response: store it with your other secrets. Hosted deployments deliver only to public https URLs; typesign serve on localhost also accepts http://localhost.
curl -X POST $BASE/webhooks \ -H "Authorization: Bearer $OSK" -H "Content-Type: application/json" \ -d '{"url":"https://app.example.com/webhooks/typesign","events":["envelope.completed","envelope.declined","envelope.expired"]}' # → { "id": "whk_…", "secret": "whsec_…", … } - 7
Verify webhooks
Verify the HMAC over the timestamp and raw body before parsing, reject old timestamps, and de-duplicate on webhook-id. Ordering is not guaranteed; fetch the envelope for current state. In TypeScript, verifyWebhook(secret, rawBody, signatureHeader) from @typesign/sdk does these checks; the snippet shows what they are.
// Node/Workers (WebCrypto). Throw before you parse the body. const m = /^t=(\d+),v1=([0-9a-f]+)$/.exec(sigHeader ?? ""); if (!m) throw new Error("bad webhook-signature header"); const t = Number(m[1]); if (Math.abs(Date.now() / 1000 - t) > 300) throw new Error("timestamp outside 5 minutes"); const enc = new TextEncoder(); const sig = Uint8Array.from(m[2].match(/../g) ?? [], (h) => parseInt(h, 16)); const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["verify"]); // crypto.subtle.verify compares in constant time if (!(await crypto.subtle.verify("HMAC", key, sig, enc.encode(`${t}.${rawBody}`)))) throw new Error("bad signature"); - 8
Download the signed PDF and evidence
Artifacts are available after completion through short-lived URLs: signed.pdf, evidence.json (canonical manifest) and evidence.sig.json (Ed25519 platform seal).
curl $BASE/envelopes/env_…/artifacts -H "Authorization: Bearer $OSK"
Seal a self-signed PDF
When a person signs a PDF in your own app, without an envelope, POST /v1/seals seals a record of it: the SHA-256 of the file before and after signing, the page count, the name the person typed and their consent. You get back evidence.json and evidence.sig.json, which the verifier checks like envelope evidence. The document never leaves your app and nothing is stored. The name is self-asserted and the evidence says so. The person must see intent_text and agree; never request a seal on someone's behalf. Needs the seals:write scope; free, 600 per hour per key. The free signer uses this endpoint.
import { TypeSign, selfSignIntentText } from "@typesign/sdk";
const ts = new TypeSign({ apiKey: process.env.OSK!, baseUrl: process.env.BASE }); // key with seals:write
const name = "Test Customer"; // typed by the signer, not verified
const original = "<sha256 of the PDF before signing>";
const signed = "<sha256 of the PDF after you stamped it>";
// Show intent_text to the signer and only continue when they agree.
const intent = selfSignIntentText(name, original, "self-sign-intent/v2");
const seal = await ts.seals.create({
document: { sha256: original, size: 48213, page_count: 2 },
signed_document: { sha256: signed, size: 61877 },
signer: { name, signature_kind: "typed" },
fields: [{ type: "signature", page: 2 }],
consent: true,
intent_version: "self-sign-intent/v2",
intent_text: intent,
client_time: new Date().toISOString(),
});
// Save next to the signed PDF; nothing is kept on the server.
// seal.files["evidence.json"], seal.files["evidence.sig.json"]What this is, and is not
Signatures are simple electronic signatures (SES): the signer controls an email address, sees the locked document and explicitly consents. The platform seal proves the evidence has not been changed relative to the sealing key. It is not a qualified or advanced signature: the key is managed by the operator, not certified by a trust service provider. A sandbox deployment uses an untrusted test key.