Test an automation against a sample event
Módulo Platform
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`.
- Requiere la capacidad org.automations.write.
- Alcances de OAuth: org.
- Envía el encabezado Idempotency-Key. Una repetición con la misma clave devuelve la respuesta original.
- Estados de error: 400, 401, 404, 409, 422, 429. Los errores son detalles de problema RFC 9457.
Parámetros de ruta y de consulta
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| id | string (uuid) | Sí | Identifier of the automation. |
Cuerpo de la solicitud: AutomationTestRequest
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| event | object | Sí | A 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"
}
}
}Respuesta 200: AutomationTestResult
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| matched | boolean | Sí | Whether the conditions hold for the sample event. |
| conditions | array of AutomationConditionResult | Sí | Each condition in document order. |
{
"matched": true,
"conditions": []
}Ejemplos de código
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"}}}'