Skip to main content

Submit Form Response

Submit a response to a published form. This endpoint validates that all required fields are present before saving the response.

Endpoint

Authentication

No authentication required. This endpoint is public to allow anyone with the form link to submit responses.

Request Body

string
required
The UUID of the form to submit a response to
object
required
An object containing the form field values. Keys should match the field IDs defined in the form schema.The structure varies based on the form, but generally:
  • Keys are field IDs (e.g., “name”, “email”, “rating”)
  • Values are the user’s input for each field

Response

boolean
Indicates whether the response was submitted successfully
string
Confirmation message: “Response submitted successfully”
string
Unique identifier for the submitted response

Validation Rules

The endpoint performs the following validations:
  1. Form ID validation: Must be a non-empty string
  2. Data validation: Must be a valid object (not null, not array)
  3. Form existence: The form must exist in the database
  4. Required fields: All fields marked as required: true in the form schema must be present in the data object
If any validation fails, the request is rejected with a 400 or 404 error.

Example Request

Example Response

Error Responses

Implementation Details

The submission process:
  1. Validates the formId and data parameters
  2. Looks up the form in the database
  3. Retrieves the form’s field schema
  4. Checks that all required fields are present in the submitted data
  5. Creates a new response record in the formsResponses table
  6. Returns the response ID
Source: app/api/forms/submit/route.ts:4

Example: Required Field Validation

Given a form with this field schema:
Valid submission (phone is optional):
Invalid submission (missing required email):
This would return: