Webhooks
Webhook triggers let you start workflows from external applications and services by sending data to a unique URL.
When a webhook is called, the JSON data you send becomes available as workflow variables and can be used by later steps to generate documents, apply logic, send emails, and more.
Adding a Webhook Trigger
Select Webhook as the trigger type in the workflow designer.
Each webhook trigger gets a unique URL:
https://hooks.templatedocs.io/hooks/<webhook_id>
Send an HTTP POST request with a JSON body to this URL to start the workflow.
Webhooks invoke the published version of a workflow. If the workflow has unpublished changes, the currently published version will continue to run until the workflow is published again.
Data Structure
The webhook's data structure defines the variables that are available to later steps in the workflow.
To detect the data structure, click Start Listening in the trigger settings, then send a sample request to the webhook URL. TemplateDocs captures the request and automatically detects its structure.
Once detected, fields from the JSON body become workflow variables. Nested objects and arrays are supported, including arrays of objects that can be mapped directly to document loops.
If the structure of your webhook data changes, use Detect again to capture a new sample and update the data structure.
Incoming data is checked against the detected structure when a workflow runs. Differences are reported as warnings in the run history, but do not stop the workflow.
Calling the Webhook
Send a POST request with a JSON body to the webhook URL:
const webhookUrl = "https://hooks.templatedocs.io/hooks/my_webhook_123";
const response = await fetch(webhookUrl, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
customerName: "Jane Smith",
items: [
{
name: "Consulting services",
total: 1200
}
]
})
})
const data = await response.json()
console.log(data)
A successful request returns:
{
"accepted": true
}
The workflow starts asynchronously after the request is accepted.
The maximum request size is 10 MB.
API Key Authentication
By default, anyone with the webhook URL can invoke the workflow.
For additional protection, enable Require API Key in the webhook trigger
settings. Requests must then include an organization API key in the
Authorization header, prefixed with Bearer.
Authorization: Bearer <api_key>
See API Authentication for information about creating and using API keys.
Next Steps
- Read the Workflows overview
- Learn how to use formulas and array expressions for advanced data processing
- Generate files with Document steps