Agent registration is in beta. For the user-facing overview of how approval works, see Agent registration. This page is the deeper protocol reference for developers building agents.
https://api.migma.ai
The skill file an agent reads is served at https://api.migma.ai/auth.md.
Discovery
Agents discover the endpoints and supported scopes from the well-known metadata. Theagent_auth block in the authorization-server document lists the claim and identity endpoints.
scopes_supported, authorization_endpoint, registration_endpoint, token_endpoint, grant_types_supported, PKCE support, and the agent_auth endpoint map.
An agent that hits a protected API without a valid key receives 401 with a WWW-Authenticate challenge that points back to the protected-resource metadata, so it can find this flow:
/.well-known/oauth-protected-resource/mcp).
Endpoints
The claim page endpoints (
/agent/identity/claim/lookup and /agent/identity/claim/complete) are used by the Migma web UI when the user enters their code. Agents do not call them.
First-party clients
A host-app extension published by Migma — today the Figma plugin — registers withclient_id instead of login_hint, because it runs inside another product and cannot know the user’s Migma account until they approve. The server, not the client, then decides the display name, the key name and the scopes, so a first-party client cannot widen its own grant:
In-product sign-up
Those clients meet people who have no Migma account at all, and sending them to a registration form in another window loses most of them.POST /agent/identity/signup creates the account where they already are:
claim_token— required. Must belong to a pending, unexpired registration made by a first-partyclient_id; anything else is rejected.email— required. A conflict with an existing account answers409 account_exists.first_name— required.last_nameandwebsiteare optional;websiteseeds the brand import and is normalised to a hostname.- No password is accepted. The account is created passwordless and the person receives a link to set one, which also proves they own the address.
POST /oauth2/token exactly as it would after a browser approval, so a key is minted in one place regardless of how the account came to exist.
This endpoint is not open to third-party agents, and it can be switched off server-side with AGENT_AUTH_SIGNUP_ENABLED=false without affecting sign-in for existing accounts.
Authorization-code flow
Use this OAuth path for MCP clients that can open a browser approval flow.1
Discover Migma auth metadata
Read
https://api.migma.ai/.well-known/oauth-authorization-server to find the registration, authorization, token, and scope metadata.2
Register the client
Register with a client name and redirect URI. Migma supports public clients with
authorization_code, code, and token_endpoint_auth_method: none. Redirect URIs must use HTTPS, except localhost and 127.0.0.1 may use HTTP for local clients.3
Start authorization with PKCE
Send the user through the authorization endpoint with
response_type=code, the registered client_id, redirect_uri, requested scope, and PKCE S256. PKCE is required.4
User approves on Migma
Migma shows the consent page at
migma.ai/connect/authorize. The user signs in, reviews the client name, return host, and requested scopes, then approves or denies access. Migma marks email:send and campaign:write as delivery access.5
Exchange the code
Exchange the code at the token endpoint with the same
client_id, redirect_uri, and PKCE verifier. The response contains a scoped Migma API key in access_token.Claim-code fallback
Use this path when the agent cannot complete a browser OAuth redirect/callback but can call the API, poll, and securely store the once-only credential. Claim-code does not repair a broken hosted connector.Step 1 — Register intent
type— required, must beservice_auth. Identity-assertion and anonymous registration are not supported yet.login_hint— optional. The email of the user the agent acts for, shown on the approval page. It is display only; identity binds to whoever signs in and approves.agent_name— optional. Shown to the user at approval. Use your product name.scope— optional, space-delimited. Omit it for the full permission set; the approval page is the gate. Pass it only to narrow access.
Step 2 — Send the user to approve
Surfaceverification_uri_complete (or verification_uri plus user_code) to the user. They sign in to Migma, review the agent name and requested scopes, and confirm the code.
Step 3 — Poll for the key
Poll the token endpoint everyinterval seconds (default 5):
Success body:
Step 4 — Refresh an expired user code
Only when polling returnedexpired_token:
claim object with a new user_code. The whole registration expires one hour after Step 1; after that, start over.
Code lifecycle
- The
user_codeexpires afterexpires_inseconds (600 by default). - Refresh an expired code with
POST /agent/identity/claimusing the sameclaim_token. - The whole registration expires one hour after Step 1.
- The
access_tokenis issued exactly once; re-polling after issuance returnsinvalid_grant.
Poll loop example
Scopes
Scopes are space-delimited in thescope field of Step 1. Omit the field for the full permission set — the approval page lists every permission and marks send as destructive. Pass an explicit list to narrow access. The available scopes are published in scopes_supported in the discovery document:
Omitted
scope includes both billing scopes on every path.
Using the credential
Theaccess_token is an ordinary Migma API key. Send it as a bearer token and discover a project to work in:
projectId per request; a resource in a project you did not name returns 404. The key works everywhere a Migma key works: the REST API, the SDK, the CLI, and MCP, typically by setting MIGMA_API_KEY.
Revocation
Agent keys appear in the Migma dashboard under Settings → Developers → API Keys alongside your own keys. The user can revoke one at any time. A revoked key fails with401; the agent should re-register to obtain a new one.