Triggers & Creation
API reference for creating workflows and configuring event-based and scheduled triggers.
Create workflows with event-based or scheduled triggers that execute actions automatically.
Which triggers your key reaches
A trigger belongs to a caller service within the key's organisation: the one that created it, with the organisation of the key that created it. Two organisations can use the same caller service name; neither ever lists, reads, dry-runs, changes or deletes the other's triggers (another organisation's trigger is 404 NOT_FOUND; a dry run answers 200 with dryRun.reason: "Trigger not found" and wouldMatch: false). A trigger with no organisation (created before PlatformXe recorded organisations, or by a platform key) stays readable by its caller service's keys, but a key with an organisation cannot change or delete it (404 NOT_FOUND); ask Caldera to assign it to your organisation.
-
Platform keys (no organisation) reach only triggers with no organisation: they list, read and change their caller service's, read the platform ones, and never reach an organisation's trigger.
-
Platform triggers (no
sourceApp, no organisation) are platform-managed. A key with an organisation does not list or read them; they run only for platform events, never for your organisation's. A platform key (no organisation) still lists and reads them. -
recentExecutions(inGET /api/v1/workflows/{id}) holds the data of the events a trigger ran on, so a key receives it only for a trigger of its own organisation (a platform key: a trigger with no organisation); otherwise it is[]. -
Trigger codes are unique across all triggers: a code another organisation already uses is
409 DUPLICATE.
List workflows
Retrieve the workflows of a caller service within the key's organisation (see above).
GET /api/v1/workflows
Scope: workflows:write
Query parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
isActive | boolean | No | Filter by active status (true or false) |
triggerType | string | No | Filter by trigger type: EVENT or SCHEDULE |
eventType | string | No | Filter by one of the workflow event types. Strict: any other value is 400 VALIDATION_ERROR, even one a trigger of yours holds |
page | integer | No | Page number, from 1 (default 1) |
limit | integer | No | Page size, from 1 (default 50; above 100 is 100) |
A value that is not valid (a page or limit that is not a whole number of at least 1, an unknown triggerType or eventType) is 400 VALIDATION_ERROR. An empty value is ignored.
Response
{
"success": true,
"data": {
"workflows": [
{
"id": "wf_abc123def456",
"name": "Notify on payment failure",
"trigger": {
"type": "event",
"eventType": "PAYMENT_FAILED"
},
"actions": [
{
"type": "WEBHOOK",
"config": {
"url": "https://yourapp.com/alerts",
"method": "POST"
}
}
],
"active": true,
"createdAt": "2026-04-01T10:00:00.000Z",
"lastTriggeredAt": "2026-04-05T14:30:00.000Z"
}
]
}
}
curl
curl https://api.platformxe.com/api/v1/workflows \
-H "x-api-key: pxk_live_your_api_key_here"
Create a workflow
Register a new workflow with trigger and action configuration.
POST /api/v1/workflows
Scope: events:manage
Request body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name; not blank |
code | string | Yes | Unique across every trigger (another tenant's included); not blank. A code in use is 409 DUPLICATE |
triggerType | string | Yes | EVENT or SCHEDULE |
eventType | string | For EVENT | The workflow event type the trigger fires on, one of the event types (case-sensitive). Required when triggerType is EVENT: a trigger without one would never fire |
entityType | string | No | Fire only for events of this entity type (or events with none) |
conditions | object | No | Conditions on the event data (see Event matching) |
actions | Array<object> | Yes | Actions to run, each { "type": "SEND_EMAIL", "config": { ... } } (see Action configuration) |
cronExpression | string | No | Stored with a SCHEDULE trigger (see Scheduled triggers) |
description, isActive, priority, cooldownMinutes, maxExecutionsDay | No | isActive defaults to true, priority to 0 | |
sourceApp | string | No | Leave it out: your caller service. A tenant key may name only that |
entityQueryEndpoint | string | No | Platform keys only (see below) |
A blank name or code, a triggerType other than EVENT / SCHEDULE, an eventType that is not on Workflow Event Types, an unknown entityType, and an EVENT trigger with no eventType are 400 VALIDATION_ERROR, and nothing is stored. The same field rules apply to an update.
Event matching
An EVENT trigger fires on an event whose type is exactly its eventType (there are no wildcards), and only on events it may see (see Which triggers your key reaches). With an entityType it fires only for events of that entity type, or events with none. Its conditions must then all hold on the event data: { "amount": { "gte": 100000 } }, or { "status": "CONFIRMED" } for equality. A SCHEDULE trigger never fires on an event, whatever eventType it holds.
Scheduled triggers
The scheduled run (every five minutes) runs every active SCHEDULE trigger. It does not read cronExpression yet: the value is stored with the trigger, and a trigger with or without one runs the same way.
Entity query endpoint (scheduled triggers)
The entity query is a platform-managed feature: it is for platform-managed triggers, and its requests are signed with a platform secret that is never shared with tenants. Only a platform key (an API key with no organization, issued from the PlatformXe dashboard) or a dashboard admin can set entityQueryEndpoint. A tenant key that sends a non-empty value is refused 403 ENTITY_QUERY_NOT_ALLOWED (clearing it with null or '' is always allowed), and PlatformXe never calls the endpoint of a trigger that is not platform-managed, including one stored before 2026-11-01.
A scheduled trigger finds the records to act on by calling the source app's endpoint. Set entityQueryEndpoint on create (POST /api/v1/workflows) or update (PATCH /api/v1/workflows/{id}) with a platform key; send null or an empty string to clear it.
URL rule. The URL must:
- use
https://; - carry no credentials (
https://user:pass@…is refused); - name a public host —
localhost, private, loopback, link-local and metadata addresses are refused, and so is a host name whose DNS answer includes any non-public address.
The rule is checked when the trigger is saved — a failing URL is answered 400 VALIDATION_ERROR with a message such as entityQueryEndpoint must use HTTPS and nothing is stored — and again immediately before every request (the connection is pinned to the address that passed). Redirects are not followed, each request has a 10-second deadline, and at most 1 MiB of the answer is read; a redirect, a non-2xx status, an oversized or non-JSON answer simply yields no entities for that run.
Request. On each run PlatformXe sends:
POST <entityQueryEndpoint>
Content-Type: application/json
X-Caldera-Signature: sha256=<hex HMAC-SHA256 of "{timestamp}.{raw body}">
X-Caldera-Timestamp: <unix seconds>
X-Caldera-Delivery-Id: <uuid>
{"target":"<entityQueryEndpoint>","triggerId":"<trigger id>","sourceApp":"<owner or null>","entityType":"BOOKING","eventType":"BOOKING_CREATED","conditions":{...}}
There is no Authorization header — the secret is never sent. The signed body names the exact target URL, the triggerId and the sourceApp, so a signature is only meaningful at the endpoint it was made for. A receiver must:
- verify the signature over the raw body with
verifyWebhookWithReplayKey(canonical headers only, a delivery id required); - refuse a
replayKey(or delivery id) it has already accepted inside the 300-second window; - check that
targetis exactly its own endpoint URL.
import { verifyWebhookWithReplayKey } from '@caldera/keys-service';
const MY_URL = 'https://app.example.com/api/internal/workflow-entities';
export async function POST(req: Request) {
const body = await req.text(); // the exact bytes — never a re-serialised object
const check = verifyWebhookWithReplayKey({
secrets: process.env.WORKFLOW_INTERNAL_SECRET!, // several during a rotation
body,
headers: req.headers,
});
if (!check.ok) return new Response('invalid signature', { status: 401 });
// Record the replay key for the tolerance window; a second sight is a replay.
if (!(await recordOnce(check.replayKey, 300))) return new Response('replayed', { status: 409 });
const { target, entityType, conditions } = JSON.parse(body);
if (target !== MY_URL) return new Response('wrong target', { status: 401 });
const data = await findMatching(entityType, conditions);
return Response.json({ success: true, data }); // each item needs an `id`
}
Response. Answer 200 with { "success": true, "data": [ { "id": "…", … }, … ] }. Each item must be an object whose id is a non-empty string of at most 256 characters (or a finite number); other items are skipped. At most 1,000 entities are used per run — the rest are dropped and logged. Each kept item's id becomes the execution's entity id and the whole item is available to the trigger's conditions and action templates.
Receivers built before 2026-11-01 checked Authorization: Bearer <secret>. That header is no longer sent; switch the check to verifyWebhookWithReplayKey and the target comparison as above.
Action configuration
Each action has a type and a config object. The types the executor runs are SEND_NOTIFICATION, SEND_EMAIL, SEND_SMS, SEND_WHATSAPP, SEND_PUSH, UPDATE_STATUS, CREATE_ISSUE, CREATE_TASK, ESCALATE, ENROLL_FOLLOW_UP, AUTO_ROUTE_ISSUE, ADD_TAG and WEBHOOK; any other type is skipped when the trigger runs. String values may hold {{field}} templates, filled from the event data when the action runs.
{
"type": "SEND_NOTIFICATION",
"config": {
"title": "Email delivery failed",
"message": "An email to {{recipient}} failed. Check the dashboard for details.",
"priority": "HIGH",
"recipients": ["OPERATIONS"]
}
}
{
"type": "WEBHOOK",
"config": {
"url": "https://yourapp.com/automation/handler",
"method": "POST"
}
}
A WEBHOOK is sent to a public https:// URL. Signing (X-Caldera-Signature) uses secretRef, the name of a secret held on PlatformXe (matching WORKFLOW_SECRET_[A-Z0-9_]+): Caldera provisions one on request, and a trigger naming a secret that is not provisioned is refused at every send, so leave secretRef out unless Caldera has given you a name. A headers entry that carries a secret (such as Authorization) is flagged by the dry run (POST /api/v1/workflows/{id}, its validation verdict); saving the trigger does not check headers today, and they are sent as stored.
{
"type": "CREATE_TASK",
"config": {
"title": "Follow up on {{bookingRef}}",
"priority": "HIGH",
"dueDays": 2
}
}
{
"type": "SEND_EMAIL",
"config": {
"recipient": "Ops Desk <ops@yourapp.com>",
"subject": "Booking {{bookingRef}} confirmed",
"html": "<p>Hello {{guestName}}</p>"
}
}
A SEND_EMAIL recipient is checked when the trigger is saved (create, and update when actions is sent): it must be one email address of at most 320 characters, either a bare address or "name <address>" — the same rule as a to entry of POST /api/v1/messaging/email/send — or such an address written with {{field}} templates, resolved from the event data and checked again when the email is sent. A template is checked by the text around it: {{guestEmail}}, Guest <{{guestEmail}}>, {{guestName}} <{{guestEmail}}> and {{local}}@yourapp.com are accepted; ops@yourapp.com, {{guestEmail}} (a second address), junk {{x}}, an unclosed {{, an empty or blank token ({{}}, {{ }}), a token holding a brace ({{{guestEmail}}}) and a value over 320 characters are not. Two addresses, an address with no domain, or an unquoted comma in the name (quote the name instead) are answered 400 VALIDATION_ERROR with the message actions.<n>.config.recipient: must be one email address … and nothing is stored. A templated display name ({{guestName}} <{{guestEmail}}>) is cleaned (whether you quoted it or not, and whatever the event data holds) and then quoted when it needs to be, so a name holding a comma, brackets or other punctuation (Smith, Jones & Co) stays one name; line breaks and other control characters in it become spaces, and an address written inside it is dropped (a name that is only an address leaves the bare recipient address). Use recipientField to take the address from the event data.
Your organisation. A trigger created with an API key that belongs to an organisation is recorded as that organisation's (a platform key's trigger has none; an organizationId in the request body is ignored). Its actions run as that organisation: a task it creates is the organisation's, and its emails are sent and logged as the organisation's (its sending-domain settings apply, as for POST /api/v1/messaging/email/send). An email PlatformXe refuses (for example a {{field}} that resolved to something that is not one address) or the providers refuse is recorded as a failed step, with the reason, in that execution. An email queued for retry because every provider was down is a completed step, and so is one whose identical copy (same recipients, subject and content, from the same organisation) is already waiting in the retry queue: that queued email is sent once. An email PlatformXe declines is recorded as a DEFERRED step with a fixed reason, for any of these: the sending limit for its recipient was reached; no email provider is configured; or every provider failed and the retry queue could not store it. A deferred email is not retried, by the workflow or the queue (the run is not resumable for it); a deferred step is not a failure and never counts toward the trigger being disabled.
Run time limit. An event or scheduled run has 30 seconds (an /evaluate run has no limit). An action not finished by then is recorded as a skipped step ("Not run: the execution timed out"); the run is PARTIAL when an earlier action finished without failing and FAILED when none did, with the timeout as its error. An action still in flight at the deadline can complete after it was recorded as not run, so resuming a timed-out run may repeat its last action. A run whose result could not be recorded is marked FAILED with no step record and is never resumed, so its actions are not run twice; unlike other failed runs it still holds the trigger's cooldown, since its actions may have run.
Auto-disable. A trigger whose runs fail five times in a row (every action of the run failed, or the run stopped before any action finished) is switched off, with the reason stored as disabledReason, and PlatformXe emits WORKFLOW_TRIGGER_DISABLED to the trigger's organisation (see the event catalog). A run with at least one action that did not fail resets the count. When a failure switches a scheduled trigger off, the rest of that run's entities are not processed. Turning the trigger back on (isActive: true) clears the count and the stored reason.
SDK
import { PlatformXeClient } from '@caldera/platformxe-sdk';
const px = new PlatformXeClient({ apiKey: 'pxk_live_your_api_key_here' });
// Event-based workflow
const result = await px.workflows.create({
name: 'Notify on payment failure',
trigger: {
type: 'event',
eventType: 'PAYMENT_FAILED',
},
actions: [
{
type: 'WEBHOOK',
config: {
url: 'https://yourapp.com/alerts',
method: 'POST',
},
},
],
});
console.log(result.data.id);
// "wf_abc123def456"
// Scheduled workflow
const scheduled = await px.workflows.create({
name: 'Daily usage report',
trigger: {
type: 'scheduled',
cron: '0 9 * * 1-5', // Weekdays at 09:00 UTC
},
actions: [
{
type: 'SEND_EMAIL',
config: {
recipient: 'ops@yourapp.com',
subject: 'Daily Usage Report',
html: '<p>Your daily usage report is ready.</p>',
},
},
],
});
Test a trigger with the dry run (POST /api/v1/workflows/{id}) before you switch it on: it shows whether the conditions match and which actions would run, and runs none of them.
Update a workflow
PATCH /api/v1/workflows/{id} changes only the fields it sends, with the create's field rules. It takes name, description, code, triggerType (EVENT or SCHEDULE), eventType, entityType, cronExpression, conditions, actions, isActive, priority, cooldownMinutes, maxExecutionsDay and entityQueryEndpoint; null clears description, eventType, entityType, cronExpression, conditions, cooldownMinutes and maxExecutionsDay. The answer is { "trigger": { ... } }.
- Code, trigger type, event type, entity type. They can change: the trigger keeps its id and its executions, and each execution records the event and entity type it ran on. A code another trigger holds is
409 DUPLICATEand nothing is written; aneventTypethat is not on Workflow Event Types, or an unknownentityType, is400 VALIDATION_ERROR. Sending your trigger's storedeventTypeback unchanged is always accepted (Terraform sends every field on update). TheeventTypefilter of the list is strict: it takes only the values on that page, whatever your triggers hold. A change that would leave anEVENTtrigger with noeventType(clearing it, or switching aSCHEDULEtrigger without one toEVENT) is400 VALIDATION_ERROR: the rule is checked on the stored trigger with your change applied. sourceApp. A trigger belongs to the service that created it and never moves.sourceAppis accepted only as your caller service (it changes nothing); any other value is400 VALIDATION_ERROR(sourceApp cannot be changed: a trigger belongs to the service that created it).- Delete (
DELETE /api/v1/workflows/{id}) switches the trigger off (isActive: false,disabledReason: "Deleted via API"): there is no hard delete, so its code stays reserved. Turn it back on withisActive: true.
curl -X PATCH https://api.platformxe.com/api/v1/workflows/trg_abc123 \
-H "x-api-key: pxk_live_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{ "code": "INVOICE_SETTLED_NOTIFY", "eventType": "PAYMENT_RECEIVED", "entityType": null }'
Error responses
| Code | Description |
|---|---|
INVALID_BODY | The body is not JSON |
VALIDATION_ERROR | A field failed validation — a blank name or code, a triggerType other than EVENT / SCHEDULE, an unknown eventType or entityType, an EVENT trigger with no eventType, and an entityQueryEndpoint that is not HTTPS, carries credentials, or targets a private / local host or address, and a SEND_EMAIL recipient that is not one email address (or a {{field}} template) |
FORBIDDEN | API key does not have the workflows:read (reads) or workflows:write (writes, evaluate) scope |
ENTITY_QUERY_NOT_ALLOWED | A non-platform API key tried to set entityQueryEndpoint (403) — the entity query is reserved for platform-managed triggers |
NOT_FOUND | The trigger does not exist or is not a caller service's within the key's organisation (another organisation's trigger, even under the same caller service name). Platform triggers (no sourceApp) cannot be updated or deleted through the API, and only a platform key reads them |
DUPLICATE | 409: the trigger code is already used (codes are unique across all triggers), on create or on an update that changes the code |
RATE_LIMITED | Rate limit exceeded for this API key |