There are two ways to manage webhooks:
Navigate to Settings → Webhooks page and see, add or delete webhooks there.
Use /api/webhooks/v2 endpoint to add or delete a webhook.
Managing webhooks requires Architect access to either Space or Database.
Add webhook
Add a webhook to subscribe to Entity changes of a particular Database .
When one or several changes occur, Fibery sends a JSON with new and previous values to the specified URL. To add a new webhook, navigate to Settings → Webhooks and click Add Webhook button.
Filter and process the payload in your integration. If you need some extra fields, send a request to the regular API (check Select Fields for more).
Please note that you can send correlationId, as shown in API call example, to match it with webhook call.
Then you will receive the same correlationId in corresponding webhook event.
Limitations:
Webhooks do not support rich text Field changes at the moment.
const response = await fetch ( 'https://YOUR_ACCOUNT.fibery.io/api/webhooks/v2' , {
method: 'POST' ,
headers: {
'Authorization' : 'Token YOUR_TOKEN' ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({
url: 'http://webhook.site/c2d6d113-aebe-4f68-a337-022ec3c7ab5d' ,
type: 'Cricket/Player'
})
});
const data = await response . json ();
Result:
{
"id" : 5 ,
"url" : "http://webhook.site/c2d6d113-aebe-4f68-a337-022ec3c7ab5d" ,
"type" : "Cricket/Player" ,
"state" : "active" ,
"version" : "2" ,
"runs" : []
}
Once you update a couple of Fields:
const response = await fetch ( 'https://YOUR_ACCOUNT.fibery.io/api/commands' , {
method: 'POST' ,
headers: {
'Authorization' : 'Token YOUR_TOKEN' ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ([
{
command: 'fibery.command/batch' ,
correlationId: 'cd4490f1-21d8-4881-b85c-423ef98edc3d' ,
args: {
commands: [
{
command: 'fibery.entity/update' ,
args: {
type: 'Cricket/Player' ,
entity: {
'fibery/id' : 'd17390c4-98c8-11e9-a2a3-2a2ae2dbcce4' ,
'fibery/modification-date' : '2019-07-30T07:18:48.449Z' ,
'Cricket/name' : 'sir Curtly Ambrose'
}
}
},
{
command: 'fibery.entity/add-collection-items' ,
args: {
type: 'Cricket/Player' ,
field: 'user/Former~Teams' ,
entity: { 'fibery/id' : 'd17390c4-98c8-11e9-a2a3-2a2ae2dbcce4' },
items: [
{ 'fibery/id' : 'd328b7b0-97fa-11e9-81b9-4363f716f666' }
]
}
}
]
}
}
])
});
const data = await response . json ();
the endpoint receives an array of effects:
{
"sequenceId" : 392 ,
"authorId" : "4044090b-7165-4791-ac15-20fb12ae0b64" ,
"creationDate" : "2021-04-22T12:40:14.325Z" ,
"command" : {
"correlationId" : "cd4490f1-21d8-4881-b85c-423ef98edc3d"
},
"effects" :
[
{
"effect" : "fibery.entity/update" ,
"id" : "d17390c4-98c8-11e9-a2a3-2a2ae2dbcce4" ,
"type" : "Cricket/Player" ,
"values" : {
"fibery/modification-date" : "2019-07-30T07:18:48.449Z" ,
"Cricket/name" : "sir Curtly Ambrose"
},
"valuesBefore" : {
"fibery/modification-date" : "2019-07-04T11:12:13.423Z" ,
"Cricket/name" : "Curtly Ambrose"
}
},
{
"effect" : "fibery.entity/add-collection-items" ,
"id" : "d17390c4-98c8-11e9-a2a3-2a2ae2dbcce4" ,
"type" : "Cricket/Player" ,
"field" : "user/Former~Teams" ,
"items" : [
{
"fibery/id" : "d328b7b0-97fa-11e9-81b9-4363f716f666"
}
]
}
],
}
Delete webhook
Delete a webhook when you no longer need it to save the account resources.
const response = await fetch ( 'https://YOUR_ACCOUNT.fibery.io/api/webhooks/v2/WEBHOOK_ID' , {
method: 'DELETE' ,
headers: {
'Authorization' : 'Token YOUR_TOKEN' ,
'Content-Type' : 'application/json'
}
});
Status code 200 means that the deletion has been successful.
Get webhooks
Get a list of webhooks together with their latest 50 runs.
const response = await fetch ( 'https://YOUR_ACCOUNT.fibery.io/api/webhooks/v2' , {
headers: {
'Authorization' : 'Token YOUR_TOKEN' ,
'Content-Type' : 'application/json'
}
});
const data = await response . json ();
Result:
[
{
"id" : 5 ,
"url" : "http://webhook.site/c2d6d113-aebe-4f68-a337-022ec3c7ab5d" ,
"type" : "Cricket/Player" ,
"state" : "active" ,
"runs" : [
{
"http_status" : "200" ,
"elapsed_time" : "209" ,
"request_time" : "2019-07-30T07:18:49.883Z"
},
{
"http_status" : "200" ,
"elapsed_time" : "181" ,
"request_time" : "2019-07-30T07:23:06.738Z"
}
]
}
]