> For the complete documentation index, see [llms.txt](https://developers.make.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.make.com/custom-apps-documentation/component-blocks/api/multipart-form-data.md).

# Multipart/form-data

A form-data type that works with body payload or file upload

## Upload a file

A module that uploads a file to the service works with data type `buffer` in mappable parameters and type `multipart/form-data` in communication.

{% tabs %}
{% tab title="Occurrence in a Module" %}

<div align="left"><figure><img src="https://1562974717-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNS0mCBwODiYtOVXjc6qf%2Fuploads%2Fgit-blob-b610dc11bc01083c7a8cc17fd5142cc8ba7fa344%2Fuploadfile.png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

{% hint style="info" %}
The file input dialog is where the user can either choose the module that has a file available or manually map the file's name and data on their own.

This works only if the `buffer` is correctly implemented in [interface](#download-a-file) in preceding modules.
{% endhint %}
{% endtab %}

{% tab title="Mappable Parameters" %}

```json
[
	{
		"name": "file_name",
		"type": "text",
		"label": "Name",
		"required": true,
		"semantic": "file:name"
	},
	{
		"name": "file_data",
		"type": "buffer",
		"label": "Data",
		"required": true,
		"semantic": "file:data"
	}
]
```

{% endtab %}

{% tab title="Communication" %}

```json
{
    "url": "http://example.com",
    "body": {
        "file": {
            "value": "{{parameters.file_data}}",
            "options": {
                "filename": "{{parameters.file_name}}"
            }
        }
    },
    "type": "multipart/form-data",
    "method": "POST"
}
```

{% hint style="info" %}
The type of the request is `multipart/form-data`.
{% endhint %}
{% endtab %}
{% endtabs %}

## Preserve the order of fields

When `body` is an object, the order of its fields is not guaranteed, and each key can appear only once. If the API needs the fields in a specific order, or needs the same field name more than once, specify `body` as an array of `{ "name", "value" }` items instead.

The array syntax:

* sends the items in the order they are listed
* allows repeated names, also with other fields between them (for example `a`, `b`, `a`)

{% hint style="warning" %}
The array syntax is supported only when `type` is `multipart/form-data`.
{% endhint %}

{% tabs %}
{% tab title="Array (order preserved)" %}

```json
{
    "url": "http://example.com",
    "method": "POST",
    "type": "multipart/form-data",
    "body": [
        { "name": "b", "value": "Hello" },
        { "name": "a", "value": "Hello" }
    ]
}
```

{% endtab %}

{% tab title="Object (order not guaranteed)" %}

```json
{
    "url": "http://example.com",
    "method": "POST",
    "type": "multipart/form-data",
    "body": {
        "b": "Hello",
        "a": "Hello"
    }
}
```

{% endtab %}
{% endtabs %}

### Upload files with the array syntax

The `value` of a file item is either the buffer itself or an object with the buffer in `value` and optional `options`. `options` is either a filename string or an object with `filename` and/or `contentType`.

{% tabs %}
{% tab title="Buffer only" %}

```json
"body": [
    { "name": "file", "value": "{{parameters.file_data}}" }
]
```

This is the same as wrapping the buffer without options:

```json
"body": [
    {
        "name": "file",
        "value": {
            "value": "{{parameters.file_data}}"
        }
    }
]
```

{% endtab %}

{% tab title="Filename" %}

```json
"body": [
    {
        "name": "file",
        "value": {
            "value": "{{parameters.file_data}}",
            "options": {
                "filename": "{{parameters.file_name}}"
            }
        }
    }
]
```

Shorthand: when you only need the filename, `options` can be the filename string:

```json
"body": [
    {
        "name": "file",
        "value": {
            "value": "{{parameters.file_data}}",
            "options": "{{parameters.file_name}}"
        }
    }
]
```

{% endtab %}

{% tab title="Content type" %}

```json
"body": [
    {
        "name": "file",
        "value": {
            "value": "{{parameters.file_data}}",
            "options": {
                "contentType": "application/pdf"
            }
        }
    }
]
```

{% endtab %}

{% tab title="Filename and content type" %}

```json
"body": [
    {
        "name": "file",
        "value": {
            "value": "{{parameters.file_data}}",
            "options": {
                "filename": "{{parameters.file_name}}",
                "contentType": "application/pdf"
            }
        }
    }
]
```

{% endtab %}
{% endtabs %}

### Send multiple files under one name

To send several files under the same field name, either set `value` to an array of files:

```json
"body": [
    {
        "name": "file",
        "value": [
            { "value": "{{parameters.data1}}", "options": "first.pdf" },
            { "value": "{{parameters.data2}}", "options": "second.pdf" }
        ]
    }
]
```

Or repeat the item. This also lets you put other fields between the files:

```json
"body": [
    {
        "name": "file",
        "value": {
            "value": "{{parameters.data1}}",
            "options": "first.pdf"
        }
    },
    { "name": "description", "value": "Supporting documents" },
    {
        "name": "file",
        "value": {
            "value": "{{parameters.data2}}",
            "options": "second.pdf"
        }
    }
]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.make.com/custom-apps-documentation/component-blocks/api/multipart-form-data.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
