Skip to content

Test an automation against a sample event

Platform module

POST/automations/{id}/testautomations.test

Dry run of the automation's conditions against a sample event body through `app.test_automation`: whether they match and, per condition, the value found. Nothing runs and nothing is written. Needs org.automations.write. Requires `Idempotency-Key`; a replay returns the original response. A rule that refuses the request returns 422 with `refusal` and `reason`.

  • Requires the capability org.automations.write.
  • OAuth scopes: org.
  • Send an Idempotency-Key header. A replay with the same key returns the original response.
  • Error statuses: 400, 401, 404, 409, 422, 429. Errors are RFC 9457 problem details.

Path and query parameters

automations.test: Path and query parameters
FieldTypeRequiredDescription
idstring (uuid)YesIdentifier of the automation.

Request body: AutomationTestRequest

automations.test: AutomationTestRequest
FieldTypeRequiredDescription
eventobjectYesA sample event body, as a webhook receives it; app.sample_automation_event gives the org's latest of the trigger type.
{
  "event": {
    "id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
    "type": "record.created",
    "occurred_at": "2026-10-08T14:30:00Z",
    "project_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
    "subject": {
      "table": "records",
      "id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"
    },
    "data": {
      "record_kind": "Task",
      "title": "Call the venue"
    }
  }
}

Response 200: AutomationTestResult

automations.test: AutomationTestResult
FieldTypeRequiredDescription
matchedbooleanYesWhether the conditions hold for the sample event.
conditionsarray of AutomationConditionResultYesEach condition in document order.
{
  "matched": true,
  "conditions": []
}

Code samples

curl -X POST "$XOS_BASE_URL/automations/0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f/test" \
  -H "Authorization: Bearer $XOS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"event":{"id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","type":"record.created","occurred_at":"2026-10-08T14:30:00Z","project_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","subject":{"table":"records","id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"},"data":{"record_kind":"Task","title":"Call the venue"}}}'
const { data } = await xos.automations.test("0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", {
    "event": {
      "id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
      "type": "record.created",
      "occurred_at": "2026-10-08T14:30:00Z",
      "project_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
      "subject": {
        "table": "records",
        "id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"
      },
      "data": {
        "record_kind": "Task",
        "title": "Call the venue"
      }
    }
  });
response = xos.automations.test("0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", {"event": {"id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", "type": "record.created", "occurred_at": "2026-10-08T14:30:00Z", "project_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", "subject": {"table": "records", "id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"}, "data": {"record_kind": "Task", "title": "Call the venue"}}})
xos automations test 0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f --data '{"event":{"id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","type":"record.created","occurred_at":"2026-10-08T14:30:00Z","project_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","subject":{"table":"records","id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"},"data":{"record_kind":"Task","title":"Call the venue"}}}'