Skip to Content
Document content

Fill in values on a document

PATCH
/api/v1/documents/{id}/field-values

Fills in values by key. The same request shape works for FORM subfields, AcroForm fields, and boxes placed on a PDF. Only documents with the status DRAFT or IMPORTED can be filled in.

Keys must match exactly. To find the keys, call GET /api/v1/documents/{id}/field-values. Set a key in the editor on a FORM subfield or a placed box, or send key when you create a placed box through the API, so that the key stays the same for every document created from a template.

The following example fills in a FORM subfield, a placed text box, and a PDF checkbox:

{  "values": [    { "key": "customer-name", "value": "Example AB" },    { "key": "org-number", "value": "556000-0000" },    { "key": "accept-terms", "value": true }  ]}

A value fails, and the other values are still written, when its key doesn't exist, when two fields share the key, when a party fills in the value and the document is no longer a draft, or when the value doesn't match the type or the allowed options. results lists the outcome for each key, with an error that has a code from the error catalogue, and data holds every value on the document after the write, as GET /api/v1/documents/{id}/field-values returns them.

If another edit changes one of the fields while the request runs, nothing is written and the request fails with an HTTP 409 Conflict status code. Send the request again.

Authorization

headerAuthorizationBearer <token>

API key, e.g. Authorization: Bearer sajn_svc_.... Not scope-limited: acts with its owner's workspace role.

Path Parameters

id*string

The document ID.

Header Parameters

Sajn-Version?string

API version for this request. Without it, the request uses the organization's default version; an organization without a default is pinned to the latest version by its first request.

Value in"2026-09""2026-10"
Sajn-Workspace?string

ID of the workspace this request acts in, from GET /api/v1/workspaces. Without it, an API key acts in its default workspace. The token's user must be a member of the workspace; an OAuth token only accepts the workspace it was granted for. A workspace that doesn't exist or can't be reached returns 403 WORKSPACE_ACCESS_DENIED.

Idempotency-Key?string

Makes retries safe. A retry with the same key and the same request replays the stored response for 24 hours (header Idempotent-Replayed: true); the same key with a different request returns 400.

Lengthlength <= 255

Request Body

Body

application/json
  1. body
values*array<>

The values to write, at most 100 per request.

Items1 <= items <= 100

Response Body

200

application/json
  1. response
results*array<>

One result per input value, in request order.

remaining*array<string>

The keys of required values with filledBy SENDER that are still empty.

data*array<>

Every value on the document after the write, as GET /api/v1/documents/:id/field-values returns them.

Example Request
curl -X PATCH 'https://app.sajn.se/api/v1/documents/cm4k2x9p10003abcd1234efgh/field-values' \  -H 'Content-Type: application/json' \  -d '{  "values": [    {      "key": "startdatum",      "value": "2026-11-01"    }  ]}'
Example Response
{  "results": [    {      "key": "startdatum",      "success": true,      "error": null    }  ],  "remaining": [],  "data": [    {      "key": "startdatum",      "label": "Startdatum",      "kind": "FORM",      "fieldId": "cm4k2x9p10009abcd1234efgh",      "type": "Anställningsavtal – Kai Lindqvist",      "required": true,      "options": [        "Heltid"      ],      "value": "540000",      "filledBy": "SENDER",      "partyId": "cm4k2x9p10004abcd1234efgh"    }  ]}

Was this page helpful?