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.
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. email:send is highlighted because it allows sending from the account.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 open a browser OAuth approval flow.Step 1 — Register intent
type— required, must beservice_auth. Identity-assertion and anonymous registration are not supported yet.login_hint— required. The email of the user the agent acts for. It is display only; it grants nothing by itself.agent_name— optional. Shown to the user at approval. Use your product name.scope— optional, space-delimited. Omit for a read-mostly default. Request only what you need.
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 a read-mostly default; request only the scopes the agent needs. The available scopes are published in scopes_supported in the discovery document:
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.