Skip to content

Triggering workflows

Sending emails from workflows can be done by triggering workflows and enabling the ‘Send email’ action.

There are two options for triggering workflows using Waypoint’s API:

Option 1: Trigger using a workflow ID

The first option is to trigger a workflow explicitly by the ID of the workflow. This is the default option for workflows on Waypoint and the benefit to using this route over a custom key (option 2) is that if a workflow is triggered with a workflow ID that doesn’t exist on Waypoint, you will immediately know that it won’t run.

POST /v1/workflow_runs

PropertyDescription
workflowIdThe id of the workflow you want to send (created on the Waypoint dashboard). You can access the workflow ID from the URL. Eg. https://dashboard.usewaypoint.com/o/platform_xxx/workflows/wf_ABc123XYZ
variablesOptional – JSON data object that is passed to the template and available as variables on the template.
metaIdOptional – can be used for internal reference or idempotent requests. Eg. ‘order_1234’.

Code examples

const axios = require('axios');
axios({
method: "post",
url: "https://live.waypointapi.com/v1/workflow_runs",
headers: {
"Content-Type": "application/json"
},
auth: {
username: API_KEY_USERNAME,
password: API_KEY_PASSWORD
},
data: {
"workflowId": "wf_eXYHR685DrjeGEXz",
"variables": {
"user": {
"displayName": "Jordan",
"email": "jordan@usewaypoint.com"
},
"product": {
"title": "Beechers Mac & Cheese",
"id": "02934203942"
}
}
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
Terminal window
curl "https://live.waypointapi.com/v1/workflow_runs" \
-H "Content-Type: application/json" \
-u "API_KEY_USERNAME:API_KEY_PASSWORD" \
-d '{
"workflowId": "wf_eXYHR685DrjeGEXz",
"variables": {
"user": {
"displayName": "Jordan",
"email": "jordan@usewaypoint.com"
},
"product": {
"title": "Beechers Mac & Cheese",
"id": "02934203942"
}
}
}'

Option 2: Trigger using a custom key

Another method to trigger workflows is through the utilization of a custom key. To add a custom key, simply access the ‘Trigger’ section of the workflow builder and click on the ‘Custom workflow key’ dropdown. Incorporating a custom key provides your development team with the ability to assign a more descriptive key within your codebase.

Custom key

One added advantage is that the workflow no longer needs to be pre-existing before events and data can be sent to it. Consequently, this allows teams to overcome bottlenecks, as a developer can initiate the triggering of a ‘new_listing’ workflow even before other team members create the actual workflow and configurations on the Waypoint dashboard.

POST /v1/workflow_runs

PropertyDescription
workflowKeyYour custom workflow key (created on Waypoint’s workflow builder). Eg. ‘abandoned_cart’.
variablesOptional – JSON data object that is passed to the template and available as variables on the template.
metaIdOptional – can be used for internal reference or idempotent requests. Eg. ‘order_1234’.

Code examples

const axios = require('axios');
axios({
method: "post",
url: "https://live.waypointapi.com/v1/workflow_runs",
headers: {
"Content-Type": "application/json"
},
auth: {
username: API_KEY_USERNAME,
password: API_KEY_PASSWORD
},
data: {
"workflowKey": "abandoned_cart",
"variables": {
"user": {
"displayName": "Jordan",
"email": "jordan@usewaypoint.com"
},
"product": {
"title": "Beechers Mac & Cheese",
"id": "02934203942"
}
}
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
Terminal window
curl "https://live.waypointapi.com/v1/workflow_runs" \
-H "Content-Type: application/json" \
-u "API_KEY_USERNAME:API_KEY_PASSWORD" \
-d '{
"workflowKey": "abandoned_cart",
"variables": {
"user": {
"displayName": "Jordan",
"email": "jordan@usewaypoint.com"
},
"product": {
"title": "Beechers Mac & Cheese",
"id": "02934203942"
}
}
}'