Skip to main content
In this quickstart, you create a document with one party, send it, sign it yourself, and download the sealed PDF. Every request uses API version 2026-10.

Before you begin

You need the following:
  • A sajn workspace with API access. API access is included from the Team plan, and in every sandbox. We recommend a sandbox for this quickstart: nothing is billed, BankID is mocked, and the signed PDF is watermarked as a test.
  • An email address you can read. sajn sends the signing invitation to it, and rejects addresses on domains that can’t receive email.
  • curl, Node.js 18 or later, or Python 3 with the requests package.
1

Create an API key

In the sajn app, open the workspace you want to work in, and go to Inställningar > Utvecklare > API-nycklar. Click Skapa API-nyckel, enter a name, choose when the key expires, and copy the key. sajn shows the key only once.A production key starts with sajn_sk_, and a sandbox key starts with sajn_dev_. Store the key in an environment variable:
Replace API_KEY with the key you copied. For more information about keys, see Authentication.
2

Check the key

Call GET /me to confirm which user, workspace, and organization the key acts as. The Node.js and Python samples define a small sajn helper that the later steps reuse. The Node.js samples use top-level await, so save them in a file with the .mjs extension:
The response is similar to the following:
A 401 response with the code UNAUTHORIZED means the key is missing, mistyped, expired, or revoked.
3

Create a document with a party

Create a document and add the party in the same request. An inline party takes either a contactId or a name and an email. The party in this example signs with click-to-sign and receives the invitation by email.A document must have an expiration date before you can send it, so set expiresAt:
Replace SIGNER_EMAIL with your own email address.The response is the new document, in DRAFT status, in the same shape as GET /documents/{id}. The following excerpt shows the fields you use next:
If you use curl, save both IDs:
4

Add content

A new document has no content. Add fields to it. The request takes a fields array, also for one field. This example adds an HTML field; for other content types, such as an uploaded PDF, see Fields.
The response lists the created fields in data.
5

Send the document

Send the document. sajn emails the party an invitation, and the document moves from DRAFT to PENDING:
The response is the document, with status set to PENDING. If your workspace role can’t send without approval, the request fails with 409 APPROVAL_REQUIRED; request approval first. For more information, see Send for signing.
6

Get the signing URL

The invitation email holds a signing link. To get the same link from the API, for example to show it in your own app, get the party:
The response includes signingUrl:
Open the URL and sign. Each signing URL belongs to one party, so never publish it. sajn records an audit log entry every time you fetch it.
7

Wait for completion

After the last party signs, sajn seals the PDF and the document moves from PENDING to COMPLETED. Choose how you find out:
Create a webhook endpoint that subscribes to document.completed. sajn must reach the URL over the public internet, and rejects a URL that answers with an HTML page. For local development, see Test webhooks.
Replace WEBHOOK_URL with your endpoint’s HTTPS URL. Store the secret from the response, which starts with whsec_. sajn returns it only when you create the webhook or rotate its secret, and you use it to verify signatures.When the document completes, your endpoint receives a POST request similar to the following:
data.object is the document, in the shape of GET /documents/{id}, so data.object.id is the document ID. For the full payload, see Webhook payloads.
8

Download the signed PDF

Get the SIGNED file to get a download URL, then download the PDF. The URL works for 15 minutes:
The response has the file’s type, url, and expiresAt, and the curl sample uses jq to read url. Until the document is COMPLETED, the request returns 409 with the code INVALID_STATE.The PDF ends with a signing certificate that records who signed, how, and when.

Next steps

Document lifecycle

Every status a document passes through, and what moves it.

Parties

Roles, signing order, delivery, and verification.

Templates and forms

Create documents from a template and fill in values by key.

Webhooks

React to signing events as they happen.