# Authentication

> API keys for your servers and OAuth 2.1 sign-in for AI clients: how each credential is sent, what it can do and when it stops working.

Every request that is not from a person in the Funnel One app carries a
credential. Whatever the credential, one rule holds: **it can never do more
than the person accountable for it can do in that workspace.**

## The credentials

| Credential | Looks like | Acts as | Use it for |
|---|---|---|---|
| API key | `f1_sk_…` (older keys: `amp_…`) | Its owner, narrowed to the key's scopes | Server-to-server REST calls |
| OAuth access token | `f1_at_…` | The person who signed in, narrowed to what they allowed | Claude, ChatGPT, Cursor and other MCP clients, and apps that call the REST API for a person |

Personal access tokens (`f1_pat_…`) are not available: nothing in Funnel One
creates one. Where the API reference mentions a personal token, such as the
`user` principal of `GET /api/v1/me`, that `user` is always an OAuth access
token.

The prefixes exist so a secret scanner can recognize a leaked credential.
Funnel One stores every credential only as a hash, so it cannot show you one
again after it is created.

Every API key has an owner: the admin who created it. An older `amp_` key
keeps working, and works exactly like a new one.

## Sending a credential

Send it in the `Authorization` header as a bearer token, from a server:

```http
Authorization: Bearer <credential>
```

Never in a query string, a form field or browser code. A credential in a URL
ends up in logs, proxies and `Referer` headers.

## What a credential can do

A credential carries [scopes](https://dev.funnelone.ai/get-started/scopes/), the same permission names
the app's roles use.

- **API key:** an admin who can manage API keys (`api.manage`) creates keys
  in **Integrations**, then **Workspace integrations**, then **MCP & API**, then
  **API keys**. A key can do what its owner's role allows right now, narrowed
  to the scopes ticked on the key. If the owner's role is narrowed, the key is
  narrowed on its next request. If the owner leaves the workspace, the key
  stops working. An admin can revoke a key at any time, and it stops at once.
- **OAuth token:** what the person's role allows right now, narrowed to what
  they allowed on the consent page. If they leave the workspace, everything
  they connected stops working. The person can revoke a connected app in
  **Integrations**, then **AI clients**, and an admin can revoke any of the
  workspace's connected apps in **MCP & API**, then **Connected apps**.

Effective scopes are worked out again on every request, never at the moment
the credential was issued. A request that lacks a scope is refused with
`403 insufficient_scope`, naming every missing scope at once. See
[Errors](https://dev.funnelone.ai/rest/errors/).

A credential belongs to exactly one workspace. The workspace comes from the
credential itself, never from anything in the request.

Each surface also has a workspace switch in **MCP & API**: **REST API** for
`/api/v1` and **MCP server** for `/mcp`. Both are off until an admin turns
them on. Turning one off stops every credential on that surface on its next
request.

If the workspace requires two-factor authentication and the person behind an
OAuth token has not set it up in time, their connections are paused, not
removed: every request answers `403 two_factor_required` until they set it
up, and then works again with nothing to reconnect.

## OAuth 2.1 for MCP clients

Funnel One is its own OAuth 2.1 authorization server, on the same host as the
MCP server. An MCP client sets itself up from the server's replies, so the
person only pastes one URL.

1. The client calls `https://app.funnelone.ai/mcp` without a token and gets
   `401` with a `WWW-Authenticate` header that points at
   `/.well-known/oauth-protected-resource/mcp`.
2. From there it reads the authorization server's metadata at
   `/.well-known/oauth-authorization-server`.
3. It identifies itself, either with a client metadata document (a URL it
   hosts) or by registering at `/oauth/register`. Registered clients are
   public clients: there is no client secret. A registered client has no
   access to anything until a person consents.
4. It opens `/oauth/authorize` in the person's browser, with PKCE (`S256`
   only) and `resource=https://app.funnelone.ai/mcp`.
5. The person signs in and sees the consent page (below).
6. The client exchanges the code at `/oauth/token`, sending
   `application/x-www-form-urlencoded`, and receives tokens.
7. It calls `/mcp` with `Authorization: Bearer f1_at_…`.

### What the consent page shows

- the app that is asking, labeled **Unverified** unless Funnel One recognizes
  it (Claude, Claude Code, ChatGPT and Cursor's web sign-in are recognized);
- where the app will be sent back to, marked **Loopback** when that is your
  own computer (`localhost`);
- a workspace picker when you belong to more than one: a sign-in grants
  access to one workspace only;
- each permission the app asked for, grouped by area. Anything your role does
  not include is shown as unavailable and cannot be granted.

### Tokens

| Token | Lifetime |
|---|---|
| Authorization code `f1_code_…` | 60 seconds, used once |
| Access token `f1_at_…` | 1 hour |
| Refresh token `f1_rt_…` | Replaced on every use; expires after 30 days unused, or 90 days in all |

A refresh token works once. Presenting one that was already used revokes the
whole sign-in, because that is what a stolen token looks like. A client can
revoke its own tokens at `/oauth/revoke`.

### A token works in one place

A token is bound to the resource it was issued for. A token for
`https://app.funnelone.ai/mcp` is refused by the REST API at
`https://app.funnelone.ai/api/v1`, and the reverse.

Source: https://dev.funnelone.ai/get-started/authentication/
