Skip to main content
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.
Migma follows the auth.md convention, so an agent can discover the flow and obtain its own scoped API key without a human copying a secret. Browser-capable MCP clients should use the OAuth authorization-code flow. Agents that cannot open a browser approval flow can use the claim-code fallback. Base URL: 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. The agent_auth block in the authorization-server document lists the claim and identity endpoints.
The authorization-server document includes 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:
The MCP endpoint returns the same challenge pointing at its own resource metadata (/.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.
Success body:
The key works anywhere a Migma API key works, including the hosted MCP server. It appears in Settings → Developers → API Keys and can be revoked there. No refresh token is issued.

Claim-code fallback

Use this path when the agent cannot open a browser OAuth approval flow.

Step 1 — Register intent

  • type — required, must be service_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.
Response:

Step 2 — Send the user to approve

Surface verification_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 every interval seconds (default 5):
Responses: Success body:
The access_token is a Migma platform API key and is returned exactly once — store it securely now. Further polls return invalid_grant.

Step 4 — Refresh an expired user code

Only when polling returned expired_token:
Returns a fresh claim object with a new user_code. The whole registration expires one hour after Step 1; after that, start over.

Code lifecycle

  • The user_code expires after expires_in seconds (600 by default).
  • Refresh an expired code with POST /agent/identity/claim using the same claim_token.
  • The whole registration expires one hour after Step 1.
  • The access_token is issued exactly once; re-polling after issuance returns invalid_grant.

Poll loop example

Scopes

Scopes are space-delimited in the scope 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

The access_token is an ordinary Migma API key. Send it as a bearer token and discover a project to work in:
The key is account-scoped, so pass 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 with 401; the agent should re-register to obtain a new one.