LogoDOCS
OverviewAuthenticationRate LimitsErrors
Logo
Sign in →

Create PDF Fields

This endpoint adds interactive form fields to any existing PDF. It supports two methods for placing fields, which can be used independently or combined in the same request:

  • Placeholder tags - embed special tags directly in your PDF as plain text. The API detects each tag, removes it, and replaces it with a real form field at the exact position where the tag appeared.
  • Manual coordinates - pass field definitions with explicit page number, x/y position, width, and height. No changes to the source PDF are required.

Both methods can be used together in a single request. For example, you can have placeholder tags in your PDF for some fields and supply additional fields via manual coordinates at the same time.

Method 1: Placeholder tags

Tags are written as plain text in any PDF editor or document editor that exports PDFs. They look like regular text. For example, the tag {signature;n:sign_here;r:signer}, when processed, will be replaced with a digital signature field named "sign_here" assigned to the role "signer".

Our API automatically removes placeholder tags from the PDF after processing. However, in some cases, the original tag text may remain visible. To prevent this, we recommend setting the tag text color to match the background.

Note: Tags must be written on a single line. If they are split across multiple lines, they will not be detected.

Tag syntax

Each tag starts with the field type. Additional properties are optional and use a key:value format separated by semicolons.

KeyDescriptionRequiredApplies to
typeThe field type. Must always be defined first. Supported field types are listed below.YesAll
n:The field name. Radio buttons with the same name are grouped together. The name also links the field to a fieldOverrides entry.NoAll
r:Associates the field with a signing role. Only users assigned to that role can interact with the field.NoAll
h:The field height in points. By default, the height is automatically detected from the placeholder tag, but you can override it using this tag or through the fieldOverrides option if needed.NoAll
w:The field width in points. By default, the width is automatically detected from the placeholder tag, but you can override it using this tag or through the fieldOverrides option if needed.NoAll
fs:Sets the field font size. By default, the font size is automatically calculated based on the field height, except textarea fields where the default is 12pt. However, you can override it using this tag if needed.Notext, number, textarea, date, time, datetime, select
o:A comma-separated list of options for the select field.Noselect only
c:Specifies the value represented by this radio button within the group.Noradio only

Example tags:

Tags are case-sensitive. Keys and field types must be written exactly as shown below.

1{text;n:fullName;r:signer;h:24;w:200}2{number;n:amount;r:signer}3{textarea;n:notes;h:80;w:300}4{date;n:startDate;r:signer}5{time;n:startTime;r:signer}6{datetime;n:signedAt;r:signer}7{checkbox;n:agree;r:signer}8{radio;n:gender;c:male}9{radio;n:gender;c:female}10{select;n:status;o:Active,Inactive,Pending}11{signature;n:sig;r:signer}

Supported field types

TypeDescription
textCreates a standard text input field.
numberA text field that only accepts numbers.
textareaCreates a text input field that supports multiple lines.
dateStored as a text field in the PDF. In our signing UI is presented as a date picker.
timeStored as a text field in the PDF. In our signing UI is presented as a time picker.
datetimeStored as a text field in the PDF. In our signing UI is presented as a date and time picker. You can automatically populate this field when the document is signed by setting autoFill in fieldOverrides.
checkboxCreates a standard checkbox field.
radioCreates a radio button field. Radio buttons that share the same name behave as a group.
selectCreates a dropdown field. Options can be provided inline using the tag o: or through fieldOverrides.
signatureDefines a field where a recipient can provide their signature. It is primarily used with the digital signatures feature to collect signatures in the signing UI.

Method 2: Manual field coordinates

Pass a fields array in the request body. Each entry defines one field with explicit coordinates. No placeholder tags are needed in the PDF.

1[2  { "name": "full_name",  "type": "text",      "page": 1, "x": 100, "y": 600, "width": 200, "height": 24, "role": "signer" },3  { "name": "status",     "type": "select",    "page": 1, "x": 100, "y": 560, "width": 160, "height": 24, "role": "signer", "options": ["Active", "Inactive"] },4  { "name": "dob",        "type": "date",      "page": 1, "x": 100, "y": 520, "width": 160, "height": 24, "role": "signer" },5  { "name": "start_time", "type": "time",      "page": 1, "x": 100, "y": 480, "width": 120, "height": 24, "role": "signer" },6  { "name": "agree",      "type": "checkbox",  "page": 1, "x": 100, "y": 440, "width": 14,  "height": 14, "role": "signer" },7  { "name": "gender",     "type": "radio",     "page": 1, "x": 100, "y": 400, "width": 14,  "height": 14, "role": "signer", "value": "male" },8  { "name": "gender",     "type": "radio",     "page": 1, "x": 100, "y": 380, "width": 14,  "height": 14, "value": "female" },9  { "name": "signed_at",  "type": "datetime",  "page": 1, "x": 100, "y": 340, "width": 180, "height": 24, "role": "signer", "autoFill": true },10  { "name": "signature",  "type": "signature", "page": 1, "x": 100, "y": 260, "width": 200, "height": 80, "role": "signer" }11]

Coordinates use the PDF coordinate system where the origin (0, 0) is at the bottom-left of the page and the y-axis increases upward. All values are in points.

For radio buttons, each entry represents one button. Buttons sharing the same name are grouped together. Use the value field to set the export value for each button.

Request Body
filefilerequired if documentId is not provided

File type: .pdf

The PDF file to process. Can contain placeholder tags, or you can place fields via manual coordinates using the fields parameter.

documentIdstringrequired if file is not provided

The ID of a document that was previously uploaded to PDFGate.

fieldOverridesobject

Lets you set or override field properties from placeholder tags at request time, keyed by field name.

fieldsarray of objects

An array of field definitions with explicit coordinates.

jsonResponseboolean

Default: false

Returns JSON response instead of file stream.

preSignedUrlExpiresInnumber

Minimum: 60 seconds

Maximum: 86400 seconds (24 hours)

How long the pre-signed URL stays valid, in seconds. If you leave this out, no URL is generated.

metadataobject

Any custom data you want to store alongside the document.

POST/forms/fields
CURL
NODE.JS
PYTHON
GO
PHP
JAVA
C#
RUBY
1curl -X POST "https://api.pdfgate.com/forms/fields" \2  -H "Authorization: Bearer YOUR_API_KEY" \3  -F "file=@YOUR_FILE.pdf" \4  -F 'fieldOverrides={"status":{"options":["Active","Inactive","Pending"]},"signedAt":{"autoFill":true},"fullName":{"height":30,"width":300,"fontSize":12}}' \5  -F "jsonResponse=true" \6  -F 'metadata={"author":"John Doe","documentType":"Contract"}'
File stream response
1File stream
JSON response - Document object
1{2  "id": "6642381c5c61",3  "status": "completed",4  "type": "document_fields_added",5  "size": 142080,6  "fileUrl": "https://api.pdfgate.com/file/open/:preSignedUrlToken",7  "createdAt": "2024-02-13T15:56:12.607Z",8  "expiresAt": "2024-08-13T15:56:12.607Z"9}