Skip to main content

REST: Upload (3.x)

Overview​

POST /V1/webforms/upload/{id} is the file upload of the REST API that WebForms 3 had, kept unchanged in WebForms 4. {id} is the id of a file field, not of a form. The route stores the file as a temporary upload and returns a hash; you then send that hash as the field's value with REST: Form (3.x), which attaches the file to the new submission.

The path is relative to https://yourdomain.com/rest/all. A store view code works in place of all; the file is then checked against that store view's settings of the field.

The field must take uploads:

  • the field is a file field with drop zone switched on;
  • the field, its section and its form are switched on in the store view;
  • the file passes the field's checks: allowed extensions (one per line in the field's settings), maximum size, and the store's block on potentially dangerous files.

Authentication​

Any Magento web API credentials whose role holds Submit Forms and Upload Files (WebForms → API): an integration signed with OAuth 1.0a, or an admin token. Without it Magento answers 401. The route does not check the caller's form access.

Operations​

Method Path Operation ACL resource
POST /V1/webforms/upload/{id} DropzoneApiUploaderInterface_upload MageMe_WebForms::api_submission

Sending the file​

Send the file in one of two ways.

Multipart form post (recommended). The file goes in a part named after the field id, with its file name. The route takes the file name, declared type and size from that part; the file is then checked like any upload.

Query parameters, for clients that cannot send multipart. The file then travels in the address, which web servers limit in length and often write to their access logs, so keep this for small files without sensitive content. The route reads these parameters from the query string, not from a JSON body: parameters in a JSON body are ignored and the request fails with Filename is required.

Parameter Required Meaning
filename yes File name with extension, checked against the field's allowed extensions
content yes Either a data URI, data:<mime-type>;base64,<base64 data>, which is decoded (use this for any binary file), or plain text, which is stored as the file's content as it is
mime_type yes MIME type of the file. Required even when the data URI names one

The answer​

Status 200 and a JSON array of three values: success, error messages, hash.

[true, [], "Ze29blmSgRzsu6xEYDXZeqrczw8Z4HY9vYUCScn9"]

A file that fails a check is also a 200, with false and the reasons:

[false, ["Uploaded file floor-plan.exe has none of allowed extensions: pdf, png, jpg, txt", "Uploading of potentially dangerous files is not allowed."], ""]

Errors​

HTTP When
200 with false The field does not exist or takes no uploads (Unable to find field with ID "%1", Dropzone disabled on this field.), the form is switched off (Web-form is not active.), or the file fails the field's checks
400 filename, content or mime_type missing (Filename is required., Content is required., MIME type not found.). Magento's error shape, without parameters.code
401 No credentials, or the caller lacks Submit Forms and Upload Files

Examples​

Upload a PDF to file field 99193225 as a multipart form post:

curl -X POST https://yourdomain.com/rest/all/V1/webforms/upload/99193225 \
-H "Authorization: Bearer <admin-token>" \
-F "99193225=@floor-plan.pdf;type=application/pdf"
[true, [], "AwMM3i0xJpYnri20LTLymRQ1IRf0Qs4WO5lea0UD"]

The same file as a data URI in the query string:

B64=$(base64 < floor-plan.pdf | tr -d '\n')
curl -X POST -G https://yourdomain.com/rest/all/V1/webforms/upload/99193225 \
-H "Authorization: Bearer <admin-token>" \
--data-urlencode "filename=floor-plan.pdf" \
--data-urlencode "mime_type=application/pdf" \
--data-urlencode "content=data:application/pdf;base64,$B64"

-G puts the values into the query string while -X POST keeps the method.

Then submit the form with the hash as the field's value:

curl -X POST https://yourdomain.com/rest/all/V1/webforms/form/995656/submit \
-H "Authorization: Bearer <admin-token>" \
-H "Content-Type: application/json" \
-d '{"field": {"99193222": "Lena Hartmann", "99193223": "lena.hartmann@example.com", "99193225": "AwMM3i0xJpYnri20LTLymRQ1IRf0Qs4WO5lea0UD"}}'

Applies to WebForms 4Last reviewed November 24, 2026