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:- Form ID validation: Must be a non-empty string
- Data validation: Must be a valid object (not null, not array)
- Form existence: The form must exist in the database
- Required fields: All fields marked as
required: truein the form schema must be present in the data object
Example Request
Example Response
Error Responses
Implementation Details
The submission process:- Validates the
formIdanddataparameters - Looks up the form in the database
- Retrieves the form’s field schema
- Checks that all required fields are present in the submitted data
- Creates a new response record in the
formsResponsestable - Returns the response ID
app/api/forms/submit/route.ts:4