Workflows
SDK methods for managing event-driven workflow automations.
The client.workflows namespace provides typed methods for creating, managing, and evaluating event-driven workflow automations. Workflows match incoming events to trigger conditions and execute ordered action sequences. Available in TypeScript, Python, and Go SDKs.
| SDK | Install | Namespace |
|---|---|---|
| TypeScript | npm install @caldera/platformxe-sdk | client.workflows |
| Python | pip install platformxe | client.workflows |
| Go | go get github.com/calderax/platformxe-go | client.Workflows |
List workflows
const { workflows } = await client.workflows.list();
for (const wf of workflows) {
console.log(`${wf.id}: ${wf.name} (${wf.isActive ? 'active' : 'inactive'})`);
}
result = client.workflows.list()
result, err := client.Workflows.List()
Create a workflow
Define a workflow with a trigger configuration and an ordered list of actions.
const workflow = await client.workflows.create({
name: 'Invoice Payment Notification',
triggerConfig: {
eventType: 'INVOICE_PAID',
filters: {
'payload.amount': { gte: 100000 },
},
},
actions: [
{
type: 'webhook',
config: { webhookId: 'whk_abc123' },
},
{
type: 'email',
config: {
to: 'finance@example.com',
templateId: 'tmpl_receipt',
},
},
],
isActive: true,
});
console.log(workflow.id); // "wf_abc123"
workflow = client.workflows.create(
name="Invoice Payment Notification",
trigger_config={
"eventType": "INVOICE_PAID",
"filters": {"payload.amount": {"gte": 100000}},
},
actions=[
{"type": "webhook", "config": {"webhookId": "whk_abc123"}},
{"type": "email", "config": {"to": "finance@example.com", "templateId": "tmpl_receipt"}},
],
is_active=True,
)
workflow, err := client.Workflows.Create(map[string]interface{}{
"name": "Invoice Payment Notification",
"triggerConfig": map[string]interface{}{
"eventType": "INVOICE_PAID",
"filters": map[string]interface{}{
"payload.amount": map[string]interface{}{"gte": 100000},
},
},
"actions": []map[string]interface{}{
{"type": "webhook", "config": map[string]interface{}{"webhookId": "whk_abc123"}},
{"type": "email", "config": map[string]interface{}{"to": "finance@example.com", "templateId": "tmpl_receipt"}},
},
"isActive": true,
})
Get a workflow
const workflow = await client.workflows.get('wf_abc123');
workflow = client.workflows.get("wf_abc123")
workflow, err := client.Workflows.Get("wf_abc123")
Update a workflow
const updated = await client.workflows.update('wf_abc123', {
name: 'High-Value Invoice Alert',
isActive: false,
});
updated = client.workflows.update(
"wf_abc123",
name="High-Value Invoice Alert",
is_active=False,
)
updated, err := client.Workflows.Update("wf_abc123", map[string]interface{}{
"name": "High-Value Invoice Alert",
"isActive": false,
})
Delete a workflow
await client.workflows.delete('wf_abc123');
client.workflows.delete("wf_abc123")
result, err := client.Workflows.Delete("wf_abc123")
Evaluate
Test which workflows would match a given event type and payload. Returns the list of matching workflows and the actions that would execute.
const result = await client.workflows.evaluate({
eventType: 'INVOICE_PAID',
payload: {
invoiceId: 'inv_001',
amount: 250000,
currency: 'NGN',
},
});
console.log(result.matched); // Number of matching workflows
console.log(result.workflows); // Array of matched workflow details
result = client.workflows.evaluate(
event_type="INVOICE_PAID",
payload={"invoiceId": "inv_001", "amount": 250000, "currency": "NGN"},
)
result, err := client.Workflows.Evaluate("INVOICE_PAID", map[string]interface{}{
"invoiceId": "inv_001",
"amount": 250000,
"currency": "NGN",
})
Dry run
Execute a specific workflow trigger against a test context without side effects. Validates that the trigger conditions match and shows which actions would fire.
const result = await client.workflows.dryRun('wf_abc123', {
eventType: 'INVOICE_PAID',
payload: {
invoiceId: 'inv_001',
amount: 250000,
},
});
console.log(result.matched); // true
console.log(result.actionsToExecute); // ['webhook', 'email']
result = client.workflows.dry_run(
"wf_abc123",
context={
"eventType": "INVOICE_PAID",
"payload": {"invoiceId": "inv_001", "amount": 250000},
},
)
result, err := client.Workflows.DryRun("wf_abc123", map[string]interface{}{
"eventType": "INVOICE_PAID",
"payload": map[string]interface{}{
"invoiceId": "inv_001",
"amount": 250000,
},
})
Use dryRun during development to validate workflow configurations before activating them. It exercises the full trigger evaluation pipeline without executing any actions.
Scopes required
| Method | Scope |
|---|---|
workflows.list() | events:read |
workflows.create() | events:manage |
workflows.get() | events:read |
workflows.update() | events:manage |
workflows.delete() | events:manage |
workflows.evaluate() | events:read |
workflows.dryRun() | events:read |