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.co/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.

import axios from "axios";

const API_KEY = 'YOUR_API_KEY';

axios.request({
  method: 'POST',
  url: 'https://api.docuseal.co/submissions',
  headers: {
    'X-Auth-Token': API_KEY,
    'content-type': 'application/json'
  },
  data: {
    template_id: 123,
    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
          }
        ]
      }
    ]
  }
}).then((response) => {
  console.log(response.data[0].slug);
});
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.co/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

import axios from "axios";

const API_KEY = 'YOUR_API_KEY';

axios.request({
  method: 'PUT',
  url: 'https://api.docuseal.co/submitters/123',
  headers: {
    'X-Auth-Token': API_KEY,
    'content-type': 'application/json'
  },
  data: {
    completed: true,
    fields: [
      {
        name: 'Full Name',
        default_value: 'John Doe',
        readonly: true
      },
      {
        name: 'Signature',
        default_value: 'https://your-company.com/signature.png',
        readonly: true
      }
    ]
  }
}).then((response) => {
  console.log(response.data)
});