Unitpost Library images API
The images your templates embed. Upload from a URL, as base64, or as a file (`file_id`); a template takes an image's `path` (`/img/…`). A delete is refused while something uses the image, unless you force it.
The images your templates embed. Upload from a URL, as base64, or as a file (`file_id`); a template takes an image's `path` (`/img/…`). A delete is refused while something uses the image, unless you force it.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/unitpost-com:unitpost-com-library-images-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Unitpost Library images API
version: v1
description: 'Public, versioned API for sending email and SMS and managing contacts, segments, campaigns, templates, domains, and webhooks. SMS is included on paid plans; on the free plan `POST /sms` returns `403` with `limit_reached`. Authenticate every request with an API key: `Authorization: Bearer `. A `User-Agent` header is required. Requests are scoped to the workspace that owns the key and are rate-limited per workspace. List endpoints are cursor-paginated via `limit`/`after`/`before` and return a `{ object: "list", has_more, data }` envelope. Register webhook endpoints to receive events: each create returns a `signing_secret` (`whsec_…`) exactly once. Every delivery is **svix-compatible**: it carries `svix-id`, `svix-timestamp`, and `svix-signature` (`v1,`) headers computed over `..` with your secret — verify them and reject deliveries whose signature doesn''t match (any Svix-compatible library works). Inbound email that lands on a receiving-enabled domain is readable under `/email/received`.'
servers:
- url: https://www.unitpost.com/api/v1
description: Base URL
security:
- apiKey: []
tags:
- name: Library images
description: The images your templates embed. Upload from a URL, as base64, or as a file (`file_id`); a template takes an image's `path` (`/img/…`). A delete is refused while something uses the image, unless you force it.
paths:
/library-images:
get:
operationId: library_images_list
tags:
- Library images
summary: List images
description: 'The workspace''s image library, newest first: the images a template embeds. Each image''s `path` (`/img/…`) is what a template''s `` (or ``) takes; `url` is its public address. Requires the `templates:read` capability.'
parameters:
- name: limit
in: query
required: false
description: Max rows to return (default 20, max 100).
schema:
type: integer
minimum: 1
maximum: 100
- name: after
in: query
required: false
description: Return rows after this id (forward paging).
schema:
type: string
- name: before
in: query
required: false
description: Return rows before this id (backward paging).
schema:
type: string
responses:
'200':
description: A page of images.
content:
application/json:
schema:
type: object
properties:
object:
type: string
enum:
- list
has_more:
type: boolean
data:
type: array
items:
$ref: '#/components/schemas/LibraryImage'
required:
- object
- has_more
- data
'401':
description: Missing or invalid API key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Insufficient scope.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Invalid pagination params, or an unknown query key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
operationId: library_images_create
tags:
- Library images
summary: Upload an image
description: 'Add an image to the library from a public https `url` (fetched once, no redirects, no private addresses), base64 `data` with its `content_type`, or a `file_id` (a file made with purpose `image`, e.g. an upload session for a local image): PNG, JPEG, GIF or WebP up to 5 MB and 16,384 px a side (50 megapixels at most), counted against the plan''s image storage (`403 limit_reached`). Send an `Idempotency-Key` so a retried upload stores one image. Requires the `templates:write` capability.'
parameters:
- name: Idempotency-Key
in: header
required: false
description: Any unique string (1–256 characters, e.g. a UUID). Retrying with the same key and the same body within 24 hours returns the first result instead of sending again; the same key with a different body is `409 invalid_idempotent_request`, and one still in flight is `409 concurrent_idempotent_requests`.
schema:
type: string
minLength: 1
maxLength: 256
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LibraryImageCreate'
responses:
'201':
description: The image.
content:
application/json:
schema:
$ref: '#/components/schemas/LibraryImage'
'400':
description: The body isn't JSON, or the `Idempotency-Key` is malformed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Missing or invalid API key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Insufficient scope, or the plan's image storage is full (`limit_reached`).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'409':
description: The `Idempotency-Key` is in use by a request still running, or with another body.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'413':
description: 'The request body is over 30 MB (`invalid_payload`): it was not read, and nothing in it was sent or stored.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Neither or both of `url` and `data`, an image that couldn't be fetched or read, the wrong type, over 5 MB, over 16,384 px a side or 50 megapixels, or an unknown key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
description: Too many uploads; retry after the wait.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'502':
description: Storing the image failed; nothing was stored. Retry.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'503':
description: '`engine_unavailable`: image hosting isn''t configured on this deployment; nothing was stored.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/library-images/{id}:
parameters:
- name: id
in: path
required: true
schema:
type: string
get:
operationId: library_images_get
tags:
- Library images
summary: Retrieve an image
description: One library image. Requires the `templates:read` capability.
responses:
'200':
description: The image.
content:
application/json:
schema:
$ref: '#/components/schemas/LibraryImage'
'401':
description: Missing or invalid API key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Insufficient scope.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Image not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: A query key (this operation takes none).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
patch:
operationId: library_images_update
tags:
- Library images
summary: Update an image
description: Change the alt text the image suggests when it's inserted. Requires the `templates:write` capability.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/LibraryImageUpdate'
responses:
'200':
description: The image.
content:
application/json:
schema:
$ref: '#/components/schemas/LibraryImage'
'400':
description: The body isn't JSON.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: Missing or invalid API key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Insufficient scope.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Image not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: A bad `alt`, or an unknown key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
operationId: library_images_delete
tags:
- Library images
summary: Delete an image
description: 'Remove an image from the library. While a template, a campaign or sent mail uses it, the answer is `409 resource_in_use` naming them (`details[]`); `force=true` deletes it anyway, as the dashboard''s "Delete anyway" does: those emails then show a broken image wherever it isn''t cached yet. Requires the `templates:write` capability.'
parameters:
- name: force
in: query
required: false
description: '`true` deletes an image that''s in use.'
schema:
type: string
enum:
- 'true'
- 'false'
responses:
'204':
description: Deleted.
'401':
description: Missing or invalid API key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Insufficient scope; or `force=true` on the workspace's logo or image, or a graphic pinned to a Brand Kit profile, without `branding:write`, since deleting it changes them.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: Image not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'409':
description: The image is in use (`resource_in_use`, `details[]` names where), or the workspace is protected.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: A bad `force`, or an unknown query key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
LibraryImage:
type: object
properties:
object:
type: string
const: library_image
id:
type: string
path:
type: string
description: 'Put this in a template or design: `<Image src="/img/…">` or `<img src="/img/…">`. Template and design sends resolve it to the image host; a raw `html` send doesn''t, so use `url` there.'
url:
type: string
description: 'The image''s public address on our asset CDN: use it in raw `html` sends and anywhere outside Unitpost.'
filename:
type: string
content_type:
type: string
size:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
description: Bytes.
width:
anyOf:
- type: integer
minimum: -9007199254740991
maximum: 9007199254740991
- type: 'null'
height:
anyOf:
- type: integer
minimum: -9007199254740991
maximum: 9007199254740991
- type: 'null'
alt:
description: The alt text suggested when the image is inserted.
anyOf:
- type: string
- type: 'null'
created_at:
type: string
updated_at:
type: string
required:
- object
- id
- path
- url
- filename
- content_type
- size
- width
- height
- alt
- created_at
- updated_at
LibraryImageCreate:
type: object
properties:
url:
description: A public https image to fetch (no redirects, no private addresses). PNG, JPEG, GIF or WebP, up to 5 MB and 16,384 px a side (50 megapixels at most); anything else is a 422 naming `url`.
type: string
maxLength: 2048
data:
description: The image bytes, base64 (no `data:` prefix), up to 5 MB of image. Base64 grows bytes by a third, and a request body may be up to 30 MB. At most 16,384 px a side and 50 megapixels; anything else is a 422 naming `data`.
type: string
maxLength: 7000000
file_id:
description: 'A file made with `POST /files` and purpose `image` (`file_…`): how an agent hands over a local image without base64 (an upload session), or an image up to 5 MB. Checked by its bytes when it was made, and again here.'
type: string
minLength: 1
maxLength: 64
content_type:
description: Required with `data`; refused with `url` and `file_id` (the server reads the type from the bytes).
type: string
enum:
- image/png
- image/jpeg
- image/gif
- image/webp
filename:
description: Shown in the library. Defaults to the URL's file name, or `image`.
type: string
minLength: 1
maxLength: 200
alt:
description: Alt text suggested when the image is inserted.
anyOf:
- type: string
maxLength: 300
- type: 'null'
Error:
type: object
properties:
error:
type: object
properties:
code:
type: string
description: Stable machine-readable error code (branch on this, not the message).
message:
type: string
description: 'Human-readable summary. For validation errors it''s path-prefixed (e.g. "template.variables.first_name: …").'
details:
type: array
description: 'Present on errors that carry per-field reasons: validation errors (422), a blocked campaign send (409), a plan that doesn''t include a feature (403 `limit_reached` with one entry whose `code` is `feature_not_in_plan` and whose `field` names the feature, e.g. `smsChannel`), and a send cap (429 `quota_exceeded` with one entry, `field` empty, whose `code` says which cap: `daily_quota_exceeded` or `monthly_quota_exceeded` (the free plan''s daily or monthly cap), `plan_required` (the workspace needs a paid plan to send this), `allowance_used` (a paid plan''s allowance is spent and it has no pay-as-you-go), `shared_plan_cap` (the organization''s shared plan, or this workspace''s cap on it, is used up) or `risk_throttled` (the account review''s daily cap, which an upgrade doesn''t lift)). One entry per offending field/blocker.'
items:
type: object
properties:
field:
type: string
description: Dotted path to the field, e.g. "template.variables.first_name" (empty for a whole-body problem).
code:
type: string
description: Machine-readable reason for this entry, when there is one (e.g. `template_not_published` on `template_id` for a blocked SMS campaign send, or `feature_not_in_plan` on `smsChannel` when the plan has no SMS). Absent on plain validation errors.
message:
type: string
required:
- field
- message
doc_url:
type: string
format: uri
description: 'A page that explains this error and what to do, when there is one: an absolute link on the API''s own host. Every 429 has one (a section of the rate-limits guide: the request limit, an operation''s limit, the plan''s send caps or the account review cap), as do `sending_paused`, the SMS access review''s `sms_review_pending` and `account_under_review`, and errors about domains, API keys, idempotency keys, plan limits, billing, SMS consent and suppression. A `details[].code` with a page of its own picks it. Additive; absent otherwise.'
required:
- code
- message
required:
- error
LibraryImageUpdate:
type: object
properties:
alt:
anyOf:
- type: string
maxLength: 300
- type: 'null'
description: The new alt text; `null` or `""` clears it.
required:
- alt
securitySchemes:
apiKey:
type: http
scheme: bearer
description: Your workspace API key.