dimah-surveyv0.5.0
API reference

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.

AudienceDefault base pathOperations
Fill/api/surveyPublished surveys and responses
Editor/api/admin/surveyAuthoring, 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

MethodPathBrowser clientIn-process API
GET/survey/publishedgetPublishedSurvey(id)getPublishedSurvey({ query })
POST/response/startstartResponse({ surveyId, respondentId? })startResponse({ body })
GET/responsegetResponse(id)getResponse({ query })
GET/responseslistResponses(query)listResponses({ query })
POST/response/partialsavePartial(input)savePartial({ body })
POST/response/submitsubmitResponse(input)submitResponse({ body })
POST/response/abandonabandonResponse(input)abandonResponse({ body })
POST/response/reopenreopenResponse(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

MethodPathBrowser clientIn-process API
GET/surveygetSurvey(id)getSurvey({ query })
POST/surveysaveSurvey(input)saveSurvey({ body })
GET/surveyslistSurveys(query)listSurveys({ query })
POST/survey/publishpublishSurvey(input)publishSurvey({ body })
POST/survey/archivearchiveSurvey(input)archiveSurvey({ body })
POST/survey/settingssaveSurveySettings(input)saveSurveySettings({ body })
POST/survey/resumeresumeSurvey(input)resumeSurvey({ body })
GET/survey/versionslistSurveyVersions(query)listSurveyVersions({ query })
GET/responsegetResponse(id)getResponse({ query })
GET/responseslistResponses(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.

On this page