Run saved document configs from your automation stack.
Create an API key, list saved configs, run one with a fresh Excel file or JSON rows, then pass the returned download URL to Zapier, n8n, Make, or your own backend.
1. Create a key
Account settings shows the secret once. Store it in your automation platform as a bearer token.
2. Pick a config
Saved configs are the reusable automation unit. Template and quick configs both work.
3. Check what it expects
GET the config's schema to see the exact column keys it needs. Preserve spelling, case and any spaces in those keys.
4. Run with data
Send multipart form-data with an excel file, or JSON with row / rows, and receive a job plus output URL.
Before wiring your automation, call GET /api/v1/configs/{id} to see the exact column keys this config needs. Your JSON keys must match these exactly: case-sensitive, preserve spaces when present and do not rename keys.
{
"id": "9591c556-26d4-4fb2-a2a3-629e469225ae",
"name": "Service Agreement",
"mode": "mapped",
"expectedColumns": [
"agreement_date", "client_name", "start_date", "end_date",
"provider_name", "services_description", "total_fee",
"payment_terms", "jurisdiction",
"provider_signatory_name", "provider_signatory_title",
"client_signatory_name", "client_signatory_title"
]
}If your trigger's field names don't match (e.g. a form sends Client Name but the config expects client_name), add a mapping step between the trigger and the run request, using Zapier Formatter, Make Set Variable, or n8n Set / Edit Fields, to rename fields. Skipping this step is the most common reason for a 409 drift error.
Core endpoints
All public API routes accept Authorization: Bearer dtgd_.... Use https://doctagd.com as the API host. Generated outputs are stored as private blobs and returned as download URLs.
/api/v1/configsList saved configs for the authenticated account.
/api/v1/configs/{id}Inspect expected columns, mappings and a resolved typed schema before wiring an automation.
/api/v1/configs/{id}/validateCheck Excel/CSV or JSON input without creating a job, generating files or using document quota. Returns valid, drift, issues, schema and a preview of input values; inspect valid even on HTTP 200.
/api/v1/configs/{id}/runRun a saved config with multipart field `excel`, JSON `{ row: {...} }`, JSON `{ rows: [...] }`, or a flat JSON row object. Add `outputFormat: 'pdf'` (default `'docx'`) to receive PDFs (Pro/Business only). Pass an optional `Idempotency-Key` header so retries are safe.
/api/v1/jobs/{id}Poll a job and retrieve `downloadUrl`, status, or structured error.
/api/v1/jobs/{id}/downloadStream a single `.docx`/`.pdf` or a multi-document `.zip`. Returned signed URLs work without headers while valid (default 24h); preserve the full query string. An unsigned URL requires the owner's Bearer key or session cookie.
Schema and quota-free validation
GET /api/v1/configs/{id} includes schema: { version: 1, columns: […] }. Each column describes its key, description, type and required flag, with optional example, options and mapped placeholder. Types are inferred from saved formatting and column names; review them alongside the saved config.
{
"version": 1,
"columns": [{
"key": "agreement_date",
"description": "Agreement Date",
"type": "date",
"required": true,
"mapsToPlaceholder": "agreement_date"
}]
}curl -X POST https://doctagd.com/api/v1/configs/$CONFIG_ID/validate \
-H "Authorization: Bearer $DOCTAGD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "row": { "Client Name": "Acme Ltd" } }'
# Use every required key from YOUR config; spaces are valid.
# Excel/CSV also works: -F excel=@responses.xlsx
# Inspect valid, drift and issues, not only the HTTP status.Validation accepts the same input shapes as generation and returns valid, rowCount, mode, drift, issues, issuesTruncated, schema and preview. Missing drift columns or required values make valid false. Coercion notes are advisory; values are not transformed or stored. This is an input check, not a document preview or a guarantee of PDF entitlement or remaining quota.
Copy-paste examples
curl https://doctagd.com/api/v1/configs \
-H "Authorization: Bearer $DOCTAGD_API_KEY"curl -X POST https://doctagd.com/api/v1/configs/$CONFIG_ID/run \
-H "Authorization: Bearer $DOCTAGD_API_KEY" \
-F excel=@responses.xlsxcurl -X POST https://doctagd.com/api/v1/configs/$CONFIG_ID/run \
-H "Authorization: Bearer $DOCTAGD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"client_name": "Acme Ltd",
"agreement_date": "14 May 2026",
"total_fee": "4800"
}'curl -X POST https://doctagd.com/api/v1/configs/$CONFIG_ID/run \
-H "Authorization: Bearer $DOCTAGD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "rows": [
{ "client_name": "Acme Ltd", "total_fee": "4800" },
{ "client_name": "Northline", "total_fee": "7200" }
] }'curl -X POST https://doctagd.com/api/v1/configs/$CONFIG_ID/run \
-H "Authorization: Bearer $DOCTAGD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"row": { "client_name": "Acme Ltd", "total_fee": "4800" },
"outputFormat": "pdf"
}'
# Multipart uploads take it as a form field:
# -F excel=@responses.xlsx -F outputFormat=pdf
# PDF uses the same monthly document allowance as DOCX.curl https://doctagd.com/api/v1/jobs/$JOB_ID \
-H "Authorization: Bearer $DOCTAGD_API_KEY"curl https://doctagd.com/api/v1/configs/$CONFIG_ID \
-H "Authorization: Bearer $DOCTAGD_API_KEY"# Keep the complete downloadUrl, including exp and sig.
curl -L "$DOWNLOAD_URL" -o "$FILENAME"
# An unsigned URL requires your account's Bearer key:
curl -L "https://doctagd.com/api/v1/jobs/$JOB_ID/download" \
-H "Authorization: Bearer $DOCTAGD_API_KEY" -o "$FILENAME"curl -X POST https://doctagd.com/api/v1/configs/$CONFIG_ID/run \
-H "Authorization: Bearer $DOCTAGD_API_KEY" \
-H "Idempotency-Key: sheet-row-8842" \
-H "Content-Type: application/json" \
-d '{ "client_name": "Acme Ltd", "total_fee": "4800" }'
# A retry with the same Idempotency-Key returns the original
# job (idempotent: true) without regenerating or re-billing.{
"error": "drift",
"message": "...",
"jobId": "…",
"missingColumns": ["client_name"],
"suggestions": { "client_name": ["customer_name"] }
}{
"error": "Your Free plan has 0 documents remaining…",
"code": "usage_limit_reached",
"plan": "free",
"used": 10,
"limit": 10,
"requested": 3
}{
"error": "PDF export is available on Pro and Business plans.",
"code": "pdf_entitlement_required",
"plan": "free",
"sharedLicense": false
}
# Returned when outputFormat: "pdf" is requested on a Free
# plan. Drop outputFormat (or use "docx") to generate DOCX,
# or upgrade to Pro/Business.Limits, retries, and errors
Request limits
Up to 500 rows and 80 columns per run, 10,000 chars per cell, and a 512 KB JSON body. Larger Excel files are accepted as multipart uploads within the same row/column limits.
Status codes
401 for missing/invalid credentials on protected requests. 402 for quota or PDF entitlement. 404 for an unknown config, 409 for generation drift, and 429 for rate limits (60 req/min). An expired/invalid signed download without fallback auth returns 410 with link_expired/link_invalid.
Idempotency
Send an Idempotency-Key header on every run. A retry with the same key returns the original job and never regenerates or re-bills. Keys are scoped per account.
The key must be unique per logical row but stable across retries of that same row. Getting this wrong is the most common automation bug:
| ✓ Use | ✗ Avoid |
|---|---|
A row ID from your source (e.g. {{ $json.row_number }}, {{ recordId }}) | A constant string |
A natural composite (e.g. {{ client_name }}-{{ agreement_date }}) | The execution / run ID; it's the same across every row in one batch |
| The form submission ID | A fresh timestamp on every request, which defeats retry safety |
What happens if you get it wrong
- Same key reused across multiple rows in one batch run: the API returns the first row's job for all of them. Only one document gets generated. You'll see the same
jobIdrepeated in your responses withidempotent: trueon every item after the first. - Same key reused after a failed run: you'll get the cached error back (
status: "error",idempotent: true). The drift, quota, or other failure is fixed by sending a new key, not by retrying the old one. - Different key on a legitimate retry: the API treats it as a brand new run and bills you again. This is why a stable per-row key matters.
Always check the status field
A 200 OK response means the API processed your request, not that generation succeeded. Branch on status:
doneusedownloadUrlrunninga concurrent retry found the original request still generating; pollGET /api/v1/jobs/{id}untildoneerrorinspect theerrorobject. Most often this is a replayed cached failure; send a freshIdempotency-Keyto retry properly
error payload downstream unless you explicitly check status.Example flow: form submission → Word contract
A common automation: a web form (Typeform, Google Forms, Jotform, Tally) collects engagement details, and each submission auto-produces a branded .docx from a saved template config with no manual Word work. The trigger fires, you POST the response as a flat JSON object to the run endpoint, then fetch the returned downloadUrl including its signed query parameters and email or file the document. One row returns a ready .docx; multi-row runs return a .zip. The same three steps work in Zapier, Make, and n8n.
curl -X POST https://doctagd.com/api/v1/configs/{configId}/run \
-H "Authorization: Bearer dtgd_…" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: form-response-2f9c1a" \
-d '{
"agreement_date": "18 May 2026",
"provider_name": "Doctagd Ltd",
"client_name": "Acme Innovations Ltd",
"services_description": "Monthly document automation retainer",
"start_date": "1 June 2026",
"end_date": "31 May 2027",
"total_fee": "GBP 12,000",
"payment_terms": "Net 30",
"jurisdiction": "England and Wales",
"provider_signatory_name": "S. Khan",
"provider_signatory_title": "Director",
"client_signatory_name": "J. Doe",
"client_signatory_title": "COO"
}'
# JSON keys must match the config's expected columns
# exactly, or you get a 409 with suggested names.
# Set Idempotency-Key to the form's submission ID.{
"jobId": "f1e2d3c4-…",
"status": "done",
"inputType": "json",
"filename": "Acme Innovations Ltd.docx",
"downloadUrl": "https://doctagd.com/api/v1/jobs/f1e2d3c4-…/download?exp=…&sig=…",
"idempotent": false
}
# A run that produces ONE document returns a .docx;
# multi-row runs return a .zip (filename tells you which).
# Synchronous; no polling. downloadUrl is a signed,
# time-limited link (default 24h from issuance); keep exp/sig.
# Output retention is separate. You can fetch directly; the
# SAME Authorization: Bearer dtgd_… header also works.
# Then email / Drive / Slack it. A retry with the same
# Idempotency-Key returns this same job
# ("idempotent": true, no re-billing).Driving doctagd from an AI agent?
doctagd also exposes a Model Context Protocol server, so an agent can discover your configs, read a typed column schema, validate input with no quota cost, and generate documents using the same dtgd_ key and the same endpoints described here. If you're building an agent rather than a fixed pipeline, start there.
Per-platform setup
Pick your automation platform below. Each walkthrough produces a ready .docx for a single-row run; multi-row runs return a .zip.
5 steps · single-row run returns a ready .docx
Trigger
Whatever app collects your data, such as Typeform, Google Forms, Jotform, Tally, or Google Sheets, (New Spreadsheet Row), Airtable, etc. One trigger event = one document.
Map your fields (optional Formatter step)
If your trigger's field names don't match the config's expected columns exactly (e.g. Typeform sends Client Name but the config expects client_name), add a Formatter by Zapier step (Utilities → Lookup Table, or just map them inline in the next step's Data fields). Without this rename step, you'll hit a 409 drift error. Run GET /api/v1/configs/{id} first to see the canonical keys.
POST the run
- App: Webhooks by Zapier
- Action Event:
Custom Request, with a raw JSON body and the headers below - Method:
POST - URL:
https://doctagd.com/api/v1/configs/<your-config-id>/run - Data: raw JSON with the config's expected-column keys, mapping each value from the trigger:
{
"client_name": "{{trigger.client_name}}",
"agreement_date": "{{trigger.agreement_date}}",
"total_fee": "{{trigger.total_fee}}"
}(Zapier uses its own field-picker syntax in the actual UI; drag fields in from the previous step.)
- Unflatten: No
- Headers:
Authorization: Bearer dtgd_<your-key>
Content-Type: application/json
Idempotency-Key: <a unique-per-row, stable-on-retry value>For the Idempotency-Key, pick something natural from the trigger, such as the form submission ID, an Airtable record ID, a Google Sheets row number, or a composite like {{trigger.client_name}}-{{trigger.agreement_date}}. Reusing the same value across rows produces only one document; reusing it after a failed run replays the failure.
Fetch the file
- App: Webhooks by Zapier (a second action step)
- Action Event:
GET - URL:
{{step3.downloadUrl}}. ThedownloadUrlvalue from the POST response - Headers (optional for a valid signed URL):
Authorization: Bearer dtgd_<your-key>downloadUrl can be fetched without headers, including by an "upload from URL" action that preserves the complete query string. Check that action's file support. The Webhooks GET step also supports unsigned URLs when you send your Bearer key.Deliver
Pass the binary from step 04 into your final action, such as Email by Zapier (Attachments field), Gmail → Send Email, Google Drive → Upload File, Slack → Send Channel Message (with file), etc. Use the filename value from step 03's response so the file is named what doctagd named it:
File: {{step4.file}}
Filename: {{step3.filename}}The filename includes the output extension: .docx or .pdf for one document, .zip for multiple documents.
Common errors
Stuck? Match your symptom to the row below for the cause and the fix.
| Symptom | Likely cause | Fix |
|---|---|---|
401 Authentication required | Missing Bearer prefix, header name misspelled (Authorisation vs Authorization), key has stray whitespace | Re-check the credential value; regenerate the key if you’re not sure it copied cleanly |
409 with missingColumns | JSON keys don’t match the config’s expected columns exactly | GET /api/v1/configs/{id} for the canonical list; rename keys with a Set / Formatter step before the POST |
Response is 200 but body says status: "error" and idempotent: true | You're replaying a failed job via a reused Idempotency-Key | Send a fresh Idempotency-Key to actually retry |
Multiple rows return the same jobId and only one document is generated | The same Idempotency-Key is being sent for every row | Make the key unique per row ({{ row_number }} or a natural composite) |
status: "running" with no downloadUrl | A concurrent idempotent retry found the original request still running | Poll GET /api/v1/jobs/{id} every few seconds until status: "done" |
401 when fetching downloadUrl | The URL has no signature and the GET has no valid Authorization header or owner session cookie | Use the complete signed downloadUrl, or send the owner’s Bearer credential for an unsigned URL |
410 link_expired / link_invalid | Signed link expired or its exp/sig parameters changed, with no valid fallback auth | Preserve the complete returned URL. Request the job again for a fresh link while output is retained, or generate again after cleanup |
402 usage_limit_reached | Monthly document quota exhausted | Upgrade your plan or wait until the next UTC month rolls over |
402 pdf_entitlement_required | Requested outputFormat: "pdf" on a Free plan | Drop outputFormat (DOCX is default) or upgrade to Pro/Business for PDF |
429 | Rate-limited (60 requests/min) | Add a Wait/backoff step, or batch rows into one request with { "rows": [...] } instead of one request per row |
| Download URL returns 404 after a while | Jobs/files older than 24 hours are eligible for the daily cleanup | Fetch and store the file immediately after the run; don’t pass URLs around for later use |
