---
title: "Upload a reusable attachment"
method: POST
path: "/attachments"
tags: ["Attachments"]
---

# Upload a reusable attachment

`POST /attachments`

## Request

- Base URL: `https://sending.dev/api/v1`
- URL: `https://sending.dev/api/v1/attachments`
- Auth: HTTP bearer

Two modes: with `content` (base64) the file is uploaded immediately and the attachment is born ready; with `size` the response carries a signed `uploadUrl` to PUT the file to (mandatory beyond the few MB accepted in the body). Executable extensions and files over 10 MB are rejected. Required scope: `email:send` or `inbox:send`. An attachment uploaded once is reused across sends: pass `attachments: [{ id }]` to `/emails`, `/messages`, `/campaigns` or `/inboxes/{id}/send`.

## Request body

- CreateAttachmentInput
  - `filename` string, required: File name shown to the recipient.
  - `contentType` string: When absent, it is inferred from the file name.
  - `size` integer: File size in bytes: required in signed upload mode (without `content`).
  - `content` string: Base64 content for an immediate upload, without the `data:` prefix.

## Response `201`

Attachment created: `attachment` alone with `content`, `attachment` + `uploadUrl` with `size`.

- AttachmentUpload
  - `attachment` Attachment, required
    - `id` string, uuid, required
    - `filename` string, required
    - `contentType` string, required
    - `size` integer, required: File size in bytes.
    - `status` 'pending' | 'ready', required: `pending` until the signed upload is confirmed.
    - `createdAt` string, date-time, required
  - `uploadUrl` string, required: Signed URL to PUT the file to, with the same declared Content-Type and Content-Length.
  - `expiresIn` integer, required: Validity of the uploadUrl, in seconds.

## Other responses

- `401`: Missing or invalid token.
- `403`: Insufficient scope.
- `422`: Invalid input.

---

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