HTTP protocol
Map fill and editor routes to browser clients and the in-process API.
Route constants, payload schemas, and clients live in
@dimah-survey/core.
| Audience | Default base path | Operations |
|---|---|---|
| Fill | /api/survey | Published surveys and responses |
| Editor | /api/admin/survey | Authoring, settings, publish, and response analysis |
The suffixes below are appended to those bases. Browser clients take flat
objects; the in-process API takes { query } or { body }. Operations from
the wrong audience are not mounted and return NOT_FOUND.
List endpoints default to 50 rows and cap at 100.
Fill routes
| Method | Path | Browser client | In-process API |
|---|---|---|---|
GET | /survey/published | getPublishedSurvey(id) | getPublishedSurvey({ query }) |
POST | /response/start | startResponse({ surveyId, respondentId? }) | startResponse({ body }) |
GET | /response | getResponse(id) | getResponse({ query }) |
GET | /responses | listResponses(query) | listResponses({ query }) |
POST | /response/partial | savePartial(input) | savePartial({ body }) |
POST | /response/submit | submitResponse(input) | submitResponse({ body }) |
POST | /response/abandon | abandonResponse(input) | abandonResponse({ body }) |
POST | /response/reopen | reopenResponse(input) | reopenResponse({ body }) |
On survey reads, id accepts a survey id or slug. startResponse.surveyId
accepts either as well. Every response mutation uses the response row id.
getPublishedSurvey returns the active published document and does not stamp
a respondent. draftJson is not part of this result.
import type { PublishedSurvey } from "@dimah-survey/core";Prop
Type
The guard stamps respondentId for identified callers. A matching value in the
body is tolerated, but the browser cannot claim another owner. Anonymous
callers cannot list responses; identified callers cannot request
include: "full".
Editor routes
| Method | Path | Browser client | In-process API |
|---|---|---|---|
GET | /survey | getSurvey(id) | getSurvey({ query }) |
POST | /survey | saveSurvey(input) | saveSurvey({ body }) |
GET | /surveys | listSurveys(query) | listSurveys({ query }) |
POST | /survey/publish | publishSurvey(input) | publishSurvey({ body }) |
POST | /survey/archive | archiveSurvey(input) | archiveSurvey({ body }) |
POST | /survey/settings | saveSurveySettings(input) | saveSurveySettings({ body }) |
POST | /survey/resume | resumeSurvey(input) | resumeSurvey({ body }) |
GET | /survey/versions | listSurveyVersions(query) | listSurveyVersions({ query }) |
GET | /response | getResponse(id) | getResponse({ query }) |
GET | /responses | listResponses(query) | listResponses({ query }) |
saveSurvey creates the survey when the id is new. slug defaults to id.
Pass expectedUpdatedAt when updating. A create that includes the token fails
with STALE_UPDATE.
List queries
listResponses accepts:
import type { ListResponsesQuery } from "@dimah-survey/core";Prop
Type
"summary" omits data. "full" adds data and returns each referenced
version once on versions. Rows sort by updatedAt descending.
listSurveyVersions pages one survey's versions, newest first.
listSurveys accepts:
import type { ListSurveysQuery } from "@dimah-survey/core";Prop
Type
List results
listSurveys returns:
import type { SurveyList } from "@dimah-survey/core";Prop
Type
listResponses returns:
import type { ResponseList } from "@dimah-survey/core";Prop
Type
Compare-and-swap inputs
expectedUpdatedAt is optional on draft, publish, archive, settings, resume,
partial save, submit, abandon, and reopen. When it is set, the stored
updatedAt must match or the write fails with STALE_UPDATE. The React
bindings always send the token from their last successful read or write.
The exported Zod schemas are the authoritative payload definitions. See Errors for stable failure codes.