API & Webhook Integration

Generate Documents using Webhooks & APIs

Webhook Integration

You can configure webhook in your CRM, Forms to send data to Docupilot to create your document.

Webhook Endpoint

Http Method : POST

Content-Type : application/json

https://api.docupilot.app/documents/create/{org_unique}/{document_unique}

Sample Endpoint
https://api.docupilot.app/documents/create/46ac75c3/5e7d03ec

You can find this URL in Create section in template's details page.
Sample Template
Hello {{name}},

{{email}}
{{address}} {{state}} {{country}}
sample data in JSON format
{
"name":"John",
"email":"johj@example.com",
"address":"XYZ Street",
"state":"CA",
"country":"USA"
}

Please note that the tokens(merge fields) defined in the template should match the keys in the webhook data.

API Integration

If you want to download the created document along with triggering deliveries you need to append download=true parameter in the URL. A secure file url with 24 hour expiry is provided to download the document.

https://api.docupilot.app/documents/create/{org_unique}/{template_unique}?download=true

If you want to download the created document directly along with triggering deliveries you need to append download=file parameter in the URL. The created document is returned in the API response.

https://api.docupilot.app/documents/create/{org_unique}/{template_unique}?download=file

CURL

curl -X POST \
  https://api.docupilot.app/documents/create/46ac75c3/5e7d03ec \
  -H 'Content-Type: application/json' \
  -d '{
"customer_name":"John",
"customer_email":"john@example.com",
"line_items":[
    {
        "description":"Design",
        "quantity":1,
        "price":"230"
    },
    {
        "description":"Development",
        "quantity":4,
        "price":"130"
    }
]
}'

Python

import requests

url = "https://api.docupilot.app/documents/create/46ac75c3/5e7d03ec"

payload = {
"customer_name":"John",
"customer_email":"john@example.com",
"line_items":[
    {
        "description":"Design",
        "quantity":1,
        "price":"230"
    },
    {
        "description":"Development",
        "quantity":4,
        "price":"130"
    }
]
}
headers = {
    'Content-Type': "application/json"
    }

response = requests.post(url, data=payload, headers=headers)

print(response.text)

API Response

API response with download parameter or no deliveries configured.

{
    "status": "success",
    "data": {
        "file_url": "https://docupilot-documents.s3.amazonaws.com/temp/1a2cadd4-33f7-4f0c-9d9a-3e87803d3e7b/contract.pdf?AWSAccessKeyId=AKIAJTKZBQI56EOPGLFQ&Signature=BHG3mejXO3f1ymBcZVjMB04Sr6U%3D&Expires=1530277229",
        "file_name": "contract.pdf"
    }
}
API response with deliveries configured.

{
    "status": "success",
    "data": null
}

Last updated