How to Create a Document from a File Upload

Upload a PDF, DocX, or RTF to create a PandaDoc document via the API.

Problem

You need to create a PandaDoc document from a PDF, DocX, or RTF file. You can either upload a local file or provide a publicly accessible URL.

Prerequisites

  • A PandaDoc API key or OAuth token
  • A PDF, DocX, or RTF file (local or publicly accessible URL)
  • Recipients to assign to the document

Solution

Step 1: Choose your upload method

Option A -- Upload a local file using multipart/form-data:

Use your HTTP framework's file upload support to send the file. Most frameworks handle the Content-Type: multipart/form-data header automatically when you attach a file.

Option B -- Provide a public URL using application/json:

POST /public/v1/documents

{
  "name": "My document",
  "url": "https://cdn2.hubspot.net/hubfs/2127247/public-templates/SamplePandaDocPdf_FormFields.pdf",
  "recipients": [
    {
      "email": "[email protected]",
      "role": "user"
    }
  ],
  "parse_form_fields": false
}

See the Create Document API reference for full parameters.

🚧

A file you upload is not stored in your PandaDoc account. You must upload it with every request.

Step 2: Add interactive fields (optional)

Choose one of two approaches to add interactive fields to uploaded files:

Step 3: Assign roles to recipients

When using field tags, associate each tag with a recipient role and map them in the fields section:

{
  "recipients": [
    {
      "email": "[email protected]",
      "role": "user"
    }
  ],
  "fields": {
    "textfield": {
      "value": "Jane",
      "role": "user"
    }
  }
}

The role in the field tag (e.g., [textfield:user___]) must match a role assigned to a recipient.

Step 4: Wait for draft status

Document creation is asynchronous. The document is not ready until it reaches document.draft status. See Building a Reliable Document Creation Workflow for polling and webhook strategies.

Sample files

Test your integration with these sample files:

With native form fields:

With field tags:

Limitations

  • Only one file per request (multiple documents not supported).
  • Maximum file size: 100 MB (returns 413 Request Entity Too Large if exceeded).
  • Encrypted PDFs are not supported. To check: open the PDF properties and look for "Secure: Password Encrypted."
  • Supported formats: PDF, DocX, RTF.

Troubleshooting

Processing errors

ErrorCause
PDF content hasn't been processed: document is broken or lockedThe PDF is corrupted or password-protected. Verify the file opens correctly and is not encrypted.
Error occurred while parsing PDF field tags. Please try PDF flatteningAt least one field tag has invalid positioning (e.g., negative coordinates). Flatten the PDF and retry.

Field tag validation errors

ErrorCause
No role='{role}' for field tag specified in recipients foundThe role in a field tag doesn't match any recipient role in the request.
All field tags within PDF must be declared within fields object. No field with optId='{optid}' foundA field tag's optId is missing from the fields object in the request body.
One of field tags in PDF with type='{field}' doesn't have a roleA field tag is missing its role segment (e.g., [textfield:::optId___]).

Form field validation errors

ErrorCause
Role for form field with name='{name}' is not provided in payloadA native form field's role is missing from the request.
Field for form field with name='{name}' is not specified in payloadA native form field name doesn't appear in the fields object.
No role='{role}' for form field specified in 'recipients' foundThe role assigned to a form field doesn't match any recipient.

Source errors

ErrorCause
Failed to download file from link {url}The URL is unreachable or returned an error. Verify the URL is publicly accessible.
Content type='{type}' is not supportedThe file format is not PDF, DocX, or RTF.
The maximum file size is exceeded, limit is {limit} MBThe file exceeds the size limit. Reduce the file size or contact support.

Verification

  1. Check the document status -- confirm it reaches document.draft.
  2. Open the document in the PandaDoc web app to verify the file rendered correctly and fields are recognized.
  3. Use the Document Details endpoint to inspect fields, roles, and recipients programmatically.

Related