Skip to main content

Start here

  1. Hosted MCP: add https://migma.ai/mcp and approve in the browser. See MCP Server. IT reviewers: MCP for IT admins.
  2. CLI: run migma login. Same browser sign-in; the key is stored locally.
  3. Direct agents without a working OAuth callback: fetch https://api.migma.ai/auth.md and approve the claim code. They must be able to call the API, poll, and securely store the returned credential. See Agent registration.
  4. CI and servers: set MIGMA_API_KEY. Create a Settings key only for this case.

API Keys

Migma.ai uses API keys to authenticate requests. Browser OAuth and claim-code both mint a key for you. Keep keys out of client-side code and git.

Creating a CI API Key

Use this only for CI, cron, or server automation. Agents and the CLI should not start here.
1

Navigate to Settings

Log in to migma.ai and go to Settings → Developers → API Keys
2

Create New Key

Click Create API Key in the API Keys tab
3

Configure Permissions

Give your key a name and select the permissions it needs
4

Save Securely

Copy the key immediately - it won’t be shown again!
API keys are shown only once at creation. Store them securely in a password manager or environment variables.

Using Your API Key

Include your API key in the Authorization header of every request:

Example Request

Node.js SDK
cURL
JavaScript
Python

API Key Permissions

When creating an API key, you can grant specific permissions to limit what the key can access.

Audience Permissions

Follow the principle of least privilege: only grant the permissions your application needs.
email:send allows test and direct email. campaign:write allows campaign creation, send, and schedule. Omitting scope grants the full permission set — the approval page shows every permission and marks send as destructive. Pass an explicit scope to narrow access.

Environment-Specific Keys

Use different API keys for different environments:
Development
Production
Test keys start with sk_test_ and production keys start with sk_live_

Security best practices

  • Never hardcode keys — use environment variables: const migma = new Migma(process.env.MIGMA_API_KEY)
  • Least privilege — only grant the permissions your integration actually needs
  • Rotate periodically — create a new key, update your app, then revoke the old one
  • Monitor usage — check last-used dates in Settings → Developers → API Keys and revoke anything unexpected
  • Remote agents — keep claim tokens and returned keys out of chat, logs, shell history, and shared remote-computer files

Key Management

Viewing Your Keys

Navigate to Settings → Developers → API Keys to see:
  • Key name and ID (first 8 characters)
  • Permissions granted
  • Creation date
  • Last used date
  • Usage statistics

Revoking a Key

If a key is compromised or no longer needed:
1

Find the Key

Go to Settings → Developers → API Keys
2

Delete

Click the delete icon next to the key
3

Confirm

Confirm the deletion - this action cannot be undone
Revoking a key will immediately invalidate it. Any applications using that key will receive 401 Unauthorized errors.

Error Responses

401 Unauthorized

Your API key is invalid or missing:
Common causes:
  • API key not included in Authorization header
  • Wrong format (must be Bearer YOUR_KEY)
  • Key has been revoked
  • Using test key in production environment

403 Forbidden

Your API key doesn’t have permission for this action:
Solution: Create a new key with the required permissions or update the existing key’s permissions.

Rate Limiting

API keys are subject to rate limits based on your plan: Rate limit headers are included in every response:
When you exceed the rate limit, you’ll receive a 429 Too Many Requests response:
Implement exponential backoff when you receive 429 responses to avoid further rate limiting.

Need help?

Quickstart

Get started with your first API call

Node.js SDK

SDK handles authentication automatically

CLI

migma login to authenticate the CLI

API Reference

Full endpoint documentation
Last modified on September 1, 2026