Skip to main content
POST
/
createDocument
Create Document via API
curl --request POST \
  --url https://api.docsautomator.co/createDocument \
  --header 'Content-Type: application/json' \
  --data '
{
  "docId": "<string>",
  "data": {},
  "documentName": "<string>",
  "async": true,
  "webhookParams": {},
  "existingPdfs": [
    "<string>"
  ],
  "docTemplateLink": "<string>"
}
'
When your automation’s data source is set to API, you pass all field data directly in the request body. This is the most flexible option, as you control exactly what data goes into the document.

Endpoint

POST https://api.docsautomator.co/createDocument

Request Body

docId
string
required
The automation ID. Find it on the automation’s settings page or via GET /automations.
data
object
required
Key-value pairs for template placeholders. Keys must match the placeholder names in your template (e.g., {{customer_name}} in your template → "customer_name" in the data object). Line items are also included inside this object as line_items_1, line_items_2, etc. — see Example with Line Items below.
documentName
string
Custom name for the generated document. Overrides the automation’s document name setting.
async
boolean
default:"false"
When true, returns immediately with a jobId (HTTP 202). Poll GET /job/{jobId} for the result.
webhookParams
object
Custom parameters passed through to webhook notifications as additionalParams.
existingPdfs
string[]
Array of publicly accessible PDF URLs to merge or prepend to the generated document.
Override the automation’s Google Doc template URL for this request only. Pass a full Google Docs URL or just the document ID.

Basic Example

curl -X POST https://api.docsautomator.co/createDocument \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "docId": "YOUR_AUTOMATION_ID",
    "data": {
      "customer_name": "Acme Corp",
      "invoice_number": "INV-2025-001",
      "invoice_date": "2025-01-15",
      "due_date": "2025-02-15",
      "total": "$5,500.00"
    }
  }'

Example with Line Items

Pass line items as arrays inside the data object. Use line_items_1 for the first group, line_items_2 for a second group, and so on — there is no limit on the number of line item groups. Each object’s keys must match the line item placeholder names in your template.
curl -X POST https://api.docsautomator.co/createDocument \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "docId": "YOUR_AUTOMATION_ID",
    "data": {
      "customer_name": "Acme Corp",
      "invoice_date": "2025-01-15",
      "subtotal": "$5,500.00",
      "tax": "$495.00",
      "total": "$5,995.00",
      "line_items_1": [
        { "description": "Consulting", "quantity": 10, "rate": "$150", "amount": "$1,500" },
        { "description": "Development", "quantity": 20, "rate": "$200", "amount": "$4,000" }
      ]
    }
  }'

Nested Line Items

Use the children key for nesting (up to 2 levels):
{
  "docId": "YOUR_AUTOMATION_ID",
  "data": {
    "project_name": "Website Redesign",
    "line_items_1": [
      {
        "phase": "Design",
        "children": [
          {
            "task": "Wireframes",
            "hours": 8,
            "children": [
              { "detail": "Homepage wireframe", "status": "Complete" }
            ]
          }
        ]
      }
    ]
  }
}
Learn more about setting up line items in your template in the Line Items guide.

Async Mode

For high-volume or latency-sensitive workflows, use async mode. The API returns a jobId immediately, and you poll for the result.
# 1. Start async document creation
curl -X POST https://api.docsautomator.co/createDocument \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "docId": "YOUR_AUTOMATION_ID",
    "async": true,
    "data": {
      "customer_name": "Acme Corp",
      "total": "$5,500.00"
    }
  }'
# Returns: { "message": "Document creation request queued.", "jobId": "job_abc123", "logId": "..." }

# 2. Poll for the result
curl https://api.docsautomator.co/job/job_abc123 \
  -H "Authorization: Bearer YOUR_API_KEY"
# Returns: { "status": "completed", "result": { "pdfUrl": "https://...", ... } }

Response

Sync mode (200)

{
  "message": "success",
  "pdfUrl": "https://files.docsautomator.co/..."
}
Additional fields are included depending on your automation’s configuration:
FieldIncluded when
googleDocUrlSave Google Doc is enabled
savePdfGoogleDriveFolderIdSave PDF to Google Drive is enabled
savePdfGoogleDriveFileIdSave PDF to Google Drive is enabled
savePdfGoogleDriveUrlSave PDF to Google Drive is enabled
wordFileUrlSave Word document is enabled (Word templates; download URL for the generated .docx)
saveWordGoogleDriveFolderIdSave Word document to Google Drive is enabled
saveWordGoogleDriveFileIdSave Word document to Google Drive is enabled
signingSessionIdE-signature is enabled
signingStatusE-signature is enabled ("created" or "queued")
signingLinksE-signature is enabled (array of signer objects with signerIndex, email, name, signingUrl, status)
signingDeliveryMethodE-signature is enabled

Async mode (202)

{
  "message": "Document creation request queued.",
  "jobId": "job_abc123",
  "logId": "log_xyz789"
}
Last modified on June 4, 2026