# Stage a binary attachment upload

Streams the request body (the file's raw bytes, NOT base64, NOT multipart) into staging storage and returns a `blobId` to reference from `/send`, `/compose` or `/reply` (the `blobId` form of an attachment). `Content-Length` is required and enforced against the per-message size ceiling. The staged blob expires at the result's `expiresAt`, or earlier when the uploader's oldest temporary blobs must be reclaimed for a new upload. Recorded send retries recover their durable message bytes.

## `POST /api/v1/mailboxes/{mailboxId}/uploads`

### Path parameters

- `mailboxId` (string, required) — Mailbox ULID identifier

### Header parameters

- `content-length` (string, required) — Exact size of the uploaded binary in bytes
- `content-type` (string) — MIME type of the uploaded file (default application/octet-stream)

### Request body (required)

`application/octet-stream`

Type: string <binary>

### Responses

**201** — Staged upload metadata

`application/json` → UploadResult

- `blobId` (string, required) — Opaque upload id (u_…); pass it as an attachment's blobId, or to JMAP as a blobId
- `expiresAt` (integer <int64>, required) — Epoch seconds after which the upload is treated as gone — reference it before then
- `size` (integer <int64>, required) — Stored byte length
- `type` (string, required) — The media type recorded for the blob (echoes the request Content-Type)

**400** — empty_body — request body was empty

`application/json` → ErrorOrValidation

**401** — unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a `WWW-Authenticate: Bearer` challenge

`application/json` → ErrorBody

**404** — Mailbox not found or not accessible to this principal

`application/json` → ErrorBody

**411** — length_required — Content-Length header is required

`application/json` → ErrorBody

**413** — too_large — file exceeds maximum message size; metadata_too_large — Content-Type exceeds metadata limit

`application/json` → ErrorBody

**429** — upload_busy — concurrent upload allowance is full

`application/json` → ErrorBody

**503** — upload_cleanup_pending — temporary storage reclamation must be retried. Or temporary_failure: the platform's storage could not answer just now; retry after the Retry-After window. Any operation can answer this. A write that got it may have been applied, so retry it with the same idempotency key where it takes one, or read the state back first (see Transient failures in the API description)

`application/json` → ErrorBody

**507** — store_full — owner storage is full and this uploader has no reclaimable space

`application/json` → ErrorBody

### Example request

```bash
curl -X POST 'https://api.open.email/api/v1/mailboxes/{mailboxId}/uploads' \
  -H 'Authorization: Bearer oek_…' \
  -H 'Content-Type: application/octet-stream'
```

## TypeScript SDK

[`openemail.uploads.create`](/docs/sdks/typescript/uploads/create)

```ts
const uploadResult = await openemail.uploads.create(mailboxId, data)
```
