Uploading Files
You can attach files to a request while you create it. Send the same POST /v2/forms/{formId}/requests call as a
multipart/form-data body instead of JSON, and the files are uploaded and stored alongside the prefilled answers in one step.
It is all-or-nothing: if any file fails, the whole request is rolled back and every file already uploaded is removed. You never end up with a half-created request.
This is the only way to put a value into a
FILEfield up front.FILEfields cannot be prefilled through the JSON body.
Upload files with a request
POST /v2/forms/{formId}/requests
Content-Type: multipart/form-dataThe body is a sequence of parts. The first part is
request and carries the same JSON body you would send for a fileless request. After it, send two parts per file, in this
order:
| Part | Type | Description |
|---|---|---|
file_info | JSON | Where the file goes and what it is (see below). |
| the file | binary | The file content. |
The file_info part
file_info part{
"formVersion": "1",
"sectionSlug": "documents",
"sectionInstanceIndex": 0,
"fieldName": "id_scan",
"fileName": "passport.pdf",
"size": 20481
}| Property | Type | Description |
|---|---|---|
formVersion | string | The form's active version. Must match, or the request is rejected. |
sectionSlug | string | The slug of the section the field lives in. |
sectionInstanceIndex | integer | Which instance of the section this file belongs to (0 for a normal section). |
fieldName | string | The FILE field to attach the file to. |
fileName | string | The original filename. |
size | integer | The file size in bytes. |
Rules
- At most 10 files per request.
- A
FILEfield accepts more than one file only if it is multi-entry. A normal file field takes a single file. - Filenames must be valid (max 255 characters, no path separators or OS-reserved names).
- 100 MB per file.
- If the
FILEfield is signable, the file must be a PDF. Whether a field is signable is set on the form, not in this request.
Example
Attaching an ID scan to a documents section:
POST /v2/forms/a1b2c3d4-e5f6-7890-abcd-ef1234567890/requests
Authorization: Bearer <your_api_token>
Content-Type: multipart/form-data; boundary=----boundary
------boundary
Content-Disposition: form-data; name="request"
Content-Type: application/json
{ "answers": { "personal": [ { "full_name": { "value": "Jane Smith", "editable": false } } ] } }
------boundary
Content-Disposition: form-data; name="file_info"
Content-Type: application/json
{ "formVersion": "1", "sectionSlug": "documents", "sectionInstanceIndex": 0, "fieldName": "id_scan", "fileName": "passport.pdf", "size": 20481 }
------boundary
Content-Disposition: form-data; name="file"; filename="passport.pdf"
Content-Type: application/pdf
<binary content>
------boundary--Response
Identical to a fileless request — you get back the requestId, submissionId, and
requestUrl. Retrieve the files later together with the other answers using the requestId (see Submissions).
Errors
| Status | When |
|---|---|
400 Bad Request | Wrong part order, unknown or non-file field target, wrong formVersion, more than one file on a non-multi-entry field, invalid filename, or more than 10 files. |
404 Not Found | The form doesn't exist or isn't ACTIVE. |
Updated 15 days ago
