REST: Drafts
Overview
Every change to a form's structure goes through a draft, the same draft the form builder uses: open it, change it with commands, validate it, publish it. The live form keeps working unchanged until the publish. See Drafts and versions for how drafts behave in the admin.
- Open —
POST /V1/webforms/forms/{formId}/draft. A form has at most one draft; when one is already open, the call returns that draft instead of creating another. - Read —
GET /V1/webforms/drafts/{draftId}for the summary,GET …/documentfor the draft's whole document. - Change —
POST /V1/webforms/drafts/{draftId}/commands/{name}, one command per call, each with theexpected_draft_revisionyou hold. Each change raises the draft revision by one. - Validate —
POST …/validatelists errors, warnings and the impact of publishing. - Prepare —
POST …/commands/prepare-publishreturns a confirmation token. You need it when the publish removes answered data or changes a setting that reaches outside the form. - Publish —
POST …/commands/publish. The draft becomes the live form, the replaced state is kept as a version, and the draft id answers404from then on.
POST …/commands/discard throws the draft away instead (with expected_draft_revision).
Draft summary
| Member | Meaning |
|---|---|
draft_id | Id of the draft; use it on every draft route |
live_id | Id of the live form |
draft_revision | Current draft revision; starts at 0 |
live_revision | Revision of the live form the draft is based on |
started_by_type, started_by_id, started_by_name | Who opened the draft: an admin or an integration |
Ids inside a draft (field ids in particular) are the draft's own and differ from the live form's. Codes stay the same, so address fields by code where you can.
Commands
Every command takes request_id and expected_draft_revision. The answer has draft_id, the new draft_revision, changed (false when the command changed nothing, and then the revision stays) and payload_json with the command's own result.
A field reference (field_ref, after_field_ref) is a field id or a field code (case-sensitive). A field code follows the rule fields are stored by: up to 255 bytes, starting with a letter, then letters, digits, underscores, hyphens and colons; a code of digits only is refused. limits_json.code_bytes_max in REST: Capabilities (100) is the limit for form and section codes. Sections (fieldset_ref) and logic rules (logic_ref) are referenced by id. JSON arguments (settings_json, rules_json …) are JSON strings.
| Command | Request keys | Payload |
|---|---|---|
update-form | settings_json; optional store_code, use_default_json; confirmation_token when the change needs one | updated, reset, live_updated |
prepare-update-form | the same keys as update-form | confirmation_token, expires_at, requires_confirmation, changes |
add-fieldset | optional settings_json, position | fieldset_id |
update-fieldset | fieldset_ref, settings_json; optional store_code, use_default_json | fieldset_id, reset |
remove-fieldset | fieldset_ref | fieldset_id |
reorder | positions_json: {"fieldsets": [{"fieldset": id, "position": n}], "fields": [{"field": ref, "fieldset": id, "position": n}]} | reordered |
add-field | type; optional name, code, settings_json, fieldset_ref, and after_field_ref or position | field_id, code, type. A given code is kept as it is; a suffix is added only when another field holds it |
update-field | field_ref, settings_json; optional store_code, use_default_json | field_id, reset |
turn-into | field_ref, target_type | field_id, type |
duplicate-field | field_ref | field_id, code |
prepare-remove-field | field_ref | field_id, requires_confirmation, references, global_candidates, confirmation_token, expires_at |
remove-field | field_ref; confirmation_token from prepare-remove-field when other parts of the form refer to the field | field_id. The field goes to the form's trash |
restore-field | trash_ref from GET /V1/webforms/drafts/{draftId}/trash | the restored field; its code may change when another field took it. Calling it again for a field already restored changes nothing |
set-logic | rules_json: the complete list of rules; optional store_code | saved, deleted |
add-logic | rules_json: rules to add | logic_ids, added |
remove-logic | logic_ref | logic_id |
set-translations | store_code (a store view, required), translations_json; mode: "replace" replaces, otherwise merges | entities_written |
replace-document | document_json: a whole form document | counts of sections and fields added, updated and removed; logic; warnings |
Settings are checked against REST: Schema: an unknown key is refused with VALIDATION_FAILED. The field-types schema also lists, per type, the types turn-into can convert to (convertible_to) and which types can drive logic.
Form settings and authority. In update-form, a setting whose schema authority is draft is stored in the draft and goes live on publish. A setting with authority live is written to the live form at once, needs the forms_edit permission, and is listed in live_updated. Such a write does not change the live form's revision, so the open draft still publishes with the expected_live_revision it holds.
The schema's write descriptor says how the API writes each setting: direct at once, confirm only with a confirmation token (a live setting whose effect reaches beyond the form's page: url_key, success_text, redirect_url, captcha, published submissions, cleanup, Do Not Store Submissions, customer access and registration), script with forms_scripts and a token (on_load_script, after_submission_script), none not at all (400 VALIDATION_FAILED). An update-form that changes a confirm or script setting, or changes submitter_email_field_id so that a switched-on notification emails someone else, is refused with 409 CONFIRMATION_REQUIRED until you send the token from prepare-update-form: see Confirmations. A setting written with its current value needs no token. The success message of a confirmation in a store view has its own route, see REST: Forms.
Store views. With store_code, update-form, update-fieldset and update-field write that store view's values. use_default_json lists keys whose value for the store view is removed, so the default applies again. A store view text written this way follows the rules of set-translations.
Translations. set-translations checks each entry of translations_json and names the element in its error: form: "name" is not translatable., fields[<ref>]: "columns" is not translatable. (also fieldsets[…] and logic[…]). A text whose base is empty and which the storefront fills with a phrase takes only that phrase's placeholders: "min_length_validation_message" may use only the placeholders %1; %2 has no value there. A value equal to that phrase on top of an empty base text is not stored, so the store view keeps following the phrase. mode: "replace" keeps the store view's keys that are not translations. The draft document and translations carry the phrases as defaults (see REST: Translations).
Replacing the document. replace-document refuses a new field of a type the store does not offer with 400 and the field's path; a field of such a type that the draft already has is kept and reported in warnings.
Validate, prepare, publish
validate takes no body. It answers:
| Member | Meaning |
|---|---|
errors_json, warnings_json | Problems found in the draft document |
impact_json | What publishing would do to the live form: one item per change, with kind (field_delete, field_type_change, option_remove, logic_change, setting_change), severity, subject and detail (for deletions: how many submissions, answers and files are affected) |
requires_confirmation | true when an item is destructive (it removes answered data) or external (it changes a setting that reaches outside the form) |
plan_digest | Digest of the impact list |
prepare-publish takes expected_draft_revision and expected_live_revision and returns confirmation_token, expires_at (10 minutes later), impact_json and requires_confirmation. The token is bound to this integration, this draft and this impact list: if the draft or the live form changes afterwards, prepare again.
publish takes expected_draft_revision, expected_live_revision and, when requires_confirmation is true, the confirmation_token. Without it such a publish is refused with 409 CONFIRMATION_REQUIRED, whose details list the impact. The answer is the form summary with its new revision.
Authentication
OAuth 1.0a integration credentials, as described on REST API. Reading, changing and publishing a draft, and live form settings in update-form, need forms_edit. Form scripts and markup that runs code in the form texts or an HTML field need forms_scripts as well (see Markup that runs code).
Operations
| Method | Path | Operation | ACL resource |
|---|---|---|---|
| GET | /V1/webforms/drafts/{draftId} | DraftInterface_get | MageMe_WebForms::api_v1_forms_edit |
| POST | /V1/webforms/drafts/{draftId}/commands/{name} | remove-field takes the confirmation token of the plan like publish does: 409 CONFIRMATION_REQUIRED without one when it is needed, 409 CONFIRMATION_INVALID for an unknown, malformed or spent one. update-form takes the token of prepare-update-form the same way when it writes a live setting whose schema write is "confirm" or "script" (a "script" setting also needs MageMe_WebForms::api_v1_forms_scripts; a "none" setting is refused with 400). It also takes one when submitter_email_field_id changes whom a switched-on notification with a submitter source sends to: changes then holds {key: "submitter_email_field_id", kind: "recipients_change", subject {entity, id, name}, detail {recipients [{store_id, source, field_code, role, before, after}]}}, as recipients_change in the publish plan. The answer or refusal of prepare-update-form and prepare-remove-field is not kept, since the answer carries a token: a retry under the same request_id answers 409 REPLAY_UNAVAILABLE, so each prepare goes out under a new request_id. | MageMe_WebForms::api_v1_forms_edit |
| POST | /V1/webforms/drafts/{draftId}/commands/discard | DraftInterface_discard | MageMe_WebForms::api_v1_forms_edit |
| POST | /V1/webforms/drafts/{draftId}/commands/prepare-publish | DraftInterface_preparePublish | MageMe_WebForms::api_v1_forms_edit |
| POST | /V1/webforms/drafts/{draftId}/commands/publish | A confirmation token is spent when the publish is accepted, also when the plan needed none; a publish refused before that leaves it usable. 409 CONFIRMATION_REQUIRED when the plan needs a token and none was sent; 409 CONFIRMATION_INVALID when the token sent is unknown, malformed, spent, of another draft, or no longer matches the plan: prepare again and ask again. Publishing needs Edit Form Scripts (MageMe_WebForms::api_v1_forms_scripts) when the draft brings in markup that runs code on the storefront, or changes markup that already runs, in a text of the form or an HTML field printed as it is, by the rules of the draft commands: without it the answer is 403 ACTOR_NOT_ALLOWED with details {key, store_id, parts} and nothing is published. Markup the draft leaves as it was does not stop it; switching on a field or section that holds such markup brings it in. | MageMe_WebForms::api_v1_forms_edit |
| GET | /V1/webforms/drafts/{draftId}/document | DraftInterface_getDocument | MageMe_WebForms::api_v1_forms_edit |
| GET | /V1/webforms/drafts/{draftId}/trash | DraftInterface_getTrash | MageMe_WebForms::api_v1_forms_edit |
| POST | /V1/webforms/drafts/{draftId}/validate | DraftInterface_validate | MageMe_WebForms::api_v1_forms_edit |
The draft is opened with POST /V1/webforms/forms/{formId}/draft, listed on REST: Forms.
Errors
| Code | HTTP | When |
|---|---|---|
VALIDATION_FAILED | 400 | expected_draft_revision is missing; a setting key or field type is unknown; a value does not fit its schema |
AMBIGUOUS_REF | 400 | A field code matches more than one field |
ACTOR_NOT_ALLOWED | 403 | A form script or markup that runs code without forms_scripts (details_json {key, store_id, parts[]} for markup). Without forms_edit Magento refuses the draft routes with 401 |
NOT_FOUND | 404 | No such draft (also after it was published or discarded), a form outside the integration's form scope, or an unknown command name |
DRAFT_REVISION_MISMATCH | 409 | expected_draft_revision is stale; details_json.current_revision has the current one |
LIVE_REVISION_MISMATCH | 409 | The live form changed since the draft was based on it |
CONFIRMATION_REQUIRED | 409 | Publish, remove-field or update-form needs a confirmation token; details_json describes the change |
CONFIRMATION_INVALID | 409 | The token belongs to another object or plan |
REQUEST_ID_REUSED | 409 | The request_id was already used with a different request |
LICENSE_NOT_COVERED | 403 | The store's WebForms license does not cover this version; draft writes are refused |
Examples
<signed-header> stands for the OAuth 1.0a header computed for each request. The first examples are one sequence on form 995542.
Open a draft (POST /V1/webforms/forms/995542/draft):
curl -X POST https://yourdomain.com/rest/all/V1/webforms/forms/995542/draft \
-H "Authorization: <signed-header>" -H "Content-Type: application/json" \
-d '{"request": {"request_id": "erp-open-0001"}}'
{"draft_id": 995543, "live_id": 995542, "draft_revision": 0, "live_revision": 4, "started_by_type": "integration", "started_by_id": 5, "started_by_name": "ERP sync"}
Add a Phone field after the Email field (POST /V1/webforms/drafts/995543/commands/add-field):
{"request": {"request_id": "erp-cmd-0001", "expected_draft_revision": 0, "type": "phone_number", "name": "Phone", "code": "phone", "after_field_ref": "email"}}
{"draft_id": 995543, "draft_revision": 1, "changed": true, "payload_json": "{\"field_id\":99192196,\"code\":\"phone\",\"type\":\"phone_number\"}"}
Another add-field command, with a new request_id, that still sends revision 0:
{"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}"}}
Make a field required and give it a comment (POST /V1/webforms/drafts/995543/commands/update-field); the answer has draft_revision: 2:
{"request": {"request_id": "erp-cmd-0002", "expected_draft_revision": 1, "field_ref": "items", "settings_json": "{\"comment\":\"List the pieces and their order numbers, if you have them.\",\"is_required\":\"1\"}"}}
Change the submit button text (POST /V1/webforms/drafts/995543/commands/update-form); the answer has draft_revision: 3 and "live_updated": []:
{"request": {"request_id": "erp-cmd-0003", "expected_draft_revision": 2, "settings_json": "{\"submit_button_text\":\"Request assembly\"}"}}
Validate (POST /V1/webforms/drafts/995543/validate, no body):
curl -X POST https://yourdomain.com/rest/all/V1/webforms/drafts/995543/validate \
-H "Authorization: <signed-header>"
{"errors_json": "[]", "warnings_json": "[]", "impact_json": "[]", "requires_confirmation": false, "plan_digest": "sha256:4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945"}
Publish (POST /V1/webforms/drafts/995543/commands/publish). No confirmation is needed, so the token is left out:
{"request": {"request_id": "erp-publish-0001", "expected_draft_revision": 3, "expected_live_revision": 4}}
{"id": 995542, "code": "assembly_request", "name": "Assembly Service Request", "revision": 8, "is_active": false, "has_draft": false, "draft_started_by_type": "", "draft_started_by_name": "", "updated_at": "2026-10-05T20:18:53Z", "warnings": []}
A separate, later draft of the same form (995552) shows a draft setting and a live setting in one update-form. meta_title is written to the live form at once; submit_button_text waits for the publish:
{"request": {"request_id": "erp-cmd-0101", "expected_draft_revision": 0, "settings_json": "{\"meta_title\":\"Furniture assembly service\",\"submit_button_text\":\"Request assembly\"}"}}
{"draft_id": 995552, "draft_revision": 1, "changed": true, "payload_json": "{\"updated\":[\"meta_title\",\"submit_button_text\"],\"reset\":[],\"live_updated\":[\"meta_title\"]}"}
An impact item from a draft that removes a field nobody has answered yet. It is a warning, so no confirmation is needed:
[{"kind": "field_delete", "severity": "warning", "subject": {"entity": "field", "id": 99192210, "code": "phone", "name": "Phone", "type": "phone_number"}, "detail": {"results": 0, "answers": 0, "files": 0}}]