Skip to main content

Form Submission API

Submit form data with contact information, consent management, and custom fields.

Endpoint

POST /api/v1/forms/accept-submission

Authentication

Requires bearer token authentication. See Authentication.

Request Format

Headers

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

Request Body

{
// Required: Form identifier
form_id: string;

// Optional: Unique submission identifier (for idempotency)
submission_id?: string;

// Contact Information
email?: string;
phone_number?: string;
first_name?: string;
last_name?: string;
name_prefix?: string;

// Address
address_street?: string;
address_house_number?: string;
address_city?: string;
address_postcode?: string;

// Consent Management (at least one consent required)
consent_to_primary_purpose?: boolean;
consent_to_primary_purpose_deadline_date?: string; // ISO 8601 format
consent_to_primary_purpose_deadline_interval?: string; // e.g., "30d", "1y"

consent_to_general_contact_email?: boolean;
consent_to_general_contact_phone?: boolean;
consent_to_general_contact_deadline_date?: string;
consent_to_general_contact_deadline_interval?: string;

// Custom Fields
[key: string]: any;
}

Consent deadlines can be specified in two formats:

ISO 8601 Date

{
"consent_to_primary_purpose_deadline_date": "2026-12-31T23:59:59Z"
}

Time Interval

{
"consent_to_primary_purpose_deadline_interval": "1y"
}

Supported intervals: 30d, 90d, 1y, 2y, etc. Uses the ms library format.

Both Formats

If both are provided, the earlier deadline is used:

{
"consent_to_primary_purpose_deadline_date": "2027-12-31T23:59:59Z",
"consent_to_primary_purpose_deadline_interval": "6M"
}

Response Format

Success Response

Empty response body.

HTTP Status: 200 OK

Error Response

{
"errors": [
"form_id_missing",
"consent_to_primary_purpose_missing"
]
}

HTTP Status: 400 Bad Request

Error Codes

CodeDescription
form_id_missingThe form_id field is required
submission_id_invalidInvalid format for submission_id
consent_missingAt least one consent must be provided
consent_to_primary_purpose_missingPrimary purpose consent required when other fields are present
consent_to_primary_purpose_invalidInvalid value for primary purpose consent
consent_to_primary_purpose_declinedPrimary purpose consent was declined
consent_to_primary_purpose_deadline_missingDeadline required for primary purpose consent
consent_to_primary_purpose_deadline_invalidInvalid deadline format
consent_to_general_contact_phone_missingPhone number required when phone consent is granted
consent_to_general_contact_phone_invalidInvalid phone number format
consent_to_general_contact_email_missingEmail required when email consent is granted
consent_to_general_contact_email_invalidInvalid email format
consent_to_general_contact_deadline_invalidInvalid deadline format for general contact consent

Examples

Newsletter Signup

curl -X POST https://api.statelessapp.com/api/v1/forms/accept-submission \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"form_id": "newsletter-signup",
"email": "user@example.com",
"first_name": "Jane",
"last_name": "Smith",
"consent_to_general_contact_email": true,
"consent_to_general_contact_deadline_interval": "1y"
}'

Event Registration

curl -X POST https://api.statelessapp.com/api/v1/forms/accept-submission \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"form_id": "event-registration",
"email": "attendee@example.com",
"first_name": "John",
"last_name": "Doe",
"phone_number": "+15551234567",
"address_street": "Main St",
"address_house_number": "123",
"address_city": "San Francisco",
"address_postcode": "94102",
"consent_to_primary_purpose": true,
"consent_to_primary_purpose_deadline_date": "2026-12-31T23:59:59Z",
"event_preferences": "vegetarian",
"attendance_confirmed": true
}'

Petition Signature

curl -X POST https://api.statelessapp.com/api/v1/forms/accept-submission \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"form_id": "climate-petition",
"submission_id": "unique-submission-123",
"email": "activist@example.com",
"first_name": "Alex",
"last_name": "Johnson",
"consent_to_primary_purpose": true,
"consent_to_primary_purpose_deadline_interval": "2y",
"consent_to_general_contact_email": true,
"consent_to_general_contact_deadline_interval": "1y",
"address_street": "Oak Ave",
"address_house_number": "456",
"address_city": "Portland",
"address_postcode": "97201",
"comment": "We need urgent climate action!"
}'

Use Cases

  • Newsletter Signups: Collect email addresses with consent for marketing communications
  • Event Registrations: Gather attendee information with custom fields
  • Volunteer Recruitment: Capture contact details and availability preferences
  • Petition Signatures: Collect signatures with optional comments and demographic data
  • Survey Responses: Store survey answers with respondent contact information

Notes

  • At least one consent field must be set to true
  • Custom fields can be added beyond the standard fields (they will be stored in the payload JSON field)
  • The submission_id field enables idempotent submissions (resubmitting with the same ID won't create duplicates)
  • Consent deadlines are stored and enforced by the system
  • Phone numbers (phone_number field) should be in E.164 format (e.g., +15551234567)
  • Address fields are stored in separate columns for structured querying (used for districting and geo-targeting)