> ## Documentation Index
> Fetch the complete documentation index at: https://help.maestra.io/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Send a Campaign with an Attachment

You can send an email campaign with a file attached by calling an API operation.

Here's how it works:

1. You upload the file to the server, which returns a unique identifier for it.
2. You send the campaign through an operation, passing that identifier in the call. The file is attached to the email.

Here's a closer look at each step.

## 1. Upload the attachment to the server

The upload uses the [standard file upload method](https://developers.maestra.io/docs/upload-attachments-for-emails). This section walks through doing it yourself in Postman.

<Steps>
  <Step title="Prepare the request">
    Select the **POST** method, then build the request URL for your account.

    The general form of the URL:

    ```
    https://api.maestra.io/v3/files/upload?endpointId={integration point system name}&fileKind=attachment
    ```

    One part needs editing: after the `=` sign in `endpointId`, put the system name of the integration point the operation will be called through.

    You can use any integration point from the **Integrations** section. The system name is in the **Endpoint** column.

    <img src="https://mintcdn.com/maestraio/N_YmMwr2qxjuyUwl/images/campaign-with-attachment/endpoint-system-name.png?fit=max&auto=format&n=N_YmMwr2qxjuyUwl&q=85&s=8e303b0648cf5034844bb9f1cd07a499" alt="" width="2916" height="738" data-path="images/campaign-with-attachment/endpoint-system-name.png" />

    A finished URL looks like this:

    ```
    https://api.maestra.io/v3/files/upload?endpointId=demo.Website&fileKind=attachment
    ```
  </Step>

  <Step title="Add the headers">
    Copy the headers below into the **Headers** tab. This operation requires a secret key — replace `{Secret key}` with the secret key of the integration point you specified in `endpointId`.

    ```
    Accept: application/json
    Content-Type: multipart/form-data
    Authorization: SecretKey {Secret key}
    ```

    <img src="https://mintcdn.com/maestraio/N_YmMwr2qxjuyUwl/images/campaign-with-attachment/postman-headers.png?fit=max&auto=format&n=N_YmMwr2qxjuyUwl&q=85&s=70ec269eeec2f3d4dabf4a6052360e98" alt="" width="1668" height="716" data-path="images/campaign-with-attachment/postman-headers.png" />
  </Step>

  <Step title="Attach the file to the request">
    Go to the **Body** tab and select **form-data**.

    <img src="https://mintcdn.com/maestraio/N_YmMwr2qxjuyUwl/images/campaign-with-attachment/postman-body-form-data.png?fit=max&auto=format&n=N_YmMwr2qxjuyUwl&q=85&s=2d9d84c4b6b472e73bcd41c33f2de150" alt="" width="1656" height="718" data-path="images/campaign-with-attachment/postman-body-form-data.png" />

    Choose **File** in the **Key** field, then click **Select files** in the **Value** field. In the file picker, select the file you want to attach to the campaign.

    <img src="https://mintcdn.com/maestraio/N_YmMwr2qxjuyUwl/images/campaign-with-attachment/postman-select-file.png?fit=max&auto=format&n=N_YmMwr2qxjuyUwl&q=85&s=571e195bd2ded7ab70fe8131df19a9a2" alt="" width="1662" height="702" data-path="images/campaign-with-attachment/postman-select-file.png" />
  </Step>

  <Step title="Send the request">
    Click **Send** and copy the `fileId` value from the response.

    <img src="https://mintcdn.com/maestraio/N_YmMwr2qxjuyUwl/images/campaign-with-attachment/postman-file-id.png?fit=max&auto=format&n=N_YmMwr2qxjuyUwl&q=85&s=06be5b7dc8254a1ed285b7e188a83732" alt="" width="1668" height="1050" data-path="images/campaign-with-attachment/postman-file-id.png" />
  </Step>
</Steps>

## 2. Create an automated email campaign

Follow the steps in [How to Create Automated Email Campaign](/campaigns/email-campaigns/how-to-create-automated-email-campaign).

## 3. Add an operation with a step that sends the campaign

Create the operation as described in [API v3 Methods: Basics](/api-integrations/api-v3-methods-basics).

Example of an operation:

<img src="https://mintcdn.com/maestraio/N_YmMwr2qxjuyUwl/images/campaign-with-attachment/operation-setup-example.png?fit=max&auto=format&n=N_YmMwr2qxjuyUwl&q=85&s=d59b059d46d1656d4d15de9165041f15" alt="" width="2928" height="1520" data-path="images/campaign-with-attachment/operation-setup-example.png" />

### Build the call

Open the operation description. When an operation uses the **Send Email** step, its request specification gains a contract for attaching a file:

* `fileId` — the file identifier you got in step 1.
* `fileName` — the name the file will have in the sent email.

Both fields are required to send an attachment.

<img src="https://mintcdn.com/maestraio/N_YmMwr2qxjuyUwl/images/campaign-with-attachment/request-spec-attachments.png?fit=max&auto=format&n=N_YmMwr2qxjuyUwl&q=85&s=a13138d66b27acd563d60716fe1a5281" alt="" width="1576" height="844" data-path="images/campaign-with-attachment/request-spec-attachments.png" />

Example request body:

```json theme={null}
{
  "customer": {
    "email": "test@example.com"
  },
  "emailMailing": {
    "attachments": [
      {
        "fileName": "Invoice",
        "body": {
          "fileId": "4d238d4e-20a8-4a44-9388-b16bf206978a"
        }
      }
    ]
  }
}
```

## FAQ

<AccordionGroup>
  <Accordion title="Which files can I attach?">
    These formats are supported:

    ```
    application/msword
    application/pdf
    application/rtf
    application/vnd.ms-excel
    application/vnd.ms-powerpoint
    application/vnd.oasis.opendocument.graphics
    application/vnd.oasis.opendocument.presentation
    application/vnd.oasis.opendocument.spreadsheet
    application/vnd.oasis.opendocument.text
    application/vnd.openxmlformats-officedocument.presentationml.presentation
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    application/vnd.openxmlformats-officedocument.wordprocessingml.document
    application/x-7z-compressed
    application/x-rar-compressed
    application/zip
    image/gif
    image/jpeg
    image/pjpeg
    image/png
    image/svg+xml
    image/tiff
    image/vnd.microsoft.icon
    text/calendar
    text/html
    text/plain
    video/mp4
    video/mpeg
    ```
  </Accordion>

  <Accordion title="Is there a file size limit?">
    The maximum size of an email including all its attachments is 25 MB.
  </Accordion>

  <Accordion title="Is there a limit on the number of files?">
    No. You can attach any number of files.
  </Accordion>

  <Accordion title="How do I view attachments in sent emails?">
    You can't view attachments from the account interface. To check one, forward the email to yourself from the customer profile.

    <img src="https://mintcdn.com/maestraio/N_YmMwr2qxjuyUwl/images/campaign-with-attachment/forward-message.png?fit=max&auto=format&n=N_YmMwr2qxjuyUwl&q=85&s=940d6a1d12e51b7191ba4c2dca296ce4" alt="" width="2744" height="702" data-path="images/campaign-with-attachment/forward-message.png" />

    <Note>
      Forwarding a campaign with an attachment requires the `Forwarding email attachments` permission. Out of the box only the **Owners** group has it, and it [can be granted to others](/administration/staff/how-to-extend-staff-permissions). If a user doesn't have it, the email is forwarded without the attachment.
    </Note>
  </Accordion>
</AccordionGroup>
