Skip to main content

Forms API

The Forms API is available under /apis/v1/forms and requires a Ration bearer token. Forms may be visible through ownership or a Ration share grant.

Authorization: Bearer <ration_access_token>
Content-Type: application/json

Form model

Form responses are wrapped in a form object. A form includes its id, title, description, sections/questions, status and acceptance state, author data, sharing/access configuration, and builder mechanics such as conditional logic and question settings.

Question and section definitions are sent within the form body. Keep question IDs stable when updating an existing form so submitted answers and analytics continue to align with the intended fields.

Authoring CRUD

GET /apis/v1/forms/presets returns the available detailed-builder presets, each with key, label, and summary.

POST /apis/v1/forms/draft creates a saved starter draft. Send method: "detailed" with a preset, or method: "assisted" with a description. Optional audience: "external" initializes external/link access. The response contains form, note, and generated.

MethodPathDescription
GET/apis/v1/formsList visible forms in a forms array.
POST/apis/v1/formsCreate a form and return 201 with a form object.
GET/apis/v1/forms/:idRead a form. Shared forms also return shared: true.
PATCH, PUT/apis/v1/forms/:idUpdate the builder definition and return the form.
DELETE/apis/v1/forms/:idDelete a form and return it.

Example minimal form:

{
"title": "Product feedback",
"description": "Tell us what you think.",
"sections": [
{
"id": "section-1",
"title": "Feedback",
"questions": [
{ "id": "q1", "type": "short_text", "label": "What worked well?", "required": true }
]
}
]
}

Publishing lifecycle

MethodPathRequestResponse
POST/:id/publishPublished form.
POST/:id/archiveArchived form.
POST/:id/unarchiveRestored form.
POST/:id/acceptingaccepting Boolean.Updated form.

Paths in this table are relative to /apis/v1/forms. Publishing makes a form available according to its configured access mode; archiving stops its normal lifecycle. accepting: false closes response collection without deleting the form.

Submit and review responses

Submit as an authenticated user

POST /apis/v1/forms/:id/submit

{
"answers": {
"q1": "The search workflow was very clear."
},
"device_type": "mobile",
"locale": "en"
}
FieldTypeRequiredDescription
answersObjectYesKeys are form question IDs; values must satisfy their question type and validation.
device_typeStringNoResponding device classification.
localeStringNoRespondent locale.
metadataObjectNoAdditional client metadata.

Ration derives respondent ID, name, email, and source from the bearer-authenticated user. Success returns 201 with a response object; validation errors return 422 with error: "validation_failed" and an errors object.

Read responses and analytics

MethodPathResponse
GET/:id/responsesResponses array; use supported list query parameters for pagination/filtering.
GET/:id/responses/:response_idOne response object.
GET/:id/analyticsAnalytics object aggregated for the form questions.

These paths are relative to /apis/v1/forms and require form-owner access.

Export responses

MethodPathResult
GET/:id/export.csvCSV attachment named responses-<form-id>.csv.
GET/:id/export.xlsxXLSX attachment named responses-<form-id>.xlsx.

Paths are relative to /apis/v1/forms.

Sharing, attachments, and report builder

Form sharing and uploaded answers

MethodPathRequest / response
POST/:id/shareOptional expires_at; creates a share link and returns the form.
DELETE/:id/shareRevokes the form share link and returns the form.
POST/:id/share/regenerateReplaces the form share link and returns the form.
POST/:id/attachmentsMultipart request with required file; returns 201 and a file descriptor.

The file descriptor contains secure_id, filename, content_type, size, and url. The hard attachment limit is 25,000,000 bytes; per-question upload limits may be smaller.

Saved reports

The visual report builder is now available to API clients. Its persisted report spec is the definition behind the draggable report layout.

MethodPathRequest / response
GET/:id/report_snapshotCurrent materialized per-question snapshot, or snapshot: null.
GET, POST/:id/reportsList reports, or create one with required name and spec.
GET, PUT, DELETE/:id/reports/:report_idRead, update (name, spec), or delete a saved report.
POST/:id/reports/:report_id/shareSet read-only viewers with emails or shared_with.
GET/:id/reports/:report_id/shareList report viewers in shared_with.
POST/:id/report.xlsxExport client-computed report sheets to XLSX; optional name.

Paths are relative to /apis/v1/forms.

Reports shared with the caller

MethodPathResult
GET/apis/v1/reports/sharedReports shared read-only with the caller.
GET/apis/v1/reports/shared/:report_idSaved report specification.
GET/apis/v1/reports/shared/:report_id/responsesResponse data needed to render the shared report.
GET/apis/v1/reports/shared/:report_id/formRead-only form definition for the shared report.

Errors

StatusMeaning
401Missing or invalid bearer authentication.
404Form or response not found, or not visible to the caller.
422Invalid form definition, validation failure, invalid ID, no changes, or an unavailable lifecycle operation.