# Hyperleap AI auth.md

This guide is for AI agents, MCP clients, and API clients connecting to a
user's Hyperleap AI workspace.

- Application and account provisioning: https://studio.hyperleapai.com
- API resource and OAuth issuer: https://api.hyperleapai.com
- MCP endpoint: https://api.hyperleapai.com/mcp
- API documentation: https://hyperleap.ai/api-docs
- OpenAPI specification: https://hyperleap.ai/openapi.json

## 1. Discover authentication metadata

Fetch the resource server's public metadata:

https://api.hyperleapai.com/.well-known/oauth-protected-resource

The resource is `https://api.hyperleapai.com`. Its `authorization_servers`
advertises `https://api.hyperleapai.com`, its `scopes_supported` includes
`crm:read`, and its `bearer_methods_supported` includes `header`.

Fetch the advertised authorization server's metadata:

https://api.hyperleapai.com/.well-known/oauth-authorization-server

Verify that `issuer` matches the advertised authorization server. Read the
current authorization, token, registration, and revocation endpoint URLs
from this document before connecting.

The marketing site at https://hyperleap.ai also mirrors these two discovery
documents. Studio is the application; the API host is the resource server
and OAuth issuer.

## 2. Choose a supported method

- MCP: OAuth authorization code with PKCE (`S256`), with user authorization
  using an MCP key from Studio. The resulting access is scoped to `crm:read`.
- REST API: a workspace API key provisioned by the user in Studio, sent in
  the `x-hl-api-key` request header.

OAuth dynamic client registration registers a client, not a Hyperleap user
account, and does not grant workspace access. The current authorization
server does not advertise an Auth.md `agent_auth` block or anonymous,
verified-email, or ID-JAG agent account registration. Do not assume those
methods are available.

## 3. Register an MCP client and obtain user authorization

When the user requests a connection, an MCP client that needs a client ID
can send JSON to the advertised `registration_endpoint`, currently:

`POST https://api.hyperleapai.com/mcp/register`

Supply `client_name` and `redirect_uris` for the client. The response includes
`client_id`, `token_endpoint_auth_method: "none"`, and the supported grants
and response types. A registered redirect URI must also satisfy the
authorization server's redirect policy.

Have the user sign in at https://studio.hyperleapai.com and create an MCP
key from their profile's **My MCP Keys** menu. Follow the
[MCP setup guide](https://hyperleap.ai/help/integrations/crm-mcp/setup).

Open the advertised `authorization_endpoint`, currently
`https://api.hyperleapai.com/mcp/authorize`, with `response_type=code`,
`client_id`, `redirect_uri`, `state`, `code_challenge`,
`code_challenge_method=S256`, and `scope=crm:read`. The user enters their
MCP key on that authorization page. A regular REST API key is not an MCP key.

Validate the returned `state`. Exchange the authorization code at the
advertised `token_endpoint`, currently `https://api.hyperleapai.com/mcp/token`,
using an `application/x-www-form-urlencoded` POST with
`grant_type=authorization_code`, `code`, `redirect_uri`, `code_verifier`,
and `client_id`.

Use the returned `access_token`, `refresh_token`, and `expires_in` values.

## 4. Provision a REST API key

Ask the user to sign in at https://studio.hyperleapai.com and open
[Manage → API Keys](https://studio.hyperleapai.com/api-keys).
The user creates a labeled key and copies it when shown. See the
[API key guide](https://hyperleap.ai/api-docs/api-reference/api-keys).

This is user-managed provisioning. There is no agent account-registration
endpoint advertised by this guide.

## 5. Use credentials

For requests to `https://api.hyperleapai.com/mcp`, send the OAuth token as:

```http
Authorization: Bearer <access_token>
```

For REST API requests to `https://api.hyperleapai.com`, send:

```http
x-hl-api-key: <workspace_api_key>
```

Send credentials only to the intended API host over HTTPS. Store them in
the client's credential store and keep them out of URLs and logs.

## 6. Refresh, revoke, and recover

Refresh MCP tokens at the advertised token endpoint with a form-encoded
POST containing `grant_type=refresh_token` and `refresh_token`. Store the
tokens returned by the refresh response.

To revoke an OAuth token, use the advertised `revocation_endpoint`, currently
`https://api.hyperleapai.com/mcp/revoke`, with a form-encoded POST containing
`token`. If refresh fails with `invalid_grant`, request user authorization
again. For rejected REST keys, ask the user to check or replace the key in
Studio.

## Passive discovery

Read this guide and the public metadata using GET. Do not probe registration,
authorization, token, or revocation POST endpoints during a passive scan.
Do not call a guessed `/agent/auth` endpoint. Register or provision credentials
only when the user has requested a connection.
