Bouncewise

Bouncewise › Guides › Postmark Server API token vs Account API token

Postmark guide

Postmark Server API token vs Account API token

Updated · 2 min read

Short answer

The Server API token, sent in the X-Postmark-Server-Token header, belongs to one server and is what your app uses to send email and to work with that server's bounces, messages, streams, suppressions, stats, templates and webhooks. The Account API token, sent in X-Postmark-Account-Token, is for account-level work: creating and managing servers, domains and sender signatures. Give applications the server token; keep the account token for admin tooling, because it can reach every server.

Side by side

Server API tokenAccount API token
HeaderX-Postmark-Server-TokenX-Postmark-Account-Token
ScopeOne serverThe whole account
Where to find itThe server's API Tokens tabAPI Tokens in the Account section
Who can see itAccount Owners, Account Admins, and Server Admins for their serversAccount Owner and Account Admins
How manyUp to 3 per serverUp to 3
Used forSending (Email, batch, templates), Bounce, Messages, Message Streams, Suppressions, Stats, Webhooks, Server API; also the default SMTP credentialsServers API, Domains, Sender Signatures, pushing templates between servers, data removal requests

Each endpoint's reference page names the header it needs. The header name and value are case-insensitive.

Which one does my request need?

Anything about mail on one server takes the server token:

curl "https://api.postmarkapp.com/bounces?count=10&offset=0" \
  -H "Accept: application/json" \
  -H "X-Postmark-Server-Token: $POSTMARK_SERVER_TOKEN"

Anything about the account's structure takes the account token:

curl "https://api.postmarkapp.com/servers?count=50&offset=0" \
  -H "Accept: application/json" \
  -H "X-Postmark-Account-Token: $POSTMARK_ACCOUNT_TOKEN"

Send the wrong one and Postmark answers 401 with ErrorCode 10: Request does not contain a valid Server or Account token, or the wrong token type was used for the endpoint.

HTTP/1.1 401 Unauthorized
{"ErrorCode": 10, "Message": "..."}

The common mistakes: calling /domains or /servers with a server token, and trying to send with the account token. The account token can't send mail; the Email API only accepts a server token.

Least privilege: what each token can change

Neither token is read-only, so treat both as secrets:

  • Server token: send email from your confirmed senders through that server, reactivate bounces, add and remove suppressions, retry or bypass inbound mail, edit the server's settings and webhooks.
  • Account token: create and edit servers, add domains and sender signatures, change a domain's Return-Path and rotate its DKIM keys. The Servers API also returns each server's ApiTokens, so whoever holds the account token can get every server token too.

For SMTP, prefer an SMTP Token generated in a stream's Settings tab: it is tied to that one stream, and its secret key is only shown once.

Connect screen asking for a Postmark Server or Account API token, with a note that it stays on the device
A server token is enough for one server; an account token lists them all.

Rotate a token

For a server token: open the server, choose API Tokens, select Generate New, deploy the new token, then delete the old one. For the account token: on the Account page's API Tokens tab, click Generate another token; existing tokens keep working until you delete them, and with three tokens you must delete one before generating another.

Keep both tokens on the server side: in a secret store or environment variable, never in front-end JavaScript, a public repository or a log line. If one leaks, generate a new one first, switch your app to it, and only then delete the old token so sending doesn't stop. Give each application or environment its own server (and so its own token) where you can; then revoking one doesn't affect the rest.

For tests that shouldn't deliver mail, pass POSTMARK_API_TEST as the server token value; Postmark checks the request without sending it.

Questions

Can the Postmark account token send email?

No. Sending endpoints take the X-Postmark-Server-Token header; use the token of the server you want to send from.

Where is my Postmark server token?

Open the server in Postmark and go to its API Tokens tab. Account Owners and Admins see tokens for every server; Server Admins see them for their own servers.

Is the server token the same as the SMTP password?

The server API token also works as the default SMTP credentials. You can generate per-stream SMTP Tokens instead, with an access key and a secret key.

Why do I get a 401 with a token I just copied?

Usually the token is in the wrong header for that endpoint (server vs account), or has extra whitespace. Postmark returns ErrorCode 10 for both.

Sources