Skip to content

Webhooks

Creating a webhook

Webhooks can be created using the CLI (or an HTTP request, using your app key as the API_KEY). Record the returned id from the request, as it will be used later to trigger the webhook.

contrail webhooks create -j
# response:
# {
#   "createdOn": "2023-05-14T20:29:11.714Z",
#   "updatedOn": "2023-05-14T20:29:11.714Z",
#   "createdById": "3wedKxNFaDLbvsVM",
#   "updatedById": "3wedKxNFaDLbvsVM",
#   "orgId": "ORG_ID",
#   "id": "4X0bETHdBKw87l6h"
# }
curl --request POST \
    --url https://api.vibeiq.com/prod/api/webhooks \
    --header 'Content-Type: application/json' \
    --header 'X-Api-Key: API_KEY' \
    --header 'X-Api-Org: ORG_KEY'
# response:
# {
#   "createdOn": "2023-05-14T20:29:11.714Z",
#   "updatedOn": "2023-05-14T20:29:11.714Z",
#   "createdById": "3wedKxNFaDLbvsVM",
#   "updatedById": "3wedKxNFaDLbvsVM",
#   "orgId": "ORG_ID",
#   "id": "4X0bETHdBKw87l6h"
# }

Webhooks can be managed through the CLI contrail webhooks --help.

Triggering a webhook

You can run a workflow from a webhook call by setting the trigger on a workflow to be webhookId:WEBHOOK_ID. In the example above, it would be webhookId:4X0bETHdBKw87l6h.

To trigger the webhook (and the connected workflows), make a POST request to https://api.vibeiq.com/prod/api/trigger-webhooks/WEBHOOK_ID. The POST body and headers will be passed to the workflow event object, and be available to the actions that run the workflow.

Sample webhook trigger:

curl --request POST \
  --url https://api.vibeiq.com/prod/api/trigger-webhooks/4X0bETHdBKw87l6h \
  --header 'Content-Type: application/json' \
    --header 'X-Verify-Signature: my-secret-key' \
  --data '{
    "foo": "bar"
}'
Sample return value from the request. Here we see that the webhook triggered one workflow. If the webhook is hooked up to multiple workflows (i.e. multiple workflows have the trigger webhookId:Od9ntdpYJuUGh3wt), then the list would have included more processes.
[
    {
        "eventWorkflowTemplateId": "rbGtiz4rUX8JNJZv",
        "status": "PENDING",
        "triggerEvent": {
            "foo": "bar"
        },
        "taskOutputs": {},
        "createdOn": "2023-05-14T20:35:22.414Z",
        "updatedOn": "2023-05-14T20:35:22.414Z",
        "orgId": "ugxouwtGjeTPWRN7",
        "id": "_v_R91m5VM-CqX3Y",
        "eventWorkflowTaskIds": [
            "EJ0ITwGWbtrUBGh5"
        ]
    }
]

The event sent to the first action in the event workflows triggered by the webhook will be:

{
    "body": {
            "foo": "bar"
    },
    "headers": {
        "content-type": "application/json",
        "x-verify-signature": "my-secret-key",
        "host": "api.vibeiq.com"
    }
}