Karta API (/api/v2)

Karta's own HTTP API: sending (one message, a message given whole, or a batch), message status, delivery attempts, opens and clicks, credentials, the suppression list and webhooks. It is described by an OpenAPI 3.1 document, which Karta serves at /api/v2/openapi.json and which is also published with this documentation: openapi/karta-api-v2.json. Every request is validated against that document, and the test suite checks every answer against it.

Conventions

  • Base URL: https://<host>/api/v2.
  • Authentication: Authorization: Bearer <API key> (API keys and scopes).
  • Request bodies are JSON (Content-Type: application/json) and accept only the properties listed; an unknown property is an error. A body has at most 8,000,000 bytes; a larger one is refused (413). The exception is the body of POST /api/v2/messages/raw, which may have 37,049,688 bytes: a message of the SMTP maximum (25 MiB) as base64, and 2 MiB for the rest.
  • Answers are JSON. A value that is not known is left out, never written as null.
  • Times are ISO 8601 in UTC with microseconds (2026-11-08T15:52:29.006668Z).
  • Ids are UUIDs. An id that is not a UUID, or that belongs to another server, is simply not found (404).

Errors

Every error has an HTTP status and this body:

{
  "error": {
    "code": "invalid_request",
    "message": "The request does not match the API",
    "details": [{"field": "/colour", "message": "Unexpected field: colour"}]
  }
}

code is stable and meant for programs; details (only for invalid requests) lists the fields concerned as JSON pointers.

StatuscodeWhen
401unauthorizedno key (WWW-Authenticate: Bearer), or an invalid one (WWW-Authenticate: Bearer error="invalid_token")
403forbiddenthe key lacks the operation's scope
403server_suspendedthe server is suspended
403scope_not_allowedcreating a credential with more rights than the calling key
404not_foundno such message, credential, suppression, webhook or webhook delivery
409webhook_disabledthe webhook is switched off (a test event, a replay)
409delivery_pendingthe webhook delivery is still being sent (a replay)
409no_secreta webhook in Postal's or Postmark's format has no secret to rotate
422invalid_requestthe request does not match the OpenAPI document
422invalid_address, invalid_header, invalid_attachment, no_recipients, no_content, invalid_message, message_too_large, from_not_permitted, sender_not_permitted, invalid_author, invalid_tags, invalid_variables, send_at_too_late, missing_replacement, invalid_replacement, too_many_recipients, batch_too_largethe message, or a message of the batch, cannot be sent (below)
422invalid_credential, invalid_suppression, invalid_webhookthe record is invalid; details names the fields
429rate_limitedtoo many requests; Retry-After gives seconds
503temporary_failurethe message could not be stored; try again

Messages

Send a message

POST /api/v2/messages (operation sendMessage, scope messages:send)

Builds a message from its parts, checks it and queues it.

PropertyTypeNotes
fromstring, requiredann@example.com or Ann <ann@example.com>; must be at a verified domain
senderstringone address; must be at a verified domain
reply_tostringone address
to, cc, bccarrays of stringsat most 50 each; at least one recipient in all; Bcc is not written into the message
subjectstringno line breaks or control characters
text, htmlstringat least one of text, html or an attachment
headersobject of stringsfurther header fields; not those Karta writes (From, Sender, To, Cc, Bcc, Reply-To, Subject, Date, Message-ID, MIME-Version, Content-Type, Content-Transfer-Encoding, Content-Disposition, Received, Return-Path, DKIM-Signature); names of 1 to 76 printable ASCII characters without :, values at most 998 bytes without line breaks
attachmentsarray{"filename", "content_type", "data"}: data is base64, content_type required (type/subtype), filename 1 to 255 characters
tagstringone tag, at most 100 characters: put in front of tags
tagsarray of stringslabels for your own use: at most 10 with tag, each 1 to 128 bytes without control characters; duplicates are dropped, the first is the message's tag
variablesobject of stringsdata for your own use, returned with the message and in its webhooks: names of 1 to 128 bytes without control characters, at most 16 KiB as JSON
send_atstringdeliver at this time, an RFC 3339 time with its offset, at most 72 hours ahead; a time that has passed means at once
track_opens, track_clicksbooleanfalse switches open or click tracking off for this message; true is the server's setting, as when left out (a message cannot turn on what its server has off)
require_tlsbooleantrue: REQUIRETLS (RFC 8689): delivered only over verified TLS to servers that support REQUIRETLS, else bounced, never sent in the clear (Delivery); false or left out: the usual policy

The envelope sender is the From address; the recipients are To, Cc and Bcc. Karta writes Date and Message-ID (<message id>@<KARTA_OUTBOUND_HOSTNAME>).

curl -s https://karta.example.com/api/v2/messages \
  -H "Authorization: Bearer $KARTA_API_KEY" -H "Content-Type: application/json" \
  -d @message.json
{
  "from": "Ann <ann@example.com>",
  "to": ["bob@example.net"],
  "cc": ["carol@example.org"],
  "subject": "Your order",
  "text": "Thank you for your order.",
  "html": "<p>Thank you for your order.</p>",
  "headers": {"X-Order": "1234"},
  "attachments": [
    {"filename": "receipt.txt", "content_type": "text/plain", "data": "VG90YWw6IDEwLjAw"}
  ],
  "tags": ["receipts", "web-shop"],
  "variables": {"order": "1234"}
}

202 Accepted:

{
  "id": "01a1bbdc-7238-7cdf-8767-ae15a5baedfd",
  "message_id": "<01a1bbdc-7238-7cdf-8767-ae15a5baedfd@karta.example.com>",
  "recipients": [
    {"address": "bob@example.net", "attempts": 0, "id": "01a1bbdc-7264-7024-a75b-f842b240b955", "status": "queued"},
    {"address": "carol@example.org", "attempts": 0, "id": "01a1bbdc-7264-7e96-b601-01fb55024b50", "status": "queued"}
  ]
}

A recipient on the suppression list is listed with "status": "suppressed". A scheduled message's answer has its send_at, in UTC.

Tags, variables and scheduling says what the options do and where they come back.

Errors specific to sending (422):

codeMeaning
invalid_addressa field is not a valid address (message names it)
invalid_headerthe subject, an extra header, or a reserved header name
invalid_attachmentan attachment has an invalid file name or content type
no_recipientsno To, Cc or Bcc
no_contentno text, HTML or attachment
from_not_permittedFrom or Sender is not at a verified domain of the organisation
sender_not_permittedthe envelope sender is not at a verified domain
invalid_authorFrom or Sender is malformed (no From, several From fields, a From with several mailboxes and no Sender, ...)
invalid_tagsmore than 10 tags, an empty one, one of more than 128 bytes or with a control character
invalid_variablesa variable's name is empty, longer than 128 bytes or has a control character (details names /variables), or the variables have more than 16 KiB as JSON
send_at_too_latesend_at is more than 72 hours ahead

For example, a From at a domain that is not verified:

{"error": {"code": "from_not_permitted", "message": "From or Sender is not at a verified domain of this server"}}

Send a message given whole

POST /api/v2/messages/raw (operation sendRawMessage, scope messages:send)

PropertyTypeNotes
mail_fromstring, requiredthe envelope sender; "" for none; else at a verified domain
rcpt_toarray of strings, required1 to 150 envelope recipients
datastring, requiredthe message (header and body), base64; LF line endings are stored as CRLF
tag, tags, variables, send_at, track_opens, track_clicks, require_tlsas for a message built from its parts

The message's From and Sender are checked as for SMTP. Karta does not add a Message-ID or Date; message_id is absent from the answer when the message has none.

{
  "mail_from": "ann@example.com",
  "rcpt_to": ["bob@example.net"],
  "data": "RnJvbTogQW5uIDxhbm5AZXhhbXBsZS5jb20+DQpUbzogYm9iQGV4YW1wbGUubmV0DQpTdWJqZWN0OiBIZWxsbw0KDQpIZWxsbyBCb2INCg=="
}

202 Accepted:

{
  "id": "01a1bbdc-7279-7930-be3e-33f2a2d0131c",
  "recipients": [
    {"address": "bob@example.net", "attempts": 0, "id": "01a1bbdc-727d-7125-81f8-017660d38a9d", "status": "queued"}
  ]
}

invalid_message (422) means data has no valid header block. message_too_large (422) means the message, once decoded, is larger than 25 MiB (26,214,400 bytes), the limit of the SMTP listeners. A body larger than 37,049,688 bytes is refused (413) before it is read in full.

Send a batch

POST /api/v2/messages/batch (operation sendBatch, scope messages:send)

One message per recipient, built from the same parts and options, each with only its recipient in To and that recipient's replacements made. Every recipient is checked, and every message built and authorised, before anything is stored: all are accepted, or none is, and the error names the first problem.

The properties of a message built from its parts except to, cc and bcc, and:

PropertyTypeNotes
recipientsarray, required1 recipient to the instance's batch limit (KARTA_BATCH_MAX_MESSAGES, 100 by default, never more than 1000), a message each, in this order
recipients[].tostring, requiredthe message's only recipient, plain or with a name
recipients[].replacementsobject of stringsat most 100: a value for each {{name}} in the subject, the text and the HTML
recipients[].variablesobject of stringsadded to the batch's variables, over those of the same name

Replacements:

  • A placeholder is {{name}}, a name of 1 to 64 ASCII letters, digits, _ or -, without spaces. Other text between double braces stays as written.
  • Only the subject, the text and the HTML are replaced: not the addresses, header fields, tags, variables or attachments.
  • It is plain substitution, in one pass: nothing is evaluated, and a value is never searched again (a value holding {{other}} stays as written).
  • Every placeholder needs a value for every recipient (missing_replacement): no message goes out half filled in.
  • In the HTML a value is text: its &, <, >, " and ' become character references, so it can add no markup and cannot leave an attribute. A value in a link (href="{{url}}") is still a link target: check values that come from your users before you send them.
  • A value may hold tabs and line breaks, no other control character; a value put into the subject may hold no line break (invalid_replacement), so that it cannot start another header field.

The messages may have at most 50 MiB of content together (subject, text, HTML and attachments, after replacement); they are counted as they are made, and a batch past the limit is refused (batch_too_large) before it is made whole. The key's rate limit counts the request once; the server's sending limit and its suspension apply to each message when it is delivered. Each message has its own id and Message-ID.

{
  "from": "Shop <shop@example.com>",
  "subject": "Your order {{order}}",
  "text": "Hi {{name}}, order {{order}} is on its way.",
  "html": "<p>Hi {{name}}, order {{order}} is on its way.</p>",
  "tags": ["shipping"],
  "variables": {"campaign": "autumn"},
  "recipients": [
    {"to": "Ann <ann@example.net>", "replacements": {"name": "Ann", "order": "1041"}, "variables": {"order": "1041"}},
    {"to": "bob@example.org", "replacements": {"name": "Bob", "order": "1042"}, "variables": {"order": "1042"}}
  ]
}

202 Accepted, the messages in the order of the recipients:

{
  "data": [
    {
      "id": "01a1bbdc-7290-7a1e-9c55-1f4b8e2d3c01",
      "message_id": "<01a1bbdc-7290-7a1e-9c55-1f4b8e2d3c01@karta.example.com>",
      "recipients": [{"address": "ann@example.net", "attempts": 0, "id": "01a1bbdc-72a4-7b10-8d3e-5a6f7b8c9d01", "status": "queued"}]
    },
    {
      "id": "01a1bbdc-7290-7a1e-9c55-1f4b8e2d3c02",
      "message_id": "<01a1bbdc-7290-7a1e-9c55-1f4b8e2d3c02@karta.example.com>",
      "recipients": [{"address": "bob@example.org", "attempts": 0, "id": "01a1bbdc-72a4-7b10-8d3e-5a6f7b8c9d02", "status": "queued"}]
    }
  ]
}

Errors (422) besides those of a single message; details names the recipient:

codeMeaning
invalid_addressa recipient's to is not a valid address (/recipients/1/to)
missing_replacementa placeholder has no value for a recipient (/recipients/1/replacements/order)
invalid_replacementa replacement's name is not a placeholder name, or its value has a control character, or a line break for the subject
invalid_variablesa name of a recipient's variables (/recipients/1/variables), or the variables of a message are more than 16 KiB
too_many_recipientsmore recipients than the batch limit (/recipients)
batch_too_largemore than 50 MiB of content together
{"error": {"code": "missing_replacement", "message": "A recipient has no value for {{order}}", "details": [{"field": "/recipients/1/replacements/order", "message": "invalid"}]}}

Get a message

GET /api/v2/messages/{id} (operation getMessage, scope messages:read)

{
  "created_at": "2026-11-08T15:52:29.006668Z",
  "direction": "outgoing",
  "from": "ann@example.com",
  "id": "01a1bbdc-7238-7cdf-8767-ae15a5baedfd",
  "mail_from": "ann@example.com",
  "message_id": "<01a1bbdc-7238-7cdf-8767-ae15a5baedfd@karta.example.com>",
  "recipients": [
    {
      "address": "bob@example.net",
      "attempts": 1,
      "clicks": 0,
      "id": "01a1bbdc-7264-7024-a75b-f842b240b955",
      "last_code": 250,
      "last_details": "250 2.0.0 Ok: queued as 4XyZ",
      "last_enhanced": "2.0.0",
      "opens": 0,
      "status": "delivered"
    },
    {
      "address": "carol@example.org",
      "attempts": 0,
      "clicks": 0,
      "id": "01a1bbdc-7264-7e96-b601-01fb55024b50",
      "opens": 0,
      "status": "queued"
    }
  ],
  "size": 1101,
  "subject": "Your order",
  "tag": "receipts",
  "tags": ["receipts", "web-shop"],
  "variables": {"order": "1234"}
}
FieldMeaning
directionoutgoing (incoming exists for the future)
mail_fromenvelope sender ("" for none)
fromthe first From address
sizebytes stored, including Karta's Received: field
tag, tagsthe first tag, and all of them ([] without)
variablesas given ({} without); a message sent over Mailgun's API may have other JSON values than text
send_atwhen delivery was to start, for a scheduled message
track_opens, track_clicksfalse when the message switched that tracking off; absent otherwise
require_tlstrue when the message was sent with REQUIRETLS; absent otherwise
recipients[].statusqueued, deferred, delivered, bounced, suppressed (Delivery)
recipients[].next_attempt_atwhen a deferred recipient is tried again
recipients[].last_code, last_enhanced, last_detailsthe last outcome
recipients[].opens, clicksevents recorded

A message removed by retention is not found.

Retry, hold, release or cancel a message

POST /api/v2/messages/{id}/retry
POST /api/v2/messages/{id}/hold
POST /api/v2/messages/{id}/release
POST /api/v2/messages/{id}/cancel

Scope messages:manage. Each answers 200 with the message as Get a message shows it (a held recipient has "held": true; a cancelled one the status cancelled), or 409 not_possible with the reason when the recipients are not in a state the action can act on, or 404. Every action is judged recipient by recipient, and a message that is already delivered, bounced, suppressed or cancelled cannot be changed by any of them. See Delivery.

List delivery attempts

GET /api/v2/messages/{id}/deliveries (operation listMessageDeliveries, scope messages:read)

Every attempt for every recipient, oldest first:

{
  "data": [
    {
      "attempt": 1,
      "code": 250,
      "created_at": "2026-11-08T15:52:29.056123Z",
      "details": "250 2.0.0 Ok: queued as 4XyZ",
      "enhanced": "2.0.0",
      "id": "01a1bbdc-7280-7fbf-893b-98bee3baea2e",
      "mx_host": "mx.example.net",
      "recipient_id": "01a1bbdc-7264-7024-a75b-f842b240b955",
      "remote_ip": "198.51.100.25",
      "status": "delivered",
      "tls_cipher": "TLS_AES_256_GCM_SHA384",
      "tls_version": "TLSv1.3"
    }
  ]
}

status is delivered, deferred or bounced. Without a server reply (code absent), details says what Karta decided, for example connecting failed: econnrefused or the recipient domain does not exist.

List opens and clicks

GET /api/v2/messages/{id}/events (operation listMessageEvents, scope messages:read)

Query: limit (1 to 1000, default 100), after (an event id: continue after it).

{
  "data": [
    {
      "created_at": "2026-11-08T15:53:42.788469Z",
      "id": "01a1bbdd-9284-774f-b57c-64924eea24cd",
      "ip_address": "198.51.100.0",
      "kind": "open",
      "recipient_id": "01a1bbdd-9037-7e3d-811f-3c3fa383a897",
      "user_agent": "Mozilla/5.0"
    },
    {
      "created_at": "2026-11-08T15:53:42.798962Z",
      "id": "01a1bbdd-928e-7f3d-8c2d-81a53b10bf47",
      "ip_address": "198.51.100.0",
      "kind": "click",
      "recipient_id": "01a1bbdd-9037-7e3d-811f-3c3fa383a897",
      "url": "https://example.org/offer",
      "user_agent": "Mozilla/5.0"
    }
  ]
}

When a page is full, next holds the id to pass as after. ip_address is the client's network (IPv4 /24 or IPv6 /48), never its address (Tracking and unsubscribe).

Credentials

List credentials

GET /api/v2/credentials (operation listCredentials, scope credentials:read)

The server's API keys, SMTP credentials and IP ranges, oldest first, revoked ones included. Secrets are never shown.

{
  "data": [
    {
      "created_at": "2026-11-08T15:52:28.880915Z",
      "id": "27ba6ca9-7726-4e20-82d4-1b932aa07759",
      "kind": "api",
      "last_used_at": "2026-11-08T15:52:28.955275Z",
      "name": "App",
      "prefix": "ln6ml74h",
      "scopes": ["messages:send", "messages:read", "suppressions:read",
                 "suppressions:write", "credentials:read", "credentials:write"]
    }
  ]
}

last_used_at is updated at most once a minute. SMTP credentials have username instead of scopes; IP ranges have cidr and tls_required instead; a revoked credential has revoked_at.

Create a credential

POST /api/v2/credentials (operation createCredential, scope credentials:write)

PropertyTypeNotes
kindapi, smtp or ip, required
namestring, requiredat most 100 characters
scopesarrayAPI keys only; default messages:send, messages:read; only scopes the calling key has
cidrstringIP ranges only, required: the address range, in CIDR notation
tls_requiredbooleanIP ranges only; default true
rate_limit_per_minuteinteger ≥ 1default 600

Creating an SMTP credential or an IP range needs messages:send (it can send mail). 201 Created returns the credential with its secret, shown this once: key for an API key, password (and username) for an SMTP credential. An IP range has no secret. An IP range wider than the instance's minimum prefix, or the whole address space, gets 422 invalid_credential. Examples are on API keys and scopes, SMTP submission and SMTP submission.

A key asking for scopes it does not have gets 403 scope_not_allowed ("This key cannot give scopes it does not have: ...").

Revoke a credential

DELETE /api/v2/credentials/{id} (operation revokeCredential, scope credentials:write)

Revokes the credential for good and returns it (200, with revoked_at). Revoking it again returns it unchanged. Credentials are never deleted.

{
  "created_at": "2026-11-08T15:52:29.222633Z",
  "id": "1ed28ca1-f9a1-4907-83c5-12659a781b1c",
  "kind": "smtp",
  "name": "Shop",
  "prefix": "kxsxup63",
  "revoked_at": "2026-11-08T15:52:29.225813Z",
  "username": "kxsxup63"
}

A key can revoke itself.

Suppressions

Addresses in paths are URL-encoded (bob%40example.net).

List suppressions

GET /api/v2/suppressions (operation listSuppressions, scope suppressions:read)

Query: limit (1 to 1000, default 100), after (an address: continue after it). Entries are in address order; when a page is full, next holds the address to pass as after.

{
  "data": [
    {
      "address": "dave@example.net",
      "created_at": "2026-11-08T15:52:29.303027Z",
      "reason": "unsubscribe",
      "source": "api:ln6ml74h",
      "updated_at": "2026-11-08T15:52:29.303027Z"
    }
  ]
}

reason is manual, unsubscribe, hard_bounce or complaint; expires_at is present when set. Expired entries are listed too.

Get a suppression

GET /api/v2/suppressions/{address} (operation getSuppression, scope suppressions:read)

Returns the entry, or 404 not_found ("The address is not on the list").

Add or update a suppression

POST /api/v2/suppressions (operation createSuppression, scope suppressions:write)

PropertyTypeNotes
addressstring, required
reasonmanual (default) or unsubscribe
expires_atdate-timefrom then on the entry no longer counts
{"address": "dave@example.net", "reason": "unsubscribe"}

201 Created when the address was not on the list, 200 OK when its entry was updated; the body is the entry. An invalid address gives 422 invalid_suppression with details.

Remove a suppression

DELETE /api/v2/suppressions/{address} (operation deleteSuppression, scope suppressions:write)

204 No Content, or 404 not_found.

The suppression policy

GET /api/v2/suppression-policy (operation getSuppressionPolicy, scope suppressions:read)

PUT /api/v2/suppression-policy (operation putSuppressionPolicy, scope suppressions:write)

When an address goes onto the list by itself, and how long an entry of each reason lasts (Suppressions).

{
  "soft_bounce_threshold": 3,
  "soft_bounce_window_days": 30,
  "hard_bounce_days": 30,
  "complaint_days": 365,
  "unsubscribe_days": 0,
  "manual_days": 0
}
PropertyNotes
soft_bounce_thresholdTemporary failures of one address, within the window, that suppress it; 0 never
soft_bounce_window_days1 to 3650
hard_bounce_days, complaint_days, unsubscribe_days, manual_daysDays an entry of that reason lasts from when it takes that reason; 0 never

The PUT is the whole policy: a day count left out is 0, which never expires. Values outside their bounds give 422 invalid_suppression_policy with details.

Webhooks

What webhooks send, how requests are signed and verified, and how they are retried: Webhooks. Ids in paths are UUIDs.

List webhooks

GET /api/v2/webhooks (operation listWebhooks, scope webhooks:read)

The server's webhooks, oldest first. Secrets are never shown.

{
  "data": [
    {
      "created_at": "2026-12-02T10:15:00.104227Z",
      "enabled": true,
      "events": ["message.bounced", "message.delivered"],
      "format": "standard",
      "id": "019adf2e-5c4b-7d1a-9e2f-3a4b5c6d7e8f",
      "name": "Orders",
      "updated_at": "2026-12-02T10:15:00.104227Z",
      "url": "https://hooks.example.com/karta/events"
    }
  ]
}

events is ["*"] for every event type (of the webhook's format). basic_auth_user is the user name its URL was given with; the password is never shown. A webhook in SendGrid's format has public_key, the key its requests' signatures verify with. A webhook Karta switched off has enabled: false, disabled_reason: "failing" and disabled_at; failing_since is present while its requests fail; previous_secret_expires_at while the secret before the last rotation still signs.

Add a webhook

POST /api/v2/webhooks (operation createWebhook, scope webhooks:write)

PropertyTypeNotes
namestring, requiredat most 100 characters
urlstring, requiredhttps:// (http:// only where the instance allows it), no fragment; at most 2000 characters. A user name and password in it (https:// only) are kept apart and sent as Basic authentication
formatstringstandard (the default), postal, mailgun, sendgrid or postmark (Formats); it cannot be changed later
eventsarrayevent types the format has, or ["*"] (the default) for all of them
enabledbooleandefault true
auth_headerstringan extra header sent with every request beside the format's signature, for a receiver that cannot check a signature (an HTTP token; see Header authentication)
auth_header_valuestringthe header's secret value: printable ASCII, shown once, in this answer
{"name": "Orders", "url": "https://hooks.example.com/karta/events",
 "events": ["message.delivered", "message.bounced"]}

201 Created returns the webhook with its secret, shown this once: whsec_… in the standard format, the signing key (64 hexadecimal digits) in Mailgun's. A webhook in SendGrid's format shows its public_key instead (its private key is never shown); one in Postal's format has no secret (its organisation's key signs it, published at the organisation's JWK set), nor has one in Postmark's (not signed). An auth_header_value is shown once too, in this answer. A server has at most 20 webhooks; an invalid URL, an event the format does not have or one more webhook gives 422 invalid_webhook with details.

Get, change or remove a webhook

GET /api/v2/webhooks/{id} (operation getWebhook, scope webhooks:read) returns it. PATCH /api/v2/webhooks/{id} (operation updateWebhook, scope webhooks:write) changes the properties given, as above, except the format; a url given replaces the user name and password; {"enabled": false} switches it off, {"enabled": true} on again (which clears disabled_reason and failing_since). auth_header and auth_header_value set the extra header (a name alone renames it and keeps its value; a value alone changes the value); {"auth_header_remove": true} removes both, and a read returns only the name. DELETE /api/v2/webhooks/{id} (operation deleteWebhook, scope webhooks:write) removes it with its deliveries: 204 No Content.

Rotate the secret

POST /api/v2/webhooks/{id}/secret (operation rotateWebhookSecret, scope webhooks:write)

Body (optional): {"keep_previous_for": 86400}, the seconds (0 to 604800, default a day) the previous secret keeps signing too (not in Mailgun's or SendGrid's format, which have room for one signature: the new key signs at once). Returns the webhook with its new secret, shown this once; in SendGrid's format a new key pair, whose public_key the webhook then shows. In Mailgun's format the server's other webhooks with the same key (those Mailgun's webhooks API made share one) get the new key too. 409 no_secret for a webhook in Postal's or Postmark's format.

Send a test event

POST /api/v2/webhooks/{id}/test (operation sendWebhookTest, scope webhooks:write)

Queues a webhook.test event for this webhook alone and returns its delivery (202 Accepted); 409 webhook_disabled while it is switched off.

List deliveries

GET /api/v2/webhooks/{id}/deliveries (operation listWebhookDeliveries, scope webhooks:read)

Query: state (pending, succeeded or failed), limit (1 to 200, default 50), before (a delivery id: continue after it). Newest first; when a page is full, next holds the id to pass as before.

{
  "data": [
    {
      "attempts": 2,
      "created_at": "2026-12-02T10:15:00.211532Z",
      "event_id": "019adf2e-5c4b-7d1a-9e2f-3a4b5c6d7e8f",
      "event_type": "message.delivered",
      "id": "019adf2e-5c53-7a2e-8f1b-2c3d4e5f6a7b",
      "last_attempt_at": "2026-12-02T10:16:03.402117Z",
      "last_error": "HTTP 503",
      "last_status": 503,
      "next_attempt_at": "2026-12-02T10:21:11.402117Z",
      "occurred_at": "2026-12-02T10:15:00.198004Z",
      "state": "pending"
    }
  ]
}

event_id is the webhook-id of its requests; attempts counts the requests made since it was queued or replayed.

Get a delivery

GET /api/v2/webhooks/{id}/deliveries/{delivery_id} (operation getWebhookDelivery, scope webhooks:read)

The delivery with payload, the body its requests send (in the webhook's format; in Mailgun's without signature, which each request makes anew), and requests, every request made for it, oldest first (replays included): number, url, address (connected to), status, response (the start of the answer's body) or error (in words), duration_ms, created_at.

Send deliveries again

POST /api/v2/webhooks/{id}/deliveries/{delivery_id}/replay (operation replayWebhookDelivery, scope webhooks:write) sends one delivery again: 202 Accepted with the delivery; 409 delivery_pending while it is still being sent.

POST /api/v2/webhooks/{id}/replay (operation replayWebhookDeliveries, scope webhooks:write) sends again the webhook's deliveries of events that happened in a time range: body (optional) from, to (date-times) and states (["failed"] by default, the dead letters; "succeeded" may be added). At most 10,000 per request, oldest first; 202 Accepted with {"count": n}. Both give 409 webhook_disabled while the webhook is switched off.

The Postal signing key

GET /api/v2/postal-key (operation getPostalSigningKey, scope webhooks:read) returns the organisation's key that signs its requests in Postal's format: kid (sent as X-Postal-Signature-KID), bits, jwks_url (the organisation's JWK set), jwk (the active key's public JWK), dns_record (the public key in Postal's DNS record form) and created_at. The key is made when it is first needed; reading it makes it if there is none. It is rotated in a release command or on a Postal-format webhook's page; the old key stays in the JWK set for a week and jwks_url does not change. Only public values are returned; the private key never is.

Receiving mail

Routes, endpoints and received messages (Receiving mail). Scopes routes:read (reading) and routes:write (changing). Ids in paths are UUIDs; another server's records are not found.

Endpoints

GET /api/v2/endpoints (operation listInboundEndpoints), POST /api/v2/endpoints (createInboundEndpoint), GET, PATCH and DELETE /api/v2/endpoints/{id} (getInboundEndpoint, updateInboundEndpoint, deleteInboundEndpoint).

PropertyTypeNotes
namestring, requiredat most 200 characters
kindstring, requiredhttp, smtp or address; it cannot be changed later
urlstringhttp: https:// (http:// only where the instance allows it); a user name and password in it (https:// only) are kept apart and sent as Basic authentication
formatstringhttp: karta (the default), raw, postal, postal_hash, mailgun, sendgrid or postmark (HTTP endpoints); it cannot be changed later
encodingstringpostal and postal_hash: json (the default) or form; mailgun: form (the default), mime or json; none for the others
host, port, tlsstring, integer, stringsmtp: a host name or address; port 25; opportunistic (the default), encrypted or verified
addressesarrayaddress: one to ten addresses
auth_headerstringhttp: an extra header sent with every request beside the format's signature (an HTTP token; see Header authentication)
auth_header_valuestringhttp: the header's secret value: printable ASCII, shown once, in this answer
{"name": "Orders inbox", "kind": "http", "url": "https://app.example.com/inbound"}

201 returns the endpoint with secret (whsec_..., shown this once) for HTTP endpoints in Karta's formats and Mailgun's (it is the signing key a Mailgun receiver verifies with); Postal's formats are signed with the key of the endpoint's organisation, and SendGrid's and Postmark's authenticate with the URL's user name and password or an extra header. An auth_header_value is shown once too, in the answer that sets it. Endpoints never show a secret, a header value or a password again (basic_auth_user is the user name). A PATCH sets the extra header like a webhook's, {"auth_header_remove": true} removes it, and only an HTTP endpoint has one. Removing an endpoint that a route uses answers 409 endpoint_in_use.

Routes

GET /api/v2/routes (operation listInboundRoutes), POST /api/v2/routes (createInboundRoute), GET, PATCH and DELETE /api/v2/routes/{id} (getInboundRoute, updateInboundRoute, deleteInboundRoute).

PropertyTypeNotes
domainstring, requireda verified domain of the server's organisation; it cannot be changed later
local_partstring, requiredletters, digits, ., _ and - (no +), or *
modestringendpoint (the default), accept, report (stored and read as a DMARC or TLS report), hold or reject
endpoint_idstringmode endpoint or hold, or spam_mode hold: an endpoint of the server (where a held message is delivered when it is released)
plus_addressingbooleandefault true: name+anything is received as name
dmarc_rejectbooleandefault true: mail that fails DMARC for a domain whose policy is reject is refused; false accepts it, marked
spam_modestringmark (the default), hold or reject: what happens when the scanners score a message at or above spam_threshold (Spam and virus scanning)
spam_thresholdnumberdefault 6.0, from 0 to 100: the score from which the message is spam for this route
fail_closedbooleandefault true: a scanner that cannot answer refuses the message (451 4.7.1); false accepts it, marked
{"domain": "example.com", "local_part": "orders", "endpoint_id": "019b3c2a-..."}

A domain of another organisation, or one not verified, answers 422 invalid_route with /domain. Answers carry address (orders@example.com). Changes reach the mx listeners of every node at once.

Get a received message

GET /api/v2/inbound/messages/{id} (operation getInboundMessage, scope routes:read): the envelope, the header's Message-ID, From and Subject, the size, and a delivery per recipient: status (pending, delivered, failed, accepted, held), attempts, next_attempt_at, the last answer (last_code, last_details), the route and endpoint, and forward_message_id for a forward (an outgoing message, read with GET /api/v2/messages/{id}).

scan is what the scanners said (Spam and virus scanning): spam (status scanned, unavailable, too_large or disabled; when it was scanned, the score, rspamd's action, the required_score, is_spam (the score reached the threshold of one of the message's routes) and the symbols, each with its name, score and description; a reason when it could not answer) and virus (status clean, unavailable, too_large or disabled, and the name of a signature when it found one). It is absent for a message received before scanning was recorded.

authentication is what Karta found out about the sender (Checking the sender): the client's ip, its helo name and the mail_from; spf and spf_helo (result, the domain checked, a reason for errors); dkim, one per signature (result, domain, selector, algorithm); dmarc, one per author domain (result, domain, the policy that applies and its policy_domain, testing, spf_aligned, dkim_aligned, override (arc when a trusted ARC sealer's results made Karta accept a failure), and the published record's p, sp, np, adkim, aspf and t); arc, the message's ARC chain (result none, pass or fail, a reason for fail, the number of sets, oldest_pass and the sealers' instance, domain and selector); and the authserv_id of the Authentication-Results: field Karta added.

{
  "ip": "192.0.2.25",
  "helo": "mail.example.org",
  "mail_from": "ann@example.org",
  "spf": {"result": "pass", "domain": "example.org"},
  "spf_helo": {"result": "none", "domain": "mail.example.org"},
  "dkim": [{"result": "pass", "domain": "example.org", "selector": "s1", "algorithm": "ed25519_sha256"}],
  "dmarc": [{"result": "pass", "domain": "example.org", "policy": "reject", "policy_domain": "example.org",
             "testing": false, "spf_aligned": true, "dkim_aligned": true,
             "published": {"p": "reject", "adkim": "relaxed", "aspf": "relaxed", "t": false}}],
  "arc": {"result": "pass", "sets": 1, "oldest_pass": 0,
          "sealers": [{"instance": 1, "domain": "lists.example.org", "selector": "s1"}]},
  "authserv_id": "mx.example.net"
}

Release the held deliveries

POST /api/v2/inbound/messages/{id}/release (operation releaseInboundMessage, scope routes:write) delivers a received message's held deliveries to the endpoints they were held for, as if it had just been accepted: each becomes pending and gets its job (one per delivery to an HTTP endpoint, one per SMTP or address endpoint). 200 answers with the message as getInboundMessage does; 409 not_held when nothing of it is held; 404 for an outgoing message, a message of another server, or none. A second release releases nothing.

The OpenAPI document

GET /api/v2/openapi.json needs no key. It lists the operations above with their schemas and the bearer security scheme. Generate a client from it with any OpenAPI 3.1 generator. The copy published with this documentation is produced from the same code when the documentation is built (mix openapi.spec.json --spec KartaWeb.API.V2.Spec).