---
title: "Create email attachment"
method: POST
path: "/api/attachments"
tags: ["Email"]
---

# Create email attachment

`POST /api/attachments`

## Request

- Base URL: `https://go.urbanairship.com`
- URL: `https://go.urbanairship.com/api/attachments`
- Auth: one of:
  - HTTP basic
  - HTTP bearer
  - OAuth 2
    - Client credentials
    - Token URL: `http://oauth2.{domain}.com/token` scopes: `att`
- TypeScript: <https://skmtc.dev/airship/apis/airship-api/docs/api/attachments/post.ts> (a function with typed inputs; its response is checked against the schema)

Create attachments by `POST`ing to the attachments URI. The body of the request must be a JSON object describing and including the contents of a file to attach.

## Request body

- object
  - `content_type` string, required: The mimetype of the uploaded file including the charset parameter, if needed. Example: `"text/plain; charset=\"UTF-8\""`
  - `data` string, required: Base64-encoded bytes of the file contents representing a maximum of 2.5 MiB of data when decoded. Padding with `=` chars is optional.
  - `filename` string, required: The name of the uploaded file (max 255 UTF-8 bytes). Multiple files with the same name are allowed in separate requests.

## Response `201`

The email attachment was created. The response body will contain the IDs of the created attachments.

- object: The response body for an email attachment creation request.
  - `attachment_id` string[]: The attachment ID for a newly-created attachment. Reference this ID in the `attachments` list in the [Email overrides](/developer/rest-api/ua/schemas/platform-overrides/#emailoverrideobject).
  - `ok` boolean: Either `true` or `false`. Represents if the operation completed successfully or not. If false, other properties defined here will not necessarily be present.

## Other responses

- `400`: There was a parsing or validation error in the request. Bad Request errors typically include `path` and `location` in the response to help you find the cause of the error.
- `401`: Authentication information (the app key and secret or bearer token) was either incorrect or missing.
- `403`: The application does not have the proper entitlement to create attachments.

---

[API](https://skmtc.dev/airship/apis/airship-api.md) - [All operations](https://skmtc.dev/airship/apis/airship-api/llms.txt) - [OpenAPI document](https://skmtc.dev/airship/apis/airship-api/revisions/bd6ab947117a?raw)
