Workflows
Start a workflow run
Queue a published event-to-call workflow with context.
POST
/
v1
/
workflows
/
{workflowId}
/
run
Start a workflow run
curl --request POST \
--url https://api.persistence.dev/v1/workflows/{workflowId}/run \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'X-API-Key: <api-key>' \
--data '
{
"context": {
"phone_number": "+14155550123"
}
}
'import requests
url = "https://api.persistence.dev/v1/workflows/{workflowId}/run"
payload = { "context": { "phone_number": "+14155550123" } }
headers = {
"Idempotency-Key": "<idempotency-key>",
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'X-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({context: {phone_number: '+14155550123'}})
};
fetch('https://api.persistence.dev/v1/workflows/{workflowId}/run', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.persistence.dev/v1/workflows/{workflowId}/run",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'context' => [
'phone_number' => '+14155550123'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.persistence.dev/v1/workflows/{workflowId}/run"
payload := strings.NewReader("{\n \"context\": {\n \"phone_number\": \"+14155550123\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.persistence.dev/v1/workflows/{workflowId}/run")
.header("Idempotency-Key", "<idempotency-key>")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"context\": {\n \"phone_number\": \"+14155550123\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.persistence.dev/v1/workflows/{workflowId}/run")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"context\": {\n \"phone_number\": \"+14155550123\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"automationId": "<string>",
"version": 123,
"status": "queued",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"automationName": "<string>",
"parentRunId": "<string>",
"parentStepId": "<string>",
"currentStepId": "<string>",
"concurrencyKey": "<string>",
"currentNodeId": "<string>",
"currentNodeTitle": "<string>",
"context": {},
"output": {},
"error": {},
"revision": 123,
"wakeAt": "2023-11-07T05:31:56Z"
}
}{
"code": "<string>",
"error": "<string>"
}{
"code": "<string>",
"error": "<string>"
}{
"code": "<string>",
"error": "<string>"
}{
"code": "<string>",
"error": "<string>"
}{
"code": "<string>",
"error": "<string>"
}Authorizations
Workspace API key with workflow run, and workflow read to check status.
Headers
Stable key reused when retrying the same request
Runs sharing this key never overlap. Omit to allow parallel runs.
With Concurrency-Key: refuse new runs for that key until this many minutes after its last run ended (0-10080).
Required range:
0 <= x <= 10080Path Parameters
Published workflow ID
Body
application/json
Initial values for the run. phone_number becomes {{phone_number}} in later steps.
Example:
{ "phone_number": "+14155550123" }
⌘I
Start a workflow run
curl --request POST \
--url https://api.persistence.dev/v1/workflows/{workflowId}/run \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--header 'X-API-Key: <api-key>' \
--data '
{
"context": {
"phone_number": "+14155550123"
}
}
'import requests
url = "https://api.persistence.dev/v1/workflows/{workflowId}/run"
payload = { "context": { "phone_number": "+14155550123" } }
headers = {
"Idempotency-Key": "<idempotency-key>",
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'X-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({context: {phone_number: '+14155550123'}})
};
fetch('https://api.persistence.dev/v1/workflows/{workflowId}/run', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.persistence.dev/v1/workflows/{workflowId}/run",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'context' => [
'phone_number' => '+14155550123'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.persistence.dev/v1/workflows/{workflowId}/run"
payload := strings.NewReader("{\n \"context\": {\n \"phone_number\": \"+14155550123\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.persistence.dev/v1/workflows/{workflowId}/run")
.header("Idempotency-Key", "<idempotency-key>")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"context\": {\n \"phone_number\": \"+14155550123\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.persistence.dev/v1/workflows/{workflowId}/run")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"context\": {\n \"phone_number\": \"+14155550123\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"automationId": "<string>",
"version": 123,
"status": "queued",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"automationName": "<string>",
"parentRunId": "<string>",
"parentStepId": "<string>",
"currentStepId": "<string>",
"concurrencyKey": "<string>",
"currentNodeId": "<string>",
"currentNodeTitle": "<string>",
"context": {},
"output": {},
"error": {},
"revision": 123,
"wakeAt": "2023-11-07T05:31:56Z"
}
}{
"code": "<string>",
"error": "<string>"
}{
"code": "<string>",
"error": "<string>"
}{
"code": "<string>",
"error": "<string>"
}{
"code": "<string>",
"error": "<string>"
}{
"code": "<string>",
"error": "<string>"
}