Draft a survey
Módulo Workforce
POST/surveys/draftsurveys.draft
Drafts a pulse survey with its questions. 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, 409, 422, 429. Los errores son detalles de problema RFC 9457.
Cuerpo de la solicitud: SurveyDraftRequest
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| title | string | Sí | Survey title.Restricciones: length 1 to 200 |
| description | string | No | What the survey asks about.Restricciones: length 0 to 2000 |
| audience_kind | "Organization" | "Project" | "Team" | "Department" | "Role" | "Group" | No | Who the row reaches. Department (a canon department, 1365) is for feed posts only. |
| project_id | string (uuid) | No | Project audience. |
| team_id | string (uuid) | No | Team audience. |
| role_id | string (uuid) | No | Role audience. |
| group_id | string (uuid) | No | Group audience. |
| is_anonymous | boolean | No | Anonymous by default. |
| min_responses | integer | No | Responses before results show; 5 by default.Restricciones: range 3 to 1000 |
| closes_at | string (date-time) | No | When responses stop. |
| questions | array of object | Sí | 1 to 50 questions in order. |
{
"title": "Load-in pulse",
"description": "How did it go?",
"audience_kind": "Organization",
"project_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"team_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"role_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"group_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"is_anonymous": true,
"min_responses": 5,
"closes_at": "2026-10-08T14:30:00Z",
"questions": [
{
"prompt": "How safe did it feel?",
"kind": "Scale"
}
]
}Respuesta 201: Survey
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| id | string (uuid) | Sí | Identifier of the survey. |
| org_id | string (uuid) | Sí | Identifier of the owning organization, derived from the parent row and never accepted from the caller. |
| created_at | string (date-time) | Sí | When the row was created. |
| created_by | string (uuid) | null | Sí | Person who created the row; null for seed, platform or system writes. |
| updated_at | string (date-time) | Sí | When the row was last updated. |
| updated_by | string (uuid) | null | Sí | Person who last updated the row; null for seed, platform or system writes. |
| title | string | Sí | Survey title.Restricciones: length 1 to 200 |
| description | string | null | Sí | What the survey asks about.Restricciones: length 1 to 2000 |
| audience_kind | "Organization" | "Project" | "Team" | "Department" | "Role" | "Group" | Sí | Who the row reaches. Department (a canon department, 1365) is for feed posts only. |
| project_id | string (uuid) | null | Sí | Identifier of the project audience, or the project the row belongs to. |
| team_id | string (uuid) | null | Sí | Identifier of the team audience. |
| role_id | string (uuid) | null | Sí | Identifier of the org role audience. |
| group_id | string (uuid) | null | Sí | Identifier of the group audience, including department groups. |
| author_membership_id | string (uuid) | null | Sí | Identifier of the member who wrote the survey. |
| is_anonymous | boolean | Sí | Whether answers are stored with no respondent. |
| min_responses | integer | Sí | Responses needed before results show.Restricciones: range 3 to any |
| survey_state | "Draft" | "Open" | "Closed" | Sí | Draft, Open or Closed. |
| closes_at | string (date-time) | null | Sí | When responses stop. |
{
"id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"org_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"created_at": "2026-10-08T14:30:00Z",
"created_by": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"updated_at": "2026-10-08T14:30:00Z",
"updated_by": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"title": "Load-in pulse",
"description": "Tell us how the load-in felt.",
"audience_kind": "Organization",
"project_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"team_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"role_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"group_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"author_membership_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"is_anonymous": true,
"min_responses": 5,
"survey_state": "Draft",
"closes_at": "2026-10-08T14:30:00Z"
}Ejemplos de código
curl -X POST "$XOS_BASE_URL/surveys/draft" \
-H "Authorization: Bearer $XOS_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"title":"Load-in pulse","description":"How did it go?","audience_kind":"Organization","project_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","team_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","role_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","group_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","is_anonymous":true,"min_responses":5,"closes_at":"2026-10-08T14:30:00Z","questions":[{"prompt":"How safe did it feel?","kind":"Scale"}]}'const { data } = await xos.surveys.draft({
"title": "Load-in pulse",
"description": "How did it go?",
"audience_kind": "Organization",
"project_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"team_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"role_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"group_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f",
"is_anonymous": true,
"min_responses": 5,
"closes_at": "2026-10-08T14:30:00Z",
"questions": [
{
"prompt": "How safe did it feel?",
"kind": "Scale"
}
]
});response = xos.surveys.draft({"title": "Load-in pulse", "description": "How did it go?", "audience_kind": "Organization", "project_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", "team_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", "role_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", "group_id": "0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f", "is_anonymous": True, "min_responses": 5, "closes_at": "2026-10-08T14:30:00Z", "questions": [{"prompt": "How safe did it feel?", "kind": "Scale"}]})xos surveys draft --data '{"title":"Load-in pulse","description":"How did it go?","audience_kind":"Organization","project_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","team_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","role_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","group_id":"0192f1e2-7c3a-7b4d-9e8f-1a2b3c4d5e6f","is_anonymous":true,"min_responses":5,"closes_at":"2026-10-08T14:30:00Z","questions":[{"prompt":"How safe did it feel?","kind":"Scale"}]}'