{"openapi":"3.1.0","info":{"title":"LegalDock Partner API","version":"1.0.0","summary":"Generate Nordic legal documents from versioned templates and collect signatures.","description":"Partner REST API. Keys are scoped to one partner and one environment: ldk_test_... keys only see test documents, ldk_live_... keys only see live documents. Test documents never send email and are never billed; each partner may create 100 test documents per calendar month. LegalDock provides document templates, not individual legal advice; partners must show that notice to their end users (see the Partner and API Terms).","termsOfService":"https://legaldock.dk/legal/partner-terms","contact":{"name":"LegalDock","url":"https://legaldock.dk/partners"}},"servers":[{"url":"https://legaldock.dk/api/v1","description":"Production (test and live keys)"}],"tags":[{"name":"Templates","description":"Read the published template catalogue."},{"name":"Documents","description":"Create, fill, send, track and download documents."},{"name":"Customers","description":"GDPR export and erasure per end customer."}],"security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"paths":{"/templates":{"get":{"operationId":"listTemplates","tags":["Templates"],"summary":"List templates","description":"All active templates with their current version id.","x-required-scope":"templates:read","security":[{"bearerAuth":["templates:read"]},{"apiKeyHeader":["templates:read"]}],"responses":{"200":{"description":"Template list.","content":{"application/json":{"schema":{"type":"object","required":["templates","count"],"properties":{"templates":{"type":"array","items":{"$ref":"#/components/schemas/TemplateSummary"}},"count":{"type":"integer"}}},"example":{"templates":[{"slug":"consulting-agreement-dk","name":"Konsulentaftale","name_da":"Konsulentaftale","name_en":"Consulting agreement","locale":"da","available_locales":["da","en"],"version":3,"current_version_id":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d"}],"count":1}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/templates/{slug}":{"get":{"operationId":"getTemplate","tags":["Templates"],"summary":"Get a template","description":"One active template with its current version and field definitions.","x-required-scope":"templates:read","security":[{"bearerAuth":["templates:read"]},{"apiKeyHeader":["templates:read"]}],"parameters":[{"name":"slug","in":"path","required":true,"schema":{"type":"string","pattern":"^[a-z0-9-]+$","maxLength":120}}],"responses":{"200":{"description":"Template.","content":{"application/json":{"schema":{"type":"object","required":["template"],"properties":{"template":{"$ref":"#/components/schemas/Template"}}},"example":{"template":{"slug":"consulting-agreement-dk","name":"Konsulentaftale","name_da":"Konsulentaftale","name_en":"Consulting agreement","description_da":"Aftale mellem virksomhed og selvstændig konsulent.","description_en":"Agreement between a company and an independent consultant.","locale":"da","available_locales":["da","en"],"estimated_minutes":10,"signing_enabled":true,"current_version":{"id":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d","version":3,"created_at":"2026-10-01T09:00:00.000Z"},"fields":[{"key":"client_name","type":"text","label_da":"Kundens navn","label_en":"Client name","options":null,"default_value":null,"required":true,"depends_on":null,"min_value":null,"max_value":null,"max_field":null}]}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/documents":{"post":{"operationId":"createDocument","tags":["Documents"],"summary":"Create a document","description":"Creates a draft in the key's environment from the template's current (or pinned) version. delivery_mode and redirect_url are fixed at creation. Supports the Idempotency-Key header; successful responses are stored for 24 hours. Pass data_collection to also get a hosted fill-in link (data_collection.url) for whoever has the information: values you send in data are pre-filled and locked, the rest is collected on a LegalDock page and validated with the same field rules as this API. The link is returned only in this response (an idempotent replay returns url: null; issue a new one with POST /documents/{id}/data-collection). Test keys may create at most 100 test documents per partner per calendar month (UTC, counted at creation, not refunded by deletion); beyond that the call returns 429 TEST_DOCUMENT_LIMIT_REACHED.","x-required-scope":"documents:write","security":[{"bearerAuth":["documents:write"]},{"apiKeyHeader":["documents:write"]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateDocumentRequest"},"example":{"template_slug":"consulting-agreement-dk","locale":"da","title":"Konsulentaftale: Nordlys ApS","data":{"client_name":"Nordlys ApS","consultant_name":"Anna Hansen","start_date":"2026-12-01"},"signers":[{"name":"Anna Hansen","email":"anna@example.dk","role":"Konsulent"},{"name":"Peter Sørensen","email":"peter@nordlys.dk","role":"Kunde"}],"signing_order":"sequential","delivery_mode":"email","external_id":"deal_4821","external_customer_id":"cust_1093","metadata":{"crm_owner":"team-north"}}}}},"responses":{"201":{"description":"Created. Replays carry the header Idempotency-Replayed: true. data_collection is present when requested (url only in the first response).","headers":{"Idempotency-Replayed":{"schema":{"type":"string","enum":["true"]}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentResponse"},"example":{"document":{"id":"7d2c1f8e-3b4a-4c6d-9e1f-2a3b4c5d6e7f","template_id":"4b3a2c1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d","template_slug":"consulting-agreement-dk","template_version":3,"template_version_id":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d","locale":"da","title":"Konsulentaftale: Nordlys ApS","data":{"client_name":"Nordlys ApS","consultant_name":"Anna Hansen","start_date":"2026-12-01"},"status":"draft","signing_order":"sequential","delivery_mode":"email","redirect_url":null,"environment":"test","external_id":"deal_4821","external_customer_id":"cust_1093","metadata":{"crm_owner":"team-north"},"rendered_sha256":null,"expires_at":null,"sent_for_signing_at":null,"completed_at":null,"cancelled_at":null,"personal_data_erased_at":null,"created_at":"2026-11-15T10:00:00.000Z","updated_at":"2026-11-15T10:00:00.000Z"},"template":{"id":"4b3a2c1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d","slug":"consulting-agreement-dk","version":3,"name_da":"Konsulentaftale","name_en":"Consulting agreement","signing_enabled":true},"fields":[{"key":"client_name","type":"text","label_da":"Kundens navn","label_en":"Client name","options":null,"default_value":null,"required":true,"depends_on":null,"min_value":null,"max_value":null,"max_field":null}],"signers":[{"id":"0f9e8d7c-6b5a-4d3c-8b2a-1f0e9d8c7b6a","name":"Anna Hansen","email":"anna@example.dk","role":"Konsulent","sort":0,"status":"pending","signed_at":null,"declined_at":null,"decline_reason":null,"signature_method":null,"signature_typed_name":null,"reminders_sent":0,"last_reminder_at":null,"invited_at":null}],"data_collection":{"id":"3c2b1a0f-9e8d-4c7b-8a6f-5e4d3c2b1a0f","status":"pending","url":"https://legaldock.dk/fill/Vb8x2kQ...","locked_fields":["client_name"],"expires_at":"2026-11-22T10:00:00.000Z","first_opened_at":null,"submitted_at":null,"revoked_at":null,"created_at":"2026-11-15T10:00:00.000Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"422":{"$ref":"#/components/responses/FieldValidation"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}},"get":{"operationId":"listDocuments","tags":["Documents"],"summary":"List documents","description":"Newest-updated first, cursor paginated. Only documents in the key's environment.","x-required-scope":"documents:read","security":[{"bearerAuth":["documents:read"]},{"apiKeyHeader":["documents:read"]}],"parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"cursor","in":"query","schema":{"type":"string","maxLength":500},"description":"next_cursor from the previous page."},{"name":"external_id","in":"query","schema":{"type":"string","maxLength":200},"description":"Exact match filter."}],"responses":{"200":{"description":"One page.","content":{"application/json":{"schema":{"type":"object","required":["items","next_cursor"],"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/DocumentSummary"}},"next_cursor":{"type":["string","null"]}}},"example":{"items":[{"id":"7d2c1f8e-3b4a-4c6d-9e1f-2a3b4c5d6e7f","title":"Konsulentaftale: Nordlys ApS","status":"draft","template_slug":"consulting-agreement-dk","template_id":"4b3a2c1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d","template_version_id":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d","locale":"da","external_id":"deal_4821","external_customer_id":"cust_1093","metadata":{"crm_owner":"team-north"},"environment":"test","signing_order":"sequential","created_at":"2026-11-15T10:00:00.000Z","updated_at":"2026-11-15T10:00:00.000Z","completed_at":null,"sent_for_signing_at":null,"cancelled_at":null}],"next_cursor":null}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/documents/{id}":{"get":{"operationId":"getDocument","tags":["Documents"],"summary":"Get a document","description":"Document, pinned template summary, field definitions, signers and the latest hosted fill-in link state (data_collection, null if none). Signing tokens and fill-in URLs are never returned here.","x-required-scope":"documents:read","security":[{"bearerAuth":["documents:read"]},{"apiKeyHeader":["documents:read"]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Document id (UUID).","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Document.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentResponse"},"example":{"document":{"id":"7d2c1f8e-3b4a-4c6d-9e1f-2a3b4c5d6e7f","template_id":"4b3a2c1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d","template_slug":"consulting-agreement-dk","template_version":3,"template_version_id":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d","locale":"da","title":"Konsulentaftale: Nordlys ApS","data":{"client_name":"Nordlys ApS","consultant_name":"Anna Hansen","start_date":"2026-12-01"},"status":"draft","signing_order":"sequential","delivery_mode":"email","redirect_url":null,"environment":"test","external_id":"deal_4821","external_customer_id":"cust_1093","metadata":{"crm_owner":"team-north"},"rendered_sha256":null,"expires_at":null,"sent_for_signing_at":null,"completed_at":null,"cancelled_at":null,"personal_data_erased_at":null,"created_at":"2026-11-15T10:00:00.000Z","updated_at":"2026-11-15T10:00:00.000Z"},"template":{"id":"4b3a2c1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d","slug":"consulting-agreement-dk","version":3,"name_da":"Konsulentaftale","name_en":"Consulting agreement","signing_enabled":true},"fields":[{"key":"client_name","type":"text","label_da":"Kundens navn","label_en":"Client name","options":null,"default_value":null,"required":true,"depends_on":null,"min_value":null,"max_value":null,"max_field":null}],"signers":[{"id":"0f9e8d7c-6b5a-4d3c-8b2a-1f0e9d8c7b6a","name":"Anna Hansen","email":"anna@example.dk","role":"Konsulent","sort":0,"status":"pending","signed_at":null,"declined_at":null,"decline_reason":null,"signature_method":null,"signature_typed_name":null,"reminders_sent":0,"last_reminder_at":null,"invited_at":null}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}},"patch":{"operationId":"updateDocument","tags":["Documents"],"summary":"Update a draft","description":"Partial update while the document is a draft. data is merged into existing values and validated against the template. Sending signers replaces the whole signer list. While a hosted fill-in link is pending, data cannot be changed (409 DATA_COLLECTION_PENDING); other fields can.","x-required-scope":"documents:write","security":[{"bearerAuth":["documents:write"]},{"apiKeyHeader":["documents:write"]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Document id (UUID).","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateDocumentRequest"},"example":{"data":{"start_date":"2027-01-01"},"metadata":{"crm_owner":"team-south"}}}}},"responses":{"200":{"description":"Updated document.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentResponse"},"example":{"document":{"id":"7d2c1f8e-3b4a-4c6d-9e1f-2a3b4c5d6e7f","template_id":"4b3a2c1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d","template_slug":"consulting-agreement-dk","template_version":3,"template_version_id":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d","locale":"da","title":"Konsulentaftale: Nordlys ApS","data":{"client_name":"Nordlys ApS","consultant_name":"Anna Hansen","start_date":"2026-12-01"},"status":"draft","signing_order":"sequential","delivery_mode":"email","redirect_url":null,"environment":"test","external_id":"deal_4821","external_customer_id":"cust_1093","metadata":{"crm_owner":"team-north"},"rendered_sha256":null,"expires_at":null,"sent_for_signing_at":null,"completed_at":null,"cancelled_at":null,"personal_data_erased_at":null,"created_at":"2026-11-15T10:00:00.000Z","updated_at":"2026-11-15T10:00:00.000Z"},"template":{"id":"4b3a2c1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d","slug":"consulting-agreement-dk","version":3,"name_da":"Konsulentaftale","name_en":"Consulting agreement","signing_enabled":true},"fields":[{"key":"client_name","type":"text","label_da":"Kundens navn","label_en":"Client name","options":null,"default_value":null,"required":true,"depends_on":null,"min_value":null,"max_value":null,"max_field":null}],"signers":[{"id":"0f9e8d7c-6b5a-4d3c-8b2a-1f0e9d8c7b6a","name":"Anna Hansen","email":"anna@example.dk","role":"Konsulent","sort":0,"status":"pending","signed_at":null,"declined_at":null,"decline_reason":null,"signature_method":null,"signature_typed_name":null,"reminders_sent":0,"last_reminder_at":null,"invited_at":null}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"413":{"$ref":"#/components/responses/PayloadTooLarge"},"422":{"$ref":"#/components/responses/FieldValidation"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/documents/{id}/send":{"post":{"operationId":"sendDocument","tags":["Documents"],"summary":"Send for signing","description":"Validates required fields, seals the document text (SHA-256) and issues fresh per-signer links valid for 14 days. Email mode emails signers in live; embedded mode and every test-environment document send no email and return signing_links instead. signing_links are only returned in this response, store them securely. Live sends are prepaid: each document uses one credit from the partner's balance (one per document, never charged twice); with no credit left the call returns 402 INSUFFICIENT_CREDITS and nothing is sent. While a hosted fill-in link is pending the call returns 409 DATA_COLLECTION_PENDING; submitting the form never sends the document by itself.","x-required-scope":"documents:write","security":[{"bearerAuth":["documents:write"]},{"apiKeyHeader":["documents:write"]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Document id (UUID).","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SendResponse"},"example":{"status":"pending_signatures","ok":true,"emailed":0,"failed":[],"failures":[],"sandbox":true,"email_suppressed":true,"signing_links":[{"signer_id":"0f9e8d7c-6b5a-4d3c-8b2a-1f0e9d8c7b6a","name":"Anna Hansen","email":"anna@example.dk","signing_url":"https://legaldock.dk/sign/3q2-7xKp..."}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"422":{"$ref":"#/components/responses/FieldValidation"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/documents/{id}/data-collection":{"post":{"operationId":"requestDocumentData","tags":["Documents"],"summary":"Issue a hosted fill-in link","description":"Issues a new single-use link to a LegalDock-hosted form built from the document's template fields, for a draft that has not been signed. Any earlier pending link for the document stops working immediately. Fields you locked when creating the document stay locked. Default expiry 7 days (1-30). The url is returned only in this response; LegalDock stores only a hash of it. On submission the values are validated with the same rules as PATCH and send (all visible required fields must be filled), saved to the document, and document.data_submitted is emitted. The document stays a draft: call /send yourself (this is when embedded signing links are returned and the credit is used). Test-environment links show a TEST banner.","x-required-scope":"documents:write","security":[{"bearerAuth":["documents:write"]},{"apiKeyHeader":["documents:write"]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Document id (UUID).","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"expires_in_days":{"type":"integer","minimum":1,"maximum":30,"default":7}}},"example":{"expires_in_days":7}}}},"responses":{"201":{"description":"Link issued.","content":{"application/json":{"schema":{"type":"object","required":["data_collection"],"properties":{"data_collection":{"$ref":"#/components/schemas/DataCollection"}}},"example":{"data_collection":{"id":"3c2b1a0f-9e8d-4c7b-8a6f-5e4d3c2b1a0f","status":"pending","url":"https://legaldock.dk/fill/Vb8x2kQ...","locked_fields":["client_name"],"expires_at":"2026-11-22T10:00:00.000Z","first_opened_at":null,"submitted_at":null,"revoked_at":null,"created_at":"2026-11-15T10:00:00.000Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}},"delete":{"operationId":"revokeDocumentData","tags":["Documents"],"summary":"Revoke the hosted fill-in link","description":"Revokes a pending fill-in link so you can supply data through PATCH instead. Idempotent; returns the latest link state (null if none was ever issued). Cancelling the document also revokes it.","x-required-scope":"documents:write","security":[{"bearerAuth":["documents:write"]},{"apiKeyHeader":["documents:write"]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Document id (UUID).","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Latest link state.","content":{"application/json":{"schema":{"type":"object","required":["data_collection"],"properties":{"data_collection":{"oneOf":[{"$ref":"#/components/schemas/DataCollection"},{"type":"null"}]}}},"example":{"data_collection":{"id":"3c2b1a0f-9e8d-4c7b-8a6f-5e4d3c2b1a0f","status":"revoked","url":null,"locked_fields":["client_name"],"expires_at":"2026-11-22T10:00:00.000Z","first_opened_at":null,"submitted_at":null,"revoked_at":"2026-11-15T11:00:00.000Z","created_at":"2026-11-15T10:00:00.000Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/documents/{id}/cancel":{"post":{"operationId":"cancelDocument","tags":["Documents"],"summary":"Cancel a document","description":"Cancels any document that is not completed and revokes a pending hosted fill-in link. Idempotent for already-cancelled documents.","x-required-scope":"documents:write","security":[{"bearerAuth":["documents:write"]},{"apiKeyHeader":["documents:write"]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Document id (UUID).","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Cancelled.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"const":"cancelled"}}},"example":{"status":"cancelled"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/documents/{id}/signers/{signerId}/remind":{"post":{"operationId":"remindSigner","tags":["Documents"],"summary":"Remind a signer","description":"Emails a fresh signing link to a pending signer (the old link stops working). Not available in embedded mode. In the test environment no email is sent, the existing link stays valid, and the response has sandbox: true.","x-required-scope":"documents:write","security":[{"bearerAuth":["documents:write"]},{"apiKeyHeader":["documents:write"]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Document id (UUID).","schema":{"type":"string","format":"uuid"}},{"name":"signerId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Reminder sent (or suppressed in test).","content":{"application/json":{"schema":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean"},"sandbox":{"type":"boolean"},"email_suppressed":{"type":"boolean"}}},"example":{"ok":true}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/documents/{id}/audit":{"get":{"operationId":"getAuditTrail","tags":["Documents"],"summary":"Audit trail","description":"Hash-chained audit events, oldest first. Each event's hash covers its content and the previous hash. Events with redacted_at were redacted on an erasure request: their hashes are kept so the chain linkage still verifies, but their content can no longer be re-hashed.","x-required-scope":"documents:read","security":[{"bearerAuth":["documents:read"]},{"apiKeyHeader":["documents:read"]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Document id (UUID).","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Events.","content":{"application/json":{"schema":{"type":"object","required":["events"],"properties":{"events":{"type":"array","items":{"$ref":"#/components/schemas/AuditEvent"}}}},"example":{"events":[{"id":"5e4d3c2b-1a0f-4e9d-8c7b-6a5f4e3d2c1b","document_id":"7d2c1f8e-3b4a-4c6d-9e1f-2a3b4c5d6e7f","event_type":"document.created","actor_type":"partner","actor_user_id":null,"partner_id":"1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d","api_key_id":"2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e","actor_email":null,"actor_name":null,"ip_address":"203.0.113.7","user_agent":"acme-crm/2.1","data":null,"prev_hash":"","hash":"b1946ac92492d2347c6235b4d2611184...","created_at":"2026-11-15T10:00:00.000Z","redacted_at":null}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/documents/{id}/pdf":{"get":{"operationId":"getDocumentPdf","tags":["Documents"],"summary":"Download signed PDF","description":"Available only for completed documents. Returns application/pdf.","x-required-scope":"documents:read","security":[{"bearerAuth":["documents:read"]},{"apiKeyHeader":["documents:read"]}],"parameters":[{"name":"id","in":"path","required":true,"description":"Document id (UUID).","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"PDF file.","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"410":{"$ref":"#/components/responses/Gone"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/customers/{customerId}/export":{"get":{"operationId":"exportCustomer","tags":["Customers"],"summary":"Export a customer's data","description":"Every document (including data and rendered text), signer and audit event with this external_customer_id in the key's environment, oldest first, cursor paginated. Use it to answer access and portability requests. Already-erased documents no longer carry the customer id and are not included.","x-required-scope":"customers:manage","security":[{"bearerAuth":["customers:manage"]},{"apiKeyHeader":["customers:manage"]}],"parameters":[{"name":"customerId","in":"path","required":true,"description":"Your external_customer_id, URL-encoded (1-200 characters).","schema":{"type":"string","minLength":1,"maxLength":200}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":25}},{"name":"cursor","in":"query","schema":{"type":"string","maxLength":500}}],"responses":{"200":{"description":"One page of the export.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerExport"},"example":{"format_version":"2026-11-15","exported_at":"2026-11-15T12:00:00.000Z","environment":"live","external_customer_id":"cust_1093","documents":[{"id":"7d2c1f8e-3b4a-4c6d-9e1f-2a3b4c5d6e7f","template_id":"4b3a2c1d-0e9f-4a8b-9c7d-6e5f4a3b2c1d","template_slug":"consulting-agreement-dk","template_version":3,"template_version_id":"9a8b7c6d-5e4f-4a3b-8c2d-1e0f9a8b7c6d","locale":"da","title":"Konsulentaftale: Nordlys ApS","data":{"client_name":"Nordlys ApS","consultant_name":"Anna Hansen","start_date":"2026-12-01"},"status":"draft","signing_order":"sequential","delivery_mode":"email","redirect_url":null,"environment":"live","external_id":"deal_4821","external_customer_id":"cust_1093","metadata":{"crm_owner":"team-north"},"rendered_sha256":null,"expires_at":null,"sent_for_signing_at":null,"completed_at":null,"cancelled_at":null,"personal_data_erased_at":null,"created_at":"2026-11-15T10:00:00.000Z","updated_at":"2026-11-15T10:00:00.000Z","rendered_html":null,"signers":[{"id":"0f9e8d7c-6b5a-4d3c-8b2a-1f0e9d8c7b6a","name":"Anna Hansen","email":"anna@example.dk","role":"Konsulent","sort":0,"status":"pending","signed_at":null,"declined_at":null,"decline_reason":null,"signature_method":null,"signature_typed_name":null,"reminders_sent":0,"last_reminder_at":null,"invited_at":null}],"audit_events":[]}],"next_cursor":null}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/customers/{customerId}":{"delete":{"operationId":"eraseCustomer","tags":["Customers"],"summary":"Erase a customer's data","description":"Processes up to 100 matching documents per call in the key's environment; call again while has_more is true. Per document: draft, cancelled or expired documents that were never sent or finalised are deleted outright; completed documents, and documents that were sent and later cancelled or expired, are redacted (names, emails, IP addresses, user agents, signatures, form data, metadata, title, rendered text and the customer id are removed; status, timestamps, template version, the SHA-256 fingerprint and audit hashes remain); documents awaiting signatures are skipped (cancel them first). Export before erasing if you must retain a copy.","x-required-scope":"customers:manage","security":[{"bearerAuth":["customers:manage"]},{"apiKeyHeader":["customers:manage"]}],"parameters":[{"name":"customerId","in":"path","required":true,"description":"Your external_customer_id, URL-encoded (1-200 characters).","schema":{"type":"string","minLength":1,"maxLength":200}}],"responses":{"200":{"description":"Erasure report.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErasureReport"},"example":{"environment":"live","summary":{"deleted":1,"redacted":1,"already_erased":0,"skipped_in_progress":1,"not_found":0},"documents":[{"document_id":"7d2c1f8e-3b4a-4c6d-9e1f-2a3b4c5d6e7f","external_id":"deal_4821","previous_status":"draft","outcome":"deleted"},{"document_id":"8e7d6c5b-4a3f-4e2d-9c1b-0a9f8e7d6c5b","external_id":"deal_4790","previous_status":"completed","outcome":"redacted"},{"document_id":"9f8e7d6c-5b4a-4f3e-8d2c-1b0a9f8e7d6c","external_id":"deal_4833","previous_status":"pending_signatures","outcome":"skipped_in_progress"}],"has_more":false}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"}}}}},"webhooks":{"document.created":{"post":{"summary":"document.created","description":"Sent to your active endpoints subscribed to this event, for partner-owned documents only. Verify LegalDock-Signature before trusting the body.","parameters":[{"name":"LegalDock-Event","in":"header","required":true,"schema":{"type":"string","const":"document.created"}},{"name":"LegalDock-Delivery","in":"header","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"LegalDock-Signature","in":"header","required":true,"schema":{"type":"string"},"example":"t=1763200000,v1=5257a869e7ec..."},{"name":"LegalDock-Environment","in":"header","required":true,"schema":{"type":"string","enum":["test","live"]},"description":"Convenience copy of the signed environment field."}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Acknowledged. Any other status (or no answer within 10 s) is retried."}}}},"document.sent":{"post":{"summary":"document.sent","description":"Sent to your active endpoints subscribed to this event, for partner-owned documents only. Verify LegalDock-Signature before trusting the body.","parameters":[{"name":"LegalDock-Event","in":"header","required":true,"schema":{"type":"string","const":"document.sent"}},{"name":"LegalDock-Delivery","in":"header","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"LegalDock-Signature","in":"header","required":true,"schema":{"type":"string"},"example":"t=1763200000,v1=5257a869e7ec..."},{"name":"LegalDock-Environment","in":"header","required":true,"schema":{"type":"string","enum":["test","live"]},"description":"Convenience copy of the signed environment field."}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Acknowledged. Any other status (or no answer within 10 s) is retried."}}}},"signer.viewed":{"post":{"summary":"signer.viewed","description":"Sent to your active endpoints subscribed to this event, for partner-owned documents only. Verify LegalDock-Signature before trusting the body.","parameters":[{"name":"LegalDock-Event","in":"header","required":true,"schema":{"type":"string","const":"signer.viewed"}},{"name":"LegalDock-Delivery","in":"header","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"LegalDock-Signature","in":"header","required":true,"schema":{"type":"string"},"example":"t=1763200000,v1=5257a869e7ec..."},{"name":"LegalDock-Environment","in":"header","required":true,"schema":{"type":"string","enum":["test","live"]},"description":"Convenience copy of the signed environment field."}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Acknowledged. Any other status (or no answer within 10 s) is retried."}}}},"signer.signed":{"post":{"summary":"signer.signed","description":"Sent to your active endpoints subscribed to this event, for partner-owned documents only. Verify LegalDock-Signature before trusting the body.","parameters":[{"name":"LegalDock-Event","in":"header","required":true,"schema":{"type":"string","const":"signer.signed"}},{"name":"LegalDock-Delivery","in":"header","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"LegalDock-Signature","in":"header","required":true,"schema":{"type":"string"},"example":"t=1763200000,v1=5257a869e7ec..."},{"name":"LegalDock-Environment","in":"header","required":true,"schema":{"type":"string","enum":["test","live"]},"description":"Convenience copy of the signed environment field."}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Acknowledged. Any other status (or no answer within 10 s) is retried."}}}},"signer.declined":{"post":{"summary":"signer.declined","description":"Sent to your active endpoints subscribed to this event, for partner-owned documents only. Verify LegalDock-Signature before trusting the body.","parameters":[{"name":"LegalDock-Event","in":"header","required":true,"schema":{"type":"string","const":"signer.declined"}},{"name":"LegalDock-Delivery","in":"header","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"LegalDock-Signature","in":"header","required":true,"schema":{"type":"string"},"example":"t=1763200000,v1=5257a869e7ec..."},{"name":"LegalDock-Environment","in":"header","required":true,"schema":{"type":"string","enum":["test","live"]},"description":"Convenience copy of the signed environment field."}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Acknowledged. Any other status (or no answer within 10 s) is retried."}}}},"document.completed":{"post":{"summary":"document.completed","description":"Sent to your active endpoints subscribed to this event, for partner-owned documents only. Verify LegalDock-Signature before trusting the body.","parameters":[{"name":"LegalDock-Event","in":"header","required":true,"schema":{"type":"string","const":"document.completed"}},{"name":"LegalDock-Delivery","in":"header","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"LegalDock-Signature","in":"header","required":true,"schema":{"type":"string"},"example":"t=1763200000,v1=5257a869e7ec..."},{"name":"LegalDock-Environment","in":"header","required":true,"schema":{"type":"string","enum":["test","live"]},"description":"Convenience copy of the signed environment field."}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Acknowledged. Any other status (or no answer within 10 s) is retried."}}}},"document.expired":{"post":{"summary":"document.expired","description":"Sent to your active endpoints subscribed to this event, for partner-owned documents only. Verify LegalDock-Signature before trusting the body.","parameters":[{"name":"LegalDock-Event","in":"header","required":true,"schema":{"type":"string","const":"document.expired"}},{"name":"LegalDock-Delivery","in":"header","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"LegalDock-Signature","in":"header","required":true,"schema":{"type":"string"},"example":"t=1763200000,v1=5257a869e7ec..."},{"name":"LegalDock-Environment","in":"header","required":true,"schema":{"type":"string","enum":["test","live"]},"description":"Convenience copy of the signed environment field."}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Acknowledged. Any other status (or no answer within 10 s) is retried."}}}},"document.cancelled":{"post":{"summary":"document.cancelled","description":"Sent to your active endpoints subscribed to this event, for partner-owned documents only. Verify LegalDock-Signature before trusting the body.","parameters":[{"name":"LegalDock-Event","in":"header","required":true,"schema":{"type":"string","const":"document.cancelled"}},{"name":"LegalDock-Delivery","in":"header","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"LegalDock-Signature","in":"header","required":true,"schema":{"type":"string"},"example":"t=1763200000,v1=5257a869e7ec..."},{"name":"LegalDock-Environment","in":"header","required":true,"schema":{"type":"string","enum":["test","live"]},"description":"Convenience copy of the signed environment field."}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Acknowledged. Any other status (or no answer within 10 s) is retried."}}}},"document.data_submitted":{"post":{"summary":"document.data_submitted","description":"Sent to your active endpoints subscribed to this event, for partner-owned documents only. Verify LegalDock-Signature before trusting the body.","parameters":[{"name":"LegalDock-Event","in":"header","required":true,"schema":{"type":"string","const":"document.data_submitted"}},{"name":"LegalDock-Delivery","in":"header","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"LegalDock-Signature","in":"header","required":true,"schema":{"type":"string"},"example":"t=1763200000,v1=5257a869e7ec..."},{"name":"LegalDock-Environment","in":"header","required":true,"schema":{"type":"string","enum":["test","live"]},"description":"Convenience copy of the signed environment field."}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"2XX":{"description":"Acknowledged. Any other status (or no answer within 10 s) is retried."}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Authorization: Bearer ldk_test_... or ldk_live_... The key's prefix must match its environment."},"apiKeyHeader":{"type":"apiKey","in":"header","name":"x-api-key","description":"Alternative to the Bearer header."}},"parameters":{"IdempotencyKey":{"name":"Idempotency-Key","in":"header","required":false,"description":"1-128 characters of A-Z a-z 0-9 . _ : - . Retrying with the same key and same body within 24 hours replays the first successful response. A different body returns 409 IDEMPOTENCY_KEY_REUSED; a concurrent duplicate returns 409 IDEMPOTENCY_IN_PROGRESS. Failed requests are not stored.","schema":{"type":"string","pattern":"^[A-Za-z0-9._:-]{1,128}$"}}},"responses":{"BadRequest":{"description":"Malformed request (INVALID_JSON, VALIDATION_ERROR, INVALID_CURSOR, INVALID_IDEMPOTENCY_KEY).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"VALIDATION_ERROR","message":"Request validation failed"},"reference":"k3J9xQ2a"}}}},"Unauthorized":{"description":"Missing or invalid key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"UNAUTHORIZED","message":"Invalid or missing API key"},"reference":"k3J9xQ2a"}}}},"Forbidden":{"description":"Scope missing or partner not active.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"FORBIDDEN","message":"API key lacks the required scope"},"reference":"k3J9xQ2a"}}}},"PaymentRequired":{"description":"No prepaid document credits left.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"INSUFFICIENT_CREDITS","message":"No document credits left for this environment."},"reference":"k3J9xQ2a"}}}},"NotFound":{"description":"Not found in this partner + environment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"DOCUMENT_NOT_FOUND","message":"Document not found"},"reference":"k3J9xQ2a"}}}},"Conflict":{"description":"State or idempotency conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"INVALID_DOCUMENT_STATE","message":"Operation is not allowed in the document's current state"},"reference":"k3J9xQ2a"}}}},"Gone":{"description":"Personal data erased.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"PERSONAL_DATA_ERASED","message":"Personal data for this document was erased on request"},"reference":"k3J9xQ2a"}}}},"PayloadTooLarge":{"description":"Body over 100 KB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"PAYLOAD_TOO_LARGE","message":"Request body is too large"},"reference":"k3J9xQ2a"}}}},"FieldValidation":{"description":"Template field rules violated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"FIELD_VALIDATION","message":"Field \"Fee\" must be at most 100000"},"reference":"k3J9xQ2a"}}}},"RateLimited":{"description":"Rate limit exceeded (RATE_LIMITED), or, for POST /documents with a test key, the monthly allowance of 100 test documents is used up (TEST_DOCUMENT_LIMIT_REACHED).","headers":{"Retry-After":{"description":"Seconds to wait.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"RATE_LIMITED","message":"Too many requests"},"reference":"k3J9xQ2a"}}}},"InternalError":{"description":"Unexpected error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":{"code":"INTERNAL_ERROR","message":"Request failed"},"reference":"k3J9xQ2a"}}}}},"schemas":{"Error":{"type":"object","required":["error","reference"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","enum":["INVALID_JSON","VALIDATION_ERROR","INVALID_CURSOR","INVALID_IDEMPOTENCY_KEY","UNAUTHORIZED","FORBIDDEN","INSUFFICIENT_CREDITS","DOCUMENT_NOT_FOUND","TEMPLATE_NOT_FOUND","DOCUMENT_NOT_DRAFT","INVALID_DOCUMENT_STATE","DATA_COLLECTION_PENDING","PDF_NOT_READY","IDEMPOTENCY_KEY_REUSED","IDEMPOTENCY_IN_PROGRESS","PERSONAL_DATA_ERASED","PAYLOAD_TOO_LARGE","FIELD_VALIDATION","RATE_LIMITED","TEST_DOCUMENT_LIMIT_REACHED","INTERNAL_ERROR"]},"message":{"type":"string","description":"Human-readable, safe to log. Never contains internal details."}}},"reference":{"type":"string","description":"Opaque id for support requests."}}},"TemplateSummary":{"type":"object","properties":{"slug":{"type":"string"},"name":{"type":"string"},"name_da":{"type":"string"},"name_en":{"type":["string","null"]},"locale":{"type":"string"},"available_locales":{"type":"array","items":{"type":"string","enum":["da","en"]}},"version":{"type":"integer"},"current_version_id":{"type":["string","null"],"format":"uuid"}}},"Field":{"type":"object","properties":{"key":{"type":"string"},"type":{"type":"string","enum":["text","long_text","date","number","select","checkbox","email"]},"label_da":{"type":"string"},"label_en":{"type":["string","null"]},"options":{},"default_value":{"type":["string","null"]},"required":{"type":"boolean"},"depends_on":{"type":["string","null"]},"min_value":{"type":["number","null"]},"max_value":{"type":["number","null"]},"max_field":{"type":["string","null"]}}},"Template":{"allOf":[{"$ref":"#/components/schemas/TemplateSummary"},{"type":"object","properties":{"description_da":{"type":["string","null"]},"description_en":{"type":["string","null"]},"estimated_minutes":{"type":"integer"},"signing_enabled":{"type":"boolean"},"current_version":{"type":"object","properties":{"id":{"type":["string","null"]},"version":{"type":"integer"},"created_at":{"type":["string","null"]}}},"fields":{"type":"array","items":{"$ref":"#/components/schemas/Field"}}}}]},"SignerInput":{"type":"object","required":["name","email"],"additionalProperties":false,"properties":{"name":{"type":"string","minLength":1,"maxLength":200},"email":{"type":"string","format":"email","maxLength":254},"role":{"type":["string","null"],"maxLength":100}}},"CreateDocumentRequest":{"type":"object","required":["template_slug","title"],"additionalProperties":false,"properties":{"template_slug":{"type":"string","pattern":"^[a-z0-9-]+$","maxLength":120},"template_version_id":{"type":"string","format":"uuid","description":"Pin an earlier version; defaults to current."},"locale":{"type":"string","enum":["da","en"],"default":"da"},"title":{"type":"string","minLength":1,"maxLength":200},"data":{"type":"object","additionalProperties":true,"description":"Field values keyed by field key."},"signers":{"type":"array","minItems":1,"maxItems":20,"items":{"$ref":"#/components/schemas/SignerInput"}},"signing_order":{"type":"string","enum":["sequential","parallel"],"default":"sequential"},"delivery_mode":{"type":"string","enum":["email","embedded"],"default":"email","description":"Immutable after creation."},"redirect_url":{"type":["string","null"],"format":"uri","maxLength":2048,"description":"Clean absolute https:// URL the signer's browser is sent to after signing or declining. Immutable."},"external_id":{"type":["string","null"],"minLength":1,"maxLength":200},"external_customer_id":{"type":["string","null"],"minLength":1,"maxLength":200,"description":"Your end-customer reference, used by the Customers endpoints."},"metadata":{"type":"object","additionalProperties":true,"description":"Up to 16 KB of JSON."},"data_collection":{"type":"object","additionalProperties":false,"description":"Request a hosted fill-in link. data may be omitted or partial; keys you send in data are locked for the person filling in.","properties":{"expires_in_days":{"type":"integer","minimum":1,"maximum":30,"default":7}}}}},"DataCollection":{"type":"object","description":"Hosted fill-in link state. A document has at most one pending link.","required":["id","status","url","locked_fields","expires_at","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["pending","submitted","revoked","expired"]},"url":{"type":["string","null"],"format":"uri","description":"Single-use https://legaldock.dk/fill/... link. Only present in the response that issued it; null everywhere else."},"locked_fields":{"type":"array","items":{"type":"string"},"description":"Field keys shown read-only and never overwritten by the submission."},"expires_at":{"type":"string","format":"date-time"},"first_opened_at":{"type":["string","null"],"format":"date-time"},"submitted_at":{"type":["string","null"],"format":"date-time"},"revoked_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}},"UpdateDocumentRequest":{"type":"object","additionalProperties":false,"minProperties":1,"properties":{"title":{"type":"string","minLength":1,"maxLength":200},"data":{"type":"object","additionalProperties":true},"signers":{"type":"array","minItems":1,"maxItems":20,"items":{"$ref":"#/components/schemas/SignerInput"}},"signing_order":{"type":"string","enum":["sequential","parallel"]},"external_id":{"type":["string","null"],"maxLength":200},"external_customer_id":{"type":["string","null"],"maxLength":200},"metadata":{"type":"object","additionalProperties":true}}},"DocumentStatus":{"type":"string","enum":["draft","pending_signatures","partially_signed","completed","expired","cancelled"]},"Document":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"template_id":{"type":"string","format":"uuid"},"template_slug":{"type":"string"},"template_version":{"type":"integer"},"template_version_id":{"type":["string","null"],"format":"uuid"},"locale":{"type":"string","enum":["da","en"]},"title":{"type":"string"},"data":{"type":"object"},"status":{"$ref":"#/components/schemas/DocumentStatus"},"signing_order":{"type":"string","enum":["sequential","parallel"]},"delivery_mode":{"type":"string","enum":["email","embedded"]},"redirect_url":{"type":["string","null"]},"environment":{"type":"string","enum":["test","live"]},"external_id":{"type":["string","null"]},"external_customer_id":{"type":["string","null"]},"metadata":{"type":"object"},"rendered_sha256":{"type":["string","null"],"description":"SHA-256 fingerprint of the sealed text."},"expires_at":{"type":["string","null"],"format":"date-time"},"sent_for_signing_at":{"type":["string","null"],"format":"date-time"},"completed_at":{"type":["string","null"],"format":"date-time"},"cancelled_at":{"type":["string","null"],"format":"date-time"},"personal_data_erased_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"DocumentSummary":{"type":"object","description":"Subset of Document returned by the list endpoint.","properties":{"id":{"type":"string"},"title":{"type":"string"},"status":{"$ref":"#/components/schemas/DocumentStatus"},"template_slug":{"type":"string"},"template_id":{"type":"string"},"template_version_id":{"type":["string","null"]},"locale":{"type":"string"},"external_id":{"type":["string","null"]},"external_customer_id":{"type":["string","null"]},"metadata":{"type":"object"},"environment":{"type":"string"},"signing_order":{"type":"string"},"created_at":{"type":"string"},"updated_at":{"type":"string"},"completed_at":{"type":["string","null"]},"sent_for_signing_at":{"type":["string","null"]},"cancelled_at":{"type":["string","null"]}}},"Signer":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"email":{"type":"string"},"role":{"type":["string","null"]},"sort":{"type":"integer"},"status":{"type":"string","enum":["pending","signed","declined"]},"signed_at":{"type":["string","null"]},"declined_at":{"type":["string","null"]},"decline_reason":{"type":["string","null"]},"signature_method":{"type":["string","null"]},"signature_typed_name":{"type":["string","null"]},"reminders_sent":{"type":"integer"},"last_reminder_at":{"type":["string","null"]},"invited_at":{"type":["string","null"]}}},"DocumentResponse":{"type":"object","required":["document","fields","signers"],"properties":{"document":{"$ref":"#/components/schemas/Document"},"template":{"type":["object","null"],"properties":{"id":{"type":"string"},"slug":{"type":"string"},"version":{"type":"integer"},"name_da":{"type":"string"},"name_en":{"type":["string","null"]},"signing_enabled":{"type":"boolean"}}},"fields":{"type":"array","items":{"$ref":"#/components/schemas/Field"}},"signers":{"type":"array","items":{"$ref":"#/components/schemas/Signer"}},"data_collection":{"oneOf":[{"$ref":"#/components/schemas/DataCollection"},{"type":"null"}],"description":"Latest hosted fill-in link, or null if none was issued."}}},"SendResponse":{"type":"object","required":["status","ok","emailed","failed","failures"],"properties":{"status":{"const":"pending_signatures"},"ok":{"type":"boolean"},"emailed":{"type":"integer","description":"Signers emailed. Always 0 in embedded mode and in test."},"failed":{"type":"array","items":{"type":"string"}},"failures":{"type":"array","items":{"type":"object","properties":{"email":{"type":"string"},"reason":{"type":"string"}}}},"sandbox":{"type":"boolean","description":"Present and true for test-environment documents."},"email_suppressed":{"type":"boolean","description":"True when an email-mode test document skipped sending."},"signing_links":{"type":"array","description":"Embedded mode and test environment only. Returned once; tokens are not retrievable later.","items":{"type":"object","properties":{"signer_id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"signing_url":{"type":"string","format":"uri"}}}}}},"AuditEvent":{"type":"object","properties":{"id":{"type":"string"},"document_id":{"type":["string","null"]},"event_type":{"type":"string"},"actor_type":{"type":["string","null"],"enum":["user","partner",null]},"actor_user_id":{"type":["string","null"]},"partner_id":{"type":["string","null"]},"api_key_id":{"type":["string","null"]},"actor_email":{"type":["string","null"]},"actor_name":{"type":["string","null"]},"ip_address":{"type":["string","null"]},"user_agent":{"type":["string","null"]},"data":{},"prev_hash":{"type":"string"},"hash":{"type":"string"},"created_at":{"type":"string"},"redacted_at":{"type":["string","null"],"description":"Set when personal fields were erased on request."}}},"CustomerExport":{"type":"object","properties":{"format_version":{"type":"string"},"exported_at":{"type":"string","format":"date-time"},"environment":{"type":"string","enum":["test","live"]},"external_customer_id":{"type":"string"},"documents":{"type":"array","items":{"allOf":[{"$ref":"#/components/schemas/Document"},{"type":"object","properties":{"rendered_html":{"type":["string","null"],"description":"Sealed document text."},"signers":{"type":"array","items":{"allOf":[{"$ref":"#/components/schemas/Signer"},{"type":"object","properties":{"ip_address":{"type":["string","null"]},"user_agent":{"type":["string","null"]},"signature_image":{"type":["string","null"]},"first_viewed_at":{"type":["string","null"]},"last_viewed_at":{"type":["string","null"]}}}]}},"audit_events":{"type":"array","items":{"$ref":"#/components/schemas/AuditEvent"}}}}]}},"next_cursor":{"type":["string","null"]}}},"ErasureReport":{"type":"object","properties":{"environment":{"type":"string","enum":["test","live"]},"summary":{"type":"object","properties":{"deleted":{"type":"integer"},"redacted":{"type":"integer"},"already_erased":{"type":"integer"},"skipped_in_progress":{"type":"integer"},"not_found":{"type":"integer"}}},"documents":{"type":"array","items":{"type":"object","properties":{"document_id":{"type":"string"},"external_id":{"type":["string","null"]},"previous_status":{"$ref":"#/components/schemas/DocumentStatus"},"outcome":{"type":"string","enum":["deleted","redacted","already_erased","skipped_in_progress","not_found"]}}}},"has_more":{"type":"boolean"}}},"WebhookEvent":{"type":"object","required":["id","type","created_at","environment","livemode","data"],"properties":{"id":{"type":"string","format":"uuid","description":"Event id; identical across retries and redeliveries."},"type":{"type":"string","enum":["document.created","document.sent","signer.viewed","signer.signed","signer.declined","document.completed","document.expired","document.cancelled","document.data_submitted"]},"created_at":{"type":"string","format":"date-time"},"environment":{"type":"string","enum":["test","live"],"description":"Branch on this. Covered by the signature."},"livemode":{"type":"boolean"},"data":{"type":"object","properties":{"document":{"type":"object","properties":{"id":{"type":"string"},"external_id":{"type":["string","null"]},"external_customer_id":{"type":["string","null"]},"template_slug":{"type":"string"},"template_version":{"type":"integer"},"title":{"type":"string"},"locale":{"type":"string"},"status":{"$ref":"#/components/schemas/DocumentStatus"},"expires_at":{"type":["string","null"]},"completed_at":{"type":["string","null"]},"cancelled_at":{"type":["string","null"]},"sent_for_signing_at":{"type":["string","null"]},"created_at":{"type":"string"},"updated_at":{"type":"string"}}},"signer":{"type":"object","description":"Present on signer.* events.","properties":{"id":{"type":"string"},"status":{"type":"string"},"signed_at":{"type":["string","null"]},"declined_at":{"type":["string","null"]},"first_viewed_at":{"type":["string","null"]}}},"data_collection":{"type":"object","description":"Present on document.data_submitted. Fetch the document to read the submitted values; they are not included in the event.","properties":{"id":{"type":"string"},"status":{"const":"submitted"},"submitted_at":{"type":"string","format":"date-time"}}}}}}}}},"x-rate-limits":[{"scope":"Every request, per API key","scopeDa":"Alle kald, pr. API-nøgle","limit":"2,000 / minute","retryAfter":"60"},{"scope":"Missing, malformed, unknown, revoked or expired key, per IP","scopeDa":"Manglende, ugyldig, ukendt, tilbagekaldt eller udløbet nøgle, pr. IP","limit":"30 / 10 minutes","retryAfter":"600"},{"scope":"POST /documents, per partner (test + live combined)","scopeDa":"POST /documents, pr. partner (test og live samlet)","limit":"40 / hour","retryAfter":"60"},{"scope":"POST /documents with a test key, per partner (test documents created, all test keys combined)","scopeDa":"POST /documents med en testnøgle, pr. partner (oprettede testdokumenter, alle testnøgler samlet)","limit":"100 / calendar month (UTC)","retryAfter":"until the 1st"},{"scope":"POST /documents/{id}/send, per partner","scopeDa":"POST /documents/{id}/send, pr. partner","limit":"20 / hour","retryAfter":"60"},{"scope":"POST /documents/{id}/data-collection, per partner","scopeDa":"POST /documents/{id}/data-collection, pr. partner","limit":"120 / hour","retryAfter":"60"},{"scope":"Hosted fill-in page: opening, per IP / submitting, per IP","scopeDa":"Hostet udfyldningsside: åbning pr. IP / indsendelse pr. IP","limit":"60 / 10 minutes; 20 / hour","retryAfter":"—"},{"scope":"Reminders, per signer","scopeDa":"Påmindelser, pr. underskriver","limit":"3 / 24 hours","retryAfter":"60"},{"scope":"Reminders, per partner","scopeDa":"Påmindelser, pr. partner","limit":"30 / hour","retryAfter":"60"},{"scope":"GET /customers/{id}/export, per partner","scopeDa":"GET /customers/{id}/export, pr. partner","limit":"120 / hour","retryAfter":"3600"},{"scope":"DELETE /customers/{id}, per partner","scopeDa":"DELETE /customers/{id}, pr. partner","limit":"60 / hour","retryAfter":"3600"}],"x-scopes":["documents:read","documents:write","templates:read","webhooks:manage","customers:manage"]}