# upload_mailing_image

Upload an image for a mailing

`POST /v1/images`

| | |
| --- | --- |
| Risk | write |
| Authentication | API key or OAuth access token |
| Scopes | `mailings:write` |
| Idempotency | supported: send an Idempotency-Key header to make retries safe |
| Dry run | not applicable |
| Success status | 201 |
| Response type | application/json |

## What it does

- Use when: A mailing needs an image you hold as a file (a cover, a photo); send the bytes and use the returned url as the image src.
- Do not use when: the image already has a public https address (use that address directly).
- Side effects: Stores the image in your workspace's image storage.
- Reversible: No.
- Required scope: mailings:write.
- Idempotency: supported (Idempotency-Key header).
- Typical next step: use the url in an image or book section of create_mailing_draft.

## Scopes

- `mailings:write`: Create, edit and delete draft mailings, and ask for a send to be approved.

## Side effects

- Stores the image in your workspace's image storage

## Request

### Path parameters

None.

### Query parameters

None.

### Body (application/octet-stream)

The raw file bytes, up to 5120 KiB.

## Response

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `url` | string | yes | The public address to use as an image src in a mailing. Stable and immutable. |
| `key` | string | yes |  |
| `content_type` | one of "image/png", "image/jpeg", "image/webp" | yes | Detected from the file's bytes, never from the header you sent. |
| `bytes` | integer, min -9007199254740991, max 9007199254740991 | yes |  |
| `width` | integer, min -9007199254740991, max 9007199254740991 | yes |  |
| `height` | integer, min -9007199254740991, max 9007199254740991 | yes |  |

## Examples

### uploaded

Request:

```bash
curl -X POST 'https://api.seemly.com/v1/images' \
  -H "Authorization: Bearer $SEEMLY_API_KEY" \
  -H "Content-Type: application/octet-stream" \
  --data-binary @file
```

Response: `201`:

```json
{
  "url": "https://seemly.com/email-img/ws_9f3k2m8a1b/0123456789abcdef0123456789abcdef.png",
  "key": "ws_9f3k2m8a1b/0123456789abcdef0123456789abcdef.png",
  "content_type": "image/png",
  "bytes": 20480,
  "width": 600,
  "height": 400
}
```

## Errors

| Status | Codes |
| --- | --- |
| 400 | [`validation_failed`](/developers/md/errors/validation_failed) |
| 401 | [`unauthenticated`](/developers/md/errors/unauthenticated), [`credential_revoked`](/developers/md/errors/credential_revoked), [`credential_expired`](/developers/md/errors/credential_expired) |
| 403 | [`insufficient_scope`](/developers/md/errors/insufficient_scope), [`plan_does_not_include`](/developers/md/errors/plan_does_not_include), [`workspace_paused`](/developers/md/errors/workspace_paused), [`api_suspended`](/developers/md/errors/api_suspended), [`consent_required`](/developers/md/errors/consent_required) |
| 409 | [`conflict`](/developers/md/errors/conflict), [`idempotency_key_reused`](/developers/md/errors/idempotency_key_reused), [`request_in_progress`](/developers/md/errors/request_in_progress) |
| 413 | [`payload_too_large`](/developers/md/errors/payload_too_large) |
| 415 | [`unsupported_media_type`](/developers/md/errors/unsupported_media_type) |
| 429 | [`rate_limited`](/developers/md/errors/rate_limited), [`quota_exceeded`](/developers/md/errors/quota_exceeded) |
| 503 | [`service_unavailable`](/developers/md/errors/service_unavailable) |

Every error is an `application/problem+json` body with a `code`, a `fix` sentence and `next_actions`. See [reading a problem response](/developers/md/guides/agents#reading-a-problem-response).

## Typical next steps

- [`create_mailing_draft`](/developers/md/operations/create_mailing_draft)
- [`render_design`](/developers/md/operations/render_design)

## Related

- [OpenAPI document](https://api.seemly.com/v1/openapi.json)
- [Agent guide](/developers/md/guides/agents)
