{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://spec.openapis.org/oas/3.1/dialect/base",
  "info": {
    "title": "Polls API",
    "version": "1.0.0",
    "summary": "Build, publish and collect Typeform-style surveys.",
    "description": "Polls is a Typeform-style survey system: builders sign in with thermals-id and design surveys; anyone with the link answers them one question at a time, with no account. Everything the builder app at `/app` does goes through this API, so anything you can do there you can script.\n\n## Concepts\n\n- A **survey** has a **draft** (`title`, `description`, `settings`, `questions`) that only its owner sees. **Publishing** snapshots the draft; takers only ever see that snapshot, at `/s/{slug}` and through the Public endpoints. Edit freely, then publish again when ready.\n- `status` is `draft` (never published), `open` (taking responses) or `closed`. A survey closes by hand, when `settings.closesAt` passes, or when `settings.maxResponses` is reached.\n- There are twelve **question types**. Each has its own fields and its own **answer** shape; see the `Question` and `AnswerValue` schemas.\n- **Responses** are stored without IP address, user agent or cookie.\n\n## Authentication\n\nPublic endpoints (`/api/public/*` and `/healthz`) need no credentials. Everything else needs one of:\n\n- **API token** (scripts, CI, integrations). Mint one while signed in at [/app/tokens](/app/tokens). A token looks like `polls_` followed by 43 base64url characters, is shown once, lasts 90 days by default (365 at most) and acts as the person who minted it. Send it as `Authorization: Bearer polls_...`. Tokens cannot list, mint or revoke tokens.\n- **Session cookie** (the browser app). Signing in through `/auth/login` sets `__Host-polls_session` (HttpOnly, Secure, SameSite=Lax), which expires after 8 hours idle or 7 days in total.\n\nIf a request carries both, the bearer token wins and the cookie is ignored.\n\n### CSRF rule for cookie requests\n\nA cookie-authenticated request with any method other than GET or HEAD must send an `Origin` header equal to `https://polls.skywardfederal.com` or `https://polls.thermals.app` and, when it has a body, `Content-Type: application/json`. Otherwise it is refused with `403 forbidden`. Browsers do this for you; bearer-token requests are exempt.\n\n### Browser sign-in routes\n\nThese are browser redirects, not API operations:\n\n- `GET /auth/login?next=/app/...` starts sign-in with thermals-id (OIDC with PKCE). `next` must be a same-origin path starting with `/app`.\n- `GET /auth/callback` finishes sign-in and sets the session cookie.\n- `POST /auth/logout` ends the session and redirects (303) to `/`.\n- `POST /auth/backchannel-logout` receives logout tokens from thermals-id.\n\n## Requests and responses\n\nAll bodies are JSON (`application/json; charset=utf-8`) except the CSV export and survey files: `POST /api/surveys/import` also takes, and `GET /api/surveys/{id}/export` returns, a survey as YAML (format 1, described at [/developers#yaml](/developers#yaml)). The server normalises what you save: missing optional fields take their defaults, unknown fields are dropped, and the response shows exactly what was stored. Times are ISO-8601 in UTC, for example `2026-12-02T15:04:05.000Z`. Ids are prefixed ULIDs: `srv_...` for surveys, `rsp_...` for responses.\n\n## Errors\n\nEvery error has the same shape, and `error.code` is stable:\n\n```json\n{ \"error\": { \"code\": \"validation_failed\", \"message\": \"The request body is not valid.\",\n             \"details\": [ { \"path\": \"questions[2].choices\", \"message\": \"must have at least 2 items\" } ] } }\n```\n\n- `400` `bad_request`, `validation_failed` (with `details`)\n- `401` `unauthorized`: no valid session or token\n- `403` `forbidden`: CSRF check failed, token used where a session is required, or host not allowed\n- `404` `not_found`: also for surveys that exist but are not yours, so ids cannot be probed\n- `405` `method_not_allowed`, with an `Allow` header\n- `409` `version_conflict`, `slug_taken`, `survey_changed`, `survey_closed`\n- `413` `payload_too_large`\n- `429` `rate_limited`, with `Retry-After` in seconds\n- `500` `internal`: no detail is leaked\n- `503` `unavailable`: the data store is busy; nothing changed, retry after `Retry-After` (1 second)\n\n## Rate limits\n\nResponse submissions are limited per viewer IP (kept only as a keyed hash, never stored in the clear): 200 per survey per hour and 600 per hour across all surveys. Over the limit you get `429 rate_limited` with a `Retry-After` header.\n\nSubmissions must be sent as `Content-Type: application/json` (anything else is `400 bad_request`). A browser submission from another website is refused with `403 forbidden` (an `Origin` that is not a Polls origin, or `Sec-Fetch-Site: cross-site`), so other sites cannot make their visitors answer your poll.\n\n## Pagination\n\n`GET /api/surveys/{id}/responses` returns `{ \"items\": [...], \"nextCursor\": \"...\" }`, newest first. Pass `nextCursor` back as `cursor` until it is `null`. `limit` is 1..200 (default 50). Survey and token lists are not paginated.\n\n## Versioning and concurrency\n\nEvery survey has a `version` that increments on each successful save. `PUT /api/surveys/{id}` is a full replacement of the draft and must send the `version` it edited; if anyone saved in between, the answer is `409 version_conflict` and nothing changes. Reload, reapply your change, and try again.\n\nTakers send the published `version` with their submission. If the survey was republished meanwhile they get `409 survey_changed` and should reload.\n\nThe API itself is versioned by this document (1.0.0): changes within 1.x only add fields, endpoints and error details, so ignore fields you do not know.\n\n## Limits\n\n- Title 1..200 characters, description up to 2000, slug 3..50 of `a-z 0-9 -`.\n- Up to 100 questions (at least 1 to publish); whole definition at most 256 KB.\n- Submission body at most 64 KB; a survey file to import at most 512 KB of text (a JSON `{ \"yaml\": ... }` envelope may be up to 1.5 MB, for the escaping); any other request body at most 320 KB. Larger bodies get `413 payload_too_large`.\n\n## Quick start\n\n```sh\nexport POLLS=https://polls.thermals.app\nexport POLLS_TOKEN=polls_...   # mint at /app/tokens\n\n# Who am I?\ncurl -s \"$POLLS/api/me\" -H \"Authorization: Bearer $POLLS_TOKEN\"\n\n# Create a draft with two questions\ncurl -s \"$POLLS/api/surveys\" -H \"Authorization: Bearer $POLLS_TOKEN\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"title\":\"Lunch poll\",\"slug\":\"lunch-poll\",\"questions\":[\n        {\"id\":\"q_food\",\"type\":\"single_choice\",\"title\":\"Pizza or tacos?\",\"required\":true,\n         \"choices\":[{\"id\":\"pizza\",\"label\":\"Pizza\"},{\"id\":\"tacos\",\"label\":\"Tacos\"}]},\n        {\"id\":\"q_why\",\"type\":\"long_text\",\"title\":\"Why?\"}]}'\n\n# Publish it (use the id from the previous answer)\ncurl -s -X POST \"$POLLS/api/surveys/srv_.../publish\" -H \"Authorization: Bearer $POLLS_TOKEN\"\n\n# Answer it, as anyone (no token)\ncurl -s \"$POLLS/api/public/surveys/lunch-poll/responses\" -H \"Content-Type: application/json\" \\\n  -d '{\"version\":1,\"answers\":{\"q_food\":{\"choice\":\"tacos\"},\"q_why\":\"Obviously.\"}}'\n\n# Read the results\ncurl -s \"$POLLS/api/surveys/srv_.../summary\" -H \"Authorization: Bearer $POLLS_TOKEN\"\ncurl -s \"$POLLS/api/surveys/srv_.../responses/export\" -H \"Authorization: Bearer $POLLS_TOKEN\" -o responses.csv\n```\n",
    "contact": {
      "name": "Polls",
      "url": "https://polls.thermals.app/developers"
    }
  },
  "servers": [
    {
      "url": "https://polls.skywardfederal.com",
      "description": "Skyward Federal"
    },
    {
      "url": "https://polls.thermals.app",
      "description": "thermals"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    },
    {
      "cookieAuth": []
    }
  ],
  "tags": [
    {
      "name": "Public",
      "description": "What takers use: read a published survey and submit a response. No authentication."
    },
    {
      "name": "Surveys",
      "description": "Create, edit, publish, close, duplicate and delete your surveys, and import and export them as YAML files."
    },
    {
      "name": "Responses",
      "description": "Read, export and delete the responses to your surveys."
    },
    {
      "name": "Results",
      "description": "Aggregated results per question."
    },
    {
      "name": "Tokens",
      "description": "Manage API tokens. Browser session only."
    },
    {
      "name": "Account",
      "description": "The signed-in person."
    },
    {
      "name": "Health",
      "description": "Service health."
    }
  ],
  "paths": {
    "/healthz": {
      "get": {
        "operationId": "getHealth",
        "tags": [
          "Health"
        ],
        "summary": "Health check",
        "security": [],
        "description": "Liveness probe. Never cached. Returns the deployed commit, which is handy for checking that a deploy went out.",
        "responses": {
          "200": {
            "description": "The service is up.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          }
        }
      }
    },
    "/api/public/surveys/{slug}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Slug"
        }
      ],
      "get": {
        "operationId": "getPublicSurvey",
        "tags": [
          "Public"
        ],
        "summary": "Get a published survey",
        "security": [],
        "description": "Returns the published snapshot of a survey for a taker. No authentication. Draft edits are never visible here until the owner publishes again.\n\nWhen the survey is closed (by hand, past `closesAt`, or at `maxResponses`) the response is still `200` with `status: \"closed\"` and an empty `questions` list.",
        "responses": {
          "200": {
            "description": "The published survey.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicSurvey"
                },
                "examples": {
                  "open": {
                    "summary": "An open survey",
                    "value": {
                      "slug": "team-offsite-2027",
                      "version": 2,
                      "status": "open",
                      "title": "Team offsite 2027",
                      "description": "Five questions, two minutes.",
                      "settings": {
                        "welcome": {
                          "enabled": true,
                          "buttonLabel": "Start"
                        },
                        "thankYou": {
                          "title": "Thank you!",
                          "message": "Your answers are in."
                        },
                        "theme": {
                          "accent": "#3D5AFE",
                          "mode": "light"
                        },
                        "showProgress": true
                      },
                      "questions": [
                        {
                          "id": "q_name",
                          "type": "short_text",
                          "title": "What should we call you?",
                          "required": true,
                          "maxLength": 80,
                          "placeholder": "Ada"
                        },
                        {
                          "id": "q_venue",
                          "type": "single_choice",
                          "title": "Where should we go?",
                          "description": "Pick one, or suggest your own.",
                          "required": true,
                          "allowOther": true,
                          "choices": [
                            {
                              "id": "lake",
                              "label": "Lake house"
                            },
                            {
                              "id": "city",
                              "label": "City loft"
                            },
                            {
                              "id": "mountain",
                              "label": "Mountain lodge"
                            }
                          ]
                        },
                        {
                          "id": "q_ok",
                          "type": "yes_no",
                          "title": "Can you make the first week of March?",
                          "required": false
                        },
                        {
                          "id": "q_r",
                          "type": "rating",
                          "title": "How was last year's offsite?",
                          "required": false,
                          "steps": 5
                        },
                        {
                          "id": "q_done",
                          "type": "statement",
                          "title": "That is everything. Thank you!",
                          "buttonLabel": "Finish"
                        }
                      ]
                    }
                  },
                  "closed": {
                    "summary": "A closed survey",
                    "value": {
                      "slug": "team-offsite-2027",
                      "version": 2,
                      "status": "closed",
                      "title": "Team offsite 2027",
                      "description": "Five questions, two minutes.",
                      "settings": {
                        "welcome": {
                          "enabled": true,
                          "buttonLabel": "Start"
                        },
                        "thankYou": {
                          "title": "Thank you!",
                          "message": "Your answers are in."
                        },
                        "theme": {
                          "accent": "#3D5AFE",
                          "mode": "light"
                        },
                        "showProgress": true
                      },
                      "questions": []
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No survey with this slug, or it was never published.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "summary": "not_found",
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Survey not found."
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/public/surveys/{slug}/responses": {
      "parameters": [
        {
          "$ref": "#/components/parameters/Slug"
        }
      ],
      "post": {
        "operationId": "submitResponse",
        "tags": [
          "Public"
        ],
        "summary": "Submit a response",
        "security": [],
        "description": "Submits one complete response to a published, open survey. No authentication; no cookie is set and no IP address is stored.\n\nRules:\n\n- `version` must equal the published version, else `409 survey_changed` (reload the survey and ask again).\n- A closed survey answers `409 survey_closed`.\n- Every required question must be answered and every answer must be valid for its question type (see `AnswerValue`). Unknown question ids and answers to `statement` questions are `400 validation_failed`.\n- The body must be at most 64 KB (`413 payload_too_large`).\n- Rate limits, per viewer IP (kept only as a keyed hash): 200 submissions per survey per hour and 600 per hour overall. Over the limit: `429 rate_limited` with `Retry-After`.\n- The body must be `Content-Type: application/json` (`400 bad_request` otherwise), and a browser request from another site is refused (`403 forbidden`: foreign `Origin` or `Sec-Fetch-Site: cross-site`).\n- `website` is a honeypot: leave it out or empty.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmissionRequest"
              },
              "examples": {
                "basic": {
                  "summary": "Answers to the example survey",
                  "value": {
                    "version": 2,
                    "answers": {
                      "q_name": "Ada",
                      "q_venue": {
                        "choice": "lake"
                      },
                      "q_ok": true,
                      "q_r": 4
                    },
                    "startedAt": "2026-12-02T16:19:23.000Z"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Stored.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubmissionResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed body, or an answer is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_failed": {
                    "summary": "validation_failed",
                    "value": {
                      "error": {
                        "code": "validation_failed",
                        "message": "Some answers are not valid.",
                        "details": [
                          {
                            "path": "answers.q_name",
                            "message": "is required"
                          },
                          {
                            "path": "answers.q_r",
                            "message": "must be an integer from 1 to 5"
                          }
                        ]
                      }
                    }
                  },
                  "bad_request": {
                    "summary": "bad_request",
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "Body is not valid JSON."
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "description": "No survey with this slug, or it was never published.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "not_found": {
                    "summary": "not_found",
                    "value": {
                      "error": {
                        "code": "not_found",
                        "message": "Survey not found."
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The survey changed or closed since it was loaded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "survey_changed": {
                    "summary": "survey_changed",
                    "value": {
                      "error": {
                        "code": "survey_changed",
                        "message": "This survey was updated. Reload to continue."
                      }
                    }
                  },
                  "survey_closed": {
                    "summary": "survey_closed",
                    "value": {
                      "error": {
                        "code": "survey_closed",
                        "message": "This poll is closed."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/me": {
      "get": {
        "operationId": "getMe",
        "tags": [
          "Account"
        ],
        "summary": "Who am I",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Returns the signed-in person and how the request was authenticated. A cheap way to check that a token works.",
        "responses": {
          "200": {
            "description": "The caller.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys": {
      "get": {
        "operationId": "listSurveys",
        "tags": [
          "Surveys"
        ],
        "summary": "List your surveys",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "All surveys the caller owns, newest `updatedAt` first, without `questions`. Not paginated.",
        "responses": {
          "200": {
            "description": "Your surveys.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SurveyList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "post": {
        "operationId": "createSurvey",
        "tags": [
          "Surveys"
        ],
        "summary": "Create a survey",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Creates a new draft owned by the caller. Only `title` is required; missing settings take their defaults and question ids are generated when absent. Nothing is public until you publish.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SurveyCreate"
              },
              "examples": {
                "full": {
                  "summary": "With a slug and questions",
                  "value": {
                    "title": "Team offsite 2027",
                    "description": "Five questions, two minutes.",
                    "slug": "team-offsite-2027",
                    "questions": [
                      {
                        "id": "q_name",
                        "type": "short_text",
                        "title": "What should we call you?",
                        "required": true,
                        "maxLength": 80,
                        "placeholder": "Ada"
                      },
                      {
                        "id": "q_venue",
                        "type": "single_choice",
                        "title": "Where should we go?",
                        "description": "Pick one, or suggest your own.",
                        "required": true,
                        "allowOther": true,
                        "choices": [
                          {
                            "id": "lake",
                            "label": "Lake house"
                          },
                          {
                            "id": "city",
                            "label": "City loft"
                          },
                          {
                            "id": "mountain",
                            "label": "Mountain lodge"
                          }
                        ]
                      },
                      {
                        "id": "q_ok",
                        "type": "yes_no",
                        "title": "Can you make the first week of March?",
                        "required": false
                      }
                    ]
                  }
                },
                "minimal": {
                  "summary": "Title only",
                  "value": {
                    "title": "Lunch preferences"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new draft.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Survey"
                },
                "examples": {
                  "created": {
                    "summary": "A new draft",
                    "value": {
                      "id": "srv_01jf3p7h2c5x9b4n6m8q0w1e3r",
                      "slug": "k7m2q9x4bd",
                      "status": "draft",
                      "title": "Lunch preferences",
                      "description": "",
                      "settings": {
                        "welcome": {
                          "enabled": true,
                          "buttonLabel": "Start"
                        },
                        "thankYou": {
                          "title": "Thank you!",
                          "message": "Your answers are in."
                        },
                        "theme": {
                          "accent": "#3D5AFE",
                          "mode": "light"
                        },
                        "showProgress": true,
                        "closesAt": null,
                        "maxResponses": null
                      },
                      "questions": [],
                      "version": 1,
                      "published": null,
                      "hasUnpublishedChanges": true,
                      "responseCount": 0,
                      "lastResponseAt": null,
                      "owner": {
                        "sub": "f3b0c6a2-7d41-4e8a-9c55-1a2b3c4d5e6f",
                        "name": "Matt Peters",
                        "email": "matt@example.com"
                      },
                      "createdAt": "2026-12-02T17:00:00.000Z",
                      "updatedAt": "2026-12-02T17:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The slug is already used by another survey.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "slug_taken": {
                    "summary": "slug_taken",
                    "value": {
                      "error": {
                        "code": "slug_taken",
                        "message": "That link is already taken."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/import": {
      "post": {
        "operationId": "importSurvey",
        "tags": [
          "Surveys"
        ],
        "summary": "Import a survey file",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Creates a new draft from a survey file (YAML format 1, or JSON in the same shape; see [/developers#yaml](/developers#yaml)). Send the file either way:\n\n- `Content-Type: application/yaml` (or `text/yaml`, `application/x-yaml`) with the file as the body. **API tokens only**: a cookie request with a body that is not JSON is refused by the CSRF rule (`403 forbidden`). With curl, use `--data-binary @survey.yaml`; `-d` strips the newlines YAML depends on.\n- `Content-Type: application/json` with `{ \"yaml\": \"<the file's text>\" }`. Works with tokens and sessions.\n\nThe file is at most 512 KB of text either way (`413 payload_too_large`). Problems come back as `400 validation_failed`, each detail with `path`, `message` and, when known, the `line` it is on.\n\nWith `dryRun=true` nothing is saved: the answer is `200` with the survey the file describes. With `publish=true` the survey is created and published in one step, so it must have at least one question; both together check with the publish rules. A slug already in use is `409 slug_taken` (a dry run does not check it); import again with `slug=` (empty) for a random one.",
        "parameters": [
          {
            "name": "dryRun",
            "in": "query",
            "required": false,
            "description": "Check the file and save nothing.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "publish",
            "in": "query",
            "required": false,
            "description": "Publish the new survey straight away (needs at least one question).",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "slug",
            "in": "query",
            "required": false,
            "description": "Use this link instead of the file's `slug`. Empty (`slug=`) means a random one. A bad value is `400 validation_failed` at path `slug`.",
            "schema": {
              "type": "string",
              "pattern": "^(?:[a-z0-9](?:[a-z0-9-]{1,48}[a-z0-9]))?$",
              "maxLength": 50
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/yaml": {
              "schema": {
                "type": "string",
                "description": "The survey file, at most 512 KB of UTF-8 text. API tokens only."
              },
              "example": "polls: 1\ntitle: Lunch poll\nslug: lunch-poll\nquestions:\n  - id: q_food\n    type: single_choice\n    title: Pizza or tacos?\n    required: true\n    choices: [Pizza, Tacos]\n  - id: q_why\n    type: long_text\n    title: Why?\n"
            },
            "text/yaml": {
              "schema": {
                "type": "string",
                "description": "The same as `application/yaml`."
              }
            },
            "application/x-yaml": {
              "schema": {
                "type": "string",
                "description": "The same as `application/yaml`."
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SurveyImport"
              },
              "examples": {
                "wrapped": {
                  "summary": "A file wrapped in JSON",
                  "value": {
                    "yaml": "polls: 1\ntitle: Lunch poll\nslug: lunch-poll\nquestions:\n  - id: q_food\n    type: single_choice\n    title: Pizza or tacos?\n    required: true\n    choices: [Pizza, Tacos]\n  - id: q_why\n    type: long_text\n    title: Why?\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Dry run (`dryRun=true`): the file is valid. Nothing was saved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SurveyImportCheck"
                },
                "examples": {
                  "check": {
                    "summary": "A valid file",
                    "value": {
                      "ok": true,
                      "survey": {
                        "title": "Lunch poll",
                        "description": "",
                        "settings": {
                          "welcome": {
                            "enabled": true,
                            "buttonLabel": "Start"
                          },
                          "thankYou": {
                            "title": "Thank you!",
                            "message": "Your answers are in."
                          },
                          "theme": {
                            "accent": "#3D5AFE",
                            "mode": "light"
                          },
                          "showProgress": true,
                          "closesAt": null,
                          "maxResponses": null
                        },
                        "questions": [
                          {
                            "id": "q_food",
                            "type": "single_choice",
                            "title": "Pizza or tacos?",
                            "required": true,
                            "choices": [
                              {
                                "id": "pizza",
                                "label": "Pizza"
                              },
                              {
                                "id": "tacos",
                                "label": "Tacos"
                              }
                            ],
                            "allowOther": false
                          },
                          {
                            "id": "q_why",
                            "type": "long_text",
                            "title": "Why?",
                            "required": false,
                            "maxLength": 5000
                          }
                        ]
                      },
                      "slug": "lunch-poll"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "The new survey, as `GET /api/surveys/{id}` returns it: a draft, or `open` with `publish=true`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Survey"
                },
                "examples": {
                  "published": {
                    "summary": "Imported with publish=true",
                    "value": {
                      "id": "srv_01jf3q2w8e4r6t0y9v7x5z3p1a",
                      "slug": "lunch-poll",
                      "status": "open",
                      "title": "Lunch poll",
                      "description": "",
                      "settings": {
                        "welcome": {
                          "enabled": true,
                          "buttonLabel": "Start"
                        },
                        "thankYou": {
                          "title": "Thank you!",
                          "message": "Your answers are in."
                        },
                        "theme": {
                          "accent": "#3D5AFE",
                          "mode": "light"
                        },
                        "showProgress": true,
                        "closesAt": null,
                        "maxResponses": null
                      },
                      "questions": [
                        {
                          "id": "q_food",
                          "type": "single_choice",
                          "title": "Pizza or tacos?",
                          "required": true,
                          "choices": [
                            {
                              "id": "pizza",
                              "label": "Pizza"
                            },
                            {
                              "id": "tacos",
                              "label": "Tacos"
                            }
                          ],
                          "allowOther": false
                        },
                        {
                          "id": "q_why",
                          "type": "long_text",
                          "title": "Why?",
                          "required": false,
                          "maxLength": 5000
                        }
                      ],
                      "version": 1,
                      "published": {
                        "version": 1,
                        "publishedAt": "2026-12-02T17:00:00.000Z"
                      },
                      "hasUnpublishedChanges": false,
                      "responseCount": 0,
                      "lastResponseAt": null,
                      "owner": {
                        "sub": "f3b0c6a2-7d41-4e8a-9c55-1a2b3c4d5e6f",
                        "name": "Matt Peters",
                        "email": "matt@example.com"
                      },
                      "createdAt": "2026-12-02T17:00:00.000Z",
                      "updatedAt": "2026-12-02T17:00:00.000Z"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body is not a survey file (`bad_request`), or the file has problems (`validation_failed`, each with `path`, `message` and, when known, `line`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_failed": {
                    "summary": "validation_failed",
                    "value": {
                      "error": {
                        "code": "validation_failed",
                        "message": "Some fields are not valid.",
                        "details": [
                          {
                            "path": "slug",
                            "message": "must be 3 to 50 of a-z, 0-9 and -, not starting or ending with -",
                            "line": 3
                          },
                          {
                            "path": "questions[2].choices",
                            "message": "must have between 2 and 50 choices",
                            "line": 14
                          }
                        ]
                      }
                    }
                  },
                  "bad_request": {
                    "summary": "bad_request",
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "Send the survey file as application/yaml, or as application/json { \"yaml\": \"<the file>\" }."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "The slug is already used by another survey. Import again with another `slug`, or `slug=` for a random one.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "slug_taken": {
                    "summary": "slug_taken",
                    "value": {
                      "error": {
                        "code": "slug_taken",
                        "message": "That link is already used by another survey."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SurveyId"
        }
      ],
      "get": {
        "operationId": "getSurvey",
        "tags": [
          "Surveys"
        ],
        "summary": "Get a survey",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Returns the survey with its full draft. A survey you do not own answers `404`.",
        "responses": {
          "200": {
            "description": "The survey.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Survey"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "put": {
        "operationId": "updateSurvey",
        "tags": [
          "Surveys"
        ],
        "summary": "Replace the draft",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Replaces the whole draft (title, description, slug, settings, questions). Send the `version` you loaded: if it no longer matches, nothing is saved and the answer is `409 version_conflict`.\n\nOn a published survey this changes nothing live (except the slug) until you publish again; `hasUnpublishedChanges` becomes `true`. The whole definition must fit in 256 KB.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SurveyUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved. `version` is incremented.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Survey"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Someone saved in between, or the slug is taken.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "version_conflict": {
                    "summary": "version_conflict",
                    "value": {
                      "error": {
                        "code": "version_conflict",
                        "message": "This survey was changed elsewhere. Reload and try again."
                      }
                    }
                  },
                  "slug_taken": {
                    "summary": "slug_taken",
                    "value": {
                      "error": {
                        "code": "slug_taken",
                        "message": "That link is already taken."
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/PayloadTooLarge"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "delete": {
        "operationId": "deleteSurvey",
        "tags": [
          "Surveys"
        ],
        "summary": "Delete a survey",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Deletes the survey and all of its responses. Cannot be undone. Its public link stops working at once.",
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/{id}/publish": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SurveyId"
        }
      ],
      "post": {
        "operationId": "publishSurvey",
        "tags": [
          "Surveys"
        ],
        "summary": "Publish the draft",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Snapshots the current draft as the live version and sets `status` to `open` (this also reopens a closed survey). Takers who loaded the previous version get `409 survey_changed` on submit and reload.\n\nThe draft must be valid for publishing: 1..100 questions, every question complete. No request body.",
        "responses": {
          "200": {
            "description": "Published; `status` is `open`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Survey"
                }
              }
            }
          },
          "400": {
            "description": "The draft cannot be published.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "validation_failed": {
                    "summary": "validation_failed",
                    "value": {
                      "error": {
                        "code": "validation_failed",
                        "message": "Some fields are not valid.",
                        "details": [
                          {
                            "path": "questions",
                            "message": "a published survey needs at least one question"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "The draft was saved by someone else while publishing; nothing was published. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "version_conflict": {
                    "summary": "version_conflict",
                    "value": {
                      "error": {
                        "code": "version_conflict",
                        "message": "Someone saved this survey since you loaded it. Reload and try again."
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/{id}/close": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SurveyId"
        }
      ],
      "post": {
        "operationId": "closeSurvey",
        "tags": [
          "Surveys"
        ],
        "summary": "Close a survey",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Stops accepting responses; the public link shows \"This poll is closed\". Publish again to reopen. No request body.",
        "responses": {
          "200": {
            "description": "Closed; `status` is `closed`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Survey"
                }
              }
            }
          },
          "400": {
            "description": "The survey was never published, so there is nothing to close.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "bad_request": {
                    "summary": "bad_request",
                    "value": {
                      "error": {
                        "code": "bad_request",
                        "message": "This survey has never been published, so there is nothing to close."
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/{id}/duplicate": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SurveyId"
        }
      ],
      "post": {
        "operationId": "duplicateSurvey",
        "tags": [
          "Surveys"
        ],
        "summary": "Duplicate a survey",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Creates a new draft from this survey's draft, titled \"<title> (copy)\", with a new id and a new random slug. Responses are not copied. No request body.",
        "responses": {
          "201": {
            "description": "The copy.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Survey"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/{id}/export": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SurveyId"
        }
      ],
      "get": {
        "operationId": "exportSurvey",
        "tags": [
          "Surveys"
        ],
        "summary": "Export a survey as YAML",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "The survey's draft as a survey file (YAML format 1): the shortest file that imports back to exactly the same survey, with every question id written out. Settings and options at their defaults are left out, `defaults.required` is what most questions use, and a choice list used by two or more questions becomes a scale. Sent as an attachment named `<slug>.yaml`. Import it with `POST /api/surveys/import`.",
        "responses": {
          "200": {
            "description": "The survey file.",
            "headers": {
              "Content-Disposition": {
                "description": "Always an attachment named after the slug.",
                "schema": {
                  "type": "string"
                },
                "example": "attachment; filename=\"lunch-poll.yaml\""
              }
            },
            "content": {
              "application/yaml; charset=utf-8": {
                "schema": {
                  "type": "string",
                  "description": "YAML text."
                },
                "example": "# yaml-language-server: $schema=https://polls.thermals.app/developers/survey.schema.json\npolls: 1\ntitle: Lunch poll\nslug: lunch-poll\n\nquestions:\n  - id: q_food\n    type: single_choice\n    title: Pizza or tacos?\n    required: true\n    choices:\n      - Pizza\n      - Tacos\n\n  - id: q_why\n    type: long_text\n    title: Why?\n"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/{id}/preview": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SurveyId"
        }
      ],
      "get": {
        "operationId": "previewSurvey",
        "tags": [
          "Surveys"
        ],
        "summary": "Preview the draft as a taker",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Returns what `getPublicSurvey` would return if the current draft were published: `status` is `open` and `version` is the draft version. Used by `/s/{slug}?preview={id}`. Preview answers cannot be submitted.",
        "responses": {
          "200": {
            "description": "The draft as a public survey.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicSurvey"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/{id}/summary": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SurveyId"
        }
      ],
      "get": {
        "operationId": "getSurveySummary",
        "tags": [
          "Results"
        ],
        "summary": "Get result aggregates",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Per-question aggregates over all stored responses, computed against the currently published questions. Choice questions get counts per choice, `yes_no` gets yes/no counts, `rating` and `opinion_scale` get average/min/max/distribution, `number` gets average/min/max, and text, email and date questions get the latest 10 answers. `statement` questions are left out.",
        "responses": {
          "200": {
            "description": "The summary.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Summary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/{id}/responses": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SurveyId"
        }
      ],
      "get": {
        "operationId": "listResponses",
        "tags": [
          "Responses"
        ],
        "summary": "List responses",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Stored responses, newest first, a page at a time. Follow `nextCursor` until it is `null`.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            },
            "example": 50
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The `nextCursor` of the previous page. Opaque; do not build it yourself.",
            "schema": {
              "type": "string",
              "maxLength": 1024
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of responses.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponsePage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/{id}/responses/export": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SurveyId"
        }
      ],
      "get": {
        "operationId": "exportResponses",
        "tags": [
          "Responses"
        ],
        "summary": "Export responses as CSV",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "All responses as a CSV attachment (RFC 4180, UTF-8, CRLF line ends): one row per response, newest first. Columns: `response_id`, `submitted_at`, `survey_version`, `duration_ms`, then one column per published question (headed by its title; statements are left out). Choice answers are written as their labels, a custom answer as `Other: <text>`, multiple selections joined with `; `, and yes/no as `Yes`/`No`. Skipped answers are empty cells. To stop spreadsheet formula injection, any cell starting with `=`, `+`, `-`, `@`, tab or carriage return is prefixed with `'`.",
        "responses": {
          "200": {
            "description": "The CSV file.",
            "headers": {
              "Content-Disposition": {
                "$ref": "#/components/headers/Content-Disposition"
              }
            },
            "content": {
              "text/csv; charset=utf-8": {
                "schema": {
                  "type": "string",
                  "description": "CSV text."
                },
                "example": "response_id,submitted_at,survey_version,duration_ms,What should we call you?,Where should we go?,Can you make the first week of March?,How was last year's offsite?\r\nrsp_01jf3m9x4t7v2b8n6q5w3e1r0s,2026-12-02T16:20:11.000Z,2,48211,Ada,Lake house,Yes,4\r\nrsp_01jf3m2a7c9d4e5f6g8h0j1k2m,2026-12-02T15:10:00.000Z,2,,Grace,Other: A boat,,5\r\n"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/surveys/{id}/responses/{responseId}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/SurveyId"
        },
        {
          "$ref": "#/components/parameters/ResponseId"
        }
      ],
      "delete": {
        "operationId": "deleteResponse",
        "tags": [
          "Responses"
        ],
        "summary": "Delete a response",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "cookieAuth": []
          }
        ],
        "description": "Permanently deletes one response (for example spam or a test). Summaries and counts update immediately.",
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tokens": {
      "get": {
        "operationId": "listTokens",
        "tags": [
          "Tokens"
        ],
        "summary": "List API tokens",
        "security": [
          {
            "cookieAuth": []
          }
        ],
        "description": "The caller's unexpired API tokens (never the secrets). **Browser session only**: a request authenticated with a bearer token gets `403 forbidden`.",
        "responses": {
          "200": {
            "description": "Your tokens.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SessionOnly"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "post": {
        "operationId": "createToken",
        "tags": [
          "Tokens"
        ],
        "summary": "Mint an API token",
        "security": [
          {
            "cookieAuth": []
          }
        ],
        "description": "Mints a token that acts as you. The secret is in `token` and is shown **once**; Polls keeps only its SHA-256. Default lifetime 90 days, at most 365. **Browser session only** (tokens cannot mint tokens); most people use the page at `/app/tokens`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new token, with its secret.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenCreated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SessionOnly"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tokens/{id}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/TokenId"
        }
      ],
      "delete": {
        "operationId": "deleteToken",
        "tags": [
          "Tokens"
        ],
        "summary": "Revoke an API token",
        "security": [
          {
            "cookieAuth": []
          }
        ],
        "description": "Revokes a token at once. **Browser session only.**",
        "responses": {
          "204": {
            "description": "Revoked."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/SessionOnly"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/Internal"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "polls_ token",
        "description": "An API token minted at `/app/tokens`: `Authorization: Bearer polls_...`."
      },
      "cookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "__Host-polls_session",
        "description": "The browser session set by `/auth/login`. Non-GET requests must pass the CSRF rule (matching `Origin`, JSON body)."
      }
    },
    "headers": {
      "Retry-After": {
        "description": "Seconds to wait before retrying.",
        "schema": {
          "type": "integer",
          "minimum": 1
        },
        "example": 1800
      },
      "Content-Disposition": {
        "description": "Always an attachment with a `.csv` filename derived from the slug.",
        "schema": {
          "type": "string"
        },
        "example": "attachment; filename=\"team-offsite-2027-responses.csv\""
      }
    },
    "parameters": {
      "SurveyId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Survey id.",
        "schema": {
          "type": "string",
          "pattern": "^srv_[0-9a-hjkmnp-tv-z]{26}$"
        },
        "example": "srv_01jf3k9r0m4x7c2v8b6n5q1w2e"
      },
      "Slug": {
        "name": "slug",
        "in": "path",
        "required": true,
        "description": "Survey slug (the `/s/{slug}` link segment).",
        "schema": {
          "type": "string",
          "pattern": "^[a-z0-9](?:[a-z0-9-]{1,48}[a-z0-9])$"
        },
        "example": "team-offsite-2027"
      },
      "ResponseId": {
        "name": "responseId",
        "in": "path",
        "required": true,
        "description": "Response id.",
        "schema": {
          "type": "string",
          "pattern": "^rsp_[0-9a-hjkmnp-tv-z]{26}$"
        },
        "example": "rsp_01jf3m2a7c9d4e5f6g8h0j1k2m"
      },
      "TokenId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Token id (not the secret).",
        "schema": {
          "type": "string",
          "pattern": "^tok_[0-9a-hjkmnp-tv-z]{26}$"
        },
        "example": "tok_01jf2z8w6v4t2r0p8n6m4k2h0g"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request is malformed (`bad_request`) or fails validation (`validation_failed`, with `details`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "validation_failed": {
                "summary": "validation_failed",
                "value": {
                  "error": {
                    "code": "validation_failed",
                    "message": "The request body is not valid.",
                    "details": [
                      {
                        "path": "title",
                        "message": "must be 1..200 characters"
                      }
                    ]
                  }
                }
              },
              "bad_request": {
                "summary": "bad_request",
                "value": {
                  "error": {
                    "code": "bad_request",
                    "message": "Body is not valid JSON."
                  }
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "No valid session cookie or bearer token (missing, expired or revoked).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "unauthorized": {
                "summary": "unauthorized",
                "value": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Sign in or send a valid API token."
                  }
                }
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "Refused: a cookie request failed the CSRF check (bad or missing `Origin`, non-JSON body), or the host is not allowed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "forbidden": {
                "summary": "forbidden",
                "value": {
                  "error": {
                    "code": "forbidden",
                    "message": "Origin not allowed."
                  }
                }
              }
            }
          }
        }
      },
      "SessionOnly": {
        "description": "Refused: this endpoint needs a browser session; API tokens cannot manage tokens. Also returned when a cookie request fails the CSRF check.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "forbidden": {
                "summary": "forbidden",
                "value": {
                  "error": {
                    "code": "forbidden",
                    "message": "This endpoint requires a browser session."
                  }
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "No such resource, or it belongs to someone else (Polls never answers 403 for other people's ids).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "not_found": {
                "summary": "not_found",
                "value": {
                  "error": {
                    "code": "not_found",
                    "message": "Survey not found."
                  }
                }
              }
            }
          }
        }
      },
      "PayloadTooLarge": {
        "description": "The body exceeds the size limit.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "payload_too_large": {
                "summary": "payload_too_large",
                "value": {
                  "error": {
                    "code": "payload_too_large",
                    "message": "Request body too large."
                  }
                }
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests. Wait for `Retry-After` seconds.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "rate_limited": {
                "summary": "rate_limited",
                "value": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many submissions. Try again later."
                  }
                }
              }
            }
          }
        },
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/Retry-After"
          }
        }
      },
      "Internal": {
        "description": "Unexpected server error. No detail is leaked; retry later.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "internal": {
                "summary": "internal",
                "value": {
                  "error": {
                    "code": "internal",
                    "message": "Something went wrong."
                  }
                }
              }
            }
          }
        }
      },
      "Unavailable": {
        "description": "The data store is busy (throttling or contention that outlasted retries). Nothing was changed; retry after `Retry-After` seconds.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "unavailable": {
                "summary": "unavailable",
                "value": {
                  "error": {
                    "code": "unavailable",
                    "message": "Polls is busy. Try again in a moment."
                  }
                }
              }
            }
          }
        },
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/Retry-After"
          }
        }
      }
    },
    "schemas": {
      "QuestionType": {
        "type": "string",
        "enum": [
          "short_text",
          "long_text",
          "email",
          "number",
          "single_choice",
          "multiple_choice",
          "dropdown",
          "yes_no",
          "rating",
          "opinion_scale",
          "date",
          "statement"
        ],
        "description": "The kind of question. Determines the extra fields and the answer format."
      },
      "QuestionBase": {
        "type": "object",
        "description": "Fields every question has. Not used on its own: see `Question`.",
        "required": [
          "type",
          "title"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$",
            "description": "Unique within the survey. Optional on create/update: the server assigns `q_` + 8 base32 characters when absent. Always present in responses. Keep ids stable across edits: answers and summaries are keyed by them.",
            "examples": [
              "q_name"
            ]
          },
          "type": {
            "$ref": "#/components/schemas/QuestionType"
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "The question as the taker sees it."
          },
          "description": {
            "type": "string",
            "maxLength": 1000,
            "description": "Optional helper text under the title."
          },
          "required": {
            "type": "boolean",
            "default": false,
            "description": "Whether a submission must answer it. Ignored for `statement`."
          }
        }
      },
      "ShortTextQuestion": {
        "title": "ShortTextQuestion",
        "description": "A single line of text. Answer: a string of at most `maxLength` characters.",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "short_text"
              },
              "maxLength": {
                "type": "integer",
                "minimum": 1,
                "maximum": 1000,
                "default": 255,
                "description": "Longest accepted answer, in characters."
              },
              "placeholder": {
                "type": "string",
                "maxLength": 100,
                "description": "Hint shown in the empty input."
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_name",
            "type": "short_text",
            "title": "What should we call you?",
            "required": true,
            "maxLength": 80,
            "placeholder": "Ada"
          }
        ]
      },
      "LongTextQuestion": {
        "title": "LongTextQuestion",
        "description": "A multi-line text box. Answer: a string of at most `maxLength` characters.",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "long_text"
              },
              "maxLength": {
                "type": "integer",
                "minimum": 1,
                "maximum": 10000,
                "default": 5000,
                "description": "Longest accepted answer, in characters."
              },
              "placeholder": {
                "type": "string",
                "maxLength": 100,
                "description": "Hint shown in the empty input."
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_ideas",
            "type": "long_text",
            "title": "Anything else we should plan for?",
            "maxLength": 2000
          }
        ]
      },
      "EmailQuestion": {
        "title": "EmailQuestion",
        "description": "An email address. Answer: a string that looks like an email, at most 254 characters.",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "email"
              },
              "placeholder": {
                "type": "string",
                "maxLength": 100,
                "description": "Hint shown in the empty input."
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_email",
            "type": "email",
            "title": "Where can we reach you?",
            "required": true,
            "placeholder": "you@example.com"
          }
        ]
      },
      "NumberQuestion": {
        "title": "NumberQuestion",
        "description": "A number, optionally bounded. Answer: a JSON number within `min`..`max` (an integer when `integerOnly`).",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "number"
              },
              "min": {
                "type": [
                  "number",
                  "null"
                ],
                "default": null,
                "description": "Smallest accepted value (inclusive); `null` for no bound."
              },
              "max": {
                "type": [
                  "number",
                  "null"
                ],
                "default": null,
                "description": "Largest accepted value (inclusive); `null` for no bound. Must not be less than `min`."
              },
              "integerOnly": {
                "type": "boolean",
                "default": false,
                "description": "Accept whole numbers only."
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_people",
            "type": "number",
            "title": "How many people are coming with you?",
            "min": 0,
            "max": 10,
            "integerOnly": true
          }
        ]
      },
      "SingleChoiceQuestion": {
        "title": "SingleChoiceQuestion",
        "description": "Pick exactly one choice, or (with `allowOther`) type a custom answer. Answer: `{ \"choice\": \"<id>\" }` or `{ \"other\": \"<text>\" }`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "required": [
              "choices"
            ],
            "properties": {
              "type": {
                "const": "single_choice"
              },
              "choices": {
                "type": "array",
                "minItems": 2,
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/Choice"
                },
                "description": "2..50 choices; ids unique within the question."
              },
              "allowOther": {
                "type": "boolean",
                "default": false,
                "description": "Offer an \"Other\" free-text option (≤ 500 characters)."
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_venue",
            "type": "single_choice",
            "title": "Where should we go?",
            "allowOther": true,
            "choices": [
              {
                "id": "lake",
                "label": "Lake house"
              },
              {
                "id": "city",
                "label": "City loft"
              }
            ]
          }
        ]
      },
      "MultipleChoiceQuestion": {
        "title": "MultipleChoiceQuestion",
        "description": "Pick any number of choices within `minSelections`..`maxSelections`, plus an optional custom answer when `allowOther`. Answer: `{ \"choices\": [...], \"other\": \"...\" }` with at least one of the two.",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "required": [
              "choices"
            ],
            "properties": {
              "type": {
                "const": "multiple_choice"
              },
              "choices": {
                "type": "array",
                "minItems": 2,
                "maxItems": 50,
                "items": {
                  "$ref": "#/components/schemas/Choice"
                },
                "description": "2..50 choices; ids unique within the question."
              },
              "allowOther": {
                "type": "boolean",
                "default": false,
                "description": "Offer an \"Other\" free-text option (≤ 500 characters)."
              },
              "minSelections": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 1,
                "maximum": 51,
                "default": null,
                "description": "Fewest selections accepted when answered, at most the number of choices (+1 with `allowOther`); an \"other\" text counts as one. `null` for no minimum."
              },
              "maxSelections": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 1,
                "maximum": 51,
                "default": null,
                "description": "Most selections accepted, at most the number of choices (+1 with `allowOther`); an \"other\" text counts as one. `null` for no maximum."
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_food",
            "type": "multiple_choice",
            "title": "Which meals should we cater?",
            "allowOther": true,
            "maxSelections": 2,
            "choices": [
              {
                "id": "breakfast",
                "label": "Breakfast"
              },
              {
                "id": "lunch",
                "label": "Lunch"
              },
              {
                "id": "dinner",
                "label": "Dinner"
              }
            ]
          }
        ]
      },
      "DropdownQuestion": {
        "title": "DropdownQuestion",
        "description": "Pick exactly one of a long list. Answer: `{ \"choice\": \"<id>\" }`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "required": [
              "choices"
            ],
            "properties": {
              "type": {
                "const": "dropdown"
              },
              "choices": {
                "type": "array",
                "minItems": 2,
                "maxItems": 500,
                "items": {
                  "$ref": "#/components/schemas/Choice"
                },
                "description": "2..500 choices; ids unique within the question."
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_office",
            "type": "dropdown",
            "title": "Which office are you based in?",
            "choices": [
              {
                "id": "dc",
                "label": "Washington, DC"
              },
              {
                "id": "den",
                "label": "Denver"
              },
              {
                "id": "sea",
                "label": "Seattle"
              }
            ]
          }
        ]
      },
      "YesNoQuestion": {
        "title": "YesNoQuestion",
        "description": "A yes/no question. Answer: `true` or `false`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "yes_no"
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_ok",
            "type": "yes_no",
            "title": "Can you make the first week of March?"
          }
        ]
      },
      "RatingQuestion": {
        "title": "RatingQuestion",
        "description": "A star rating. Answer: an integer from 1 to `steps`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "rating"
              },
              "steps": {
                "type": "integer",
                "minimum": 3,
                "maximum": 10,
                "default": 5,
                "description": "Number of stars."
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_r",
            "type": "rating",
            "title": "How was last year's offsite?",
            "steps": 5
          }
        ]
      },
      "OpinionScaleQuestion": {
        "title": "OpinionScaleQuestion",
        "description": "A numbered scale (for example NPS, 0..10). Answer: an integer from `start` to `end`.",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "opinion_scale"
              },
              "start": {
                "type": "integer",
                "enum": [
                  0,
                  1
                ],
                "default": 0,
                "description": "First number on the scale."
              },
              "end": {
                "type": "integer",
                "minimum": 5,
                "maximum": 10,
                "default": 10,
                "description": "Last number on the scale."
              },
              "labels": {
                "type": "object",
                "additionalProperties": false,
                "description": "Captions under the two ends of the scale.",
                "properties": {
                  "left": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "right": {
                    "type": "string",
                    "maxLength": 40
                  }
                }
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_nps",
            "type": "opinion_scale",
            "title": "How likely are you to recommend the offsite?",
            "start": 0,
            "end": 10,
            "labels": {
              "left": "Not likely",
              "right": "Very likely"
            }
          }
        ]
      },
      "DateQuestion": {
        "title": "DateQuestion",
        "description": "A calendar date. Answer: `\"YYYY-MM-DD\"` (a real date).",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "date"
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_arrive",
            "type": "date",
            "title": "When do you arrive?"
          }
        ]
      },
      "StatementQuestion": {
        "title": "StatementQuestion",
        "description": "A screen of text with a button; never answered. `required` is ignored, and a statement never appears in answers or summaries.",
        "allOf": [
          {
            "$ref": "#/components/schemas/QuestionBase"
          },
          {
            "type": "object",
            "properties": {
              "type": {
                "const": "statement"
              },
              "buttonLabel": {
                "type": "string",
                "minLength": 1,
                "maxLength": 24,
                "default": "Continue",
                "description": "Label of the button that moves on."
              }
            }
          }
        ],
        "unevaluatedProperties": false,
        "examples": [
          {
            "id": "q_done",
            "type": "statement",
            "title": "That is everything. Thank you!",
            "buttonLabel": "Finish"
          }
        ]
      },
      "Question": {
        "description": "A question. The `type` field selects which of the twelve shapes applies.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/ShortTextQuestion"
          },
          {
            "$ref": "#/components/schemas/LongTextQuestion"
          },
          {
            "$ref": "#/components/schemas/EmailQuestion"
          },
          {
            "$ref": "#/components/schemas/NumberQuestion"
          },
          {
            "$ref": "#/components/schemas/SingleChoiceQuestion"
          },
          {
            "$ref": "#/components/schemas/MultipleChoiceQuestion"
          },
          {
            "$ref": "#/components/schemas/DropdownQuestion"
          },
          {
            "$ref": "#/components/schemas/YesNoQuestion"
          },
          {
            "$ref": "#/components/schemas/RatingQuestion"
          },
          {
            "$ref": "#/components/schemas/OpinionScaleQuestion"
          },
          {
            "$ref": "#/components/schemas/DateQuestion"
          },
          {
            "$ref": "#/components/schemas/StatementQuestion"
          }
        ],
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "short_text": "#/components/schemas/ShortTextQuestion",
            "long_text": "#/components/schemas/LongTextQuestion",
            "email": "#/components/schemas/EmailQuestion",
            "number": "#/components/schemas/NumberQuestion",
            "single_choice": "#/components/schemas/SingleChoiceQuestion",
            "multiple_choice": "#/components/schemas/MultipleChoiceQuestion",
            "dropdown": "#/components/schemas/DropdownQuestion",
            "yes_no": "#/components/schemas/YesNoQuestion",
            "rating": "#/components/schemas/RatingQuestion",
            "opinion_scale": "#/components/schemas/OpinionScaleQuestion",
            "date": "#/components/schemas/DateQuestion",
            "statement": "#/components/schemas/StatementQuestion"
          }
        }
      },
      "Choice": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "label"
        ],
        "description": "One option of a `single_choice`, `multiple_choice` or `dropdown` question.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$",
            "description": "Unique within the question. This is what answers carry. Optional on create/update: the server assigns `c_` + 6 base32 characters when absent. Always present in responses."
          },
          "label": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "What the taker sees."
          }
        },
        "examples": [
          {
            "id": "lake",
            "label": "Lake house"
          }
        ]
      },
      "WelcomeSettings": {
        "type": "object",
        "additionalProperties": false,
        "description": "The optional welcome screen before the first question. Its heading and text are the survey `title` and `description`.",
        "properties": {
          "enabled": {
            "type": "boolean",
            "default": true,
            "description": "Show the welcome screen."
          },
          "buttonLabel": {
            "type": "string",
            "minLength": 1,
            "maxLength": 24,
            "default": "Start",
            "description": "Label of the start button."
          }
        }
      },
      "ThankYouSettings": {
        "type": "object",
        "additionalProperties": false,
        "description": "The screen shown after a successful submission.",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "default": "Thank you!"
          },
          "message": {
            "type": "string",
            "maxLength": 2000,
            "default": "Your answers are in."
          }
        }
      },
      "ThemeSettings": {
        "type": "object",
        "additionalProperties": false,
        "description": "Look of the taker page.",
        "properties": {
          "accent": {
            "type": "string",
            "pattern": "^#[0-9A-Fa-f]{6}$",
            "default": "#3D5AFE",
            "description": "Accent colour as `#RRGGBB`."
          },
          "mode": {
            "type": "string",
            "enum": [
              "light",
              "dark"
            ],
            "default": "light",
            "description": "Light or dark taker page."
          }
        }
      },
      "Settings": {
        "type": "object",
        "additionalProperties": false,
        "description": "Survey settings. In requests every field is optional: anything left out takes its default. Responses always carry every field.",
        "properties": {
          "welcome": {
            "$ref": "#/components/schemas/WelcomeSettings"
          },
          "thankYou": {
            "$ref": "#/components/schemas/ThankYouSettings"
          },
          "theme": {
            "$ref": "#/components/schemas/ThemeSettings"
          },
          "showProgress": {
            "type": "boolean",
            "default": true,
            "description": "Show a progress bar to takers."
          },
          "closesAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Stop accepting responses at this instant (ISO-8601). `null` means no deadline.",
            "default": null
          },
          "maxResponses": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 1000000,
            "default": null,
            "description": "Stop accepting responses after this many. `null` means no cap."
          }
        },
        "examples": [
          {
            "welcome": {
              "enabled": true,
              "buttonLabel": "Start"
            },
            "thankYou": {
              "title": "Thank you!",
              "message": "Your answers are in."
            },
            "theme": {
              "accent": "#3D5AFE",
              "mode": "light"
            },
            "showProgress": true,
            "closesAt": null,
            "maxResponses": null
          }
        ]
      },
      "PublicSettings": {
        "type": "object",
        "additionalProperties": false,
        "description": "The subset of settings a taker needs. Deadlines and caps are applied by the server and reflected in `status`.",
        "required": [
          "welcome",
          "thankYou",
          "theme",
          "showProgress"
        ],
        "properties": {
          "welcome": {
            "$ref": "#/components/schemas/WelcomeSettings"
          },
          "thankYou": {
            "$ref": "#/components/schemas/ThankYouSettings"
          },
          "theme": {
            "$ref": "#/components/schemas/ThemeSettings"
          },
          "showProgress": {
            "type": "boolean"
          }
        },
        "examples": [
          {
            "welcome": {
              "enabled": true,
              "buttonLabel": "Start"
            },
            "thankYou": {
              "title": "Thank you!",
              "message": "Your answers are in."
            },
            "theme": {
              "accent": "#3D5AFE",
              "mode": "light"
            },
            "showProgress": true
          }
        ]
      },
      "Owner": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "sub",
          "name",
          "email"
        ],
        "description": "The person who owns the survey (from thermals-id).",
        "properties": {
          "sub": {
            "type": "string",
            "description": "Subject identifier at thermals-id."
          },
          "name": {
            "type": "string",
            "description": "Display name (may be empty)."
          },
          "email": {
            "type": "string",
            "maxLength": 254,
            "description": "Email address (may be empty if the provider shares none)."
          }
        }
      },
      "Survey": {
        "type": "object",
        "additionalProperties": false,
        "description": "A survey as its owner sees it. `title`, `description`, `settings` and `questions` are the DRAFT; takers only ever see the published snapshot.",
        "required": [
          "id",
          "slug",
          "status",
          "title",
          "description",
          "settings",
          "questions",
          "version",
          "published",
          "hasUnpublishedChanges",
          "responseCount",
          "lastResponseAt",
          "owner",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^srv_[0-9a-hjkmnp-tv-z]{26}$",
            "description": "`srv_` + 26 lowercase Crockford base32 characters (a ULID). Server-assigned."
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9](?:[a-z0-9-]{1,48}[a-z0-9])$",
            "minLength": 3,
            "maxLength": 50,
            "description": "Public link segment: the survey is taken at `/s/{slug}`. Unique across Polls."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "open",
              "closed"
            ],
            "description": "`draft`: never published. `open`: published and taking responses. `closed`: published, not taking responses (closed by hand, past `closesAt`, or at `maxResponses`)."
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Draft title."
          },
          "description": {
            "type": "string",
            "maxLength": 2000,
            "description": "Draft description (may be empty)."
          },
          "settings": {
            "$ref": "#/components/schemas/Settings"
          },
          "questions": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Question"
            },
            "description": "Draft questions, in order. 0..100 in a draft; publishing needs at least 1."
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "Draft version. Increments on every successful save; send it back in `PUT` for optimistic concurrency."
          },
          "published": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": false,
            "required": [
              "version",
              "publishedAt"
            ],
            "description": "The live snapshot, or `null` if the survey was never published.",
            "properties": {
              "version": {
                "type": "integer",
                "minimum": 1,
                "description": "Draft version that was published. Submissions must send this."
              },
              "publishedAt": {
                "type": "string",
                "format": "date-time",
                "description": "When it was published."
              }
            }
          },
          "hasUnpublishedChanges": {
            "type": "boolean",
            "description": "True when the draft differs from the published snapshot (always true for a draft)."
          },
          "responseCount": {
            "type": "integer",
            "minimum": 0,
            "description": "Stored responses."
          },
          "lastResponseAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Time of the latest response, or `null`."
          },
          "owner": {
            "$ref": "#/components/schemas/Owner"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Creation time."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Last successful save, publish or close."
          }
        },
        "examples": [
          {
            "id": "srv_01jf3k9r0m4x7c2v8b6n5q1w2e",
            "slug": "team-offsite-2027",
            "status": "open",
            "title": "Team offsite 2027",
            "description": "Five questions, two minutes.",
            "settings": {
              "welcome": {
                "enabled": true,
                "buttonLabel": "Start"
              },
              "thankYou": {
                "title": "Thank you!",
                "message": "Your answers are in."
              },
              "theme": {
                "accent": "#3D5AFE",
                "mode": "light"
              },
              "showProgress": true,
              "closesAt": null,
              "maxResponses": null
            },
            "questions": [
              {
                "id": "q_name",
                "type": "short_text",
                "title": "What should we call you?",
                "required": true,
                "maxLength": 80,
                "placeholder": "Ada"
              },
              {
                "id": "q_venue",
                "type": "single_choice",
                "title": "Where should we go?",
                "description": "Pick one, or suggest your own.",
                "required": true,
                "allowOther": true,
                "choices": [
                  {
                    "id": "lake",
                    "label": "Lake house"
                  },
                  {
                    "id": "city",
                    "label": "City loft"
                  },
                  {
                    "id": "mountain",
                    "label": "Mountain lodge"
                  }
                ]
              },
              {
                "id": "q_ok",
                "type": "yes_no",
                "title": "Can you make the first week of March?",
                "required": false
              },
              {
                "id": "q_r",
                "type": "rating",
                "title": "How was last year's offsite?",
                "required": false,
                "steps": 5
              },
              {
                "id": "q_done",
                "type": "statement",
                "title": "That is everything. Thank you!",
                "buttonLabel": "Finish"
              }
            ],
            "version": 3,
            "published": {
              "version": 2,
              "publishedAt": "2026-12-02T15:04:05.000Z"
            },
            "hasUnpublishedChanges": true,
            "responseCount": 12,
            "lastResponseAt": "2026-12-02T16:20:11.000Z",
            "owner": {
              "sub": "f3b0c6a2-7d41-4e8a-9c55-1a2b3c4d5e6f",
              "name": "Matt Peters",
              "email": "matt@example.com"
            },
            "createdAt": "2026-12-02T15:00:00.000Z",
            "updatedAt": "2026-12-02T15:30:00.000Z"
          }
        ]
      },
      "SurveyListItem": {
        "type": "object",
        "additionalProperties": false,
        "description": "A survey in a list: the `Survey` fields without `questions`.",
        "required": [
          "id",
          "slug",
          "status",
          "title",
          "description",
          "settings",
          "version",
          "published",
          "hasUnpublishedChanges",
          "responseCount",
          "lastResponseAt",
          "owner",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^srv_[0-9a-hjkmnp-tv-z]{26}$",
            "description": "`srv_` + 26 lowercase Crockford base32 characters (a ULID). Server-assigned."
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9](?:[a-z0-9-]{1,48}[a-z0-9])$",
            "minLength": 3,
            "maxLength": 50,
            "description": "Public link segment: the survey is taken at `/s/{slug}`. Unique across Polls."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "open",
              "closed"
            ],
            "description": "`draft`: never published. `open`: published and taking responses. `closed`: published, not taking responses (closed by hand, past `closesAt`, or at `maxResponses`)."
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Draft title."
          },
          "description": {
            "type": "string",
            "maxLength": 2000,
            "description": "Draft description (may be empty)."
          },
          "settings": {
            "$ref": "#/components/schemas/Settings"
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "Draft version. Increments on every successful save; send it back in `PUT` for optimistic concurrency."
          },
          "published": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": false,
            "required": [
              "version",
              "publishedAt"
            ],
            "description": "The live snapshot, or `null` if the survey was never published.",
            "properties": {
              "version": {
                "type": "integer",
                "minimum": 1,
                "description": "Draft version that was published. Submissions must send this."
              },
              "publishedAt": {
                "type": "string",
                "format": "date-time",
                "description": "When it was published."
              }
            }
          },
          "hasUnpublishedChanges": {
            "type": "boolean",
            "description": "True when the draft differs from the published snapshot (always true for a draft)."
          },
          "responseCount": {
            "type": "integer",
            "minimum": 0,
            "description": "Stored responses."
          },
          "lastResponseAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Time of the latest response, or `null`."
          },
          "owner": {
            "$ref": "#/components/schemas/Owner"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "Creation time."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Last successful save, publish or close."
          }
        },
        "examples": [
          {
            "id": "srv_01jf3k9r0m4x7c2v8b6n5q1w2e",
            "slug": "team-offsite-2027",
            "status": "open",
            "title": "Team offsite 2027",
            "description": "Five questions, two minutes.",
            "settings": {
              "welcome": {
                "enabled": true,
                "buttonLabel": "Start"
              },
              "thankYou": {
                "title": "Thank you!",
                "message": "Your answers are in."
              },
              "theme": {
                "accent": "#3D5AFE",
                "mode": "light"
              },
              "showProgress": true,
              "closesAt": null,
              "maxResponses": null
            },
            "version": 3,
            "published": {
              "version": 2,
              "publishedAt": "2026-12-02T15:04:05.000Z"
            },
            "hasUnpublishedChanges": true,
            "responseCount": 12,
            "lastResponseAt": "2026-12-02T16:20:11.000Z",
            "owner": {
              "sub": "f3b0c6a2-7d41-4e8a-9c55-1a2b3c4d5e6f",
              "name": "Matt Peters",
              "email": "matt@example.com"
            },
            "createdAt": "2026-12-02T15:00:00.000Z",
            "updatedAt": "2026-12-02T15:30:00.000Z"
          }
        ]
      },
      "SurveyList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SurveyListItem"
            },
            "description": "The caller's surveys, newest `updatedAt` first."
          }
        },
        "examples": [
          {
            "items": [
              {
                "id": "srv_01jf3p7h2c5x9b4n6m8q0w1e3r",
                "slug": "k7m2q9x4bd",
                "status": "draft",
                "title": "Lunch preferences",
                "description": "",
                "settings": {
                  "welcome": {
                    "enabled": true,
                    "buttonLabel": "Start"
                  },
                  "thankYou": {
                    "title": "Thank you!",
                    "message": "Your answers are in."
                  },
                  "theme": {
                    "accent": "#3D5AFE",
                    "mode": "light"
                  },
                  "showProgress": true,
                  "closesAt": null,
                  "maxResponses": null
                },
                "version": 1,
                "published": null,
                "hasUnpublishedChanges": true,
                "responseCount": 0,
                "lastResponseAt": null,
                "owner": {
                  "sub": "f3b0c6a2-7d41-4e8a-9c55-1a2b3c4d5e6f",
                  "name": "Matt Peters",
                  "email": "matt@example.com"
                },
                "createdAt": "2026-12-02T17:00:00.000Z",
                "updatedAt": "2026-12-02T17:00:00.000Z"
              },
              {
                "id": "srv_01jf3k9r0m4x7c2v8b6n5q1w2e",
                "slug": "team-offsite-2027",
                "status": "open",
                "title": "Team offsite 2027",
                "description": "Five questions, two minutes.",
                "settings": {
                  "welcome": {
                    "enabled": true,
                    "buttonLabel": "Start"
                  },
                  "thankYou": {
                    "title": "Thank you!",
                    "message": "Your answers are in."
                  },
                  "theme": {
                    "accent": "#3D5AFE",
                    "mode": "light"
                  },
                  "showProgress": true,
                  "closesAt": null,
                  "maxResponses": null
                },
                "version": 3,
                "published": {
                  "version": 2,
                  "publishedAt": "2026-12-02T15:04:05.000Z"
                },
                "hasUnpublishedChanges": true,
                "responseCount": 12,
                "lastResponseAt": "2026-12-02T16:20:11.000Z",
                "owner": {
                  "sub": "f3b0c6a2-7d41-4e8a-9c55-1a2b3c4d5e6f",
                  "name": "Matt Peters",
                  "email": "matt@example.com"
                },
                "createdAt": "2026-12-02T15:00:00.000Z",
                "updatedAt": "2026-12-02T15:30:00.000Z"
              }
            ]
          }
        ]
      },
      "SurveyCreate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "title"
        ],
        "description": "A new draft. Only `title` is required.",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Draft title."
          },
          "description": {
            "type": "string",
            "maxLength": 2000,
            "description": "Draft description (may be empty).",
            "default": ""
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9](?:[a-z0-9-]{1,48}[a-z0-9])$",
            "minLength": 3,
            "maxLength": 50,
            "description": "Public link segment. When absent the server picks 10 random lowercase base32 characters. `409 slug_taken` if in use."
          },
          "settings": {
            "$ref": "#/components/schemas/Settings"
          },
          "questions": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Question"
            },
            "default": [],
            "description": "Initial draft questions."
          }
        },
        "examples": [
          {
            "title": "Team offsite 2027",
            "description": "Five questions, two minutes.",
            "slug": "team-offsite-2027",
            "questions": [
              {
                "id": "q_name",
                "type": "short_text",
                "title": "What should we call you?",
                "required": true,
                "maxLength": 80,
                "placeholder": "Ada"
              },
              {
                "id": "q_venue",
                "type": "single_choice",
                "title": "Where should we go?",
                "description": "Pick one, or suggest your own.",
                "required": true,
                "allowOther": true,
                "choices": [
                  {
                    "id": "lake",
                    "label": "Lake house"
                  },
                  {
                    "id": "city",
                    "label": "City loft"
                  },
                  {
                    "id": "mountain",
                    "label": "Mountain lodge"
                  }
                ]
              },
              {
                "id": "q_ok",
                "type": "yes_no",
                "title": "Can you make the first week of March?",
                "required": false
              }
            ]
          },
          {
            "title": "Lunch preferences"
          }
        ]
      },
      "SurveyUpdate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "version",
          "title",
          "description",
          "slug",
          "settings",
          "questions"
        ],
        "description": "A full replacement of the draft. `version` must be the version you edited; if someone saved in between, the server answers `409 version_conflict` and you should reload and reapply.",
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "The `version` of the survey you loaded."
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Draft title."
          },
          "description": {
            "type": "string",
            "maxLength": 2000,
            "description": "Draft description (may be empty)."
          },
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9](?:[a-z0-9-]{1,48}[a-z0-9])$",
            "minLength": 3,
            "maxLength": 50,
            "description": "Public link segment. Changing it on a published survey changes its link immediately. `409 slug_taken` if in use."
          },
          "settings": {
            "$ref": "#/components/schemas/Settings"
          },
          "questions": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Question"
            },
            "description": "The complete, ordered draft question list."
          }
        },
        "examples": [
          {
            "version": 3,
            "title": "Team offsite 2027",
            "description": "Five questions, two minutes.",
            "slug": "team-offsite-2027",
            "settings": {
              "welcome": {
                "enabled": true,
                "buttonLabel": "Start"
              },
              "thankYou": {
                "title": "Thank you!",
                "message": "Your answers are in."
              },
              "theme": {
                "accent": "#3D5AFE",
                "mode": "light"
              },
              "showProgress": true,
              "closesAt": null,
              "maxResponses": null
            },
            "questions": [
              {
                "id": "q_name",
                "type": "short_text",
                "title": "What should we call you?",
                "required": true,
                "maxLength": 80,
                "placeholder": "Ada"
              },
              {
                "id": "q_venue",
                "type": "single_choice",
                "title": "Where should we go?",
                "description": "Pick one, or suggest your own.",
                "required": true,
                "allowOther": true,
                "choices": [
                  {
                    "id": "lake",
                    "label": "Lake house"
                  },
                  {
                    "id": "city",
                    "label": "City loft"
                  },
                  {
                    "id": "mountain",
                    "label": "Mountain lodge"
                  }
                ]
              },
              {
                "id": "q_ok",
                "type": "yes_no",
                "title": "Can you make the first week of March?",
                "required": false
              },
              {
                "id": "q_r",
                "type": "rating",
                "title": "How was last year's offsite?",
                "required": false,
                "steps": 5
              },
              {
                "id": "q_done",
                "type": "statement",
                "title": "That is everything. Thank you!",
                "buttonLabel": "Finish"
              }
            ]
          }
        ]
      },
      "PublicSurvey": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "slug",
          "version",
          "status",
          "title",
          "description",
          "settings",
          "questions"
        ],
        "description": "What a taker gets: the published snapshot. No owner, counts or survey id. When `status` is `closed`, `questions` is empty.",
        "properties": {
          "slug": {
            "type": "string",
            "pattern": "^[a-z0-9](?:[a-z0-9-]{1,48}[a-z0-9])$",
            "minLength": 3,
            "maxLength": 50,
            "description": "Public link segment: the survey is taken at `/s/{slug}`. Unique across Polls."
          },
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "Published version. Send it back when submitting."
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "closed"
            ],
            "description": "`closed` when closed by hand, past `closesAt`, or at `maxResponses`."
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200,
            "description": "Draft title."
          },
          "description": {
            "type": "string",
            "maxLength": 2000,
            "description": "Draft description (may be empty)."
          },
          "settings": {
            "$ref": "#/components/schemas/PublicSettings"
          },
          "questions": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Question"
            }
          }
        },
        "examples": [
          {
            "slug": "team-offsite-2027",
            "version": 2,
            "status": "open",
            "title": "Team offsite 2027",
            "description": "Five questions, two minutes.",
            "settings": {
              "welcome": {
                "enabled": true,
                "buttonLabel": "Start"
              },
              "thankYou": {
                "title": "Thank you!",
                "message": "Your answers are in."
              },
              "theme": {
                "accent": "#3D5AFE",
                "mode": "light"
              },
              "showProgress": true
            },
            "questions": [
              {
                "id": "q_name",
                "type": "short_text",
                "title": "What should we call you?",
                "required": true,
                "maxLength": 80,
                "placeholder": "Ada"
              },
              {
                "id": "q_venue",
                "type": "single_choice",
                "title": "Where should we go?",
                "description": "Pick one, or suggest your own.",
                "required": true,
                "allowOther": true,
                "choices": [
                  {
                    "id": "lake",
                    "label": "Lake house"
                  },
                  {
                    "id": "city",
                    "label": "City loft"
                  },
                  {
                    "id": "mountain",
                    "label": "Mountain lodge"
                  }
                ]
              },
              {
                "id": "q_ok",
                "type": "yes_no",
                "title": "Can you make the first week of March?",
                "required": false
              },
              {
                "id": "q_r",
                "type": "rating",
                "title": "How was last year's offsite?",
                "required": false,
                "steps": 5
              },
              {
                "id": "q_done",
                "type": "statement",
                "title": "That is everything. Thank you!",
                "buttonLabel": "Finish"
              }
            ]
          },
          {
            "slug": "team-offsite-2027",
            "version": 2,
            "status": "closed",
            "title": "Team offsite 2027",
            "description": "Five questions, two minutes.",
            "settings": {
              "welcome": {
                "enabled": true,
                "buttonLabel": "Start"
              },
              "thankYou": {
                "title": "Thank you!",
                "message": "Your answers are in."
              },
              "theme": {
                "accent": "#3D5AFE",
                "mode": "light"
              },
              "showProgress": true
            },
            "questions": []
          }
        ]
      },
      "ShortTextAnswer": {
        "type": "string",
        "maxLength": 1000,
        "description": "`short_text`: at most the question's `maxLength` (default 255).",
        "examples": [
          "Ada"
        ]
      },
      "LongTextAnswer": {
        "type": "string",
        "maxLength": 10000,
        "description": "`long_text`: at most the question's `maxLength` (default 5000).",
        "examples": [
          "Somewhere with a lake, please.\nAnd good coffee."
        ]
      },
      "EmailAnswer": {
        "type": "string",
        "format": "email",
        "maxLength": 254,
        "description": "`email`: a plausible email address.",
        "examples": [
          "ada@example.com"
        ]
      },
      "NumberAnswer": {
        "type": "number",
        "description": "`number`: within the question's `min`..`max`; whole when `integerOnly`.",
        "examples": [
          3
        ]
      },
      "SingleChoiceAnswer": {
        "description": "`single_choice`: the id of one choice, or a custom text when the question has `allowOther`.",
        "oneOf": [
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "choice"
            ],
            "properties": {
              "choice": {
                "type": "string",
                "pattern": "^[a-z0-9_]{1,40}$",
                "description": "A choice id of the question."
              }
            }
          },
          {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "other"
            ],
            "properties": {
              "other": {
                "type": "string",
                "minLength": 1,
                "maxLength": 500,
                "description": "Custom answer (requires `allowOther`)."
              }
            }
          }
        ],
        "examples": [
          {
            "choice": "lake"
          },
          {
            "other": "A boat"
          }
        ]
      },
      "MultipleChoiceAnswer": {
        "type": "object",
        "additionalProperties": false,
        "description": "`multiple_choice`: selected choice ids and/or a custom text (with `allowOther`). At least one of the two; the total must respect `minSelections`/`maxSelections`.",
        "properties": {
          "choices": {
            "type": "array",
            "uniqueItems": true,
            "maxItems": 50,
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9_]{1,40}$"
            }
          },
          "other": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        },
        "anyOf": [
          {
            "required": [
              "choices"
            ]
          },
          {
            "required": [
              "other"
            ]
          }
        ],
        "examples": [
          {
            "choices": [
              "lunch",
              "dinner"
            ]
          },
          {
            "choices": [
              "lunch"
            ],
            "other": "Late-night snacks"
          }
        ]
      },
      "DropdownAnswer": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "choice"
        ],
        "description": "`dropdown`: the id of one choice.",
        "properties": {
          "choice": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          }
        },
        "examples": [
          {
            "choice": "den"
          }
        ]
      },
      "YesNoAnswer": {
        "type": "boolean",
        "description": "`yes_no`: `true` for yes.",
        "examples": [
          true
        ]
      },
      "RatingAnswer": {
        "type": "integer",
        "minimum": 1,
        "maximum": 10,
        "description": "`rating`: 1..`steps`.",
        "examples": [
          4
        ]
      },
      "OpinionScaleAnswer": {
        "type": "integer",
        "minimum": 0,
        "maximum": 10,
        "description": "`opinion_scale`: `start`..`end`.",
        "examples": [
          9
        ]
      },
      "DateAnswer": {
        "type": "string",
        "format": "date",
        "pattern": "^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$",
        "description": "`date`: `YYYY-MM-DD`, a real calendar date.",
        "examples": [
          "2027-03-02"
        ]
      },
      "AnswerValue": {
        "description": "An answer. Its shape is fixed by the type of the question it answers (several types share a JSON shape, so this is `anyOf`). `statement` questions are never answered.",
        "anyOf": [
          {
            "$ref": "#/components/schemas/ShortTextAnswer"
          },
          {
            "$ref": "#/components/schemas/LongTextAnswer"
          },
          {
            "$ref": "#/components/schemas/EmailAnswer"
          },
          {
            "$ref": "#/components/schemas/NumberAnswer"
          },
          {
            "$ref": "#/components/schemas/SingleChoiceAnswer"
          },
          {
            "$ref": "#/components/schemas/MultipleChoiceAnswer"
          },
          {
            "$ref": "#/components/schemas/DropdownAnswer"
          },
          {
            "$ref": "#/components/schemas/YesNoAnswer"
          },
          {
            "$ref": "#/components/schemas/RatingAnswer"
          },
          {
            "$ref": "#/components/schemas/OpinionScaleAnswer"
          },
          {
            "$ref": "#/components/schemas/DateAnswer"
          }
        ]
      },
      "Answers": {
        "type": "object",
        "description": "Answers keyed by question id. Leave unanswered optional questions out. Unknown ids, or answers to `statement` questions, are `400 validation_failed`.",
        "propertyNames": {
          "pattern": "^[a-z0-9_]{1,40}$"
        },
        "additionalProperties": {
          "$ref": "#/components/schemas/AnswerValue"
        },
        "maxProperties": 100,
        "examples": [
          {
            "q_name": "Ada",
            "q_venue": {
              "choice": "lake"
            },
            "q_ok": true,
            "q_r": 4
          }
        ]
      },
      "SubmissionRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "version",
          "answers"
        ],
        "description": "One completed response. The whole body must be ≤ 64 KB.",
        "properties": {
          "version": {
            "type": "integer",
            "minimum": 1,
            "description": "The `version` from the public survey you rendered. If the survey was republished since, the server answers `409 survey_changed`; reload and ask again."
          },
          "answers": {
            "$ref": "#/components/schemas/Answers"
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Optional: when the taker started. Used only to compute `durationMs`."
          },
          "website": {
            "type": "string",
            "maxLength": 500,
            "description": "Honeypot. Humans never fill it (the taker hides it); leave it out or empty. When non-empty the server answers `201` with a fabricated id and stores nothing."
          }
        },
        "examples": [
          {
            "version": 2,
            "answers": {
              "q_name": "Ada",
              "q_venue": {
                "choice": "lake"
              },
              "q_ok": true,
              "q_r": 4
            },
            "startedAt": "2026-12-02T16:19:23.000Z"
          }
        ]
      },
      "SubmissionResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "submittedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^rsp_[0-9a-hjkmnp-tv-z]{26}$"
          },
          "submittedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Server time of receipt."
          }
        },
        "examples": [
          {
            "id": "rsp_01jf3m9x4t7v2b8n6q5w3e1r0s",
            "submittedAt": "2026-12-02T16:20:11.000Z"
          }
        ]
      },
      "Response": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "surveyId",
          "surveyVersion",
          "submittedAt",
          "durationMs",
          "answers"
        ],
        "description": "A stored response. Polls stores no IP address, user agent or cookie for a respondent.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^rsp_[0-9a-hjkmnp-tv-z]{26}$",
            "description": "`rsp_` + 26 lowercase Crockford base32 characters."
          },
          "surveyId": {
            "type": "string",
            "pattern": "^srv_[0-9a-hjkmnp-tv-z]{26}$"
          },
          "surveyVersion": {
            "type": "integer",
            "minimum": 1,
            "description": "Published version the taker answered."
          },
          "submittedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Server time of receipt."
          },
          "durationMs": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Time from `startedAt` to submission, or `null` if the taker sent no usable `startedAt` (missing, in the future, or more than 7 days earlier)."
          },
          "answers": {
            "$ref": "#/components/schemas/Answers"
          }
        },
        "examples": [
          {
            "id": "rsp_01jf3m9x4t7v2b8n6q5w3e1r0s",
            "surveyId": "srv_01jf3k9r0m4x7c2v8b6n5q1w2e",
            "surveyVersion": 2,
            "submittedAt": "2026-12-02T16:20:11.000Z",
            "durationMs": 48211,
            "answers": {
              "q_name": "Ada",
              "q_venue": {
                "choice": "lake"
              },
              "q_ok": true,
              "q_r": 4
            }
          }
        ]
      },
      "ResponsePage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items",
          "nextCursor"
        ],
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 200,
            "items": {
              "$ref": "#/components/schemas/Response"
            },
            "description": "Newest first."
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass as `cursor` to get the next page; `null` on the last page. Opaque."
          }
        },
        "examples": [
          {
            "items": [
              {
                "id": "rsp_01jf3m9x4t7v2b8n6q5w3e1r0s",
                "surveyId": "srv_01jf3k9r0m4x7c2v8b6n5q1w2e",
                "surveyVersion": 2,
                "submittedAt": "2026-12-02T16:20:11.000Z",
                "durationMs": 48211,
                "answers": {
                  "q_name": "Ada",
                  "q_venue": {
                    "choice": "lake"
                  },
                  "q_ok": true,
                  "q_r": 4
                }
              },
              {
                "id": "rsp_01jf3m2a7c9d4e5f6g8h0j1k2m",
                "surveyId": "srv_01jf3k9r0m4x7c2v8b6n5q1w2e",
                "surveyVersion": 2,
                "submittedAt": "2026-12-02T15:10:00.000Z",
                "durationMs": null,
                "answers": {
                  "q_name": "Grace",
                  "q_venue": {
                    "other": "A boat"
                  },
                  "q_r": 5
                }
              }
            ],
            "nextCursor": "eyJrIjoicnNwXzAxamYzbTJhN2M5ZDRlNWY2ZzhoMGoxazJtIn0"
          }
        ]
      },
      "ChoiceQuestionSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "title",
          "answered",
          "skipped",
          "choices"
        ],
        "description": "Summary of a `single_choice`, `multiple_choice` or `dropdown` question.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          },
          "type": {
            "type": "string",
            "enum": [
              "single_choice",
              "multiple_choice",
              "dropdown"
            ]
          },
          "title": {
            "type": "string"
          },
          "answered": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses that answered this question."
          },
          "skipped": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses that left it out."
          },
          "choices": {
            "type": "array",
            "description": "Every current choice, in question order, with how many responses picked it.",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "id",
                "label",
                "count"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "pattern": "^[a-z0-9_]{1,40}$"
                },
                "label": {
                  "type": "string"
                },
                "count": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          },
          "other": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses with a custom \"other\" text (choice questions with `allowOther`)."
          }
        }
      },
      "YesNoQuestionSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "title",
          "answered",
          "skipped",
          "yes",
          "no"
        ],
        "description": "Summary of a `yes_no` question.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          },
          "type": {
            "type": "string",
            "enum": [
              "yes_no"
            ]
          },
          "title": {
            "type": "string"
          },
          "answered": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses that answered this question."
          },
          "skipped": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses that left it out."
          },
          "yes": {
            "type": "integer",
            "minimum": 0
          },
          "no": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "ScaleQuestionSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "title",
          "answered",
          "skipped",
          "average",
          "min",
          "max",
          "distribution"
        ],
        "description": "Summary of a `rating` or `opinion_scale` question. Statistics are `null` when nobody answered.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          },
          "type": {
            "type": "string",
            "enum": [
              "rating",
              "opinion_scale"
            ]
          },
          "title": {
            "type": "string"
          },
          "answered": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses that answered this question."
          },
          "skipped": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses that left it out."
          },
          "average": {
            "type": [
              "number",
              "null"
            ],
            "description": "Mean answer."
          },
          "min": {
            "type": [
              "number",
              "null"
            ],
            "description": "Lowest answer."
          },
          "max": {
            "type": [
              "number",
              "null"
            ],
            "description": "Highest answer."
          },
          "distribution": {
            "type": "object",
            "description": "Count per value; keys are the integer values as strings, every value of the scale present.",
            "propertyNames": {
              "pattern": "^[0-9]+$"
            },
            "additionalProperties": {
              "type": "integer",
              "minimum": 0
            }
          }
        }
      },
      "NumberQuestionSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "title",
          "answered",
          "skipped",
          "average",
          "min",
          "max"
        ],
        "description": "Summary of a `number` question. Statistics are `null` when nobody answered.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          },
          "type": {
            "type": "string",
            "enum": [
              "number"
            ]
          },
          "title": {
            "type": "string"
          },
          "answered": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses that answered this question."
          },
          "skipped": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses that left it out."
          },
          "average": {
            "type": [
              "number",
              "null"
            ],
            "description": "Mean answer."
          },
          "min": {
            "type": [
              "number",
              "null"
            ],
            "description": "Lowest answer."
          },
          "max": {
            "type": [
              "number",
              "null"
            ],
            "description": "Highest answer."
          }
        }
      },
      "TextQuestionSummary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "title",
          "answered",
          "skipped",
          "samples"
        ],
        "description": "Summary of a `short_text`, `long_text`, `email` or `date` question.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9_]{1,40}$"
          },
          "type": {
            "type": "string",
            "enum": [
              "short_text",
              "long_text",
              "email",
              "date"
            ]
          },
          "title": {
            "type": "string"
          },
          "answered": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses that answered this question."
          },
          "skipped": {
            "type": "integer",
            "minimum": 0,
            "description": "Responses that left it out."
          },
          "samples": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "string"
            },
            "description": "The latest (up to) 10 answers, newest first."
          }
        }
      },
      "QuestionSummary": {
        "description": "Per-question aggregate. `statement` questions are left out.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/ChoiceQuestionSummary"
          },
          {
            "$ref": "#/components/schemas/YesNoQuestionSummary"
          },
          {
            "$ref": "#/components/schemas/ScaleQuestionSummary"
          },
          {
            "$ref": "#/components/schemas/NumberQuestionSummary"
          },
          {
            "$ref": "#/components/schemas/TextQuestionSummary"
          }
        ],
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "single_choice": "#/components/schemas/ChoiceQuestionSummary",
            "multiple_choice": "#/components/schemas/ChoiceQuestionSummary",
            "dropdown": "#/components/schemas/ChoiceQuestionSummary",
            "yes_no": "#/components/schemas/YesNoQuestionSummary",
            "rating": "#/components/schemas/ScaleQuestionSummary",
            "opinion_scale": "#/components/schemas/ScaleQuestionSummary",
            "number": "#/components/schemas/NumberQuestionSummary",
            "short_text": "#/components/schemas/TextQuestionSummary",
            "long_text": "#/components/schemas/TextQuestionSummary",
            "email": "#/components/schemas/TextQuestionSummary",
            "date": "#/components/schemas/TextQuestionSummary"
          }
        }
      },
      "Summary": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "responseCount",
          "lastResponseAt",
          "questions"
        ],
        "description": "Aggregates over all stored responses, computed against the published questions as they are now. Answers to removed questions are ignored. For a never-published survey, `questions` is empty.",
        "properties": {
          "responseCount": {
            "type": "integer",
            "minimum": 0
          },
          "lastResponseAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Latest response, or `null`."
          },
          "questions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QuestionSummary"
            }
          }
        },
        "examples": [
          {
            "responseCount": 12,
            "lastResponseAt": "2026-12-02T16:20:11.000Z",
            "questions": [
              {
                "id": "q_name",
                "type": "short_text",
                "title": "What should we call you?",
                "answered": 10,
                "skipped": 2,
                "samples": [
                  "Ada",
                  "Grace",
                  "Linus"
                ]
              },
              {
                "id": "q_venue",
                "type": "single_choice",
                "title": "Where should we go?",
                "answered": 11,
                "skipped": 1,
                "choices": [
                  {
                    "id": "lake",
                    "label": "Lake house",
                    "count": 7
                  },
                  {
                    "id": "city",
                    "label": "City loft",
                    "count": 2
                  },
                  {
                    "id": "mountain",
                    "label": "Mountain lodge",
                    "count": 1
                  }
                ],
                "other": 1
              },
              {
                "id": "q_ok",
                "type": "yes_no",
                "title": "Can you make the first week of March?",
                "answered": 12,
                "skipped": 0,
                "yes": 9,
                "no": 3
              },
              {
                "id": "q_r",
                "type": "rating",
                "title": "How was last year's offsite?",
                "answered": 12,
                "skipped": 0,
                "average": 4.2,
                "min": 2,
                "max": 5,
                "distribution": {
                  "1": 0,
                  "2": 1,
                  "3": 1,
                  "4": 4,
                  "5": 6
                }
              }
            ]
          }
        ]
      },
      "Token": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "prefix",
          "createdAt",
          "lastUsedAt",
          "expiresAt"
        ],
        "description": "An API token. The secret itself is shown only once, at creation.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^tok_[0-9a-hjkmnp-tv-z]{26}$",
            "description": "Token id (not the secret)."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Your label for the token."
          },
          "prefix": {
            "type": "string",
            "pattern": "^polls_[A-Za-z0-9_-]{4}$",
            "description": "The first 10 characters of the secret, so you can recognise it."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it was minted."
          },
          "lastUsedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Last successful use (updated at most every few minutes), or `null` if never used."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "After this instant the token answers `401`."
          }
        },
        "examples": [
          {
            "id": "tok_01jf2z8w6v4t2r0p8n6m4k2h0g",
            "name": "CI export job",
            "prefix": "polls_Q2hh",
            "createdAt": "2026-12-01T09:00:00.000Z",
            "lastUsedAt": "2026-12-02T08:15:00.000Z",
            "expiresAt": "2027-03-01T09:00:00.000Z"
          }
        ]
      },
      "TokenList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Token"
            }
          }
        },
        "examples": [
          {
            "items": [
              {
                "id": "tok_01jf2z8w6v4t2r0p8n6m4k2h0g",
                "name": "CI export job",
                "prefix": "polls_Q2hh",
                "createdAt": "2026-12-01T09:00:00.000Z",
                "lastUsedAt": "2026-12-02T08:15:00.000Z",
                "expiresAt": "2027-03-01T09:00:00.000Z"
              }
            ]
          }
        ]
      },
      "TokenCreate": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Your label for the token."
          },
          "expiresInDays": {
            "type": "integer",
            "minimum": 1,
            "maximum": 365,
            "default": 90,
            "description": "Lifetime in days."
          }
        },
        "examples": [
          {
            "name": "CI export job",
            "expiresInDays": 90
          }
        ]
      },
      "TokenCreated": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name",
          "prefix",
          "createdAt",
          "lastUsedAt",
          "expiresAt",
          "token"
        ],
        "description": "A freshly minted token. `token` is the secret: store it now, it is never shown again.",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^tok_[0-9a-hjkmnp-tv-z]{26}$",
            "description": "Token id (not the secret)."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Your label for the token."
          },
          "prefix": {
            "type": "string",
            "pattern": "^polls_[A-Za-z0-9_-]{4}$",
            "description": "The first 10 characters of the secret, so you can recognise it."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When it was minted."
          },
          "lastUsedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Last successful use (updated at most every few minutes), or `null` if never used."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "After this instant the token answers `401`."
          },
          "token": {
            "type": "string",
            "pattern": "^polls_[A-Za-z0-9_-]{43}$",
            "description": "`polls_` + 43 base64url characters. Send as `Authorization: Bearer <token>`."
          }
        },
        "examples": [
          {
            "id": "tok_01jf2z8w6v4t2r0p8n6m4k2h0g",
            "name": "CI export job",
            "prefix": "polls_Q2hh",
            "createdAt": "2026-12-01T09:00:00.000Z",
            "lastUsedAt": null,
            "expiresAt": "2027-03-01T09:00:00.000Z",
            "token": "polls_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
          }
        ]
      },
      "Me": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "sub",
          "name",
          "email",
          "via"
        ],
        "properties": {
          "sub": {
            "type": "string",
            "description": "Subject identifier at thermals-id."
          },
          "name": {
            "type": "string",
            "description": "Display name (may be empty)."
          },
          "email": {
            "type": "string",
            "maxLength": 254,
            "description": "Email address (may be empty if the provider shares none)."
          },
          "via": {
            "type": "string",
            "enum": [
              "session",
              "token"
            ],
            "description": "How this request was authenticated."
          }
        },
        "examples": [
          {
            "sub": "f3b0c6a2-7d41-4e8a-9c55-1a2b3c4d5e6f",
            "name": "Matt Peters",
            "email": "matt@example.com",
            "via": "token"
          }
        ]
      },
      "Health": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "ok",
          "commit",
          "time"
        ],
        "properties": {
          "ok": {
            "const": true,
            "type": "boolean"
          },
          "commit": {
            "type": "string",
            "maxLength": 40,
            "description": "Deployed commit (12 characters in production)."
          },
          "time": {
            "type": "string",
            "format": "date-time",
            "description": "Server time."
          }
        },
        "examples": [
          {
            "ok": true,
            "commit": "4f9c2a1b7e3d",
            "time": "2026-12-02T15:04:05.000Z"
          }
        ]
      },
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "description": "Every error response has this shape. Branch on `error.code`, not on `message`.",
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "bad_request",
                  "validation_failed",
                  "unauthorized",
                  "forbidden",
                  "not_found",
                  "method_not_allowed",
                  "version_conflict",
                  "slug_taken",
                  "survey_changed",
                  "survey_closed",
                  "payload_too_large",
                  "rate_limited",
                  "internal",
                  "unavailable"
                ],
                "description": "Stable machine-readable code."
              },
              "message": {
                "type": "string",
                "description": "Human-readable explanation. May change."
              },
              "details": {
                "type": "array",
                "description": "For `validation_failed`: one entry per problem.",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "path",
                    "message"
                  ],
                  "properties": {
                    "path": {
                      "type": "string",
                      "description": "Where in the body, e.g. `questions[2].choices`."
                    },
                    "message": {
                      "type": "string"
                    },
                    "line": {
                      "type": "integer",
                      "minimum": 1,
                      "description": "For a survey file (`POST /api/surveys/import`): the 1-based line the problem is on, when it is known."
                    }
                  }
                }
              }
            }
          }
        },
        "examples": [
          {
            "error": {
              "code": "validation_failed",
              "message": "The request body is not valid.",
              "details": [
                {
                  "path": "questions[2].choices",
                  "message": "must have at least 2 items"
                }
              ]
            }
          }
        ]
      },
      "SurveyDefinition": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "title",
          "description",
          "settings",
          "questions"
        ],
        "description": "A survey draft as Polls would store it, normalised: every setting and question field present, ids filled in. What a dry-run import returns.",
        "properties": {
          "title": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "maxLength": 2000
          },
          "settings": {
            "$ref": "#/components/schemas/Settings"
          },
          "questions": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Question"
            }
          }
        }
      },
      "SurveyImport": {
        "type": "object",
        "required": [
          "yaml"
        ],
        "description": "A survey file wrapped in JSON, for clients that can only send JSON (the builder, a browser session). Other properties are ignored.",
        "properties": {
          "yaml": {
            "type": "string",
            "minLength": 1,
            "description": "The text of a survey file: YAML (format 1) or JSON in the same shape, at most 512 KB in UTF-8."
          }
        },
        "examples": [
          {
            "yaml": "polls: 1\ntitle: Lunch poll\nslug: lunch-poll\nquestions:\n  - id: q_food\n    type: single_choice\n    title: Pizza or tacos?\n    required: true\n    choices: [Pizza, Tacos]\n  - id: q_why\n    type: long_text\n    title: Why?\n"
          }
        ]
      },
      "SurveyImportCheck": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "ok",
          "survey",
          "slug"
        ],
        "description": "The result of a dry-run import: the file is valid, and this is the survey it would create.",
        "properties": {
          "ok": {
            "const": true
          },
          "survey": {
            "$ref": "#/components/schemas/SurveyDefinition"
          },
          "slug": {
            "type": [
              "string",
              "null"
            ],
            "description": "The link the survey would get: the `slug` query parameter, else the file's, else `null` for a random one."
          }
        }
      }
    }
  }
}
