Skip to main content

REST API

Overview​

WebForms has two REST surfaces:

  • the Management API (/V1/webforms/forms, /drafts, /results, /imports and the rest listed under Operations), described on these pages. The WebForms MCP server uses it, and any integration you build can use it too;
  • the WebForms 3 routes (/V1/webforms/form/..., /result/..., /upload/...), kept unchanged for existing clients: see REST: Form (3.x), REST: Result (3.x) and REST: Upload (3.x).

Every path on these pages is relative to https://yourdomain.com/rest/all. A store view code works in place of all, for example /rest/default/V1/....

Conventions that hold across the Management API:

  • JSON in, JSON out. Nested structures travel as JSON strings in fields whose names end in _json (document_json, settings_json, features_json). Encode them as strings when you send them and decode them when you read them.
  • Every write is a POST (the one exception is PUT on appearance) with the body {"request": {...}}, and the request carries your own request_id.
  • Writes are idempotent per integration. A request_id is unique per integration across all routes, so use a new one for every new write. The same request_id with the same operation and body returns the stored outcome without repeating the change; the same request_id on another operation or with a different body is refused with REQUEST_ID_REUSED. Outcomes are kept for 24 hours; some operations keep theirs for 7 days (among the form operations: creating, duplicating, switching a form on or off and publishing). The answer of a prepare-* command carries a one-time token and is never stored: repeating it with the same request_id answers REPLAY_UNAVAILABLE, so prepare again with a new one.
  • Revisions guard against lost updates. Draft commands carry expected_draft_revision; publishing also carries expected_live_revision. A stale value is refused with a 409 whose details name the current revision.
  • Hidden means missing. A form outside the integration's form scope answers 404 NOT_FOUND, exactly like an id that does not exist.
  • Personal data is masked. Submission reads return masked values for fields marked as personal data unless the integration holds Disclose Personal Data or a temporary disclosure grant. See REST: Results.

Authentication​

The Management API accepts integration credentials only, signed with OAuth 1.0a (HMAC-SHA256). An admin token is refused with 403 ACTOR_NOT_ALLOWED. An unsigned request, or the integration's access token sent as a bearer token, is refused by Magento with 401 and the message The consumer isn't authorized to access …. Magento answers the same way when a correctly signed integration lacks the permission a route requires. A few operations check a second permission themselves (for example publishing on create); those refusals are 403 ACTOR_NOT_ALLOWED and name the missing permission.

Every request needs its own oauth_nonce and a current oauth_timestamp. Magento remembers the nonces an integration has used and refuses a repeated one with 401 and The nonce is already being used by the consumer with ID …. This happens when a client sends the same signed header twice, for example on a retry or on a second call that reuses the header of the first. Sign each request anew; the request_id is what makes a retried write safe.

Create the integration​

Run the connect command on the store server:

bin/magento webforms:api:connect --name="ERP sync" --preset=reader

The command creates and activates a Magento integration with the chosen permissions and prints a connection string: wf1_ followed by a base64url-encoded JSON object holding the store URL and the four OAuth values (consumer key, consumer secret, access token, access token secret). The WebForms MCP server reads the string as it is; any other client decodes it, or copies the same four values from System → Extensions → Integrations in the admin.

Option What it does
--name Integration name as it appears in the admin. Default WebForms MCP. Different names keep several integrations side by side.
--preset Permission set: reader, editor (default), support or full.
--permissions Comma-separated permissions instead of a preset, for example forms_view,forms_edit.
--forms all (every form, including later ones; the default for a new integration) or selected (only the forms ticked on the integration in the admin).
--reissue Applies the permissions again to an existing integration of that name and issues new tokens. Without --forms it keeps the current form scope.
--base-url Store URL written into the connection string. Default: the secure base URL.
--email Contact email stored on the integration.
--raw Prints the connection string alone.

Permissions​

Each resource page names the permission an operation needs (column ACL resource, MageMe_WebForms::api_v1_ plus the short name). The short names --permissions takes:

Permission Admin label reader editor support full
forms_view View Forms and Schema yes yes yes yes
forms_create Create Forms yes yes
forms_edit Edit and Publish Forms yes yes
forms_scripts Edit Form Scripts
results_view View Submissions (Masked) yes yes yes
results_pii_read Request Temporary Disclosure yes
results_pii_direct Disclose Personal Data yes
results_edit Edit Submissions yes yes
results_reply Reply to Submissions yes yes
results_export Export Submissions yes
attachments_read Download Attachments yes yes
results_import Import Submissions yes

In the admin these permissions sit under MageMe Extensions → WebForms → API on the integration's API tab (System → Extensions → Integrations). The block also holds Submit Forms and Upload Files (MageMe_WebForms::api_submission), which the WebForms 3 submit and upload routes check; --permissions doesn't take it, so select it on the integration's API tab.

forms_edit is the one permission to change a form: drafts, live settings, publishing, versions, switching a form on and off, appearance, and everything on the form's edit page in the admin: notifications and their activation, PDF documents, confirmations, customer registration mapping and lowering a field's personal data class. A notification sends what was submitted, in full, to the address it names, so an integration holding forms_edit can point a notification at its own address and receive every new submission. Grant it to integrations that are trusted with the submissions themselves.

forms_scripts covers the form scripts (on_load_script, after_submission_script) and markup that runs code on the storefront in the form texts and HTML fields. Writing such markup, publishing a draft that brings it in, and switching on or duplicating a form whose texts already run code need it; switching a form off does not. No preset includes it, full neither: add it by name, for example --permissions=forms_view,forms_edit,forms_scripts. Without it the call is refused with 403 ACTOR_NOT_ALLOWED.

Two permissions outside the API block have short names too, and no preset includes either:

Permission Resource Needed for
sales_orders_view Magento_Sales::actions_view Linking submissions to orders, and the linked_order_number filter
results_approve MageMe_WebForms::approve_result (Approve Results, under Manage Forms) set-approval on a submission, on top of results_edit

A short name the command doesn't know stops it with Unknown permission and the list of known names. A client that holds forms_view reads its own permissions and form scope from REST: Capabilities instead of probing route by route.

An integration whose Magento role is set to All Resources passes every permission check, personal data and forms_scripts included. Give an integration a preset or an explicit list when it should not read personal data or change form scripts.

Markup that runs code​

Without forms_scripts, the store checks every text it prints as HTML: the form's description, below_text and success_text, and the html of a switched-on HTML field in a switched-on section that is not shown through the sanitiser (html_safe off), in the default scope and in every store view. A write that brings in markup that runs code there, or changes such markup, is refused with 403 ACTOR_NOT_ALLOWED and details_json {key, store_id, parts[]}: key names the text (form.success_text, fields[<code>].html), parts lists what runs code (an element such as <script>, an event handler attribute, a directive, a comment, a control character). Markup the write leaves as it was does not stop it. The check runs on the draft commands that write these texts or switch such a field or section on (also restoring a field, moving it out of a switched-off section or changing its type), on publishing a draft, on restore-version, and on creating a form from a document.

In the form's own three texts, {{var}}, {{if}}, {{else}}, {{depend}} and {{trans}} outside a tag, and the address directives {{store url}}, {{store direct_url}}, {{view url}} and {{media url}} with no other parameter, are not parts. Any other directive (block, widget, layout, config, customvar) or an address directive with a further parameter is one. In an HTML field only {{store url}}, {{store direct_url}} and {{media url}} with no other parameter inside a quoted attribute value go without the permission.

Switching on or duplicating a form whose texts already run code needs forms_scripts too, and is refused the same way; switching it off does not, so an integration without the permission can switch such a form off but not back on. GET /V1/webforms/forms/{formId} reports such a form with has_executable_markup: true; the form list leaves the field null. The form scripts on_load_script and after_submission_script are settings of the write class script: they need forms_scripts and a confirmation.

Operations​

Resource What it covers
Capabilities API version, field types, the caller's permissions and form scope, limits
Schema Machine-readable schemas of field types, form and section settings, logic and the form document
Forms List and read forms; create from a document or a template; duplicate; switch on and off
Drafts Open a draft, change it with commands, validate and publish
Versions Earlier states of a form and their documents
Translations Store view texts of a form
Stats Submission counts of a form
Change feed Submissions changed since a cursor
Form templates Starter templates a form can be created from
Notifications Email notifications of a form and their activation
Confirmations The success message a store view shows after a submission
PDF documents PDF documents of a form
Appearance Store-wide appearance settings
Statuses Submission statuses
Quick responses Saved reply texts
Results Search, read, update and reply to submissions; export; disclosure grants
Imports Bulk import of submissions

Confirmations​

Some changes take effect beyond the form's page or send email at once. The store writes them only with a confirmation token, so a person can see the change before it happens:

Operation Needs a token when
drafts/{draftId}/commands/publish The plan asks for it (requires_confirmation), for example when it deletes answered fields or changes whom a switched-on notification emails (recipients_change with the addresses before and after)
drafts/{draftId}/commands/update-form It changes a setting of the write class confirm or script (see REST: Schema), or changes submitter_email_field_id so that a switched-on notification emails someone else
drafts/{draftId}/commands/remove-field Other parts of the form refer to the field
forms/{formId}/notifications/commands/update, set-content, set-store-settings, set-conditions The notification is switched on
notifications/{notificationId}/activation/confirm Always: activation/prepare issues the token
results/{resultId}/commands/set-status, results/commands/mass-status The status emails the customer
results/{resultId}/commands/set-approval The verdict emails the submitter or registers a customer account
forms/{formId}/confirmations/commands/set-content The success message changes
results/{resultId}/commands/reply Always: prepare-reply issues the token

Without a token such a command is refused with 409 CONFIRMATION_REQUIRED, and details_json describes the change: {impact[]} for publish, {references[], global_candidates[], draft_revision} for remove-field, {changes[], draft_revision} for update-form, {notification_id, changes} for a notification, {notifies_customer, status, email_template, count, recipient?} for a status, {notifies_customer, approval, notifications[], registers_customer, count, recipient?} for an approval, {changes} for a success message.

To get a token, send the same body to the prepare- twin of the command (prepare-update-form, prepare-remove-field, prepare-update, prepare-set-content, prepare-set-store-settings, prepare-set-conditions, prepare-set-status, prepare-mass-status, prepare-set-approval; prepare-publish and prepare-reply have their own routes). It writes nothing and answers with confirmation_token, expires_at, requires_confirmation and the change (changes, or impact_json for submission commands). Then send the command again with confirmation_token and a new request_id. A token lasts 10 minutes, is used once, and belongs to the plan it was issued for: the same object, revision, status, email and recipients. A token for another plan is refused with 409 CONFIRMATION_INVALID; prepare again. A status the form does not take is refused with 400 already at prepare.

Errors​

Every refusal from WebForms is a Magento web API error. parameters.code is stable and safe to branch on; message is for people and may change; details_json is a JSON string whose shape depends on the code.

{
"message": "The draft changed since you loaded it (expected revision 0, current 1). Reload and retry.",
"parameters": {
"code": "DRAFT_REVISION_MISMATCH",
"details_schema_version": "1",
"details_json": "{\"entity\":\"draft\",\"current_revision\":1}"
}
}

A store in developer mode adds a trace member; do not rely on it. Refusals that Magento makes before WebForms sees the request (a missing or invalid signature, a missing required parameter, an unknown route) have Magento's own shape, without parameters.code.

Code HTTP Retry?
VALIDATION_FAILED, INVALID_JSON, INVALID_FILTER, LIMIT_EXCEEDED, AMBIGUOUS_REF 400 No: fix the request
ACTOR_NOT_ALLOWED, PII_GRANT_REQUIRED, GRANT_EXPIRED, GRANT_EXHAUSTED 403 No: use other credentials or another grant. ACTOR_NOT_ALLOWED with {key, store_id, parts[]} is the markup check
LICENSE_NOT_COVERED 403 After the store owner renews or activates the WebForms license. Form-editing operations are refused, submission work is not
NOT_FOUND 404 No. Also returned for objects outside the integration's form scope
DRAFT_REVISION_MISMATCH, LIVE_REVISION_MISMATCH, RESULT_REVISION_MISMATCH 409 After reading the object again and using the revision from details_json.current_revision, with a new request_id
DRAFT_EXISTS 409 After the open draft (details_json.draft_id) is published or discarded
CONFIRMATION_REQUIRED 409 After the command's prepare- twin, sending its confirmation_token, with a new request_id. See Confirmations
CONFIRMATION_INVALID 409 After preparing again: the token belongs to another object, or the plan changed
REQUEST_ID_REUSED 409 With a new request_id
REPLAY_UNAVAILABLE 409 The stored outcome of this request_id is gone (older than its retention). Read the object to see whether the write happened (for a created form, list forms by the code you sent, which is why creating with a code helps), then use a new request_id if needed
INDETERMINATE 409 The earlier request with this request_id stopped midway; its effect is unknown. Read the object, then use a new request_id if needed. With details_json {saved: true, cache_cleared: false, …} the change is saved but the page cache could not be cleared after it: do not repeat the request. The details name what was saved (form_id; for a draft command also draft_id, draft_revision; for a submission command submission_id, submission_revision; for a reply also outbox_id)
CONFLICT 409 Yes: the same request_id is still being processed. Back off and send it again
QUOTA_EXCEEDED 429 Yes: after retry_after_seconds from the details, with the same request_id
INTERNAL 500 Yes, with the same request_id. Quote the correlation_id from the details when you report it

Examples​

A signed request carries an Authorization header like this one. Build it with an OAuth 1.0a library: plain curl cannot compute the signature.

GET /rest/all/V1/webforms/capabilities HTTP/1.1
Host: yourdomain.com
Accept: application/json
Authorization: OAuth oauth_consumer_key="<consumer-key>", oauth_nonce="<nonce>", oauth_signature_method="HMAC-SHA256", oauth_timestamp="<unix-time>", oauth_token="<access-token>", oauth_version="1.0", oauth_signature="<signature>"

A write with a request_id. The curl lines on these pages show the request; <signed-header> stands for the header above, computed for that request.

curl -X POST https://yourdomain.com/rest/all/V1/webforms/drafts/995543/commands/add-field \
-H "Authorization: <signed-header>" \
-H "Content-Type: application/json" \
-d '{"request": {"request_id": "erp-0001", "expected_draft_revision": 0, "type": "phone_number", "name": "Phone", "code": "phone"}}'
{"draft_id": 995543, "draft_revision": 1, "changed": true, "payload_json": "{\"field_id\":99192196,\"code\":\"phone\",\"type\":\"phone_number\"}"}

Sending this exact body again returns the same response and adds nothing. The same request_id with a different body:

{"message": "request_id \"erp-0001\" was already used with a different request.", "parameters": {"code": "REQUEST_ID_REUSED", "details_schema_version": "1", "details_json": "{}"}}

Applies to WebForms 4Last reviewed November 24, 2026