Saltar al contenido

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

surveys.transition: Parámetros de ruta y de consulta
CampoTipoObligatorioDescripción
idstring (uuid)SíIdentifier of the survey.

Cuerpo de la solicitud: SurveyTransitionRequest

surveys.transition: SurveyTransitionRequest
CampoTipoObligatorioDescripción
expected_state"Draft" | "Open" | "Closed"SíThe state the caller believes the row is in.
to_state"Draft" | "Open" | "Closed"SíTarget state.
reasonstringSíWhy the state changes.Restricciones: length 1 to 500
{
  "expected_state": "Draft",
  "to_state": "Open",
  "reason": "Ready to go."
}

Respuesta 200: WorkforceLedgerEntry

surveys.transition: WorkforceLedgerEntry
CampoTipoObligatorioDescripción
ledger_idstring (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."}'