Saltar al contenido

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

automations.test: Parámetros de ruta y de consulta
CampoTipoObligatorioDescripción
idstring (uuid)SíIdentifier of the automation.

Cuerpo de la solicitud: AutomationTestRequest

automations.test: AutomationTestRequest
CampoTipoObligatorioDescripción
eventobjectSí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

automations.test: AutomationTestResult
CampoTipoObligatorioDescripción
matchedbooleanSíWhether the conditions hold for the sample event.
conditionsarray of AutomationConditionResultSí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"}}}'