Open or close a survey
Módulo Workforce
POST/surveys/{id}/transitionsurveys.transition
Opens a draft survey (notifying its audience) or closes an open one. Requires `Idempotency-Key`; a replay returns the original response. A rule that refuses the request returns 422 with `refusal` and `reason`.
- Requiere la capacidad knowledge.sop.publish.
- Alcances de OAuth: knowledge.
- 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 survey. |
Cuerpo de la solicitud: SurveyTransitionRequest
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| expected_state | "Draft" | "Open" | "Closed" | Sí | The state the caller believes the row is in. |
| to_state | "Draft" | "Open" | "Closed" | Sí | Target state. |
| reason | string | Sí | Why the state changes.Restricciones: length 1 to 500 |
{
"expected_state": "Draft",
"to_state": "Open",
"reason": "Ready to go."
}Respuesta 200: WorkforceLedgerEntry
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| ledger_id | string (uuid) | Sí | The state transition ledger entry written. |
{
"ledger_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"
}Ejemplos de código
curl -X POST "$XOS_BASE_URL/surveys/0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f/transition" \
-H "Authorization: Bearer $XOS_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"expected_state":"Draft","to_state":"Open","reason":"Ready to go."}'const { data } = await xos.surveys.transition("0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", {
"expected_state": "Draft",
"to_state": "Open",
"reason": "Ready to go."
});response = xos.surveys.transition("0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", {"expected_state": "Draft", "to_state": "Open", "reason": "Ready to go."})xos surveys transition 0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f --data '{"expected_state":"Draft","to_state":"Open","reason":"Ready to go."}'