Skip to content

REST API

Stacko Forms registers its routes under the namespace stacko-forms/v1, for example https://example.com/wp-json/stacko-forms/v1/forms. The admin app uses these same endpoints.

  • Public routes: GET /token/{id} and POST /submit/{id} are open to everyone. Both send Cache-Control: no-store, max-age=0.
  • Every other route requires a logged-in user with the stacko_forms_manage capability. Otherwise it returns 401/403 with the code rest_forbidden. Use any standard WordPress REST authentication, such as cookie auth with an X-WP-Nonce header (what wp.apiFetch does) or Application Passwords.

Errors use the standard WordPress REST error shape. Plugin-specific codes include stacko_forms_not_found (404), stacko_forms_invalid_definition, stacko_forms_too_many_fields, stacko_forms_duplicate_field, stacko_forms_invalid_field_id, stacko_forms_unknown_field_type, stacko_forms_invalid_import (400) and stacko_forms_db_error (500).

Returns a fresh signed token for a published form. The front-end script calls this on the visitor’s first interaction.

{ "token": "1763200000.3f9c…" }

token is an empty string if the form isn’t published.

Submits a form. Send the body as application/x-www-form-urlencoded or multipart/form-data (the handler reads body parameters, not JSON).

Parameter Description
sf[{field_id}] Field values. Use sf[field][] for checkboxes and sf[name][first] / sf[name][last] for split name fields.
sf_token Signed token from /token/{id} or the rendered form. Required.
sf_hp Honeypot. Must be empty.
cf-turnstile-response Turnstile response, if Turnstile is on for the form
sf_source URL of the page the form was sent from (stored as source_url)

Response (200 on success, 422 on failure):

{
"success": false,
"errors": { "email": "Enter an email address in the correct format, like name@example.com." },
"message": "",
"redirect": ""
}
  • On success, message holds the confirmation HTML, or redirect holds the URL for the “page” and “URL” confirmation types.
  • On a general failure (expired token, too fast, rate limit, Turnstile), errors is empty and message explains the problem.
  • Submissions caught by the honeypot or with an invalid token return success: true but are not stored.
Terminal window
curl -X POST https://example.com/wp-json/stacko-forms/v1/submit/123 \
--data-urlencode "sf_token=$TOKEN" \
--data-urlencode "sf[name]=Ada Lovelace" \
--data-urlencode "sf[email]=ada@example.com" \
--data-urlencode "sf[message]=Hello"

The minimum fill time (3 seconds by default) is measured from the token’s issue time, so wait at least that long after fetching a token.

Method Route Description
GET /forms List forms. Query: status ('' or trash), search. Returns { items, counts }.
POST /forms Create a draft form. Body: title, and either template (a template slug) or definition (object). Returns 201 with the form.
GET /forms/{id} Get one form (see shape below).
PUT/PATCH/POST /forms/{id} Save title and/or definition. For a published form, the definition is saved as a draft and the live form doesn’t change.
DELETE /forms/{id} Move to trash. With force=true, delete the form, its entries and its revisions permanently.
POST /forms/{id}/publish Publish the current draft and save a revision. Fires stacko_forms_form_published.
POST /forms/{id}/unpublish Set the form back to draft.
POST /forms/{id}/duplicate Copy as a new draft titled “… (copy)”. Returns 201.
POST /forms/{id}/restore Restore from trash (as a draft).
POST /forms/{id}/discard-draft Throw away unpublished edits.
GET /forms/{id}/revisions List published revisions (last 10).
GET /forms/{id}/revisions/{revision} Get a revision’s definition.
GET /field-types All registered field types with builder metadata (type, label, group, isInput, props, defaults).
GET /templates All templates (slug, title, description, category, definition).

Built-in template slugs: contact, quote-request, feedback, newsletter, event-registration, support-request, appointment, job-application, survey, volunteer.

Form response:

{
"id": 123,
"title": "Contact form",
"status": "published",
"hasDraft": false,
"definition": { "version": 1, "fields": [], "layout": [], "settings": {} },
"shortcode": "[stacko_form id=\"123\"]",
"previewUrl": "https://example.com/?stacko_forms_preview=123&_wpnonce=…",
"formPageUrl": "https://example.com/?stacko_form=123",
"createdAt": "2026-11-15T10:00:00Z",
"updatedAt": "2026-11-15T10:05:00Z"
}

definition is the editable version (the draft if there is one). Definitions are validated by SchemaValidator; an invalid one returns a 400 error.

Method Route Description
GET /entries List entries. Returns { items, total, forms, counts }.
GET /entries/{id} Get one entry with its values, emails (email log), form and user (display name).
PUT/PATCH/POST /entries/{id} Change isRead (bool), isStarred (bool) and/or status (active, spam, trash).
DELETE /entries/{id} Delete permanently. Returns { deleted }.
POST /entries/bulk Body: ids (int[], required), plus either the same change fields or delete: true. Returns { count }.
POST /entries/{id}/resend Body: notification (notification ID, e.g. admin). Returns { sent, emails }.
POST /entries/empty-trash Delete every entry in the trash. Returns { count }.

Query parameters for GET /entries:

Parameter Type Default
form_id int all forms
status active | spam | trash active
filter '' | unread | starred ''
search string (searches all values)
date_from, date_to YYYY-MM-DD
page int ≥ 1 1
per_page int 1–100 25
Method Route Description
GET /settings Global settings. The Turnstile secret is never returned; turnstile_secret_set tells you whether one is saved.
PUT/PATCH/POST /settings Update settings with a JSON body containing any of the keys listed in the overview. An empty turnstile_secret_key keeps the saved one; send clear_turnstile_secret: true to remove it.
GET /stats Dashboard numbers.
GET /merge-tags Merge tags shown in the builder (tag, label).
GET /tools/export Export forms as JSON. Optional ids (comma-separated). Entries are not included.
POST /tools/import Import a JSON export (must have "plugin": "stacko-forms"). Up to 100 forms, created as drafts. Returns { created, failed }.
GET /tools/system-info Plain-text system report as { report }.
GET /tools/logs The latest 100 rows of the plugin log.
GET /tools/cf7 Contact Form 7 forms available to import (id, title).
POST /tools/cf7 Body: ids (CF7 post IDs). Imports each as a draft. Returns a result per form (source, title, id, error).
GET /pages Up to 200 pages (id, title), used by the “Go to a page” confirmation.

CSV export is not a REST route. It’s an authenticated download at admin-post.php?action=stacko_forms_export that requires stacko_forms_manage and a stacko_forms_export nonce (_wpnonce). Parameters: form_id, status, date_from, date_to, ids (comma-separated) and columns (comma-separated field IDs and/or entry_id, created_at, source_url, starred).