Before you begin
- Store your API key in the
SAJN_API_KEYenvironment variable. To create a key, go to workspace settings in the sajn app, then Utvecklare (Developer) > API-nycklar (API keys). - Read Create a document for the basics of creating a draft.
Choose a signing order
The document’sdocumentMeta.signingMode decides when each party is invited, and each party’s signingOrder sets its position in a sequence:
PARALLEL: every party is invited when you send the document and can sign in any order. This is the fastest option, and we recommend it when the order doesn’t matter.SEQUENTIAL: parties are invited in ascendingsigningOrder. Parties with the samesigningOrderform a group: they’re invited together, and the next group is invited when everyone in the group has signed.
SEQUENTIAL, a party hears nothing until it’s their turn. In the sajn app, a party who is waiting shows as Väntar på tur (Waiting for turn).
Create a document with a signing sequence
1
Create the document with ordered parties
The following request creates a partnership agreement. The two people from Example AB sign first, at the same time. When both have signed, the two people from Sample Oy are invited:Replace
TEMPLATE_ID with the ID of a template that holds the agreement’s content. The response is the document, with one entry in parties for each party.2
Send the document
Send the document as usual:Replace
DOCUMENT_ID with the document id. Only the parties with signingOrder 1 are invited.3
Track the parties
Each signature fires a The example leaves out some document and party fields. To count the parties who haven’t signed, filter
document.party.signed webhook event. The event has the whole document in data.object and the party who signed in data.party:data.object.parties on signingStatus. When every signing party has signed, document.fully_signed fires, followed by document.completed when the sealed PDF is ready. For every event, see Webhook events.To check the state without webhooks, call Get a document by ID and read each party’s signingStatus and readStatus.Give parties roles that don’t sign
Every party has arole:
SIGNER: signs the document.REVIEWER: reviews the document without signing.ORGANIZER: organizes the document without signing.
SIGNER parties have to sign before the document is completed.
Common sequences
The following patterns use"signingMode": "SEQUENTIAL" in the document’s documentMeta:
- Your company signs first, then the customer: give your signatory
signingOrder1 and the customer’s signatory 2. - Two companies sign, then witnesses: give both companies’ signatories 1, and every witness 2.
- An employee signs, then a manager countersigns: give the employee 1 and the manager 2.
PARALLEL and leave out signingOrder.
Things to plan for
- In a sequence, one party who doesn’t sign blocks everyone after them. Set an expiration date and keep automatic reminders on. For more information, see Reminders and expiration.
- When a party rejects the document, the document’s status becomes
REJECTED, and thedocument.party.rejectedanddocument.rejectedevents fire. To try again, create and send a new document. - To change the order of a sent document, withdraw it, update the parties’
signingOrder, and send it again.documentMeta.signingModecan’t change while the document is sent.
Handle errors
400 VALIDATION_FAILED: a party is invalid, for example withoutemail. Readissuesfor the path, such asparties.2.email.409 INVALID_STATEonPATCH /api/v1/documents/DOCUMENT_IDwith a changeddocumentMeta.signingModeafter sending, or onPATCH /api/v1/documents/DOCUMENT_ID/parties/PARTY_IDwith a changedsigningOrder: the setting is locked. Withdraw the document first.400 VALIDATION_FAILEDwithdocumentMeta.signingOrderin the request: the setting is namedsigningModeindocumentMeta.
Next steps
Reminders and expiration
Keep a long sequence moving.
Set the signing method
Use a different signing method for each party.
Webhooks
Track signing progress as it happens.
Parties
Learn how parties, roles, and contacts relate.

