Automate Document Workflows
Automate repeatable document actions: upload, create, send, embed, and more.
Select a step in this workflow to skip to a corresponding section:
Prerequisites
- You have authenticated via OAuth (see Authentication process) or have an API key (see API key authentication process).
Create a document from a template
This guide assumes you have created created a template (see Save time with templates).
Get your template ID
In the PandaDoc app, navigate to the template you would like to use for this particular document. When you are viewing the template the ID is the final part of the URL. For example, in
https://app.pandadoc.com/a/#/templates/ustHNnVaPCD6MzuoNBbZ8L
the template ID is ustHNnVaPCD6MzuoNBbZ8L
.
Structure your document details
Use the create document endpoint description to decide what metadata and details you need to pass to your document. The simplest possible document schema consists of a name, template ID, and at least one recipient. Include your template ID under “template_uuid”
{
"name": "My minimal document",
"template_uuid": "ustHNnVaPCD6MzuoNBbZ8L",
"recipients": [
{
"email":"[email protected]"
}
]
}
Create the document
Using your authentication token or API key, and the Content-type: application/json
POST https://api.pandadoc.com/public/v1/documents
The response will contain the document ID as the element id
.
{
"id":"XHjv8z3SfDuTseFSnhprML",
"name":"My minimal document",
"Status":"document.uploaded",
"date_created":"2021-07-05T15:05:27.787341Z",
"date_modified":"2021-07-05T15:05:27.787341Z",
"Expiration_date":null,
"Version":null,
"uuid":"XHjv8z3SfDuTseFSnhprML"
}
Wait for the document to enter draft status
See Listening for changes in document status. If you are actively polling your document ID is “id” from the previous step.
Upload and send a local PDF
Prepare the original PDF
If you want to include PandaDoc native elements such as signature or text fields in your PDF-derived Document you’ll need to use either the PDF native form fields structure or add manual field tags to the PDF.
You can read more about the structure and respective benefits of form fields vs. field tags in the create document from pdf documentation. If you choose to use form fields, make sure you have set "parse_form_fields": true
, otherwise set "parse_form_fields": false
.
When you’ve finalized your PDF document, you’re ready for the next step.
POST the document to PandaDoc
To inform PandaDoc to ingest and parse your PDF, usePOST https://api.pandadoc.com/public/v1/documents/
with content type multipart/form-data
. You must have two sections within your POST:
- The encoded content of your PDF file itself:
------BoundaryXXXXXXXXX
Content-Disposition: form-data; name="file"; filename="Sample PandaDoc PDF with Field Tags.pdf"
Content-Type: application/pdf
[file contents here]
------BoundaryXXXXXXXXX
- A JSON block to identify the Document:
------BoundaryXXXXXXXXX
Content-Disposition: form-data; name="data"
{
"name": "My minimal document",
"url": "https://example.com/path/to/mydocument.pdf",
"recipients": [
{
"email":"[email protected]"
}
],
"parse_form_fields": false
}
------BoundaryXXXXXXXXX
The response contains the document ID as the element id
:
{
"id":"XHjv8z3SfDuTseFSnhprML",
"name":"My minimal document",
"Status":"document.uploaded",
"date_created":"2021-07-05T15:05:27.787341Z",
"date_modified":"2021-07-05T15:05:27.787341Z",
"Expiration_date":null,
"Version":null,
"uuid":"XHjv8z3SfDuTseFSnhprML"
}
Wait for the document to enter a draft status
See Listening for changes in document status. If you are actively polling your document ID is “id” from the previous step.
Send the document
Once you’ve determined that the document has entered document.draft
status, you need to send it with a
POST <https://api.pandadoc.com/public/v1/documents/{id}/send>
request, where {id}
is the document ID from the previous step. Even if you don’t plan to send this Document via email, it’s still necessary to move it to the sent
status to lock in changes from the draft and enable a shared session.
If you want, you can include the optional parameters in your POST to set a subject line and body text:
{
"message": "Hello! This document was sent from the PandaDoc API.",
"subject": "Please check this test API document from PandaDoc"
}
You need your document to be in the sent
status for both sharing scenarios:
- If you set the
"silent": false
parameter, an email goes out with the document link. - If you want to embed your document for signing, select
"silent": true
.
Generate a shared session
After the Document is updated to “Sent” you can generate a shared session ID
POST https://api.pandadoc.com/public/v1/documents/{id}/session
Where {id} is the document ID from above.
{
"recipient": "[email protected]",
"lifetime": 90000
}
You must choose a recipient, even though this won’t be used in silent mode. Lifetime determines the number of seconds that the document link will live for and is optional. It will default to 3600 seconds.
This endpoint will respond with an ID and expiration timestamp
{
"id": "QYCPtavst3DqqBK72ZRtbF",
"expires_at": "2022-08-29T22:18:44.315Z"
}
Embed the shared session in your page or app
This process creates a page at
https://app.pandadoc.com/s/{id}
where {id} in this instance is QYCPtavst3DqqBK72ZRtbF
from above. This page can be embedded in an iframe in your application, or you can send it to recipients to open directly. Learn more: Embedded Signing.
Download document
Using the document ID you can leverage the document download endpoint to retrieve your document.
GET https://api.pandadoc.com/public/v1/documents/{id}/download
. Learn more: Download a Completed Document.
Updated 10 months ago