Skip to main content
All CollectionsIntegrationsAPI
API recipes: Create a document from a template and share it in real time
API recipes: Create a document from a template and share it in real time
M
Written by Marya Maksimchuk
Updated over a week ago

Availability: Enterprise*

* Additional volume charge will be applied for document generation via production API.

These instructions assume:

Locate your template ID

In the PandaDoc app, navigate to the template you’d like to use for this particular document. When you’re viewing the template, the template ID is the section of the URL after the final slash (/). 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 at https://developers.pandadoc.com/reference/new-document to decide what metadata and details you’ll 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.”

Create the document

mceclip0.png

Using your authentication token or API key, and the content-type application/json, add the following:Create the document

The response will contain the document ID as the element “id.”

mceclip1.png

Wait for the document to enter draft status

See Listening for changes in document status. If you’re actively polling your document, the ID is “id” from the previous step.

Send the document

Once you’ve determined that the document has entered “document.draft” status, you can send it by adding the following ({id} is the document ID from above):

You can also include these optional parameters in your POST to set a subject line and body text:

mceclip3.png

Generate a shared session

After the document is updated to “Sent,” you can generate a shared session ID by adding the following ({id} is the document ID from above):

Where {id} is the document ID from above.

mceclip6.png

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:

mceclip7.png

Embed the shared session in your page or app

This process creates a page at https://app.pandadoc.com/s/{id}. {id} 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.

Did this answer your question?