DocuBox

Developers

DocuBox API v1

Base URL https://docubox.mpisoft.com/api/v1. JSON in and out, UTF-8. Test keys give you the full API for free; their documents are watermarked and never billed.

Authentication

Every request carries an organization API key. An admin creates keys on the API keys settings page; the full key is shown only once.

Authorization: Bearer dbx_test_…   # test mode: watermarked "TEST", never billed
Authorization: Bearer dbx_live_…   # live mode

A missing, wrong or revoked key, or a key of a suspended organization, gets 401. Every lookup is scoped to the key's organization: another organization's ids answer 404, exactly like ids that do not exist.

export DOCUBOX=https://docubox.mpisoft.com
export KEY=dbx_test_...
curl -s "$DOCUBOX/api/v1/me" -H "Authorization: Bearer $KEY"

Errors

Errors are RFC 9457 application/problem+json. Validation problems (400) list every offending field.

{
  "type": "urn:docubox:problem:validation",
  "title": "Bad Request",
  "status": 400,
  "detail": "The envelope request does not fit the template.",
  "errors": [
    { "field": "recipients[1].role", "message": "must be one of BORROWER, CO_BORROWER" }
  ]
}
StatusWhen
400Malformed JSON, a wrong type, or a request that does not fit the template
401No valid API key
402A live envelope while the organization has no working card (only when the operator requires a card)
404Unknown id, or another organization's
409Void or resend on an envelope that has ended; final document asked for before it is completed
413A JSON body over 1 MB
422The Idempotency-Key was used with a different body
429Too many requests from one client address; wait for Retry-After

Templates

RequestReturns
GET /templatesActive templates with their latest locked version, roles and field keys
GET /templates/{templateId}Versions; roles and fields (field key, type, box) for locked versions

Envelopes

RequestDoes
POST /envelopesCreate and send (Idempotency-Key supported)
GET /envelopesList, newest first: ?status=SENT&limit=50&cursor=…
GET /envelopes/{id}Status, recipients, timestamps, document hashes
GET /envelopes/{id}/eventsThe hash-chained event trail and the server's chain check
GET /envelopes/{id}/documents/finalThe completed PDF with its certificate; 409 until completed
GET /envelopes/{id}/documents/originalThe template PDF the envelope was made from
POST /envelopes/{id}/void{ "reason": "…" }
POST /envelopes/{id}/recipients/{recipientId}/resendA new signing link; earlier links stop working

Envelope statuses: SENT → COMPLETING → COMPLETED, or DECLINED, VOIDED, EXPIRED. Recipient statuses: PENDING → SENT → VIEWED → SIGNED, or DECLINED.

Create an envelope

curl -s -X POST "$DOCUBOX/api/v1/envelopes" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: loan-L-1001-v1" \
  -d '{
    "templateId": "0b6e5d7a-…",
    "subject": "Please sign your loan agreement",
    "deliver": "email",
    "externalReference": "L-1001",
    "callbackUrl": "https://lender.example/hooks/docubox",
    "recipients": [
      { "role": "BORROWER",    "name": "Jane Doe",    "email": "jane@example.com",   "routingOrder": 1 },
      { "role": "CO_BORROWER", "name": "John Doe",    "email": "john@example.com",   "routingOrder": 1 },
      { "role": "LENDER",      "name": "Ann Officer", "email": "ann@lender.example", "routingOrder": 2 }
    ],
    "prefill": { "loan_amount": "25,000.00", "borrower_name": "Jane Doe" },
    "metadata": { "loanId": "L-1001" }
  }'
templateId / templateVersionId
One of them. A template means its newest locked version; an explicit version must be locked. Archived templates are refused.
recipients[]
1 to 20. Every template role bound to exactly one recipient. Equal routingOrder values sign in parallel; a higher order waits for every lower one.
prefill
Keyed by the template's field keys; not for signature or initials fields. Prefilled fields are read-only for the signer unless the template marks them editable.
expiresAt
Optional, at most 90 days away (default 30 days).
deliver
link (default): the response carries each signer's link. email: DocuBox emails each signer when their turn comes and sends reminders.
callbackUrl
Optional public https URL that receives this envelope's webhooks, signed with the callbackSecret returned once in the response.

The answer is 201 Created with the envelope, its originalSha256 and each recipient's status (and signing URL for link delivery). Signing URLs and the callback secret are returned only here and by resend, because DocuBox stores only their hashes. Repeating the same body with the same Idempotency-Key returns the original envelope with Idempotent-Replayed: true.

Events and documents

curl -s "$DOCUBOX/api/v1/envelopes/$ID/events" -H "Authorization: Bearer $KEY"
curl -s -o signed.pdf "$DOCUBOX/api/v1/envelopes/$ID/documents/final" -H "Authorization: Bearer $KEY"
sha256sum signed.pdf   # equals the envelope's finalSha256

Each event's hash is SHA-256(prevHash + canonicalJson(event)), so anyone holding the trail can recompute it. The response includes the server's own chain check. Anyone can check a completed file on the verify page; only its hash is computed.

Webhooks

DocuBox POSTs JSON to the envelope's callbackUrl and to the organization's endpoint, set by an admin in the webhook settings.

EventWhen
envelope.sentThe envelope was created and its first signers asked to sign
recipient.signedA recipient submitted their signature
envelope.completedThe signed PDF is stored; finalDocumentSha256 is its hash
envelope.declined, .voided, .expiredThe envelope ended without completing
POST /hooks/docubox HTTP/1.1
Content-Type: application/json
DocuBox-Event: envelope.completed
DocuBox-Event-Id: 4f0c…
DocuBox-Signature: t=1795262400,v1=5257a869e7ec…

{"id":"4f0c…","type":"envelope.completed","createdAt":"2026-11-21T10:00:00Z",
 "data":{"envelope":{"id":"5d1a…","status":"COMPLETED","finalDocumentSha256":"c0ff…", …}}}
  • The event id stays the same across retries: use it to de-duplicate.
  • Any 2xx within 10 seconds is success. Anything else is retried after 1 min, 5 min, 30 min, 2 h, 6 h and 12 h, then marked failed; deliveries can be resent from the settings page.
  • The PDF is never pushed: fetch it with your API key and compare its SHA-256.

Verifying the signature

DocuBox-Signature is t=<unix seconds>,v1=<hex HMAC-SHA256(secret, t + "." + raw body)>. Compute the HMAC over the raw body, compare in constant time, reject timestamps older than 5 minutes, and accept if any v1 matches (a header may carry two during a secret rotation).

import hashlib, hmac, time

def verify(secret: str, header: str, raw_body: bytes) -> bool:
    parts = [p.split("=", 1) for p in header.split(",") if "=" in p]
    t = next((v for k, v in parts if k.strip() == "t"), None)
    sigs = [v for k, v in parts if k.strip() == "v1"]
    if t is None or abs(time.time() - int(t)) > 300:
        return False
    expected = hmac.new(secret.encode(), t.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    return any(hmac.compare_digest(expected, s) for s in sigs)

Billing

Each envelope completed in live mode is billed once at the price on the pricing page; test envelopes never are. Usage and invoices are on the billing settings page.