curl --request POST \
--url https://app.sajn.se/api/v1/documents/{id}/fields \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"position": 123,
"fieldMeta": {
"type": "TEXT",
"content": "<string>",
"locked": true,
"hidden": true
},
"key": "<string>"
}
'import requests
url = "https://app.sajn.se/api/v1/documents/{id}/fields"
payload = {
"position": 123,
"fieldMeta": {
"type": "TEXT",
"content": "<string>",
"locked": True,
"hidden": True
},
"key": "<string>"
}
headers = {
"authorization": "<authorization>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
authorization: '<authorization>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
position: 123,
fieldMeta: {type: 'TEXT', content: '<string>', locked: true, hidden: true},
key: '<string>'
})
};
fetch('https://app.sajn.se/api/v1/documents/{id}/fields', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.sajn.se/api/v1/documents/{id}/fields",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'position' => 123,
'fieldMeta' => [
'type' => 'TEXT',
'content' => '<string>',
'locked' => true,
'hidden' => true
],
'key' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.sajn.se/api/v1/documents/{id}/fields"
payload := strings.NewReader("{\n \"position\": 123,\n \"fieldMeta\": {\n \"type\": \"TEXT\",\n \"content\": \"<string>\",\n \"locked\": true,\n \"hidden\": true\n },\n \"key\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.sajn.se/api/v1/documents/{id}/fields")
.header("authorization", "<authorization>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"position\": 123,\n \"fieldMeta\": {\n \"type\": \"TEXT\",\n \"content\": \"<string>\",\n \"locked\": true,\n \"hidden\": true\n },\n \"key\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.sajn.se/api/v1/documents/{id}/fields")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"position\": 123,\n \"fieldMeta\": {\n \"type\": \"TEXT\",\n \"content\": \"<string>\",\n \"locked\": true,\n \"hidden\": true\n },\n \"key\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"code": "<string>",
"errorId": "<string>"
}{
"message": "<string>",
"code": "<string>",
"errorId": "<string>"
}{
"message": "<string>",
"code": "<string>",
"errorId": "<string>"
}Create a document field
Add a field/section to a document. Can create single field or multiple fields at once.
Field Types:
TEXT- Rich text content section (Tiptap editor format)HTML- Raw HTML content with custom styling (API-only, sanitized for security)FORM- Form with input fields for signersPDF- PDF file sectionPRODUCT_TABLE- Product/service table with pricingTABLE- Simple table with custom rows and columnsSPACER,PAGE_BREAK,DURATION- Layout and duration blocks
Field Position: Determines the order fields appear in the document (0-based index).
Field Metadata: Each field type has specific metadata requirements. See schema documentation for details.
Placing fields on a PDF: a PDF field renders an uploaded PDF (fieldMeta.value is the storage key returned by the files endpoint). Add boxes on its pages with fieldMeta.placedFields. Each entry has page (0-based), rect (x, y, width, height in PDF points, origin at the bottom-left corner of the page), pageWidth and pageHeight (points), and a kind:
inputwithinputTypesignatureorinitialsand asignerId: a mark the party draws at signing, sealed into the PDF at that position.inputwithinputTypetext,date,checkboxorselectand asignerId: a value the party fills in before signing. Setrequiredto block signing until it is filled.staticwithcontent(HTML): fixed text stamped at that position.
Example:
{
"type": "PDF",
"position": 0,
"fieldMeta": {
"type": "PDF",
"value": "f/org_123/abc123def/contract.pdf",
"placedFields": [
{
"id": "sig-1",
"kind": "input",
"inputType": "signature",
"page": 2,
"rect": { "x": 72, "y": 96, "width": 200, "height": 48 },
"pageWidth": 595.28,
"pageHeight": 841.89,
"signerId": "PARTY_ID",
"required": true
}
]
}
}
Read the result back with GET /api/v1/documents/{id}/fields.
HTML Field Security: HTML fields accept raw HTML but are automatically sanitized server-side to allow only safe formatting tags (p, div, span, headings, lists, tables, images) and basic CSS styling. Links, script tags, and dangerous attributes are stripped. Images support HTTP/HTTPS URLs and data URIs for inline images.
curl --request POST \
--url https://app.sajn.se/api/v1/documents/{id}/fields \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'authorization: <authorization>' \
--data '
{
"position": 123,
"fieldMeta": {
"type": "TEXT",
"content": "<string>",
"locked": true,
"hidden": true
},
"key": "<string>"
}
'import requests
url = "https://app.sajn.se/api/v1/documents/{id}/fields"
payload = {
"position": 123,
"fieldMeta": {
"type": "TEXT",
"content": "<string>",
"locked": True,
"hidden": True
},
"key": "<string>"
}
headers = {
"authorization": "<authorization>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
authorization: '<authorization>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
position: 123,
fieldMeta: {type: 'TEXT', content: '<string>', locked: true, hidden: true},
key: '<string>'
})
};
fetch('https://app.sajn.se/api/v1/documents/{id}/fields', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.sajn.se/api/v1/documents/{id}/fields",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'position' => 123,
'fieldMeta' => [
'type' => 'TEXT',
'content' => '<string>',
'locked' => true,
'hidden' => true
],
'key' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.sajn.se/api/v1/documents/{id}/fields"
payload := strings.NewReader("{\n \"position\": 123,\n \"fieldMeta\": {\n \"type\": \"TEXT\",\n \"content\": \"<string>\",\n \"locked\": true,\n \"hidden\": true\n },\n \"key\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.sajn.se/api/v1/documents/{id}/fields")
.header("authorization", "<authorization>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"position\": 123,\n \"fieldMeta\": {\n \"type\": \"TEXT\",\n \"content\": \"<string>\",\n \"locked\": true,\n \"hidden\": true\n },\n \"key\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.sajn.se/api/v1/documents/{id}/fields")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"position\": 123,\n \"fieldMeta\": {\n \"type\": \"TEXT\",\n \"content\": \"<string>\",\n \"locked\": true,\n \"hidden\": true\n },\n \"key\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"code": "<string>",
"errorId": "<string>"
}{
"message": "<string>",
"code": "<string>",
"errorId": "<string>"
}{
"message": "<string>",
"code": "<string>",
"errorId": "<string>"
}Authorizations
OAuth 2.0 access token for a connected application. Limited to the scopes granted at consent.
Headers
Bearer token for API authentication
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.
255Path Parameters
Body
Body
- object
- object[]
Was this page helpful?

