API Keys
Create, manage, and secure your MisarMail API keys
All MisarMail API requests authenticate with an API key. Keys are scoped, revocable, and tied to your account.
Format: msk_ + 64 hex chars. Header: Authorization: Bearer msk_.... Create in Settings → API Keys. Key shown once — store it immediately.
Key Format
msk_a1b2c3d4e5f6... # 68 characters total: msk_ + 64 hexCreating a Key
Go to Settings → API Keys
Give your key a name (e.g., "Production", "MisarDev Integration")
Choose the scopes your integration requires (see table below)
The full key is shown exactly once. Copy it to a password manager or secrets vault immediately.
You cannot retrieve the key secret after creation. If lost, revoke it and create a new one.
Available Scopes
| Scope | Access |
|---|---|
send | Send transactional and marketing emails |
send:transactional | Send transactional emails only |
send:marketing | Send marketing/campaign emails only |
contacts | Full contact CRUD |
campaigns | Campaign management |
templates | Template management |
automations | Automation workflows |
analytics | Analytics and reporting |
validate | Email validation |
track | Event and purchase tracking |
track:events | Custom event tracking only |
track:purchase | Purchase event tracking only |
inbound | Inbound email domain management |
inbound:read | Read inbound config |
inbound:write | Create/update inbound config |
ips | Dedicated IP management |
ips:read | Read IP config |
ips:write | Manage IPs |
sandbox | Sandbox mode access |
monetization | Tip/monetization features |
read | Read-only access to contacts and tests |
Use the most restrictive scopes needed for your integration. A key used only for sending transactional emails should have send:transactional, not the broader send scope.
Using a Key
Include the key in every request using the Authorization: Bearer header:
curl https://api.misar.io/mail/v1/send \
-H "Authorization: Bearer msk_your_key_here" \
-H "Content-Type: application/json" \
-d '{...}'const res = await fetch("https://api.misar.io/mail/v1/send", {
headers: {
Authorization: `Bearer ${process.env.MISARMAIL_API_KEY}`,
"Content-Type": "application/json",
},
method: "POST",
body: JSON.stringify({ /* ... */ }),
});import os, requests
requests.post(
"https://api.misar.io/mail/v1/send",
headers={"Authorization": f"Bearer {os.environ['MISARMAIL_API_KEY']}"},
json={ /* ... */ },
)OAuth 2.0 (Authorization Code + PKCE)
For third-party integrations that act on behalf of a MisarMail user — such as ChatGPT Actions and Google Gemini — MisarMail supports the OAuth 2.0 Authorization Code flow with PKCE. Use this instead of a static msk_ key when a user grants a connected app access to their account.
| Endpoint | URL |
|---|---|
| Authorization | https://api.misar.io/mail/oauth/authorize |
| Token | https://api.misar.io/mail/oauth/token |
The flow is the standard Authorization Code + PKCE exchange: redirect the user to the authorization endpoint with a code_challenge, then exchange the returned code for an access token at the token endpoint using the matching code_verifier. The resulting bearer token is sent the same way as an API key:
curl https://api.misar.io/mail/v1/send \
-H "Authorization: Bearer <oauth_access_token>" \
-H "Content-Type: application/json" \
-d '{...}'OAuth Scopes
| Scope | Access |
|---|---|
send | Send emails on behalf of the user |
send:transactional | Send transactional emails only |
send:marketing | Send marketing campaigns only |
read | Read inbox, emails, and campaign analytics |
write | Create and manage campaigns, templates |
contacts | Manage contact lists |
validate | Validate email addresses |
inbound | Full inbound email domain management |
inbound:read | Read inbound domains |
inbound:write | Create and delete inbound domains |
ips | Full dedicated IP management |
ips:read | Read dedicated IP details |
ips:write | Request and update dedicated IPs |
analytics | Read analytics and reporting data |
sandbox | Send to sandbox (test mode) |
Listing and Revoking Keys
Key management endpoints require a Supabase session cookie — use them from the MisarMail settings UI, not from external apps.
| Method | Endpoint | Purpose |
|---|---|---|
GET | /api/v1/keys | List your keys (prefix only — secret never returned) |
POST | /api/v1/keys | Create a new key |
DELETE | /api/v1/keys?id=<uuid> | Revoke a key immediately |
Security Best Practices
Environment Variables
Store keys in .env files. Never hardcode in source code.
One Key Per App
Use separate keys for dev, staging, and production environments.
Rotate Regularly
Revoke old keys and create new ones periodically.
Git Ignore
Add .env and .env.local to .gitignore.
Error Responses
401 — Invalid Key
{
"success": false,
"error": "Invalid or missing API key. Use: Authorization: Bearer msk_..."
}403 — Wrong Sender
{
"success": false,
"error": "'from.email' is not a verified account for this API key"
}403 — Missing Scope
{
"success": false,
"error": "API key does not have 'send' scope"
}