Skip to content

Fields API

The Fields API allows you to retrieve and manage the signature fields and form elements placed on your documents. Fields define where signers need to sign, initial, or fill in information.

Get all fields for a specific document.

GET /wp-json/wpsigner/v1/documents/{id}/fields
ParameterTypeDescription
idintegerRequired. Document ID
Terminal window
curl -X GET "https://your-site.com/wp-json/wpsigner/v1/documents/44/fields" \
-H "X-WPS-API-Key: wps_your_key" \
-H "X-WPS-API-Secret: your_secret"
[
{
"id": "74",
"document_id": "44",
"signer_id": "38",
"field_type": "signature",
"field_name": "",
"page_number": "5",
"position_x": "90.0",
"position_y": "276.9",
"width": "200",
"height": "60",
"value": "",
"placeholder": "",
"is_required": "1",
"font_size": "14",
"font_family": "DM Sans",
"options": "",
"created_at": "2024-01-15 10:30:00",
"updated_at": "2024-01-15 10:30:00"
},
{
"id": "75",
"document_id": "44",
"signer_id": "38",
"field_type": "name",
"field_name": "",
"page_number": "5",
"position_x": "115.0",
"position_y": "337.4",
"width": "150",
"height": "30",
"value": "",
"is_required": "1"
},
{
"id": "76",
"document_id": "44",
"signer_id": "38",
"field_type": "date",
"field_name": "",
"page_number": "5",
"position_x": "300.0",
"position_y": "337.4",
"width": "100",
"height": "30",
"value": "",
"is_required": "1"
}
]

WPsigner supports various field types for different signing scenarios:

TypeDescriptionFilled By
signatureSignature field (draw, type, or upload)Signer
initialsInitials fieldSigner
nameAuto-filled signer nameAuto
emailAuto-filled signer emailAuto
dateSigning dateAuto
textFree-form text inputSigner
textareaMulti-line textSigner
checkboxCheckbox fieldSigner
dropdownDropdown selectionSigner
stampCompany stamp or sealSigner

PropertyTypeDescription
idstringUnique field identifier
document_idstringParent document ID
signer_idstringAssigned signer ID
field_typestringType of field
field_namestringCustom field name/label
PropertyTypeDescription
page_numberstringPage where field appears (1-indexed)
position_xstringX coordinate from left edge (in points)
position_ystringY coordinate from top edge (in points)
widthstringField width in points
heightstringField height in points
PropertyTypeDescription
font_sizestringFont size in points
font_familystringFont family name
placeholderstringPlaceholder text
PropertyTypeDescription
is_requiredstring1 = required, 0 = optional
valuestringCurrent field value
optionsstringOptions for dropdown fields (JSON array)

Save or update all fields for a document. This replaces all existing fields.

POST /wp-json/wpsigner/v1/documents/{id}/fields

Note: This endpoint requires Full Access permission.

Important: This endpoint replaces ALL existing fields. Include all fields in your request, not just new ones.

ParameterTypeDescription
idintegerRequired. Document ID
{
"fields": [
{
"signer_id": "38",
"field_type": "signature",
"page_number": 5,
"position_x": 90,
"position_y": 276.9,
"width": 200,
"height": 60,
"is_required": true
},
{
"signer_id": "38",
"field_type": "name",
"page_number": 5,
"position_x": 115,
"position_y": 337,
"width": 150,
"height": 30,
"is_required": true
},
{
"signer_id": "38",
"field_type": "date",
"page_number": 5,
"position_x": 300,
"position_y": 337,
"width": 100,
"height": 30,
"is_required": true
}
]
}
PropertyTypeRequiredDescription
signer_idintegerYesID of assigned signer
field_typestringYesType of field
page_numberintegerYesPage number (1-indexed)
position_xnumberYesX position in points
position_ynumberYesY position in points
widthnumberNoWidth (default varies by type)
heightnumberNoHeight (default varies by type)
is_requiredbooleanNoRequired field (default: true)
font_sizeintegerNoFont size (default: 14)
font_familystringNoFont family (default: “DM Sans”)
placeholderstringNoPlaceholder text
optionsarrayNoOptions for dropdown
Terminal window
curl -X POST "https://your-site.com/wp-json/wpsigner/v1/documents/44/fields" \
-H "X-WPS-API-Key: wps_your_key" \
-H "X-WPS-API-Secret: your_secret" \
-H "Content-Type: application/json" \
-d '{
"fields": [
{
"signer_id": 38,
"field_type": "signature",
"page_number": 5,
"position_x": 90,
"position_y": 276.9,
"width": 200,
"height": 60,
"is_required": true
}
]
}'

Returns the saved fields array:

[
{
"id": "80",
"document_id": "44",
"signer_id": "38",
"field_type": "signature",
"page_number": "5",
"position_x": "90",
"position_y": "276.9",
"width": "200",
"height": "60",
"is_required": "1"
}
]

For dropdown fields, pass options as an array:

{
"signer_id": 38,
"field_type": "dropdown",
"page_number": 1,
"position_x": 100,
"position_y": 200,
"width": 150,
"height": 30,
"options": ["Option 1", "Option 2", "Option 3"],
"placeholder": "Select an option"
}

If you don’t specify width/height, these defaults are used:

Field TypeDefault WidthDefault Height
signature20060
initials10050
name15030
email20030
date10030
text20030
textarea20080
checkbox2020
dropdown15030
stamp150100

{
"code": "invalid_data",
"message": "Invalid fields data.",
"data": {
"status": 400
}
}
{
"code": "validation_failed",
"message": "Field validation failed.",
"data": {
"status": 400,
"errors": [
"Field 1: Invalid signer_id",
"Field 3: page_number is required"
]
}
}

Ensure every field’s signer_id corresponds to a valid signer on the document:

// Get signers first
const signers = await fetch(`/documents/${id}/signers`);
const validSignerIds = signers.map(s => s.id);
// Validate before saving
fields.forEach(field => {
if (!validSignerIds.includes(field.signer_id)) {
throw new Error(`Invalid signer_id: ${field.signer_id}`);
}
});

PDF coordinates start from the bottom-left. WPsigner uses top-left origin:

// Convert from PDF coordinates to WPsigner coordinates
const wpsY = pageHeight - pdfY - fieldHeight;

The fields endpoint replaces all fields. Always include existing fields:

// Get existing fields
const existing = await fetch(`/documents/${id}/fields`);
// Add new field to existing
const allFields = [...existing, newField];
// Save all fields
await fetch(`/documents/${id}/fields`, {
method: 'POST',
body: JSON.stringify({ fields: allFields })
});