DRAFT until you send it for signing.
Before you begin
- Create an API key. In the sajn app, go to workspace settings, then Utvecklare (Developer) > API-nycklar (API keys).
-
Store the key in the
SAJN_API_KEYenvironment variable. Every example on this page reads it from there:ReplaceAPI_KEYwith your API key.
Sajn-Version: 2026-10 header, so the examples behave the same no matter what your organization’s default version is. For more information, see API versioning.
Create the document
1
Create a draft with its parties
Send a The response is the full document, in the same shape as Get a document by ID. Store the document
POST request to /api/v1/documents with a name and the parties who take part. Each party is either an existing contact, referenced by contactId, or a person given by name and email:fields is null unless you pass expand=fields. The following example leaves out documentMeta and some party fields:id and each party id. The other document and party endpoints take them as path parameters.If you leave out expiresAt, the document gets the workspace’s default expiration, if the workspace has one. If you leave out requiredSignature, the party gets the workspace’s default signing method.2
Configure the invitation and signing settings
Set the email subject, the invitation message, the signing order, and the automatic reminders in Replace
documentMeta. Set the deadline in expiresAt. You can send these fields when you create the document, or later with a PATCH request:DOCUMENT_ID with the document id from the previous step.The most-used documentMeta fields are the following:signingMode:PARALLELinvites every party at once.SEQUENTIALinvites them one at a time, in the order of each party’ssigningOrder. For more information, see Multi-party signing.reminderIntervalDays: the number of days between automatic reminders, as an integer.0turns them off, andnulluses the default of 3 days. For more information, see Reminders and expiration.language: the language of the emails and the signing page, such assvoren.redirectUrlandredirectEnabled: where to send a party after signing. For more information, see Redirect after signing.internalRecipients: up to five email addresses that get a copy of the sealed PDF when the document is completed.
3
Fill in custom field values
To set the workspace’s custom fields on the document, send Replace
customFields with each field’s customFieldId and value. To find the IDs, call List all custom fields:DOCUMENT_ID with the document ID. The response’s customFields array lists every value on the document. For more information, see Custom fields.4
Add the content
A document created without a template has no content. Add it in one of the following ways:
- Upload a PDF file and attach it as a
PDFfield. For more information, see Upload files. - Add text and HTML fields. For more information, see HTML fields.
- Create the document from a template that already has content, as described in the following section.
Create a document from a template
To reuse content and parties, pass atemplateId. The new document copies the template’s fields, parties, and settings. If you also send parties, they replace the template’s parties, and signature and initials boxes placed on a PDF for the template’s parties are removed. For a template with placed boxes, leave out parties and update the copied parties instead, as described in Create documents from templates:
TEMPLATE_ID with the ID of a template from List all templates.
To fill in the template’s form fields before you send the document, use Fill in values on a document.
Add a company party
A party with acompany is a COMPANY party, which signs on behalf of the company. Set the company’s name and orgNumber together, and optionally the party’s role at the company. Leave out company for a private individual:
country is an ISO 3166-1 alpha-2 code, such as SE. The response returns the company as company, with id, name, orgNumber, and role, and company is null for a private individual.
A party added by name and email has no phone number. To deliver the invitation by SMS, add the party from a contact that has a phone number, with contactId and "deliveryMethod": "SMS". You can also set phone later with Update a party.
Handle errors
Errors have the same shape on every endpoint. Branch oncode:
400 VALIDATION_FAILED: the body is invalid, for example a party withoutemail, acompanywithnamebut noorgNumber, or a flat key such ascompanyName. Theissuesarray lists each problem with itspath, such asparties.0.email.404 NOT_FOUND: acontactIdor thetemplateIddoesn’t exist in the workspace.429 RATE_LIMITED: wait the number of seconds in theRetry-Afterheader, and then retry.
POST request safely, send the same Idempotency-Key header on every attempt. For more information, see Errors and Idempotency.
Next steps
Send for signing
Send the draft and track each party’s progress.
Upload files
Attach a PDF file as the document’s content.
Set the signing method
Choose BankID, eID, drawn, or click-to-sign for each party.
Create a new document
See every request field in the API reference.

