Create Workflow
curl --request POST \
--url https://api.example.com/v1/workflows \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"condition_entity": "<string>",
"condition_field": "<string>",
"condition_operator": "<string>",
"condition_value": "<string>",
"action_type": "<string>",
"action_config": {},
"max_triggers_per_day": 123,
"enabled": true
}
'import requests
url = "https://api.example.com/v1/workflows"
payload = {
"name": "<string>",
"condition_entity": "<string>",
"condition_field": "<string>",
"condition_operator": "<string>",
"condition_value": "<string>",
"action_type": "<string>",
"action_config": {},
"max_triggers_per_day": 123,
"enabled": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
condition_entity: '<string>',
condition_field: '<string>',
condition_operator: '<string>',
condition_value: '<string>',
action_type: '<string>',
action_config: {},
max_triggers_per_day: 123,
enabled: true
})
};
fetch('https://api.example.com/v1/workflows', 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.example.com/v1/workflows",
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([
'name' => '<string>',
'condition_entity' => '<string>',
'condition_field' => '<string>',
'condition_operator' => '<string>',
'condition_value' => '<string>',
'action_type' => '<string>',
'action_config' => [
],
'max_triggers_per_day' => 123,
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.example.com/v1/workflows"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"condition_entity\": \"<string>\",\n \"condition_field\": \"<string>\",\n \"condition_operator\": \"<string>\",\n \"condition_value\": \"<string>\",\n \"action_type\": \"<string>\",\n \"action_config\": {},\n \"max_triggers_per_day\": 123,\n \"enabled\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/v1/workflows")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"condition_entity\": \"<string>\",\n \"condition_field\": \"<string>\",\n \"condition_operator\": \"<string>\",\n \"condition_value\": \"<string>\",\n \"action_type\": \"<string>\",\n \"action_config\": {},\n \"max_triggers_per_day\": 123,\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/workflows")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"condition_entity\": \"<string>\",\n \"condition_field\": \"<string>\",\n \"condition_operator\": \"<string>\",\n \"condition_value\": \"<string>\",\n \"action_type\": \"<string>\",\n \"action_config\": {},\n \"max_triggers_per_day\": 123,\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {}
}Workflows
Create Workflow
Define a new automation workflow that triggers on entity changes
POST
/
v1
/
workflows
Create Workflow
curl --request POST \
--url https://api.example.com/v1/workflows \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"condition_entity": "<string>",
"condition_field": "<string>",
"condition_operator": "<string>",
"condition_value": "<string>",
"action_type": "<string>",
"action_config": {},
"max_triggers_per_day": 123,
"enabled": true
}
'import requests
url = "https://api.example.com/v1/workflows"
payload = {
"name": "<string>",
"condition_entity": "<string>",
"condition_field": "<string>",
"condition_operator": "<string>",
"condition_value": "<string>",
"action_type": "<string>",
"action_config": {},
"max_triggers_per_day": 123,
"enabled": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
condition_entity: '<string>',
condition_field: '<string>',
condition_operator: '<string>',
condition_value: '<string>',
action_type: '<string>',
action_config: {},
max_triggers_per_day: 123,
enabled: true
})
};
fetch('https://api.example.com/v1/workflows', 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.example.com/v1/workflows",
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([
'name' => '<string>',
'condition_entity' => '<string>',
'condition_field' => '<string>',
'condition_operator' => '<string>',
'condition_value' => '<string>',
'action_type' => '<string>',
'action_config' => [
],
'max_triggers_per_day' => 123,
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.example.com/v1/workflows"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"condition_entity\": \"<string>\",\n \"condition_field\": \"<string>\",\n \"condition_operator\": \"<string>\",\n \"condition_value\": \"<string>\",\n \"action_type\": \"<string>\",\n \"action_config\": {},\n \"max_triggers_per_day\": 123,\n \"enabled\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/v1/workflows")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"condition_entity\": \"<string>\",\n \"condition_field\": \"<string>\",\n \"condition_operator\": \"<string>\",\n \"condition_value\": \"<string>\",\n \"action_type\": \"<string>\",\n \"action_config\": {},\n \"max_triggers_per_day\": 123,\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/workflows")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"condition_entity\": \"<string>\",\n \"condition_field\": \"<string>\",\n \"condition_operator\": \"<string>\",\n \"condition_value\": \"<string>\",\n \"action_type\": \"<string>\",\n \"action_config\": {},\n \"max_triggers_per_day\": 123,\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {}
}Request
Headers
Authorization: Bearer wbk_your_api_key_here
Content-Type: application/json
string
Optional UUID for retry deduplication within 24 hours.
Body Parameters
string
required
Human-readable name. 1 - 120 characters.
string
required
Entity type to listen on:
contact, deal, task, email, or meeting.string
required
Field on the entity to evaluate (e.g.
status, stage_id, tags).string
required
Operator:
equals, not_equals, contains, changed, changed_to, greater_than, less_than.string
required
Value to compare against. For
changed no value is needed but the parameter is still required as an empty string.string
required
Action to perform:
send_email, create_task, send_channel_message, webhook, update_field.object
required
Action-specific configuration. Accepts merge tokens referencing the triggering entity (e.g.
{{deal.name}}).integer
default:"100"
Circuit-breaker threshold. When exceeded, the workflow auto-disables and raises an alert.
boolean
default:"true"
Whether the workflow should be active upon creation.
Response
object
The created workflow record (same shape as
GET /v1/workflows/{id}).X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, and X-Request-ID.
curl -X POST \
https://data.leadlex.com/functions/v1/api-gateway/v1/workflows \
-H "Authorization: Bearer wbk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"name": "Ping owner on won deals",
"condition_entity": "deal",
"condition_field": "status",
"condition_operator": "changed_to",
"condition_value": "won",
"action_type": "send_channel_message",
"action_config": {
"channel": "slack",
"recipient": "#sales-wins",
"message": "Deal {{deal.name}} closed at {{deal.value}} {{deal.currency}}"
},
"max_triggers_per_day": 50
}'
import requests
API_KEY = "wbk_your_api_key_here"
BASE_URL = "https://data.leadlex.com/functions/v1/api-gateway"
payload = {
"name": "Ping owner on won deals",
"condition_entity": "deal",
"condition_field": "status",
"condition_operator": "changed_to",
"condition_value": "won",
"action_type": "send_channel_message",
"action_config": {
"channel": "slack",
"recipient": "#sales-wins",
"message": "Deal {{deal.name}} closed at {{deal.value}} {{deal.currency}}",
},
"max_triggers_per_day": 50,
}
r = requests.post(
f"{BASE_URL}/v1/workflows",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json=payload,
)
print(r.json()["data"]["id"])
const res = await fetch(
'https://data.leadlex.com/functions/v1/api-gateway/v1/workflows',
{
method: 'POST',
headers: {
'Authorization': 'Bearer wbk_your_api_key_here',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Ping owner on won deals',
condition_entity: 'deal',
condition_field: 'status',
condition_operator: 'changed_to',
condition_value: 'won',
action_type: 'send_channel_message',
action_config: {
channel: 'slack',
recipient: '#sales-wins',
message: 'Deal {{deal.name}} closed',
},
max_triggers_per_day: 50,
}),
}
);
const { data } = await res.json();
console.log(data.id);
Example Response
{
"data": {
"id": "wf_02HY2",
"name": "Ping owner on won deals",
"enabled": true,
"condition_entity": "deal",
"condition_field": "status",
"condition_operator": "changed_to",
"condition_value": "won",
"action_type": "send_channel_message",
"action_config": {
"channel": "slack",
"recipient": "#sales-wins",
"message": "Deal {{deal.name}} closed at {{deal.value}} {{deal.currency}}"
},
"max_triggers_per_day": 50,
"last_triggered_at": null,
"created_at": "2026-04-17T11:05:00Z"
}
}
Errors
| Status | Code | Description |
|---|---|---|
| 400 | validation_error | Missing required fields or unsupported operator/action combination |
| 401 | invalid_key | Invalid or expired API key |
| 403 | insufficient_permissions | Missing write:workflows permission |
| 409 | duplicate_name | A workflow with this name already exists |
| 429 | rate_limited | Rate limit exceeded |