Manage using API¶
Webhooks can be programmatically managed. Prerequisite is to have an API key with permissions allowing webhook module operations. The dashboard (API key wizard) can be used to quickly create such API key as explained in the API key section Manage using dashboard. Such API key might have the following permissions:
Path | Methods | ACL |
---|---|---|
/webhooks/core\.webhook/[0-9a-fA-F]{24} | POST, PATCH, DELETE | off |
/webhooks/core\.webhook | GET, POST | off |
Create¶
The webhook document is of type core.webhook and has attributes:
- name - user defined name for a webhook
- invoke - object containing callback properties URI and headers
- listeners - array of listener objects where each contains properties document and events
Example API request creating a webhook:
curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-d '
{
"data": {
"type": "core.webhook",
"attributes": {
"name": "hook for my-domain.com",
"invoke": {
"uri": "https://www.my-domain.com/jazer-callback",
"headers": {
"Authorization": "Bearer 1234567890"
}
},
"listeners": [
{
"document": "car",
"events": [
"core.webhook.event.document-created",
"core.webhook.event.document-updated",
"core.webhook.event.document-deleted"
]
},
{
"document": "fleet",
"events": [
"core.webhook.event.document-created"
]
}
]
}
}
}' \
-X POST https://api.jazer.io/webhooks/core.webhook
The response contains a created webhook:
{
"data": {
"type": "core.webhook",
"id": "5a42d667a01c5b1b9341dd30",
"attributes": {
"name": "hook for my-domain.com",
"invoke": {
"uri": "https://www.my-domain.com/jazer-callback",
"headers": {
"Authorization": "Bearer 1234567890"
}
},
"listeners": [
{
"document": "car",
"events": [
"core.webhook.event.document-created",
"core.webhook.event.document-updated",
"core.webhook.event.document-deleted"
]
},
{
"document": "fleet",
"events": [
"core.webhook.event.document-created"
]
}
]
},
"links": {
"self": "https://api.jazer.io/webhooks/core.webhook/5a42d667a01c5b1b9341dd30"
}
}
}
Read¶
Fetching webhook by ID is achievable with an API request:
curl -H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-X GET https://api.jazer.io/webhooks/core.webhook/<WEBHOOK_ID>
Update¶
Example API request updating a webhook:
curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-d '
{
"data": {
"type": "core.webhook",
"id": "<WEBHOOK_ID>",
"attributes": {
"listeners": [
{
"document": "car",
"events": [
"core.webhook.event.document-created",
"core.webhook.event.document-updated",
"core.webhook.event.document-deleted"
]
},
{
"document": "fleet",
"events": [
"core.webhook.event.document-created"
]
},
{
"document": "driver",
"events": [
"core.webhook.event.document-created"
]
}
]
}
}
}' \
-X PATCH https://api.jazer.io/webhooks/core.webhook/<WEBHOOK_ID>
Delete¶
To remove a webhook use following API request:
curl -H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-X DELETE https://api.jazer.io/webhooks/core.webhook/<WEBHOOK_ID>
Search¶
Search is enabled on a webhook endpoint. An API request to fetch webhooks is:
curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-X GET https://api.jazer.io/webhooks/core.webhook
Search features like filtering, sorting, pagination etc. are available as is Search in the resources module.