Upload an image for a mailing
On this page
POST
/v1/imagesupload_mailing_image| 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:
curl -X POST 'https://api.seemly.com/v1/images' \
-H "Authorization: Bearer $SEEMLY_API_KEY" \
-H "Content-Type: application/octet-stream" \
--data-binary @fileconst response = await fetch("https://api.seemly.com/v1/images", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SEEMLY_API_KEY}`,
"Content-Type": "application/octet-stream",
},
body: await readFile("file"), // import { readFile } from "node:fs/promises"
});
const result = await response.json();
console.log(response.status, result);import os
import requests
response = requests.post(
"https://api.seemly.com/v1/images",
headers={
"Authorization": f"Bearer {os.environ['SEEMLY_API_KEY']}",
"Content-Type": "application/octet-stream",
},
data=open("file", "rb"),
)
print(response.status_code, response.json())Response: 201:
{
"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#
Every error is an application/problem+json body with a code, a fix sentence and next_actions. See reading a problem response.