# Postmark API keys: find, store, rotate, and use them safely with AI agents

Source: https://botpassword.com/keys/postmark
Last checked: 2026-10-25

Postmark uses a Server API token (per server, found on the server's API Tokens tab) for sending, and an Account API token (Account section → API Tokens) for account-level actions. Requests send them in the `X-Postmark-Server-Token` or `X-Postmark-Account-Token` header.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| Server API token | — | Yes | Sends messages, checks sent messages and uses the Bounce API; also the default SMTP credential | — |
| Account API token | — | Yes | Creates servers and adds Sender Signatures or Domains | — |
| SMTP token (Access Key and Secret Key) | — | Yes | SMTP sending for one Outbound Stream | — |

## How to create a Postmark key

1. Sign in to Postmark and open **Servers**, then pick a server.
2. Open the **API Tokens** tab to see the Server API token.
3. For the Account API token, open **API Tokens** in the Account section.

## Limiting what the key can do

Postmark scopes by token type and by server: a Server token only works on its own server. Which people can see which token depends on role (Account Owner, Account Admin, Server Admin). The articles researched describe no finer-grained permissions.

## How to rotate a Postmark key

1. Open the server's **API Tokens** tab.
2. Use the additional token slot (up to 3 per server) to introduce a new token, update callers, then retire the old one.

## How to revoke a Postmark key

1. Open the server's **API Tokens** tab and remove or regenerate the exposed token there.

## If the key leaked

1. Replace the exposed token from the server's API Tokens tab.
2. Update every deployment and secret store.
3. Check the server's activity for messages you did not send.

## Environment variables

- `POSTMARK_SERVER_TOKEN`

## Gotchas

- Server and Account tokens go in different headers and are not interchangeable.
- The value `POSTMARK_API_TEST` in the server token header sends test emails that are not delivered.
- The official MCP server is meant for local development use and reads `POSTMARK_SERVER_TOKEN` from a `.env` file.

## Using this key with AI agents (BotPassword)

- `run_with`: Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output.
- `http_request`: Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused.
- `rotate`: Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet.
- `store_secret`: Saves a value the agent already holds as a new vault item.

## FAQ

### Where do I find my Postmark server API token?

Open Servers, choose a server and open its API Tokens tab. Account Owners, Admins and Server Admins can see it.

### What is the difference between Postmark Server and Account API tokens?

A Server token sends messages and uses the Bounce API for one server. An Account token creates servers and adds sender signatures or domains.

### Is there a Postmark test API token?

Yes. Using `POSTMARK_API_TEST` as the server token sends test emails that are not delivered.

### Can an AI agent use my Postmark key without seeing it?

Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a `.env` file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with `run_with`, `http_request`, `store_secret`, so the agent gets the result and never the value.

## Sources

- https://postmarkapp.com/support/article/1008-what-are-the-account-and-server-api-tokens
- https://postmarkapp.com/developer/api/overview
- https://postmarkapp.com/lp/mcp/
