Skip to content

Respond to a survey

Workforce module

POST/surveys/{id}/respondsurveys.respond

Responds once with answers keyed by question id. Anonymous answers carry no respondent. 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.acknowledge.
  • 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.respond: Path and query parameters
FieldTypeRequiredDescription
idstring (uuid)YesIdentifier of the survey.

Request body: SurveyResponseRequest

surveys.respond: SurveyResponseRequest
FieldTypeRequiredDescription
answersobjectYesAnswers keyed by question id.
{
  "answers": {
    "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f": 4
  }
}

Response 200: SurveyResponseResult

surveys.respond: SurveyResponseResult
FieldTypeRequiredDescription
response_idstring (uuid) | nullYesThe response, or null for an anonymous survey.
{
  "response_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f"
}

Code samples

curl -X POST "$XOS_BASE_URL/surveys/0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f/respond" \
  -H "Authorization: Bearer $XOS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"answers":{"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f":4}}'
const { data } = await xos.surveys.respond("0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", {
    "answers": {
      "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f": 4
    }
  });
response = xos.surveys.respond("0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", {"answers": {"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f": 4}})
xos surveys respond 0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f --data '{"answers":{"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f":4}}'