Appearance
Fill a template API
http
POST /api/v1/templates/{document_id}/fill
Authorization: Bearer YOUR_TOKEN
Accept: application/json
Content-Type: application/jsondocument_id is the template public UUID. The Sanctum token owner must belong to its workspace.
Request
json
{
"name": "Employment agreement - Jane Doe",
"format": "docx",
"fields": {
"first name": "Jane",
"last name": "Doe"
}
}fields is required and must contain every placeholder whose resolver is provided. Internal-variable fields are resolved by the server. name defaults to the template name. format defaults to docx; accepted values are docx and pdf.
Accepted response
Status 202:
json
{
"data": {
"id": "0198f00a-4ac5-7000-9000-acde00000001",
"status": "processing",
"download_url": "https://dokusablon.com/api/v1/documents/0198f00a-4ac5-7000-9000-acde00000001/download"
}
}The download uses the same bearer token and returns the binary once ready.
Errors
401: token missing or invalid.403: user is not a workspace member.409: template parsing is incomplete or failed.422: invalid payload, includingmissing_fieldswhen placeholders are omitted.
Configure field resolvers
http
PUT /api/v1/templates/{document_id}/fields
Authorization: Bearer YOUR_TOKEN
Accept: application/json
Content-Type: application/jsonThe payload must define every existing placeholder key exactly once. Keys cannot be renamed through this endpoint because that would disagree with the DOCX content.
json
{
"fields": [
{
"key": "first_name",
"label": "First name",
"group": "Person",
"source": "first_name",
"resolver": "provided"
},
{
"key": "contract_date",
"label": "Contract date",
"group": "Agreement",
"source": "current_date",
"resolver": "internal"
}
]
}Supported resolvers are provided and internal. Internal sources are current_date, current_datetime, workspace.name, user.name, user.email, and template.name. Successful responses return the updated template resource, including field_definitions and parse_method.