Create a Document from File Upload
Upload a PDF, DocX, or an RTF to create a document.
Create from an upload or a URL
You have two options to create a document from file:
- Upload a local file. For this, use the
multipart/form-datarequest type. Typically, the frameworks are handling the headers and you just need to pass a file to the request. - Send a public URL in the document creation request like this:
curl --request POST 'https://api.pandadoc.com/public/v1/documents' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "My minimal 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 from public PDF guide for more details.
Note: A file you upload is not stored in your PandaDoc account, so you have to upload it with every request.
Samples
We support PDF, DocX, and RTF. We've prepared two samples that you can use to test the request. Download them here:
Form Fields:
Field Tags:
Limitations
- This method does not support multiple documents.
- The maximum supported file size is 100 MB. API returns "413 Request entity too large" in case of bigger files.
- PandaDoc does not support creating document from an encrypted PDF. To check whether a file is encrypted or not, try Get info -> Secure: Password Encrypted.
See all possible errors and the ways to mitigate them: Error handling.
Document creation is a non-blocking (asynchronous) operationThe document creation process may take time.
With a successful request, you receive a response with the created document's ID and status
document.uploaded. After processing completes on our servers, usually a few seconds, the document moves to thedocument.draftstatus. Please wait for the webhook call or check this document's status before proceeding.The change of status from
document.uploadedto another status signifies the document is ready for further processing. Attempting to use a newly created document before PandaDoc servers process it will result in a "404 document not found" response.
PDF form fields
PandaDoc can recognize native PDF form fields (text fields, dropdowns, and signatures) when you set parse_form_fields to true in the create document request.
For details on configuring form fields and using optId mappings, see Form Fields.
PDF/DocX/RTF field tags
Field tags let you embed form fields (signatures, text fields, checkboxes, dates, etc.) directly in your PDF, DocX, or RTF file using bracket notation such as [textfield:s1:optId___]. PandaDoc parses these tags during document creation and converts them into interactive form fields.
For the full syntax, supported field types, and limitations, see Field Tags.
Create on member's behalf
Create documents on your colleagues' behalf when it's needed. Simply add an additional owner section in the document creation request.
You can set an owner of a document as an email or membership_id. Unique member's identifier you may find in the List Members.
"owner":{
"email":"[email protected]"
}"owner":{
"membership_id":"radQBiBkU7MBk59NSgaGfd"
}Roles
To set roles for a document from a PDF upload, you need to do these things:
- Associate the field tag in a document with a recipient role. For example,
textfield:user___denotes a required text field assigned to the role "user" - Assign roles to recipients in the request body
fieldssection:
"fields": {
"textfield": {
"value": "Jane",
"role": "user"
}
}
Signing order
Set a signing order for documents created from a file.
"recipients": [
{
"email": "[email protected]",
"first_name": "Josh",
"last_name": "Ron",
"role": "user",
"signing_order": 1
}
]Error handling
Error description | Type | Root cause |
|---|---|---|
PDF content hasn't been processed: document is broken or locked | Processing errors: Failed to process document content | Document converter service can’t process PDF. This may be caused by locked PDF or if it’s broken. |
Error occurred while parsing PDF field tags. Please try PDF flattening or reach out to support | Processing errors: Field tag / Form field validation error | Doc converter managed to parse PDF and extract tags, but at least 1 of them is invalid (having negative position, for example). Usually we recommend PDF flattening and it helps |
No role='{role}' for field tag specified in | Validation errors: Field tags | Role is invalid. When the role specified in field tag is empty or wasn’t provided in a payload for any recipient |
All field tags within PDF must be declared within | Validation errors: Field tags | Label is invalid. Occurs when optId specified in field tag is empty or no field with name = optId was provided in a payload |
One of field tags in PDF with type='{field}' doesn't have a role | Validation errors: Field tags | Field tag in PDF has no role. One of field tags in PDF with type=% doesn't have a role. |
Role for form field with name='{role}' is not provided in payload | Validation errors: Form fields | Role for form field with ‘name’ is not provided. Occurs when |
Field for form field with name='{name}' is not specified in payload, available names are {names} | Validation errors: Form fields | Field ‘name’ is not specified in payload. Occurs when no field with name = form field name was provided in a payload |
No role='{role}' for form field specified in 'recipients' found, roles passed were {roles}" | Validation errors: Form fields | Failed to resolve field actor for |
Failed to download file from link {url}. | Source errors | Error on attempt to download file. |
Failed to download file from link {url} (status code: {status code}) | Source errors | Error with HTTP status code on attempt to download file. |
Content type='{type}' is not supported, available types are {types} | Source errors | Content type is not supported. |
The maximum file size is exceeded, limit is {limit} MB | Source errors | The file size has exceeded the allowed limits. An error occurred while trying to download a file that is too large (limit is 50M). |
Updated 2 days ago
