Gravity Forms submission bridge
const url = 'https://example.com/wp-json/wp2lms/turbo/v1/gravity-forms/submit';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"form_id":3,"input_values":{"input_1":"Ivanov","input_2":"learner@example.com"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/wp-json/wp2lms/turbo/v1/gravity-forms/submit \ --header 'Content-Type: application/json' \ --data '{ "form_id": 3, "input_values": { "input_1": "Ivanov", "input_2": "learner@example.com" } }'Public REST bridge to GFAPI::submit_form from a Turbo page. PHP collects input_* fields from the body root and/or from input_values (object or JSON string). Files are multipart input_N / input_N[i]. Empty checkbox sub-inputs and booleans are dropped.
A positive form_id is required (otherwise 400 invalid_form). Unknown form — 404 not_found. No GFAPI class — 503 unavailable. A wp_rest nonce is required in X-WP-Nonce or _wpnonce (403 invalid_nonce).
This is not the heartbeat admin-ajax fallback (data[wp2t]) and does not create a form. Invalid GF fields still return HTTP 200 with is_valid=false and validation_messages. Successful poll submit: pollResults from gf_polls; gpoll HTML is stripped from confirmation.
A cookie session is not required.
Request Body
Section titled “Request Body”object
Gravity Forms form ID. Must be > 0, otherwise 400 invalid_form. May be sent as JSON, query, or multipart.
Map of input_N → value. Alternatively the same keys at the body root. A JSON string is also accepted. Keys without the input_ prefix are ignored.
object
Example
{ "form_id": 3, "input_values": { "input_1": "Ivanov", "input_2": "learner@example.com" }}Responses
Section titled “Responses”GFAPI::submit_form result, normalized by the bridge: is_valid, validation_messages, confirmation, pollResults, entry_id, user_id.
object
Whether GF validation passed (!empty(result['is_valid'])). false does not change the HTTP code — it stays 200.
Failed_validation messages keyed by GF field id. Empty object when the form is valid.
object
GF confirmation_message (string; may be HTML). gpoll_container markup is stripped when pollResults is present.
Structured poll results (gf_polls). [] when the add-on is missing, displayResults is off, or there were no poll fields.
object
Gravity Forms poll field ID.
Poll field label.
Gf_polls style (form setting, often green).
Whether to show percentages (form displayResults setting).
Whether to show absolute counts.
Poll choices with shares and whether the current entry selected them.
object
Poll choice label.
Vote share (0…1) from gpoll_get_results.
Vote count for the choice.
True if the current entry selected this choice.
GF entry ID. null when no entry was created (often when is_valid=false).
Get_current_user_id() at submit time; 0 for a guest (typical public Turbo).
Example
{ "is_valid": true, "validation_messages": {}, "confirmation": "Thank you, your entry was received.", "pollResults": [], "entry_id": 901, "user_id": 0}Invalid_form — form_id ≤ 0. Or a WP_Error from GFAPI::submit_form with status 400 (Gravity Forms code).
object
Machine-readable WP_Error code (for example wp2lms_static_builder_busy, rest_forbidden, invalid_nonce).
Human-readable error message from PHP / WordPress REST.
Usually { status: <HTTP code> }. If status is missing, core REST often returns 500.
object
Example
{ "code": "wp2lms_static_builder_busy", "message": "Build is currently building and cannot be updated.", "data": { "status": 409 }}Invalid_nonce — missing or invalid wp_rest nonce (X-WP-Nonce header or _wpnonce param).
object
Machine-readable WP_Error code (for example wp2lms_static_builder_busy, rest_forbidden, invalid_nonce).
Human-readable error message from PHP / WordPress REST.
Usually { status: <HTTP code> }. If status is missing, core REST often returns 500.
object
Example
{ "code": "wp2lms_static_builder_busy", "message": "Build is currently building and cannot be updated.", "data": { "status": 409 }}Not_found — GFAPI::get_form did not return a form array.
object
Machine-readable WP_Error code (for example wp2lms_static_builder_busy, rest_forbidden, invalid_nonce).
Human-readable error message from PHP / WordPress REST.
Usually { status: <HTTP code> }. If status is missing, core REST often returns 500.
object
Example
{ "code": "wp2lms_static_builder_busy", "message": "Build is currently building and cannot be updated.", "data": { "status": 409 }}Submit_failed — GFAPI::submit_form returned neither an array nor a WP_Error. Or a GF WP_Error without its own status.
object
Machine-readable WP_Error code (for example wp2lms_static_builder_busy, rest_forbidden, invalid_nonce).
Human-readable error message from PHP / WordPress REST.
Usually { status: <HTTP code> }. If status is missing, core REST often returns 500.
object
Example
{ "code": "wp2lms_static_builder_busy", "message": "Build is currently building and cannot be updated.", "data": { "status": 409 }}Unavailable — GFAPI class is missing (Gravity Forms plugin not active).
object
Machine-readable WP_Error code (for example wp2lms_static_builder_busy, rest_forbidden, invalid_nonce).
Human-readable error message from PHP / WordPress REST.
Usually { status: <HTTP code> }. If status is missing, core REST often returns 500.
object
Example
{ "code": "wp2lms_static_builder_busy", "message": "Build is currently building and cannot be updated.", "data": { "status": 409 }}