Provisioning API

The provisioning API lets an external system that signs customers up (a billing or sign-up application, an installer's own control plane) set them up in Karta without the admin pages. Karta knows nothing about that system: it sees a provisioning key and the system's own references.

It is part of /api/v2 but separate from the sending API: its own keys, its own OpenAPI document at /api/v2/provisioning/openapi.json, and no way to read a message.

Provisioning keys

An instance administrator makes a key from the command line, once for each system that provisions:

bin/karta eval 'Karta.Release.provisioning_key("sign-up system")'
# sign-up system (provisioning): kprov_k3xm2c9q_...   (shown this once)

bin/karta eval 'Karta.Release.provisioning_key("dashboard", ["provisioning:read"])'
bin/karta eval 'Karta.Release.revoke_provisioning_key("k3xm2c9q")'

A key is sent as Authorization: Bearer kprov_<prefix>_<secret>. Like the API keys of mail servers it is kept only as an Argon2id hash.

ScopeAllows
provisioningevery operation on this page
provisioning:readthe GET operations

A provisioning key belongs to no mail server and cannot read mail: no operation here returns a message, a recipient address or a message body, and the key is not accepted on any other API. A mail server's API key, for its part, is not accepted here. Requests are limited per key (600 a minute) and verifications per client address, as on the rest of /api/v2. Errors have the shape of /api/v2: {"error": {"code": "...", "message": "...", "details": [...]}}; the codes are listed in Driving Karta from your own system.

Idempotency

Every operation can be repeated safely. The natural key is a reference the calling system chooses, in the path: the organisation's reference, and below it a domain's name or a credential's reference. A PUT makes the record or returns the one that exists (201 the first time, 200 after); POST actions such as suspend leave the record as they made it; DELETE answers 204 whether or not the record was there. Two identical requests at the same moment make one record: the operations on one organisation take a lock in the database.

A secret (an API key or a password) is shown only when it is made. A repeated PUT returns the credential without it; to get a new secret, rotate.

Organisations

PUT /api/v2/provisioning/organisations/{ref} with {"name": "Acme"} makes the organisation for the reference ref (letters, digits and . _ : -, at most 128), with one mail server named "Default" that its domains, credentials and webhooks belong to. The slug is made from the name and made unique with a few random characters when another organisation has it, because customers share names.

curl -s -X PUT https://karta.example.com/api/v2/provisioning/organisations/cust-1001 \
  -H "Authorization: Bearer $KARTA_PROVISIONING_KEY" \
  -H "Content-Type: application/json" -d '{"name": "Acme BV"}'
{"reference": "cust-1001", "id": "01a2…", "name": "Acme BV", "slug": "acme-bv",
 "status": "active", "trust_level": "restricted",
 "created_at": "2026-12-01T10:00:00Z"}

status is active or suspended; a suspended organisation also shows its suspension_reason.

A second PUT with another name renames the organisation (its slug stays).

Operation
GET …/organisations/{ref}the organisation, 404 when there is none
POST …/organisations/{ref}/suspend with {"reason": "…"}stops all sending: its credentials are refused (server_suspended) and the mail it has queued waits, as for a server an administrator suspends. The reason is shown to the organisation (at most 230 characters; without one, "suspended by the provisioning system"). Repeating it changes the reason.
POST …/organisations/{ref}/resumelets it send again and delivers what waited. It lifts only what the suspension made: a server an administrator suspended stays suspended.
DELETE …/organisations/{ref}ends the organisation: sending stops, credentials are revoked, webhooks are switched off, domains are removed, the organisation no longer shows on any page, and the reference is free again. The organisation's mail is kept until retention removes it.

A server created in a suspended organisation (on the admin pages) starts suspended.

Domains

PUT …/organisations/{ref}/domains/{name} adds a sending domain (its name in any spelling: Example.com. and example.com are the same domain) with a first DKIM key (RSA, 2048 bits), or returns it. The answer says what to publish:

{"name": "example.com", "status": "pending",
 "records": [
  {"purpose": "ownership", "type": "TXT", "name": "_karta.example.com",
   "value": "karta-verification=…", "required": true, "note": "…"},
  {"purpose": "dkim", "type": "TXT", "name": "karta-x7k2m9qa._domainkey.example.com",
   "value": "v=DKIM1; k=rsa; p=…", "selector": "karta-x7k2m9qa", "required": true, "note": "…"},
  {"purpose": "spf", "type": "TXT", "name": "example.com",
   "value": "v=spf1 ip4:192.0.2.10 ~all", "required": true, "note": "…"},
  {"purpose": "dmarc", "type": "TXT", "name": "_dmarc.example.com",
   "value": "v=DMARC1; p=none", "required": false, "note": "…"},
  {"purpose": "mx", "type": "MX", "name": "example.com",
   "value": "10 mx.karta.example", "required": false, "note": "Only when …"}],
 "return_path": {"domain": "bounces.karta.example", "note": "…"},
 "checks": [], "created_at": "…"}
  • ownership proves the domain belongs to the organisation. Until it is found the domain is pending and nothing can be sent from it.
  • dkim: one record for each key that is not retired; the key signs once its record is in DNS.
  • spf is a suggestion made of the addresses Karta sends this organisation's mail from (Karta has no include: to name). A domain has one SPF record, so a domain that has one adds these mechanisms to it. value is left out, and note says why, while Karta cannot work the addresses out.
  • dmarc is a start; mx only matters when the domain's mail is received by Karta (the SMTP listeners must run).
  • return_path names the instance's bounce domain (KARTA_RETURN_PATH_DOMAIN, null when VERP is off). The owner of a sending domain publishes nothing for it.

POST …/domains/{name}/verify looks at DNS now: it verifies the domain when the ownership record is found, activates the first DKIM key when its record is, and runs the DNS health checks (checks: the status of each, as on the domain's page). Repeat it until status is verified; Karta also checks every hour. ownership says what the last check found: found, missing, taken (another organisation has verified the name) or failed (the lookup failed).

Lists (GET …/domains, …/credentials, …/webhooks) answer {"data": [...]}. GET …/domains lists the organisation's domains, GET …/domains/{name} is one, and DELETE …/domains/{name} removes it and its keys (204 also when it was not there). Deleting an organisation removes its domains.

Credentials

The credentials of an organisation's mail server, for its own applications, named by a reference the calling system chooses (letters, digits and . _ : -):

curl -s -X PUT .../organisations/cust-1001/credentials/web-app \
  -H "Authorization: Bearer $KARTA_PROVISIONING_KEY" -H "Content-Type: application/json" \
  -d '{"kind": "api", "scopes": ["messages:send"]}'
  • kind is api (a key for the sending API, with scopes; by default messages:send and messages:read, any of the scopes in API keys and scopes) or smtp (a login for SMTP submission: the answer has a username, and the secret is the password). rate_limit_per_minute is optional.
  • The first PUT answers 201 with the secret, which is shown this once (Karta keeps a hash). A repeated PUT answers 200 without it, setting the scopes and rate limit given. A different kind for a reference that exists is 409. At most 50 credentials are active at a time.
  • POST …/credentials/{cref}/rotate makes a new secret under the same reference and revokes the old one at once. A client that cannot be switched at one moment makes a second credential under another reference, moves, and deletes the first.
  • DELETE …/credentials/{cref} revokes (204, also when there is none); the reference can be used again. GET lists (revoked ones included) or shows credentials, never with a secret. Ending the organisation revokes them all.

A client that lost the answer to the first PUT does not get the secret again: it rotates.

Webhooks

PUT …/organisations/{ref}/webhooks/{wref} registers where the events of the organisation's mail server go, or updates the registration with that reference:

{"url": "https://hooks.example.com/karta", "events": ["message.delivered", "message.bounced"]}

events (default: every event of the format), format (standard, the default, is Standard Webhooks; Postal's, Mailgun's, SendGrid's and Postmark's formats are there for receivers written for them; chosen when the webhook is made) and enabled are optional. The first call answers 201 with the signing secret, once; a later one 200, setting the URL, events and enabled given. POST …/webhooks/{wref}/secret rotates the secret (in Standard Webhooks' format the old one keeps signing for a day); DELETE removes the webhook. URLs must be public https: addresses, as for every webhook (Webhooks). An organisation has at most 20.

Limits and the trust level

A new organisation can send only low-volume transactional mail until the calling system says otherwise. GET …/organisations/{ref}/limits shows where it stands and PUT sets it (what is left out stays; a limit of 0 removes it):

curl -s -X PUT .../organisations/cust-1001/limits \
  -H "Authorization: Bearer $KARTA_PROVISIONING_KEY" -H "Content-Type: application/json" \
  -d '{"trust_level": "standard", "daily_send_limit": 5000, "per_recipient_daily_limit": 20}'
{"trust_level": "standard", "daily_send_limit": 5000,
 "per_recipient_daily_limit": 20, "recipients_today": 132}
SettingMeaning
trust_levelrestricted holds back free-form and bulk sending: at most 5 recipients to a message (To, Cc and Bcc together) and no batches (one message to a request on the batch endpoints; SendGrid's several personalizations, Postmark's batch of several messages, Mailgun's recipient variables all count). standard holds nothing back.
daily_send_limitrecipients accepted per UTC day
per_recipient_daily_limitmessages accepted per UTC day for one recipient address (case does not matter)

An organisation made by this API starts restricted, with 100 recipients a day and 10 messages a day to one recipient. An operator can start new organisations differently with config :karta, Karta.Provisioning, defaults: [trust_level: :standard, daily_send_limit: 1000, per_recipient_daily_limit: 25]; organisations made on the admin pages are standard and unlimited. The organisation sees nothing of this except the refusals.

The limits are checked when Karta accepts a message, in the same database transaction, so they hold for every way in (SMTP submission and all five HTTP APIs) on every node, and two requests at the same moment cannot both pass the last of a limit. A message that would pass a limit is refused whole and counts for nothing; messages Karta writes itself (delivery status notifications, reports, forwards) are not counted. recipients_today counts only while a daily limit is set.

A refusal says which limit and, for the daily ones, when to try again:

HTTP (/api/v2)SMTP
daily limit, per-recipient limit429, code sending_limit_reached, Retry-After (seconds to midnight UTC)450 4.7.1: the client holds the message and tries again
restricted: too many recipients, batch403, code organisation_restricted550 5.5.3

The other APIs answer in their own forms: SendGrid and Mailgun 429 with Retry-After (or 403 when restricted), Postmark error code 405 (429 for the daily limits, 422 when restricted), Postal ServerSendLimitReached.