Postmark-compatible API (/postmark)
Karta speaks Postmark's Email API (/email, /email/batch), its
messages API for outbound messages and its bounce API, so Postmark's
official clients and framework adapters send and read through Karta by
changing the host and the token. Karta's tests run Postmark's official
Ruby client (the postmark gem 1.25.1) and Swoosh's Postmark adapter
against it.
Pointing a client at Karta
| Setting | Value |
|---|---|
| Base URL | https://karta.example.com/postmark |
| Server token | a Karta API key of the server, in X-Postmark-Server-Token |
The API lives under /postmark so that its paths (/email,
/messages, ...) do not meet Karta's own. The token is read from the
X-Postmark-Server-Token header only, never from the query string. Karta
serves none of Postmark's account APIs: an X-Postmark-Account-Token is
not read.
Ruby, postmark (the host and the path prefix):
client = Postmark::ApiClient.new(ENV["KARTA_API_KEY"],
host: "karta.example.com", path_prefix: "/postmark/")
client.deliver(from: "ann@example.com", to: "bob@example.net",
subject: "Hello", text_body: "Hello")For Rails with postmark-rails, set the same options under
config.action_mailer.postmark_settings (api_token, host,
path_prefix).
Elixir, Swoosh (Swoosh.Adapters.Postmark):
config :my_app, MyApp.Mailer,
adapter: Swoosh.Adapters.Postmark,
api_key: System.fetch_env!("KARTA_API_KEY"),
base_url: "https://karta.example.com/postmark"Other clients: set the API's base URL to https://<host>/postmark.
Errors
In Postmark's form, with Postmark's status codes; the code is also in
the X-PM-ApiErrorCode header:
{"ErrorCode": 300, "Message": "Invalid 'To' address."}| Status | ErrorCode | When |
|---|---|---|
| 401 | 10 | no server token, a wrong one, or one without the endpoint's scope |
| 404 | 404 | a Postmark path Karta does not serve |
| 413 | 300 | a body over 10 MiB (50 MiB for /email/batch) |
| 415 | 415 | a POST without an application/json body |
| 422 | 300 | the message is not valid; the From address is not at a verified domain of the server's organisation |
| 422 | 402 | the body is not JSON, or not the JSON expected |
| 422 | 403 | a field has the wrong type (Invalid request field(s): 'TrackOpens'.) |
| 422 | 410 | more messages in a batch than the batch limit |
| 422 | 413 | the server is suspended |
| 422 | 700, 701 | a messages search that is not valid; a message not found |
| 422 | 1000, 1001 | a bounce search that is not valid; a bounce not found |
| 422 | 1101 | /email/withTemplate, /email/batchWithTemplates: Karta keeps no templates |
| 422 | 1235 | a MessageStream other than outbound |
| 429 | 429 | rate limited; Retry-After |
| 500 | 101 | the message could not be stored, or a stored one read; try again |
Postmark gives no ErrorCode for 404, 415 and 429; Karta answers the status as the code.
POST /postmark/email
Scope messages:send. One message, a JSON object of up to 10 MiB.
| Field | Notes |
|---|---|
From | required; one address, with or without a name; must be at a verified domain |
To, Cc, Bcc | addresses separated by commas (a name with a comma is quoted); at most 50 in all, each at most 254 characters |
ReplyTo | one or more addresses |
Subject | at most 2000 characters, no line breaks |
TextBody, HtmlBody | at least one |
Headers | [{"Name", "Value"}]; a Message-ID becomes the message's Message-ID; fields Karta writes itself (From, To, Subject, Date, the MIME fields, ...) and line breaks are refused |
Attachments | [{"Name", "Content" (base64), "ContentType", "ContentID"}]; with a ContentID (cid: in front or not) an inline part the HTML shows |
Tag | the message's tag, 1 to 128 bytes |
Metadata | variables: at most 10, names of 1 to 20 characters, values of at most 80; a number or true/false is kept as its text, as Postmark keeps metadata as strings |
TrackOpens | false switches open tracking off for this message |
TrackLinks | None or TextOnly switch link tracking off (Karta tracks links in the HTML only); HtmlOnly and HtmlAndText leave the server's setting |
MessageStream | outbound (the default), Karta's only stream |
InlineCss and other fields | ignored |
The text, the HTML and the attachments together may have at most 10 MiB.
An empty string is no value, as Postmark's clients send fields they do
not set. A message never turns on tracking its server has off:
TrackOpens: true leaves the server's setting.
{
"From": "Ann <ann@example.com>",
"To": "\"Doe, Bob\" <bob@example.net>",
"Subject": "Your order",
"TextBody": "Thank you for your order.",
"Tag": "receipts",
"Metadata": {"order": "1042"}
}The answer is Postmark's; MessageID is Karta's id of the message, the
same as in webhooks in Postmark's format:
{
"To": "\"Doe, Bob\" <bob@example.net>",
"SubmittedAt": "2026-11-10T09:00:00.123456Z",
"MessageID": "01a1c35f-5da5-7e7a-8c9c-5e90acc0b0ae",
"ErrorCode": 0,
"Message": "OK"
}POST /postmark/email/batch
Scope messages:send. A JSON array of messages, as for /email, of up
to 50 MiB together; each message at most 10 MiB of content. A batch has at
most the instance's batch limit of messages (KARTA_BATCH_MAX_MESSAGES,
100 by default, at most 1000; Postmark's is 500; see
Configuration). As Postmark does, the answer is 200 with one result per
message, in order, even when some are refused: check each ErrorCode.
[
{"ErrorCode": 0, "Message": "OK", "MessageID": "01a1c35f-5da5-7e7a-8c9c-5e90acc0b0ae",
"SubmittedAt": "2026-11-10T09:00:00.123456Z", "To": "bob@example.net"},
{"ErrorCode": 300, "Message": "Invalid 'To' address."}
]Every message is checked on its own; those that pass are stored together.
So either all the valid messages are sent, or, when Karta cannot store
them, none is and the answer is 500 (code 101): send the batch again.
Each message has its own id and Message-ID.
Messages
Scope messages:read. The server's own outgoing messages only.
| Request | Answer |
|---|---|
GET /postmark/messages/outbound | {"TotalCount", "Messages": [...]}, newest first |
GET /postmark/messages/outbound/{id}/details | one message, with its content and events |
GET /postmark/messages/outbound/{id}/dump | {"Body": ...}, the message as stored |
The search takes count (required, 1 to 500) and offset (required;
count and offset together at most 10,000), and filters: recipient,
fromemail, tag, status (queued, or sent and processed, which
are the same), fromdate and todate (inclusive; ISO 8601, a date alone
is its midnight; a time without an offset is UTC, where Postmark reads
US Eastern time), subject (text found in it), messagestream and
metadata_<name>.
A message is {"Tag", "MessageID", "MessageStream", "To", "Cc", "Bcc", "Recipients", "ReceivedAt", "From", "Subject", "Attachments", "Status", "TrackOpens", "TrackLinks", "Metadata", "Sandboxed"}. Status is
Queued while a recipient is queued or deferred, Sent after.
TrackOpens and TrackLinks (HtmlOnly or None) say what applies to
the message under its server's settings now. In a search, To lists all
the envelope recipients and Cc, Bcc and Attachments are empty; the
details read the stored message and add TextBody, HtmlBody, Body,
To and Cc as addressed, Bcc (the recipients in neither), the
attachments' names and MessageEvents:
| Type | When | Details |
|---|---|---|
Delivered | a recipient's server accepted it | DeliveryMessage, DestinationServer, DestinationIP |
Transient | an attempt failed; Karta tries again | the same |
Bounced | the recipient bounced | Summary, BounceID |
Opened | tracked open | Summary |
LinkClicked | tracked click | Summary, Link, ClickLocation (HTML) |
At most 300 events, oldest first. A message that is not the server's, or an id that is not a UUID, is code 701.
Bounces
Scope messages:read. A bounce is the delivery attempt after which a
recipient bounced: HardBounce (type code 1) when the recipient's
server refused the message, SoftBounce (4096) when Karta stopped
trying after its retry period.
| Request | Answer |
|---|---|
GET /postmark/deliverystats | {"InactiveMails", "Bounces": [{"Name": "All", "Count"}, {"Type", "Name", "Count"}, ...]} |
GET /postmark/bounces | {"TotalCount", "Bounces": [...]}, newest first |
GET /postmark/bounces/{id} | one bounce, with Content |
GET /postmark/bounces/{id}/dump | {"Body": ""} |
InactiveMails is the number of the server's addresses on its
suppression list. The search takes count and offset as above, and
type, inactive, emailFilter (text found in the address), tag,
messageID, fromdate, todate and messagestream.
A bounce is {"ID", "Type", "TypeCode", "Name", "Tag", "MessageID", "MessageStream", "Description", "Details", "Email", "From", "BouncedAt", "DumpAvailable", "Inactive", "CanActivate", "Subject"}, with
RecordType in a search and Content alone. Its ID is Karta's id of
the delivery attempt, a UUID where Postmark's are numbers (clients that
read it as a number cannot use it), its MessageID the message's id.
Karta keeps no bounce message (DumpAvailable false, Content and the
dump empty), and a bounce does not put the address on the suppression
list (Inactive false, CanActivate true). A bounce that is not the
server's is code 1001.
What differs from Postmark
- No templates (
/email/withTemplate,/email/batchWithTemplates: 1101), one message stream (outbound), and no sandbox token (POSTMARK_API_TESTis a wrong token). - A recipient on the suppression list does not make the message fail (Postmark's 406): the message is sent to the others and the address is recorded as suppressed, as for every Karta API.
- Karta does not refuse attachments by file type (Postmark's 411).
- Tags have 1 to 128 bytes (Postmark: up to 1000 characters).
- A batch has at most the instance's batch limit of messages, 100 by default (Postmark: 500).
- Times are answered in UTC (
...Z), with microseconds. - Not served (
404): opens and clicks (/messages/outbound/opens,/clicks), inbound messages, activating a bounce, suppressions, statistics, servers, message streams, webhooks, sender signatures and domains, and the account APIs.