Forms API
Submitting a response
Endpoint:
/apps/endpoints-app/form-submissions/public/submit
Method:
POST
Content Type:
multipart/form-data
Overview
Handles form submissions with file uploads. Accepts standard form fields and file attachments, with special handling for metadata fields.
Field Types
Standard Fields:
- The database is set up to accept these standard fields: firstName, lastName, email, phone, body. Other fields can be added as metadata fields.
- File inputs must have unique names (e.g.,
image1
,image2
) - No fields are required by the API
Metadata Fields:
Use format metadata[Field Name]
→ appears as metadata.Business Name
Example Form
<form id="verificationForm" enctype="multipart/form-data">
<input type="text" name="formCode" value="ENTER YOUR FORM CODE HERE">
<input type="text" name="firstName">
<input type="email" name="email">
<!-- Metadata fields -->
<input type="text" name="metadata[Business Name]">
<input type="text" name="metadata[Business Type]">
<!-- File uploads -->
<input type="file" name="image1" accept="image/*">
<input type="file" name="image2" accept="image/*">
<button type="submit">Submit Form</button>
</form>
JavaScript Usage
const form = document.getElementById('verificationForm');
form.addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(form);
try {
const response = await fetch('/apps/endpoints-app/form-submissions/public/submit', {
method: 'POST',
body: formData
// No need to set Content-Type header - browser sets it automatically with boundary
});
if (!response.ok) {
throw new Error('Submission failed');
}
const result = await response.json();
console.log('Form submitted successfully:', result);
} catch (error) {
console.error('Error submitting form:', error);
}
});
File Requirements
- Images only (
accept="image/*"
) - Max size: 10MB per file
- Formats: JPEG, PNG, GIF