Webhooks

Updated on October 2, 2024

Apart from sending messages to users, workflows can be used to call webhooks and pass the list of profiles that have reached a given workflow step. This functionaliy makes it possible to leverage Releva’s powerful analytics and segmentation capabilities to trigger your own custom business logic.

Request Structure #

Releva will call your webhook for all profiles that have arrived at a given workflow step in batches of 50 profiles using the curl equivalent below. Releva will pass the shared secret key in an authorization header, and you can check the value of this header to authorize the request. If you return an HTTP status other than 2xx, we will retry the request up to 10 times with an exponential back-off.

curl -H 'Content-Type: application/json' -H 'Authorization: Bearer <secretKey>' -XPOST https://your-webhook-url -d'{
  "source": {
    "campaign": {
      "id": 123,
      "name": "<workflow name as seen in Releva admin panel>"
    },
    "segment": {
      "id": 234,
      "name": "<segment name as seen in Releva admin panel>"
    },
    "segmentRunId": "...",
    "flowStepId": "...",
    "batchNumber": 1
  },
  "profiles": [
    {
      "firstName": "John",
      "lastName": "Smith",
      "email": "john@example.com",
      "phoneNumber": "+123456",
      "tags": ["t1", "t2"],
      "subscriptions": ["sub1", "sub2"],
      "registeredAt": "2023-09-15T00:20:21.000Z",
      "subscribedAt": "2023-09-15T00:20:21.000Z",
      "webhookClick": <URL endpoint to generate webhook click event for this profile>,
      "webhookOpen" <URL endpoint to generate webhook open event for this profile>
      "custom": { "string": [{ "key": "foo", "values": ["bar"] }] }
    }
  ],
  "triggerEvent": {
    "action": "yourCustomAction",
    "actionClass": "yourCustomActionClass",
    "custom": { "string": [{ "key": "foo", "values": ["bar"] }] },
    "timestamp": "2023-09-15T00:20:21.000Z"
  }
}'

Request Body #

FieldTypeDescription
sourceObjectThis field contains information about the source of the webhook
source.campaign.nameStringThis is the name of the workflow which triggered this request (as seen in the Releva admin panel)
source.campaign.idIntegerThis is the id of the workflow which triggered this request (as seen in the URL of the releva admin when you open the details page – <id>/details)
source.segment.nameStringThis is the id of the segment which is currenctly associated with the workflow which triggered this request (as seen in the Releva admin panel)
source.segment.idIntegerThis is the id of the segment which is currenctly associated with the workflow which triggered this request (as seen in the URL of the releva admin when you open the details page – <id>/details)
source.segmentRunIdStringThis identifies a unique execution of the workflow and the corresponding cohort of profiles which entered the workflow during this execution.
source.flowStepIdStringThis identifies the step within the workflow where this execution was triggered.
source.batchNumberIntegerThis is the batch number (zero-indexed) of this request in relation to all profiles that have reached the given workflow step as part of the given workflow execution.
profiles[].firstNameString | NULLFirst name
profiles[].lastNameString | NULLLast name
profiles[].emailString | NULLEmail address
profiles[].phoneNumberString | NULLPhone number (including country code)
profiles[].tagsArray[String]Tags associated with the profile
profiles[].subscriptionsArray[String]Subscriptions associated with the user
profiles[].registeredAtISO-8601 String | NULLDate of registration of the profile
profiles[].subscribedAtISO-8601 String | NULLDate of subscription for marketing
profiles[].webhookOpenStringThis field is a URL endpoint used to generate and send analytics data for webhook open events associated with the profile.
profiles[].webhookClickStringThis field is a URL endpoint used to generate and send analytics data for webhook click events associated with the profile.
profiles[].customObject Profile custom fields
triggerEventObject | NULLThe event which triggered the workflow execution (if the webhook source was a triggered workflow, null otherwise)
triggerEvent.actionStringName of the trigger event
triggerEvent.actionClassString | NULLAction class of the trigger event
triggerEvent.customObjectCustom fields associated with the trigger event
triggerEvent.timestampISO-8601 StringThe time when the trigger event occurred