Skip to main content

Webhooks

This section explains how to use rules to create webhooks on CargoX Platform. Webhooks allow you to perform certain actions when a specific event occurs.

Parameters

Rules are managed through the https://cargox.digital/api/v3/companies/COMPANY_ID/rules/ API endpoint. Allowed methods are GET, POST, PUT, PATCH, DELETE.

Each rule you create must have the following arguments:

ArgumentDescriptionTypeRequiredDefault
nameName of the webhook.StringYes
eventEvent ID (see Supported events table).StringYes
actionsArray of action objects (see table below for details).ArrayYes
enabledControls if rule is processed or not.BooleanNoTrue

Action objects have the following arguments:

ArgumentDescriptionRequired
typeAction ID (see Supported actions table).Yes
dataData argument (see Supported actions table).Depends on action

Example request

Example request using Bearer access token for authorization. See Authorization and authentication page on how to obtain a bearer token.

curl --location --request POST 'https://cargox.digital/api/v3/companies/COMPANY_ID/rules/' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Notify John and Anne",
"event": "envelope_received",
"actions": [
{
"type": "send_email_to",
"data": [
"[email protected]",
"[email protected]"
]
}
]
}'

Example response

A call such as the one above will generate the following response:

{
"id": "e4a9e4bd-f108-49a6-89b5-af534d28a8ea",
"name": "Notify John and Anne",
"event": "envelope_received",
"event_name": "Envelope received",
"enabled": true,
"actions": [
{
"id": "fd636faa-1437-494e-b5b1-6887e8ec838d",
"rule_id": "e4a9e4bd-f108-49a6-89b5-af534d28a8ea",
"type": "send_email_to",
"type_name": "Send email to",
"data": ["[email protected]", "[email protected]"]
}
],
"actions_description": "Send email to [email protected], [email protected]"
}

Supported events

EventEvent IDDescription
Envelope receivedenvelope_receivedTriggered when an envelope is received. If the envelope contains documents that transferred via blockchain, this event triggers when all blockchain transactions are confirmed and processed.
Contact invitation acceptedcontact_invitation_acceptedTriggered when a sent contact invitation is accepted.

Supported actions

ActionAction IDDescriptionData requiredData type
Send email tosend_email_toSends email to specified email address(es).YesArray of email addresses
Send email to everyonesend_email_to_everyoneSends email to every user in the company.NoNone
Post webhookpost_webhookSend an HTTP POST request to a webhook with a serialized envelope as data.YesArray of URL addresses