Test workflow (dry run)
Runs the builder version of a workflow (the draft when there is one) against a payload without executing the
actions: conditions are really evaluated, actions are only previewed. Nothing is sent, changed or assigned and no
credits are used. Without payload the sample payload of the trigger is used (see
Get sample payload). The dry run is recorded as an execution with source test.
Base URL:
POST: https://api.smsgatewayapi.com/v1/flows/{flow_id}/testExample:
POST: https://api.smsgatewayapi.com/v1/flows/flw_5d41402abc4b2a76b9719d911017c592/test
| Parameter | Input | Description | |
|---|---|---|---|
| client_id | API client ID | Developer › API & Webhooks › API credentials | Required |
| client_secret | API client secret | A cs_ credential, shown once when you create it under Developer › API & Webhooks › API credentials | Required |
| flow_id | workflow ID | The public ID (flw_...) of the workflow as returned by List workflows; the numeric ID is accepted too | Required |
| payload | object | The payload the trigger would produce, e.g. { "message": { "body": "STOP" }, "contact": { "phone": "32470123456" } }. May carry system: { date, time, timezone } to simulate a moment in time. Default: the sample payload | Optional |
<?php
//PHP - cURL
$ch = curl_init();
$url = "https://api.smsgatewayapi.com/v1/flows/{flow_id}/test";
$client_id = "XXX"; // Your API client ID (required)
$client_secret = "YYY"; // Your API client secret (required)
$data = [
'payload' => [ //Payload the trigger would produce (optional, default: the sample payload)
"message" => ["body" => "STOP"],
"contact" => ["phone" => "32495123456"]
]
];
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-Client-Id: $client_id",
"X-Client-Secret: $client_secret",
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$response = curl_exec($ch);
?>
Example request:
{
"payload": {
"message": { "body": "STOP" },
"contact": { "phone": "32470123456" }
}
}
Example success response:
{
"flow": "flw_5d41402abc4b2a76b9719d911017c592",
"execution": "0f2d9c4e-7b1a-4e6d-8c3f-5a6b7c8d9e0f",
"version_number": 1,
"version_status": "draft",
"result": {
"visited_nodes": [
{ "id": "trigger", "type": "triggerNode", "label": "Inbound message", "result": "triggered", "subtitle": "inbound_message", "incoming_edge_id": null },
{ "id": "is_stop", "type": "conditionNode", "label": "Message is STOP?", "result": "matched", "branch": "true", "incoming_edge_id": "e1" },
{ "id": "opt_out", "type": "actionNode", "label": "Opt out", "result": "would_execute", "subtitle": "Opt-out action would run", "incoming_edge_id": "e2" }
],
"actions": [
{
"type": "opt_out",
"summary": "Opt-out action would run",
"details": { "method": "opt_out", "groupid": null }
}
],
"stopped_reason": "completed"
}
}
In a dry run every action is reported as would_execute with a preview (summary and details); a real run reports status executed, skipped or failed instead.
Example error response:
{
"error": 139,
"errorMsg": "Parameter payload must be an object"
}