Use embedded text field tags in the PDF to create a fillable form

Prerequisites:

Sign Up and Obtain API Key: Visit DocuSeal API Console to obtain your API key.

1

Embedded PDF field text tags

The PDF embedded text tags can be defined in the PDF using {{ }} curly brackets. These tags act as placeholders in the document, which should be replaced with interactive and fillable document fields. Each tag contains a defined field name along with its associated attributes:

Text field tags can contain the following attributes:

  • name: Name of the field in the template.
  • role: signer role name. Specify different names in case the document contains multiple signing parties with their own set of fields.
  • default: default field value to be used in the template (optional).
  • required: set false to make the field optional and skipable. true by default.
  • readonly: set true to make it impossible for the signer to edit the pre-filled field value. false by default.
  • options: comma separated list of options for select and radio field types.
  • width: absolute width of the field in pixels. This attribute is optional, text tag width will be used for the field width by default.
  • height: absolute height of the field in pixels. This attribute is optional, font size height will be used for the field height by default.

Attributes should be separated with semicolon (;) with attribute value specified after the equal (=) sign: {{DOB;type=date;role=Customer;required=false}}

{{Field Name}} Text field
{{Sign;type=signature}} Signature field
{{DOB;type=date}} Date field
{{Date;type=datenow}} Read-only signing date
{{Photo;type=image}} Image upload field
{{Documents;type=file}} Files upload field
{{type=checkbox}} Checkbox
{{Radio name;type=radio;options=Opt1,Opt2}} Radio select field
{{Select name;type=select;options=Opt1,Opt2}} Select field
{{type=stamp;readonly=true}} Stamp field (non-interactive)
{{type=phone;required=true}} Phone 2FA field
2

Send PDF to the API

Use POST https://api.docuseal.co/templates/pdf API to create interactive document form template from the given PDF with field text tags.

API request body should contain JSON payload with "file": '...' encoded as base64 string value.

Upon a successful request, you'll receive a "id" of the new template to be used in the signature request process.

Learn more:

REST API Reference

PDF text tags example file

const axios = require('axios');
const fs = require('fs');

// Read the file synchronously and encode it to base64
const filePath = 'path/to/your/file.pdf'; // Replace this with your file path
const fileData = fs.readFileSync(filePath, { encoding: 'base64' });

axios.post('https://api.docuseal.co/templates/pdf', {
  name: 'Rental Agreement',
  file: fileData, // Pass the encoded file data here
}, {
  headers: {
    'X-Auth-Token': 'API_KEY',
    'Content-Type': 'application/json',
  },
}).then((response) => {
  console.log(response.data);
}).catch((error) => {
  console.error('Error:', error);
});