Every API here is available over the APIs.io API and to AI agents over MCP.
openapi: 3.2.0
info:
title: Unitpost API keys 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: API Keys
description: 'Create and revoke the API keys your integrations authenticate with. Each key has a scope: `full`, `sending`, `read_only`, or an explicit `capabilities` list (paid plans for `read_only` and custom lists); a request outside the key''s capabilities returns 403 `insufficient_scope`. No key can manage keys, the team, the workspace or billing. Creating and revoking keys is session-gated (dashboard cookie + `apikeys:manage`) and NOT usable with a Bearer API key; listing keys and a key''s usage take a key or app holding `apikeys:read`, which no preset includes.'
paths:
/api-keys:
get:
operationId: api_keys_list
tags:
- API Keys
summary: List API keys
description: 'Retrieve a list of your workspace''s API keys — the key prefix, scope, capabilities and last use, never the secret. With an API key or an MCP sign-in it needs `apikeys:read`, which no key preset includes: tick it on the key that audits your keys. From a dashboard session it needs `apikeys:manage`. See how a key is used with Retrieve an API key''s usage. Creating (Create an API key) and revoking (Revoke an API key) keys stay in a dashboard session. Requires the `apikeys: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 API keys.
content:
application/json:
schema:
type: object
properties:
object:
type: string
enum:
- list
has_more:
type: boolean
data:
type: array
items:
$ref: '#/components/schemas/ApiKey'
required:
- object
- has_more
- data
headers:
Unitpost-Warning:
$ref: '#/components/headers/UnitpostWarning'
'401':
description: Missing or invalid credential (and no dashboard session).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Insufficient scope (`apikeys:read`; from a session, `apikeys:manage`).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Invalid pagination params.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
operationId: api_keys_create
tags:
- API Keys
summary: Create an API key
description: 'Create an API key scoped to the capabilities you choose. The response includes the plaintext `key` exactly once — store it securely now, because it can never be retrieved again (only revoked). This endpoint is session-gated: it requires a dashboard session and cannot be called with a Bearer API key.'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ApiKeyCreate'
responses:
'201':
description: Created — includes the one-time plaintext key.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiKeyCreated'
headers:
Unitpost-Warning:
$ref: '#/components/headers/UnitpostWarning'
'401':
description: Not authenticated (no dashboard session).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: 'Insufficient permission (`apikeys:manage` required), or the workspace owner has not verified their phone number yet (`forbidden`) — the same anti-abuse prerequisite as creating a key in the dashboard, waived once the workspace has sent a real email or is on a paid plan. Also `insufficient_scope` when the key would hold a capability the creating member does not hold: a member who is not the owner gets a key with at most their own permissions, and a full-access scope from a member without full access is refused, with no key created. Pick `capabilities` the member holds. A seat opened through an organization cannot create keys.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Validation error.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/logs:
get:
operationId: logs_list
tags:
- API Keys
summary: List request logs
description: 'Your workspace''s API request log, newest first and cursor-paginated: each call''s method, path, status, time taken, the API key that made it and its `x-request-id` (quote it to support). Never the caller''s IP and never a body. Narrow with `status` (a code, or a class such as `4xx`), `api_key_id`, `method`, `path_prefix` (e.g. `/email`), `request_id` and a `created_after` / `created_before` range. Rows are kept 30 days. Needs `apikeys:read`, which no key preset includes, and has its own per-workspace rate limit. Requires the `apikeys: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
- name: status
in: query
required: false
description: 'A status code (e.g. `429`) or a class: `2xx`, `3xx`, `4xx`, `5xx`.'
schema:
type: string
- name: api_key_id
in: query
required: false
description: Only one API key's calls (`key_…`).
schema:
type: string
- name: method
in: query
required: false
description: Only one HTTP method.
schema:
type: string
enum:
- GET
- POST
- PUT
- PATCH
- DELETE
- name: path_prefix
in: query
required: false
description: 'Only paths under this one, as in this reference (e.g. `/email/campaigns`): whole path segments, matched literally (`/email` matches `/email` and `/email/campaigns`, not `/emails`). It can''t name an email address or a phone number (paths show them as `{email}` / `{phone}`).'
schema:
type: string
maxLength: 200
- name: request_id
in: query
required: false
description: One call, by the `x-request-id` its response carried. Searches the last 24 hours unless `created_after` is given.
schema:
type: string
- name: created_after
in: query
required: false
description: Calls at or after this time (ISO 8601 with a zone).
schema:
type: string
format: date-time
- name: created_before
in: query
required: false
description: Calls before this time (ISO 8601 with a zone).
schema:
type: string
format: date-time
responses:
'200':
description: A page of request logs.
content:
application/json:
schema:
type: object
properties:
object:
type: string
enum:
- list
has_more:
type: boolean
data:
type: array
items:
$ref: '#/components/schemas/RequestLog'
required:
- object
- has_more
- data
'401':
description: Missing or invalid API key.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Insufficient scope (`apikeys:read`).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: Invalid pagination or filter params, a parameter given twice, or an unknown query parameter.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'429':
description: 'Too many log reads: wait for `Retry-After`.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'503':
description: '`operation_timed_out`: a narrow filter took too long. Add a time range, or retry.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api-keys/{id}/usage:
parameters:
- name: id
in: path
required: true
schema:
type: string
get:
operationId: api_keys_usage
tags:
- API Keys
summary: Retrieve an API key's usage
description: 'One key''s last 24 hours: how many requests it made, how many were answered 4xx, 5xx or 429, and when it was last used. Check it before you revoke a key (is anything still calling with it?) or when an integration''s calls fail. The dashboard''s revoke dialog reads the same count. Needs `apikeys:read`, which no key preset includes. Requires the `apikeys:read` capability.'
responses:
'200':
description: The key's usage.
content:
application/json:
schema:
$ref: '#/components/schemas/ApiKeyUsage'
'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: API key not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: An unknown query parameter.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'503':
description: '`operation_timed_out`: a very busy key''s count took too long; retry.'
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/api-keys/{id}:
parameters:
- name: id
in: path
required: true
schema:
type: string
delete:
operationId: api_keys_revoke
tags:
- API Keys
summary: Revoke an API key
description: 'Permanently revoke an API key. Requests made with it start failing with `401` immediately, and revocation cannot be undone — create a replacement first with Create an API key if you''re rotating. This endpoint is session-gated: it requires a dashboard session and cannot be called with a Bearer API key.'
responses:
'204':
description: Revoked.
'401':
description: Not authenticated (no dashboard session).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'403':
description: Insufficient permission (`apikeys:manage` required).
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'404':
description: API key not found.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
ApiKeyCreate:
type: object
properties:
name:
type: string
minLength: 1
maxLength: 120
scope:
default: full
type: string
enum:
- full
- sending
- read_only
capabilities:
type: array
items:
type: string
enum:
- contacts:read
- contacts:write
- suppressions:read
- suppressions:write
- segments:read
- segments:write
- topics:read
- topics:write
- templates:read
- templates:write
- campaigns:read
- campaigns:write
- campaigns:send
- domains:read
- domains:write
- emails:read
- emails:send
- emails:read_content
- sms:read
- sms:send
- sms:manage
- sms:purchase
- apikeys:read
- apikeys:manage
- webhooks:read
- webhooks:manage
- branding:write
- activity:read
- spend_caps:write
- team:read
- team:invite
- team:manage_members
- workspace:update
- workspace:delete
- billing:manage
required:
- name
RequestLog:
type: object
properties:
object:
type: string
const: request_log
id:
type: string
description: The log row (`rlog_…`); page with it as `after` / `before`.
request_id:
description: 'The `x-request-id` the response carried: quote it to support.'
anyOf:
- type: string
- type: 'null'
method:
type: string
path:
type: string
description: The path called, without the host and `/api/v1` (e.g. `/email/email_…`); no query string. An email address or phone number in it reads `{email}` / `{phone}`.
status:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
description: The HTTP status answered.
duration_ms:
anyOf:
- type: integer
minimum: -9007199254740991
maximum: 9007199254740991
- type: 'null'
description: How long the request took to answer.
api_key_id:
description: The API key that called (`key_…`); null for an MCP or CLI sign-in, or a key since deleted.
anyOf:
- type: string
- type: 'null'
user_agent:
anyOf:
- type: string
- type: 'null'
created_at:
type: string
required:
- object
- id
- request_id
- method
- path
- status
- duration_ms
- api_key_id
- user_agent
- created_at
ApiKeyUsage:
type: object
properties:
object:
type: string
const: api_key_usage
id:
type: string
description: The key (`key_…`).
last_used_at:
anyOf:
- type: string
- type: 'null'
requests_24h:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
description: 'Requests the key made in the last 24 hours, counted up to 100,000: `100001` means more than 100,000.'
client_errors_24h:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
description: Of those, answered 4xx (`rate_limited_24h` included). Past the cap, these three count the latest 100,001 requests.
server_errors_24h:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
description: Of those, answered 5xx.
rate_limited_24h:
type: integer
minimum: -9007199254740991
maximum: 9007199254740991
description: Of those, answered 429.
required:
- object
- id
- last_used_at
- requests_24h
- client_errors_24h
- server_errors_24h
- rate_limited_24h
ApiKey:
type: object
properties:
object:
type: string
const: api_key
id:
type: string
name:
type: string
prefix:
type: string
scope:
type: string
enum:
- full
- sending
- read_only
capabilities:
type: array
items:
type: string
last_used_at:
anyOf:
- type: string
- type: 'null'
revoked_at:
anyOf:
- type: string
- type: 'null'
created_at:
type: string
required:
- object
- id
- name
- prefix
- scope
- capabilities
- last_used_at
- revoked_at
- created_at
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
ApiKeyCreated:
allOf:
- $ref: '#/components/schemas/ApiKey'
- type: object
properties:
key:
type: string
description: The plaintext secret. Shown exactly once — store it now; it can never be retrieved again.
required:
- key
headers:
UnitpostWarning:
description: 'Present when the request carried something this operation ignored (an unknown body key, a filter value it can''t apply, a recipient on a reserved domain it left out, …): one sentence per item, at most 1 KB in all (notes past that are counted, and a long list of addresses names the first ones and how many in all). The answer is the one without it. Send `Unitpost-Strict: true` to have such a request refused with a `422` instead; on `POST /email/batch` a reserved recipient refuses only its item, which comes back in `failed` while the rest of the batch is sent.'
schema:
type: string
securitySchemes:
apiKey:
type: http
scheme: bearer
description: Your workspace API key.