LogoLogo
HomePricingSign inRegister
  • PDFMonkey Documentation
  • Guides
    • From zero to generating your first Document
    • Generating your first Document with Zapier
    • Generating your first Document with Make
    • Making your first API call
  • PDFMonkey Features
    • 14-day Pro trial
    • Automatic deletion (TTL)
    • CLI
    • Generating images
    • Share links
    • Synchronous generation
    • Snippets
    • Webhooks
  • Frequent questions
    • Troubleshooting
      • My Document is blank
      • My data is not showing up in the Document
      • The Download URL is empty
    • What can you do with PDFMonkey?
    • What happens if I use all of my quota?
    • How do I change my password?
    • How do I delete my account?
    • Authoring Templates
      • Can I import an existing PDF or Word file in PDFMonkey?
      • What are the Template test data?
      • Can you create templates for me?
      • Can I display the number of the current page in the content?
      • Can I use links?
    • Privacy and security
      • What data do you keep and for how long?
      • How is my data secured?
      • Do you have a DPA
    • Compliance
  • How-tos
    • Adding a header or footer to your document
    • Including images in your documents
    • Styling your documents
      • Writing your own CSS
      • Using external libraries
      • Providing per-Document styles
      • Dealing with page breaks
    • Using different fonts
      • Handling special characters (UTF-8, Hebrew, Chinese, etc)
      • Using different fonts in header and footer
    • Using JavaScript
      • What are the available JavaScript features
      • JavaScript and Dynamic Data
      • Using external libraries
      • Displaying dates and time using JS
      • Including charts in your Documents
      • Debugging your JavaScript
    • Setting the filename of the generated Document
    • Changing the size of the page and its margins
    • Forcing a single page or use a full-page background
    • Using QR Codes
  • Integrations
    • List of integrations
    • Zapier
      • Generating your first Document with Zapier
      • Document generation options in Zapier
      • Reacting to generated documents in Zapier
      • TODO Retrieving a Document in Zapier
      • TODO Deleting a document using Zapier
      • Fixing frequent Zapier errors
    • Make (formerly Integromat)
      • Generating your first Document with Make
    • Workato
      • Generating a document with Workato
      • Deleting a document using Workato
      • Reacting to generated documents in Workato
    • Glide
    • Bubble
    • InvoiceBerry (via Zapier)
    • Ruby SDK
  • References
    • The Document Lifecycle
    • Liquid Reference
      • Introduction
      • Defining and using dynamic data
      • Variables
      • Naming variables
      • Conditions (if/else)
      • Iteration (dealing with lists)
      • Filters (data transformation)
        • Built-in filters
        • PDFMonkey filters
      • PDFMonkey Liquid tags
      • Whitespace control
    • API Reference
      • Documents
      • Templates
Powered by GitBook
On this page
  • TL;DR
  • Sample HTTP request to generate a Document
  • Response
  • Sample HTTP request to fetch details about a document
  • Response
  • Two Objects To Know
  • Rules of thumb
  • The Document object
  • Attributes
  • The DocumentCard object
  • Attributes
  • Listing Documents
  • Lists the DocumentCards for your Documents
  • Fetching a Document
  • Fetching a DocumentCard
  • Fetches the DocumentCard data for a given Document
  • Fetching a Document
  • Fetches the data for a given Document
  • Creating a Document
  • Creates a Document
  • Example
  • Attaching meta data to the Document
  • Generating the Document upon creation
  • Generating a Document
  • Updating a Document
  • Updates an existing Document
  • Deleting a Document
  • Deletes a Document

Was this helpful?

  1. References
  2. API Reference

Documents

Learn how to generate or fetch your PDF documents with the PDFMonkey API

TL;DR

Sample HTTP request to generate a Document

curl \
  "https://api.pdfmonkey.io/api/v1/documents" \
  -X POST \
  -H 'Authorization: Bearer YOUR-API-KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "document": {
      "document_template_id": "ID-OF-YOUR-TEMPLATE",
      "status": "pending", // To force generation to be queued upon creation
      "payload": {
        "clientName": "Peter Parker",
        "orderDate": "2050-03-14",
        "products": [
          { "name": "Spider silk", "quantity": 12, "unitPrice": 123.50 },
          { "name": "Spandex fabric", "quantity": 2, "unitPrice": 28.90 }
        ]
      },
      "meta": {
        "_filename": "2050-03-14 Peter Parker.pdf",
        "clientRef": "spidey-616"
      }
    }
  }'

Response

201 Created
{
  "document": {
    "id": "12345678-1234-1234-1234-123456789012",
    "document_template_id": "ID-OF-YOUR-TEMPLATE",
    "status": "generating", // Document is queued (could also still be "pending")
    "failure_cause": null, // Filled in case of error
    "filename": "2050-03-14 Peter Parker.pdf",
    "download_url": null, // Not filled until generation success
    "preview_url": "https://...", // Usable to embed a preview of the PDF in your app
    "public_share_link": null, // Filled upon generation success on a Pro+/Premium plan
    "payload": {
      "clientName": "Peter Parker",
      "orderDate": "2050-03-14",
      "products": [
        { "name": "Spider silk", "quantity": 12, "unitPrice": 123.50 },
        { "name": "Spandex fabric", "quantity": 2, "unitPrice": 28.90 }
      ]
    },
    "meta": {
      "_filename": "2050-03-14 Peter Parker.pdf",
      "clientRef": "spidey-616"
    },
    "created_at": "2050-03-13T12:34:56.181+02:00",
    "updated_at": "2050-03-13T12:34:56.181+02:00"
  }
}

Sample HTTP request to fetch details about a document

curl \
    -H 'Authorization: Bearer YOUR-API-KEY' \
    https://api.pdfmonkey.io/api/v1/document_cards/12345678-1234-1234-1234-123456789012

Response

200 OK
{
  "id": "12345678-1234-1234-1234-123456789012",
  "app_id": "c2b67b84-4aac-49ea-bed8-69a15d7a65d3",
  "created_at": "2022-04-07T11:01:38.201+02:00",
  "document_template_id": "96611e9e-ab03-4ac3-8551-1b485210c892",
  "document_template_identifier": "My Awesome Template",
  "download_url": "https://pdfmonkey.s3.eu-west-1.amazonaws.com/production/backend/document/11475e57-0334-4ad5-8896-9462a2243957/my-test-document.pdf?response-content-disposition=attachment&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ2ZTKW4HMOLK63IQ%2F20220406%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20220407T204150Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=24e3a8c0801ad8d1efd6aaa22d946ee70f5c8d5b55c586f346a094afa5046c77",
  "failure_cause": null,
  "filename": "my-test-document.pdf",
  "meta": "{ \"_filename\":\"my-test-document.pdf\" }",
  "public_share_link": "https://files.pdfmonkey.io/share/72BE2293-D130-4C19-9E11-C82B5CEA8C37/my-test-document.pdf",
  "status": "success",
  "updated_at": "2022-04-07T11:01:41.181+02:00"
}

Two Objects To Know

When you interact with your Documents, there are two objects you need to be aware of: Document and DocumentCard.

The main distinction between the two is that DocumentCard does not include the payload attribute of the Document. This matters because in many cases, this attribute will have a important size and will thus have an impact on performance on both your side and ours.

Rules of thumb

  1. Always prefer DocumentCard unless you really need access to payload

  2. Store any data you need later on in meta instead of (or in addition to) payload that way you won't need access to payload

The Document object

The Document object represents a single document (PDF), with its status, data and meta-data. It is used to manipulate the data used to generate a PDF.

Attributes

Document JSON
{
  "id": "11475e57-0334-4ad5-8896-9462a2243957",
  "app_id": "c2b67b84-4aac-49ea-bed8-69a15d7a65d3",
  "checksum": "c230530f6f0aa32900af0924cf228e5c",
  "created_at": "2022-04-07T11:01:38.201+02:00",
  "document_template_id": "96611e9e-ab03-4ac3-8551-1b485210c892",
  "download_url": "https://pdfmonkey.s3.eu-west-1.amazonaws.com/production/backend/document/11475e57-0334-4ad5-8896-9462a2243957/my-test-document.pdf?response-content-disposition=attachment&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ2ZTKW4HMOLK63IQ%2F20220406%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20220407T204150Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=24e3a8c0801ad8d1efd6aaa22d946ee70f5c8d5b55c586f346a094afa5046c77",
  "failure_cause": null,
  "filename": "my-test-document.pdf",
  "generation_logs": [
    {
      "type": "info",
      "message": "Starting PDF generation.",
      "timestamp": "Thu, 07 Apr 2022 09:01:39 GMT"
    },
    {
      "type": "info",
      "message": "CONTEXT: {\n  origin: 'backend',\n  type: 'document',\n  id: '11475e57-0334-4ad5-8896-9462a2243957',\n  filename: 'my-test-document.pdf'\n}",
      "timestamp": "Thu, 07 Apr 2022 09:01:39 GMT"
    },
    {
      "type": "info",
      "message": "Generation took 1617ms to load and render.",
      "timestamp": "Thu, 07 Apr 2022 09:01:40 GMT"
    },
    {
      "type": "info",
      "message": "Content size is 96302.",
      "timestamp": "Thu, 07 Apr 2022 09:01:40 GMT"
    },
    {
      "type": "info",
      "message": "Document stored as production/backend/document/11475e57-0334-4ad5-8896-9462a2243957/my-test-document.pdf",
      "timestamp": "Thu, 07 Apr 2022 09:01:40 GMT"
    }
  ],
  "meta": "{ \"_filename\":\"my-test-document.pdf\" }",
  "payload": "{ \"name\": \"Peter Parker\" }",
  "preview_url": "https://preview.pdfmonkey.io/pdf/web/viewer.html?file=https%3A%2F%2Fpreview.pdfmonkey.io%2Fdocument-render%2F11475e57-0334-4ad5-8896-9462a2243957%2Fc230530f6f0aa32900af0924cf228e5c",
  "public_share_link": "https://files.pdfmonkey.io/share/72BE2293-D130-4C19-9E11-C82B5CEA8C37/my-test-document.pdf",
  "status": "success",
  "updated_at": "2022-04-07T11:01:41.181+02:00"
}

id

(String, UUID) Unique identifier for the object.

app_id

(String, UUID) Unique identifier of the Document's Workspace.

checksum

(String) Internal checksum of the Document's content, mainly used for the Document's preview.

created_at

(String, Date) Time at which the object was created.

document_template_id

(String, UUID) Unique identifier of the Document's Template.

download_url

(String, URL) The URL at which the Document can be downloaded.

Valid for 1 hour

Any time you fetch the details of a document, you get a fresh download URL. It is valid for 1 hour. Once that time has passed, you'll need to fetch the Document's details again to get a fresh URL.

failure_cause

(String) In case the Document's status is failure, this field will contain the reason of the failure. In any other case, this will be null.

filename

(String) Name of the generated file when the Document's status is success, will be null otherwise.

generation_logs

(Array of Objects) Logs collected during the Document's generation. Can be especially useful in case of generation failure.

type: Can be info or error message: The log message timestamp: The date and time of the log message

Will default to an empty array [] before the generation.

meta

(String, JSON) The meta-data of the Document. Can be null or an arbitrary object containing data that you want to attach to a Document. This can be useful when using integrations, like Zapier or Integromat, as the payload will not be accessible.

payload

preview_url

(String, URL) This URL is especially useful if you want to embed a preview of the PDF in your own UI. A good example of this is the preview in our own dashboard, when you create a new Document.

This is not a Download URL!

This attributes is often mixed up with the Download URL but it cannot be used to download a generated PDF, it should only be used in an iframe.

public_share_link

Premium plan only

The share links feature is only available for Premium plans.

status

updated_at

(String, Date) Time at which the object was last updated.

The DocumentCard object

The DocumentCard object is a lightweight version of the Document. It contains almost the same information but excludes the payload.

Attributes

DocumentCard JSON
{
  "id": "11475e57-0334-4ad5-8896-9462a2243957",
  "app_id": "c2b67b84-4aac-49ea-bed8-69a15d7a65d3",
  "created_at": "2022-04-07T11:01:38.201+02:00",
  "document_template_id": "96611e9e-ab03-4ac3-8551-1b485210c892",
  "document_template_identifier": "My Awesome Template",
  "download_url": "https://pdfmonkey.s3.eu-west-1.amazonaws.com/production/backend/document/11475e57-0334-4ad5-8896-9462a2243957/my-test-document.pdf?response-content-disposition=attachment&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ2ZTKW4HMOLK63IQ%2F20220406%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20220407T204150Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=24e3a8c0801ad8d1efd6aaa22d946ee70f5c8d5b55c586f346a094afa5046c77",
  "failure_cause": null,
  "filename": "my-test-document.pdf",
  "meta": "{ \"_filename\":\"my-test-document.pdf\" }",
  "public_share_link": "https://files.pdfmonkey.io/share/72BE2293-D130-4C19-9E11-C82B5CEA8C37/my-test-document.pdf",
  "status": "success",
  "updated_at": "2022-04-07T11:01:41.181+02:00"
}

id

(String, UUID) Unique identifier for the object.

app_id

(String, UUID) Unique identifier of the Document's Workspace.

created_at

(String, Date) Time at which the object was created.

document_template_id

(String, UUID) Unique identifier of the Document's Template.

document_template_identifier

(String) The name you gave to the Document's Template.

download_url

(String, URL) The URL at which the Document can be downloaded.

Valid for 1 hour

Any time you fetch the details of a document, you get a fresh download URL. It is valid for 1 hour. Once that time has passed, you'll need to fetch the Document's details again to get a fresh URL.

failure_cause

(String) In case the Document's status is failure, this field will contain the reason of the failure. In any other case, this will be null.

filename

(String) Name of the generated file when the Document's status is success, will be null otherwise.

meta

(String, JSON) The meta-data of the Document. Can be null or an arbitrary object containing data that you want to attach to a Document. This can be useful when using integrations, like Zapier or Integromat, as the payload will not be accessible.

public_share_link

Premium plan only

The share links feature is only available for Premium plans.

status

updated_at

(String, Date) Time at which the object was last updated.

Listing Documents

In most cases, when listing Documents, you will only need to use DocumentCards.

Lists the DocumentCards for your Documents

GET

This endpoint is limited to 24 items and provides pagination data.

Query Parameters

Name
Type
Description

page[number]

Integer

Number of the page to show (default 1)

q[document_template_id]

Array<UUID>

List of Template IDs to filter on

q[status]

String

Can be one of: • success • failure • draft

q[workspace_id]

UUID

ID of a workspace to filter on

q[updated_since]

Timestamp

Filter documents that have been updated after a given point in time (example 1640995200 for 2022-01-01 00:00:00)

{
  "document_cards": [
    {
      "id": "11475e57-0334-4ad5-8896-9462a2243957",
      "app_id": "c2b67b84-4aac-49ea-bed8-69a15d7a65d3",
      "created_at": "2022-04-07T11:01:38.201+02:00",
      "document_template_id": "96611e9e-ab03-4ac3-8551-1b485210c892",
      "document_template_identifier": "My Awesome Template",
      "download_url": "https://pdfmonkey.s3.eu-west-1.amazonaws.com/production/backend/document/11475e57-0334-4ad5-8896-9462a2243957/my-test-document.pdf?response-content-disposition=attachment&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ2ZTKW4HMOLK63IQ%2F20220406%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20220407T204150Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=24e3a8c0801ad8d1efd6aaa22d946ee70f5c8d5b55c586f346a094afa5046c77",
      "failure_cause": null,
      "filename": "my-test-document.pdf",
      "meta": "{ \"_filename\":\"my-test-document.pdf\" }",
      "public_share_link": "https://files.pdfmonkey.io/share/5CEA8C37-D130-4C19-9E11-72BE2293C82B/my-test-document.pdf",
      "status": "success",
      "updated_at": "2022-04-03T11:12:56.023+02:00"
    },
    {
      "id": "a2243957-0334-4ad5-8896-11475e579462",
      "app_id": "c2b67b84-4aac-49ea-bed8-69a15d7a65d3",
      "created_at": "2022-04-07T11:01:38.201+02:00",
      "document_template_id": "96611e9e-ab03-4ac3-8551-1b485210c892",
      "document_template_identifier": "My Awesome Template",
      "download_url": "https://pdfmonkey.s3.eu-west-1.amazonaws.com/production/backend/document/11475e57-0334-4ad5-8896-9462a2243957/my-test-document.pdf?response-content-disposition=attachment&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ2ZTKW4HMOLK63IQ%2F20220406%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20220407T204150Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=24e3a8c0801ad8d1efd6aaa22d946ee70f5c8d5b55c586f346a094afa5046c77",
      "failure_cause": null,
      "filename": "my-test-document.pdf",
      "meta": "{ \"_filename\":\"my-test-document.pdf\" }",
      "public_share_link": "https://files.pdfmonkey.io/share/72BE2293-D130-4C19-9E11-C82B5CEA8C37/my-test-document.pdf",
      "status": "success",
      "updated_at": "2022-04-07T11:01:41.181+02:00"
    }
  ]
}

Fetching a Document

Fetching a DocumentCard

Fetches the DocumentCard data for a given Document

GET https://api.pdfmonkey.io/api/v1/document_cards/ID

Path Parameters

Name
Type
Description

ID*

UUID

ID of the Document to fetch

{
  "document_card": {
    "id": "11475e57-0334-4ad5-8896-9462a2243957",
    "app_id": "c2b67b84-4aac-49ea-bed8-69a15d7a65d3",
    "created_at": "2022-04-07T11:01:38.201+02:00",
    "document_template_id": "96611e9e-ab03-4ac3-8551-1b485210c892",
    "document_template_identifier": "My Awesome Template",
    "download_url": "https://pdfmonkey.s3.eu-west-1.amazonaws.com/production/backend/document/11475e57-0334-4ad5-8896-9462a2243957/my-test-document.pdf?response-content-disposition=attachment&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ2ZTKW4HMOLK63IQ%2F20220406%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20220407T204150Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=24e3a8c0801ad8d1efd6aaa22d946ee70f5c8d5b55c586f346a094afa5046c77",
    "failure_cause": null,
    "filename": "my-test-document.pdf",
    "meta": "{ \"_filename\":\"my-test-document.pdf\" }",
    "public_share_link": "https://files.pdfmonkey.io/share/72BE2293-D130-4C19-9E11-C82B5CEA8C37/my-test-document.pdf",
    "status": "success",
    "updated_at": "2022-04-07T11:01:41.181+02:00"
  }
}

Fetching a Document

Fetches the data for a given Document

GET https://api.pdfmonkey.io/api/v1/documents/ID

Path Parameters

Name
Type
Description

ID*

UUID

ID of the Document to fetch

{
  "document": {
    "id": "11475e57-0334-4ad5-8896-9462a2243957",
    "app_id": "c2b67b84-4aac-49ea-bed8-69a15d7a65d3",
    "checksum": "c230530f6f0aa32900af0924cf228e5c",
    "created_at": "2022-04-07T11:01:38.201+02:00",
    "document_template_id": "96611e9e-ab03-4ac3-8551-1b485210c892",
    "download_url": "https://pdfmonkey.s3.eu-west-1.amazonaws.com/production/backend/document/11475e57-0334-4ad5-8896-9462a2243957/my-test-document.pdf?response-content-disposition=attachment&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJ2ZTKW4HMOLK63IQ%2F20220406%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Date=20220407T204150Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=24e3a8c0801ad8d1efd6aaa22d946ee70f5c8d5b55c586f346a094afa5046c77",
    "failure_cause": null,
    "filename": "my-test-document.pdf",
    "generation_logs": [
      {
        "type": "info",
        "message": "Starting PDF generation.",
        "timestamp": "Thu, 07 Apr 2022 09:01:39 GMT"
      },
      {
        "type": "info",
        "message": "CONTEXT: {\n  origin: 'backend',\n  type: 'document',\n  id: '11475e57-0334-4ad5-8896-9462a2243957',\n  filename: 'my-test-document.pdf'\n}",
        "timestamp": "Thu, 07 Apr 2022 09:01:39 GMT"
      },
      {
        "type": "info",
        "message": "Generation took 1617ms to load and render.",
        "timestamp": "Thu, 07 Apr 2022 09:01:40 GMT"
      },
      {
        "type": "info",
        "message": "Content size is 96302.",
        "timestamp": "Thu, 07 Apr 2022 09:01:40 GMT"
      },
      {
        "type": "info",
        "message": "Document stored as production/backend/document/11475e57-0334-4ad5-8896-9462a2243957/my-test-document.pdf",
        "timestamp": "Thu, 07 Apr 2022 09:01:40 GMT"
      }
    ],
    "meta": "{ \"_filename\":\"my-test-document.pdf\" }",
    "payload": "{ \"name\": \"Peter Parker\" }",
    "preview_url": "https://preview.pdfmonkey.io/pdf/web/viewer.html?file=https%3A%2F%2Fpreview.pdfmonkey.io%2Fdocument-render%2F11475e57-0334-4ad5-8896-9462a2243957%2Fc230530f6f0aa32900af0924cf228e5c",
    "public_share_link": "https://files.pdfmonkey.io/share/72BE2293-D130-4C19-9E11-C82B5CEA8C37/my-test-document.pdf",
    "status": "success",
    "updated_at": "2022-04-07T11:01:41.181+02:00"
  }
}

Creating a Document

Creates a Document

POST https://api.pdfmonkey.io/api/v1/documents

Headers

Name
Type
Description

Content-Type*

String

application/json

Request Body

Name
Type
Description

document[document_template_id]*

UUID

ID of the source Template to use

document[payload]

Object or String

Data to use for the Document generation. Can be either an Object or a string of JSON. Must be a single Object in any case.

document[meta]

Object or String

Meta-Data to attach to the Document. Can be either an Object or a string of JSON. Must be a single Object in any case.

document[status]

String

Can be one of: • draft (default) • pending (to trigger generation)

{
  "document": {
    "id": "11475e57-0334-4ad5-8896-9462a2243957",
    "created_at": "2022-05-09T16:53:14.487+02:00",
    "document_template_id": "96611e9e-ab03-4ac3-8551-1b485210c892",
    "meta": null,
    "payload": null,
    "status": "draft",
    "updated_at": "2022-05-09T16:53:14.487+02:00",
    "app_id": "c2b67b84-4aac-49ea-bed8-69a15d7a65d3",
    "download_url": null,
    "checksum": "529e58bf3c29f864dc5d319318e7e30d",
    "failure_cause": null,
    "filename": null,
    "generation_logs": [],
    "preview_url": "https://preview.pdfmonkey.io/pdf/web/viewer.html?file=https%3A%2F%2Fpreview.pdfmonkey.io%2Fdocument-render%2F8939a8b6-d4bb-49d5-816f-8909b04ae059%2F529e58bf3c29f864dc5d319318e7e30d",
    "public_share_link": null
  }
}
{
  "errors": {
    "document_template_id": ["can't be blank"]
  }
}

Example

POST https://api.pdfmonkey.io/api/v1/documents
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
  "document": {
    "document_template_id": "12345678-90ab-cdef-1234-567890abcdef",
    "payload": {
      "name": "Jane Doe"
    },
    "meta": {
      "clientId": "ABC1234-DE",
      "_filename": "my-document.pdf"
    }
  }
}

Attaching meta data to the Document

In addition to the Document’s payload you can add meta data when generating a Document.

Generating the Document upon creation

If you want to generate the Document in one go, you can set its status to pending. Doing so, the Document will be queued for generation directly.

POST https://api.pdfmonkey.io/api/v1/documents
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
  "document": {
    "document_template_id": "12345678-90ab-cdef-1234-567890abcdef",
    "status": "pending",
    "payload": {
      "name": "Jane Doe"
    },
    "meta": {
      "clientId": "ABC1234-DE",
      "_filename": "my-document.pdf"
    }
  }
}

Generating a Document

To generate a Document you can either:

Updating a Document

Updates an existing Document

PUT https://api.pdfmonkey.io/api/v1/documents/ID

Headers

Name
Type
Description

Content-Type*

String

application/json

Request Body

Name
Type
Description

document[document_template_id]

UUID

ID of the source Template to use

document[payload]

Object or String

Data to use for the Document generation. Can be either an Object or a string of JSON. Must be a single Object in any case.

document[meta]

Object or String

Meta-Data to attach to the Document. Can be either an Object or a string of JSON. Must be a single Object in any case.

document[status]

String

Can be one of: • draft (default) • pending (to trigger generation)

{
  "document": {
    "id": "8939a8b6-d4bb-49d5-816f-8909b04ae059",
    "created_at": "2022-05-09T16:53:14.487+02:00",
    "document_template_id": "4E666986-54C1-4CD8-BBE8-A3896CEEE6C7",
    "meta": null,
    "payload": null,
    "status": "draft",
    "updated_at": "2022-05-09T16:58:43.425+02:00",
    "app_id": "3161c5e5-9966-4630-9b07-63f718092738",
    "download_url": null,
    "checksum": "529e58bf3c29f864dc5d319318e7e30d",
    "failure_cause": null,
    "filename": null,
    "generation_logs": [],
    "preview_url": "https://preview.pdfmonkey.io/pdf/web/viewer.html?file=https%3A%2F%2Fpreview.pdfmonkey.io%2Fdocument-render%2F8939a8b6-d4bb-49d5-816f-8909b04ae059%2F529e58bf3c29f864dc5d319318e7e30d",
    "public_share_link": null
  }
}

Deleting a Document

Deletes a Document

DELETE https://api.pdfmonkey.io/api/v1/documents/ID

Path Parameters

Name
Type
Description

ID*

UUID

ID of the Document to delete

{
    // Response
}
PreviousAPI ReferenceNextTemplates

Last updated 11 months ago

Was this helpful?

(String, JSON) The used to build the content of the Document. Must represent a JSON object, not an array.

(String, URL) This URL will be present if your account has enabled. It is a permalink to the generated PDF.

(String) Represents the current status of the Documents. You can learn more in .

(String, URL) This URL will be present if your account has enabled. It is a permalink to the generated PDF.

(String) Represents the current status of the Documents. You can learn more in .

This can be done by passing the document[meta] attribute. It can contain special keys to for instance.

and give it the pending status

to give it the pending status

dynamic data
Share Links
Share Links
influence the generated filename
Create a Document
Update an existing draft Document
the Document Lifecycle documentation page
the Document Lifecycle documentation page