Event Submission Flow Endpoint
Route
POST /wp-json/extrachill/v1/event-submissions
Purpose
Accepts public event submissions from blocks and forms, verifies Cloudflare Turnstile tokens, uploads optional flyers, and spins up a Data Machine job so the configured automation flow can review and publish the event.
Authentication
- Public endpoint; security relies on the required Turnstile verification token plus server-side validation inside extrachill-multisite helpers.
Request Requirements
Core Fields
| Field | Type | Required | Notes |
|---|---|---|---|
flow_id | integer | Yes | Data Machine flow configured by the block. |
turnstile_response | string | Yes | Token issued by Cloudflare Turnstile. |
contact_name | string | Conditionally | Optional when logged in; required for anonymous users. |
contact_email | string | Conditionally | Auto-filled for logged-in users; required + validated for anonymous users. |
event_title | string | Yes | Sanitized text. |
event_date | string | Yes | Stored as provided; format enforcement happens downstream. |
event_time, venue_name, event_city, event_lineup, event_link, notes | string | No | Optional context fields accepted as sanitized text/URLs. |
File Uploads
- Accepts a single
flyerfile via multipart form-data. - File is uploaded through WordPress (
wp_handle_upload) and then persisted to Data Machine’s FileStorage repository so AI/flow steps can read it later.
Processing Workflow
- Validates
flow_idand Turnstile token usingec_verify_turnstile_response(). - Extracts and sanitizes submission fields via
extrachill_api_extract_submission_fields(); leverages logged-in identity when available. - Confirms the requested Data Machine flow exists (
DataMachineCoreDatabaseFlowsFlows). - Stores the optional flyer file and attaches its storage path to the submission payload.
- Creates a Data Machine job through
DataMachineServicesJobManager, merges submission data into the engine viadatamachine_merge_engine_data(), and schedules execution withas_schedule_single_action( 'datamachine_run_flow_now', ... ). - Fires
do_action( 'extrachill_event_submission', $submission, $context )so platform plugins can react (notifications, analytics, moderation).
Response
json
{
"success": true,
"message": "Thanks! We queued your submission for review.",
"job_id": 1234
}job_idreferences the Data Machine job created for the submission.
Error Codes
| Code | Status | Description |
|---|---|---|
invalid_flow_id | 400 | Missing or non-numeric flow_id. |
turnstile_missing / turnstile_failed | 500 / 403 | Security helper unavailable or token invalid. |
missing_fields / invalid_email | 400 | Required contact or event fields missing/invalid. |
datamachine_missing / flow_not_found | 500 / 404 | Data Machine dependency missing or flow ID not found. |
flyer_upload_failed / flyer_store_failed | 400 / 500 | File handling failed at upload or storage stage. |
job_creation_failed / execution_failed | 500 | Could not create or queue the Data Machine job. |
scheduler_unavailable | 500 | Action Scheduler functions missing. |
Integration Guidance
- Always include a valid
turnstile_response; the request fails before any data is stored if verification is missing. - Submit multipart form-data when sending a flyer; JSON-only bodies should omit the
flyerfield entirely. - Use the returned
job_idto display status or poll downstream systems for completion updates. - Listen for the
extrachill_event_submissionaction on other network plugins to trigger Slack/Email alerts or moderation workflows.