Pre-fill PDF document form fields with API

Prerequisites:

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

Template ID: Identify the template ID you want to use for the form.

1

Pre-fill document data and send for signature

POST request to https://api.docuseal.com/submissions. Include the obtained API key in the headers ('X-Auto-Token'). Specify the template_id and submitter details with fields[] list containing:

  • name: Name of the field in the template.
  • default_value: The default value assigned to the field. Use base64 encoded string to pass images, signatures or files. Or pass a public downloadable URL with an image to prefill signature, image, initials fields. Pass text value if you want to pre-fill signature or initials with the font-generated text.
  • readonly: Set true to make it impossible for the signer to edit the pre-filled field value. false by default.

Upon a successful request, specified submitters of the document will receive an email invitation to click on the link to fill and sign the document.

const docuseal = require("@docuseal/api");

docuseal.configure({ key: "API_KEY", url: "https://api.docuseal.com" });

const submission = await docuseal.createSubmission({
  template_id: 1000001,
  order: 'preserved',
  submitters: [
    {
      email: 'john.doe@example.com',
      fields: [
        {
          name: 'First name',
          default_value: 'John',
          readonly: true
        },
        {
          name: 'Last name',
          default_value: 'Doe',
          readonly: true
        }
      ]
    }
  ]
});
2

Automatically sign documents via API

Signing documents on behalf of your company as a signing party can be automated with the PUT https://api.docuseal.com/submitters/{id} API. This automation reduces the time spent on administrative tasks, enabling faster turnaround times for your documents.

API request body should contain JSON payload with "completed": true value to mark the document as signed by this submitter party. Also request body should contain fields[] list to predefine values and to put a signature image with the given URL.

Upon a successful request, all signing parties will receive an email with a signed document.

Learn more:

REST API Reference

const docuseal = require("@docuseal/api");

docuseal.configure({ key: "API_KEY", url: "https://api.docuseal.com" });

const submitter = await docuseal.updateSubmitter(500001, {
  completed: true,
  fields: [
    {
      name: 'Full Name',
      default_value: 'John Doe',
      readonly: true
    },
    {
      name: 'Signature',
      default_value: 'https://your-company.com/signature.png',
      readonly: true
    }
  ]
});