Skip to content

Open or close a survey

Workforce module

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`.

  • Requires the capability knowledge.sop.publish.
  • OAuth scopes: knowledge.
  • 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

surveys.transition: Path and query parameters
FieldTypeRequiredDescription
idstring (uuid)YesIdentifier of the survey.

Request body: SurveyTransitionRequest

surveys.transition: SurveyTransitionRequest
FieldTypeRequiredDescription
expected_state"Draft" | "Open" | "Closed"YesThe state the caller believes the row is in.
to_state"Draft" | "Open" | "Closed"YesTarget state.
reasonstringYesWhy the state changes.Constraints: length 1 to 500
{
  "expected_state": "Draft",
  "to_state": "Open",
  "reason": "Ready to go."
}

Response 200: WorkforceLedgerEntry

surveys.transition: WorkforceLedgerEntry
FieldTypeRequiredDescription
ledger_idstring (uuid)YesThe state transition ledger entry written.
{
  "ledger_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"
}

Code samples

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."}'