Webhooks Definition
Webhook types
The three webhook types share most of their configuration options.
- upload
- callback
- error
Configuration
priint:cloud configurations are stored in /config.ion files for each application type (e.g., upload/config.ion).
ion is a data format originally defined by Amazon AWS and essentially compatible with JSON-5, i.e., a lax variant of JSON. Every valid JSON file is also a valid ION file. In addition to standard JSON syntax, we can use JavaScript like comments or omit the quotes around keys that contain no special characters.
Configuration files support inheritance and profiles. See Configuration Files for details.
Most configuration options allow detailed control of the requests sent to destination servers. E.g., special HTTP headers, a payload template, handling of failed requests.
Here comes a simple example:
// /tenants/mytenant/projects/myproject/callback/config.ion
{
"connections": [{
"url": "https://example.com/notfications/priint-success",
"method": "POST",
"header": {"X-KEY" : "c9f7af5626bbfae2c0295eced7d86985b90f639e8844"},
"payload": [{
"mediaType": "application/json",
"value" : '{"status":"success","ticket":"{ticket}"}'
}]
}],
redeliverOnError: [{
maxRedeliveries: 1,
redeliverIntervalMillis: 12000 // 2 min
}]
}
This is equivalent to:
If a callback URL starts with the string "https://example.com/notfications/priint-success"
then a POST request will be sent to that callback URL together with a header "X-KEY" and a JSON request body of {"status":"success","ticket":"actualTicketId"}.
If the request fails, it will be scheduled for a retry after 2 minutes. If that second attempt fails, the request will be discarded and an error notification will be sent (if configured).
The callback URL can either be defined in restapi/config.ion or sent as the "callback" parameter of the "POST /renderpdf" request.
Variable Replacement
Variable names embraced by curly brackets will be replaced by the actual context values for that variable. If a variable name does not exist in the context, it will be replaced by an empty string.
Variables can be used in
- payload values
- in URI patterns
- in headers (both name and value)
The following variables can be used:
| Name | Description |
|---|---|
| location | The absolute download URI for the artifact using the storage endpoint of the REST API |
| tenant | Name of the priint:cloud tenant |
| project | Name of the priint:cloud project |
| user | The authenticated user |
| ticket | priint:cloud ticket id useful to refer to a rendering |
| foreignKey | Value set in the original /renderpdf call that triggered the job. Used to correlate the upload to a content system specific request id. |
| dateTime | ISO DateTime string for the rendering |
| timestamp | Milliseconds since 1970 for the rendering |
| <customParam> | Any custom parameter set in the querystring of the original /renderpdf call such as custom=varName:varValue |
| <exportParam> | Any export parameter from previous processing steps (see the upload documentation for an example of this) |
When creating customParams or exportParams ensure that the names are not conflicting with the variable names above.