REST: Imports
Overview
The imports resource brings past submissions from another system into a form. The file travels in pieces, WebForms
checks every line before anything is written, and the writing itself runs in Magento's scheduled tasks (cron). The
answers never contain the rows themselves: you get counts and reason codes, and refused rows go into a report that a
person downloads. For the store owner's side of an import, including which emails to switch off first, see
Import submissions.
An import goes through these calls:
POST /V1/webforms/importsopens an import for a form. Statestaging.POST /V1/webforms/imports/{importId}/chunkuploads the file, in one piece or several.POST /V1/webforms/imports/{importId}/commands/finalizecloses the upload and checks every line at once, writing nothing. Statevalidated, orinvalidwhen every line is refused.POST /V1/webforms/imports/{importId}/commands/commitqueues the writing. Statequeued.GET /V1/webforms/imports/{importId}until the state isdoneorpartial.
The file
The file is in JSON Lines format, UTF-8, one submission per line. Each line is an object with source_system and
source_key (where the submission comes from and its id there), created_at (ISO 8601 with a time zone, such as
2026-03-12T09:41:00+01:00, at most one day ahead), store_code, values (answers under the field codes, or field
ids, of the form) and, optionally, submitter_email. The full format and every refusal reason are on
Import row schema.
Limits: a chunk of at most 1,572,864 bytes after base64 decoding, a file of at most 67,108,864 bytes and 50,000 lines, a line of at most 262,144 bytes and a single answer of at most 65,536 bytes.
Import summary
Every call except report-grant answers with the import's summary:
| Member | Meaning |
|---|---|
id | Import id |
form_id | The form the submissions go into |
source_system | As sent on create |
state | See the states below |
row_count | Lines in the file, counted by finalize |
committed_count | Submissions written |
skipped_count | Lines left out because their source_system and source_key were already imported into the form |
rejected_count | Lines refused |
reasons_json | Refusal reasons with the number of lines for each, counted over the whole file, for example {"FIELD_UNKNOWN":1} |
error_code | Why a job stopped: FORM_CHANGED, FORM_NOT_FOUND, LEASE_EXPIRED, INTERNAL or CANCELLED. Left out when there is none |
warnings | Notes about the import that don't stop it. A form with Terms fields gets one: their values are never imported |
has_report | Whether a refusal report exists |
States
| State | Meaning | What you can do |
|---|---|---|
staging | Waiting for the file | chunk, finalize, cancel |
staged, validating | The file is closed and is being checked, by finalize or by cron | cancel |
validated | Checked; nothing written yet | commit, cancel |
invalid | Every line was refused, or the check failed. Finished | report-grant |
queued | Committed; waiting for cron | cancel |
committing | Being written | cancel |
done | Every line was written or skipped. Finished | report-grant when has_report |
partial | Some lines were refused, or the writing stopped (error_code says why) | With refused lines only: report-grant, then cancel to free the form. Stopped with LEASE_EXPIRED or INTERNAL: cron resumes it, at most 3 times. Stopped with FORM_CHANGED: commit again. Stopped with CANCELLED: commit again or cancel |
failed | The writing stopped and cron resumed it 3 times without finishing | commit again, or cancel to free the form |
cancelling | A running job was asked to stop | wait |
cancelled | Stopped. Finished | — |
A form takes one open import at a time, and an integration can have two open imports across all forms. Every state
except invalid, done and cancelled counts as open, partial included: a job that ended with refused lines
holds its form until you cancel it.
Committing and resuming
commit only queues the job; cron writes it. On the next run the lines are written in file order, each line in its
own transaction. A line whose source_system and source_key the form already has from an earlier import is
skipped. Calling commit again on a job that stopped (error_code set) resumes it: lines already written are not
written twice. A job that stopped with LEASE_EXPIRED (its worker died) or INTERNAL is resumed by cron without a
new commit, at most 3 times; after that it ends invalid when it stopped while being checked, or failed when it
stopped while being written. CANCELLED means the job was cancelled while being written and its worker died before
it stopped: what was written stays, and the job is never resumed on its own, so commit it again or cancel it. A
job that is partial only because lines were refused stays partial when committed again; cancel it.
An import never reads the values of a Terms field: a Terms column in the file doesn't stop the import, and
the lines are imported without a record of consent. The imported submissions read No Acceptance Record, and the
summary's warnings says so.
The check in finalize is tied to the form as it was then. If the form's fields have changed when the writing
starts, the job goes back to staged with error_code FORM_CHANGED; cron checks it again against the current
form, and you commit it again once it is validated. A change during the writing stops the job as partial with
the same code.
Each imported submission keeps the date from created_at (stored in UTC), is marked read, and is linked to no
customer account. It gets the form's default status when the form uses statuses, is approved (or pending when the
form uses approval), and gets a reference number when the form uses reference numbers, like any new submission. No
default assignee is set and no customer account is created from it.
Cancelling
cancel stops a job that hasn't been written yet at once (state cancelled). A job being checked or written stops
between two lines (state cancelling, then cancelled, or partial if lines were already written). Written
submissions stay. Cancelling a finished job is refused with 409 CONFLICT. cancel is not replayed by
request_id; a second cancel of a stopping job answers with its summary.
The refusal report
POST /V1/webforms/imports/{importId}/report-grant returns url and expires_at: a one-time link to the refusal
report, valid for 60 seconds. Fetch it with a plain GET, without the OAuth header: the token in the link is the
authorization, and the first download uses it up. The report is a JSON Lines file with one object per refused line, line, codes and
row (the line as uploaded), for the first 1,000 refused lines. It holds your customers' answers, so hand the link
to a person rather than storing the file.
The uploaded file and the report are kept for 24 hours after finalize (after create, when the file never
arrives). Then both are deleted: an import that wasn't finished is cancelled, a finished one keeps its state and
counts, report-grant answers 404, and a partial import can no longer be resumed; cancel it to free the form. The link comes back with the store view of the request path: on a store
that adds store codes to its URLs, request it through a store view path such as /rest/default/V1/..., because a
link issued through /rest/all doesn't serve the file.
Authentication
OAuth 1.0a integration credentials, as described on REST API. Every
import route needs results_import. An integration sees only its own imports, and only on forms in its form
scope; any other import id answers 404.
Operations
| Method | Path | Operation | ACL resource |
|---|---|---|---|
| POST | /V1/webforms/imports | ImportInterface_create | MageMe_WebForms::api_v1_results_import |
| GET | /V1/webforms/imports/{importId} | ImportInterface_get | MageMe_WebForms::api_v1_results_import |
| POST | /V1/webforms/imports/{importId}/chunk | ImportInterface_upload | MageMe_WebForms::api_v1_results_import |
| POST | /V1/webforms/imports/{importId}/commands/cancel | ImportInterface_cancel | MageMe_WebForms::api_v1_results_import |
| POST | /V1/webforms/imports/{importId}/commands/commit | ImportInterface_commit | MageMe_WebForms::api_v1_results_import |
| POST | /V1/webforms/imports/{importId}/commands/finalize | ImportInterface_finalize | MageMe_WebForms::api_v1_results_import |
| POST | /V1/webforms/imports/{importId}/report-grant | ImportInterface_reportGrant | MageMe_WebForms::api_v1_results_import |
Request keys, besides request_id:
| Route | Keys |
|---|---|
| create | form_id; source_system (1 to 64 characters); schema_version, optional, 1.0 |
| chunk | chunk_base64: the next piece of the file. Pieces are appended in the order they arrive |
| finalize | artifact_digest (SHA-256 of the whole file, hex) and artifact_size (its size in bytes) |
| commit, cancel, report-grant | none |
Errors
| Code | HTTP | When |
|---|---|---|
VALIDATION_FAILED | 400 | No source_system, a schema_version other than 1.0, a chunk that is not base64, a digest that is not SHA-256 hex, nothing uploaded, or a file whose size or digest differs from the one declared |
VALIDATION_FAILED | 409 | chunk or finalize on an import that is no longer in staging |
LIMIT_EXCEEDED | 400 | A chunk or the whole file is too large |
CONFLICT | 409 | Another import is open for the form; commit in a state that can't be committed; cancel on a finished import. details_json.state names the state where there is one |
QUOTA_EXCEEDED | 429 | The integration already has two open imports |
NOT_FOUND | 404 | No such form or import, an import of another integration, a form outside the form scope, or report-grant on an import without a report |
LICENSE_NOT_COVERED | 403 | The store's WebForms license does not cover this version |
The refusals every route shares are listed on REST API.
Examples
The file appointments.jsonl, two lines:
{"source_system":"legacy-crm","source_key":"APT-1041","created_at":"2026-03-12T09:41:00+01:00","store_code":"default","submitter_email":"oskar.nilsson@example.com","values":{"full_name":"{\"first\":\"Oskar\",\"last\":\"Nilsson\"}","email":"oskar.nilsson@example.com","room":"bedroom","notes":"Wardrobe and bed for a loft bedroom."}}
{"source_system":"legacy-crm","source_key":"APT-1042","created_at":"2026-03-14T15:05:00+01:00","store_code":"default","submitter_email":"hanna.berg@example.com","values":{"full_name":"{\"first\":\"Hanna\",\"last\":\"Berg\"}","email":"hanna.berg@example.com","room":"living_room","notes":"Dining table for six and a sideboard."}}
Open the import:
curl -X POST https://yourdomain.com/rest/all/V1/webforms/imports \
-H "Authorization: <signed-header>" -H "Content-Type: application/json" \
-d '{"request": {"request_id": "erp-import-0001", "form_id": 995673, "source_system": "legacy-crm"}}'
<signed-header> stands for the OAuth 1.0a Authorization header computed for this request by your OAuth library.
{"id": 8, "form_id": 995673, "source_system": "legacy-crm", "state": "staging", "row_count": 0, "committed_count": 0, "skipped_count": 0, "rejected_count": 0, "reasons_json": "{}", "has_report": false}
Upload the file in one piece, then close and check it (base64 -w0, sha256sum and stat -c are the GNU/Linux
commands; on macOS use base64 -i, shasum -a 256 and stat -f%z):
curl -X POST https://yourdomain.com/rest/all/V1/webforms/imports/8/chunk \
-H "Authorization: <signed-header>" -H "Content-Type: application/json" \
-d "{\"request\": {\"request_id\": \"erp-import-0001-c1\", \"chunk_base64\": \"$(base64 -w0 appointments.jsonl)\"}}"
curl -X POST https://yourdomain.com/rest/all/V1/webforms/imports/8/commands/finalize \
-H "Authorization: <signed-header>" -H "Content-Type: application/json" \
-d "{\"request\": {\"request_id\": \"erp-import-0001-f\", \"artifact_digest\": \"$(sha256sum appointments.jsonl | cut -d' ' -f1)\", \"artifact_size\": $(stat -c%s appointments.jsonl)}}"
{"id": 8, "form_id": 995673, "source_system": "legacy-crm", "state": "validated", "row_count": 2, "committed_count": 0, "skipped_count": 0, "rejected_count": 0, "reasons_json": "{}", "has_report": false}
Commit, then read the import until it is finished:
curl -X POST https://yourdomain.com/rest/all/V1/webforms/imports/8/commands/commit \
-H "Authorization: <signed-header>" -H "Content-Type: application/json" \
-d '{"request": {"request_id": "erp-import-0001-commit"}}'
curl https://yourdomain.com/rest/all/V1/webforms/imports/8 \
-H "Authorization: <signed-header>"
{"id": 8, "form_id": 995673, "source_system": "legacy-crm", "state": "done", "row_count": 2, "committed_count": 2, "skipped_count": 0, "rejected_count": 0, "reasons_json": "{}", "has_report": false}
The same file imported again into the same form ends done with "committed_count": 0, "skipped_count": 2.
A file whose lines are all refused stops at finalize:
{"id": 9, "form_id": 995673, "source_system": "legacy-crm", "state": "invalid", "row_count": 2, "committed_count": 0, "skipped_count": 0, "rejected_count": 2, "reasons_json": "{\"FIELD_UNKNOWN\":1,\"CREATED_AT_NO_ZONE\":1,\"VALUE_NOT_AN_OPTION\":1}", "has_report": true}
One line of its refusal report:
{"line": 2, "codes": ["CREATED_AT_NO_ZONE", "VALUE_NOT_AN_OPTION"], "row": "{\"source_system\":\"legacy-crm\",\"source_key\":\"APT-1044\",\"created_at\":\"2026-03-16 11:00:00\",\"store_code\":\"default\",\"values\":{\"room\":\"kitchen\"}}"}
A second import while the first is still open on the form:
{"message": "Another import is already running for this form.", "parameters": {"code": "CONFLICT", "details_schema_version": "1", "details_json": "{}"}}