Webhooks overview
Webhooks in postpress are a robust feature that lets your application stay informed in real time whenever specific events occur within the postpress system. Unlike periodic polling, where your application checks for updates, webhooks use a push notification protocol so you receive immediate notifications when something changes. postpress makes webhook integration effortless by sending an HTTP POST request to a URL of your choice, allowing you to configure your application to respond promptly to these notifications.
Create Webhooks
There are two ways of creating Webhooks:
- Using the
POST /webhooksmethod or the matching SDK method. - In the postpress dashboard.
Retries
Make sure to reply with a status code 200 in less than 30 seconds. A Webhook makes five retry attempts when the HTTP response code is not equal to 200 within 30 seconds, with an incremental time delay between each attempt.
Webhook types
postpress provides the following types of Webhooks:
Webhook Content-Type
Unlike webhooks created from the dashboard, webhooks created by API do not contain the header Content-Type: application/json by default. Some applications like Bubble, Make, and others need a content-type header to receive valid JSON. You can use the headers parameter to set it.
curl --request POST \
--url https://api.postpress.ai/v1/webhooks \
--header 'X-API-KEY: XXXXXXXX' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"request_url": "https://endpoint",
"source": "messaging",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
]
}'Authentication
You can add a header with a secret key to authenticate webhooks coming from postpress.
curl --request POST \
--url https://api.postpress.ai/v1/webhooks \
--header 'X-API-KEY: XXXXXXXX' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"request_url": "https://endpoint",
"source": "messaging",
"headers": [
{
"key": "Postpress-Auth",
"value": "yoursecretkey"
}
]
}'