Authentication
How an MCP client gets and uses Zoie access tokens: RFC 9728 and RFC 8414 discovery, dynamic client registration or a client ID metadata document, the authorisation code flow with PKCE, token lifetimes and rotation, scopes per tool, the 401 challenge and revocation.
The Zoie MCP server is an OAuth 2.1 protected resource. Tokens are issued by Zoie’s authorisation server, https://api-us.zoie.ai. A client that implements the MCP authorisation specification needs no Zoie-specific code: it discovers everything from the server’s 401 response.
This page covers the protocol. For what the user sees on the consent screen, see Authentication and Access permissions in the MCP guides.
Endpoints
| Purpose | Endpoint |
|---|---|
| Protected resource metadata (RFC 9728) | GET https://mcp-us.zoie.ai/.well-known/oauth-protected-resource |
| Authorisation server metadata (RFC 8414) | GET https://api-us.zoie.ai/.well-known/oauth-authorization-server |
| Dynamic client registration (RFC 7591) | POST https://api-us.zoie.ai/oauth/register |
| Authorisation | GET https://api-us.zoie.ai/oauth/authorize |
| Token | POST https://api-us.zoie.ai/oauth/token |
| Token revocation (RFC 7009) | Not offered — see Revocation. |
The flow
- Call the MCP server without a token and receive
401with aWWW-Authenticateheader naming the metadata document. - Fetch the protected resource metadata, then the authorisation server metadata it points to.
- Register the client, once, with dynamic client registration — or use a client ID metadata document instead.
- Send the user to the authorisation endpoint with a PKCE challenge. Zoie signs them in and shows the consent screen, where they pick the business and permissions.
- Receive the code on your redirect URI and exchange it, with the PKCE verifier, for an access token and a refresh token.
- Call the MCP server with
Authorization: Bearer <access token>, refreshing the token before it expires.
Discovery
The challenge
Any request to https://mcp-us.zoie.ai/ without a valid token is refused:
curl -i -X POST https://mcp-us.zoie.ai/ \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'
HTTP/2 401
content-type: application/json; charset=utf-8
www-authenticate: Bearer realm="https://mcp-us.zoie.ai", resource_metadata="https://mcp-us.zoie.ai/.well-known/oauth-protected-resource", error="invalid_token", error_description="Missing bearer token"
{"error":"unauthorized","message":"Missing bearer token."}
Protected resource metadata
curl https://mcp-us.zoie.ai/.well-known/oauth-protected-resource
{
"resource": "https://mcp-us.zoie.ai",
"authorization_servers": ["https://api-us.zoie.ai"],
"scopes_supported": ["mcp:tools"],
"bearer_methods_supported": ["header"],
"resource_documentation": "https://mcp-us.zoie.ai/",
"resource_signing_alg_values_supported": ["HS256"]
}
| Field | Use |
|---|---|
resource | Send this as the resource parameter (RFC 8707) when you authorise. |
authorization_servers | The one authorisation server, https://api-us.zoie.ai. |
scopes_supported | mcp:tools is the OAuth-level scope. The per-area permissions are chosen on the consent screen — see Scopes. |
bearer_methods_supported | Tokens go in the Authorization header only. |
Authorisation server metadata
curl https://api-us.zoie.ai/.well-known/oauth-authorization-server
{
"issuer": "https://api-us.zoie.ai",
"authorization_endpoint": "https://api-us.zoie.ai/oauth/authorize",
"token_endpoint": "https://api-us.zoie.ai/oauth/token",
"registration_endpoint": "https://api-us.zoie.ai/oauth/register",
"response_types_supported": ["code"],
"grant_types_supported": ["authorization_code", "refresh_token"],
"code_challenge_methods_supported": ["S256"],
"token_endpoint_auth_methods_supported": ["none"],
"scopes_supported": [
"mcp:tools", "offline_access",
"leads:read", "leads:write",
"conversations:read", "conversations:write",
"appointments:read", "appointments:write",
"campaigns:read", "campaigns:write",
"notes:read", "notes:write",
"team:read", "search:read"
],
"resource_indicators_supported": true,
"client_id_metadata_document_supported": true,
"id_token_signing_alg_values_supported": ["HS256"],
"subject_types_supported": ["public"],
"authorization_response_iss_parameter_supported": true
}
Points to note:
- Public clients only. There are no client secrets; every client proves possession with PKCE.
offline_accessis advertised, but refresh tokens are issued whether or not you ask for it.- No OpenID Connect. Zoie doesn’t issue ID tokens and has no userinfo endpoint, despite the
id_token_signing_alg_values_supportedfield. isson callbacks (RFC 9207). Check that theissparameter on the redirect equalshttps://api-us.zoie.ai.
Registering a client
Use either dynamic client registration or a client ID metadata document. Both end up looking the same on the consent screen.
Dynamic client registration
curl -X POST https://api-us.zoie.ai/oauth/register \
-H 'Content-Type: application/json' \
-d '{
"client_name": "Acme Assistant",
"redirect_uris": ["https://assistant.acme.example/oauth/callback"],
"token_endpoint_auth_method": "none",
"logo_uri": "https://assistant.acme.example/logo.png"
}'const res = await fetch('https://api-us.zoie.ai/oauth/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
client_name: 'Acme Assistant',
redirect_uris: ['https://assistant.acme.example/oauth/callback'],
token_endpoint_auth_method: 'none',
logo_uri: 'https://assistant.acme.example/logo.png',
}),
});
const client = await res.json(); // 201 Created{
"client_id": "kq3Zt0X1u8vYd4Lr9mWb2sNfH6pJcE7a",
"client_id_issued_at": 1790899200,
"client_name": "Acme Assistant",
"redirect_uris": ["https://assistant.acme.example/oauth/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"token_endpoint_auth_method": "none",
"scope": "mcp:tools"
}
| Field | Required | Notes |
|---|---|---|
redirect_uris | Yes | A non-empty array of absolute URIs. The redirect_uri you send later must match one exactly. |
token_endpoint_auth_method | No | Only none is accepted. Anything else is refused with invalid_client_metadata. |
client_name | No | Shown on the consent screen as Authorize followed by the name. |
logo_uri | No | Shown on the consent screen. |
client_uri, policy_uri, tos_uri, contacts | No | Stored with the client. |
scope | No | Defaults to mcp:tools. |
grant_types and response_types are ignored: every client gets authorization_code and refresh_token. No client_secret or registration access token is returned, and there’s no endpoint to update or delete a registration.
| Status | error | error_description |
|---|---|---|
400 | invalid_redirect_uri | redirect_uris must be a non-empty array. or Invalid URI: … |
400 | invalid_client_metadata | Only public clients are supported (token_endpoint_auth_method=none). |
The consent screen shows a ✓ Verified publisher badge when every redirect URI is https on a host on Zoie’s verified list (claude.ai, chatgpt.com, chat.openai.com and cursor.com, and their subdomains, by default). Other clients are shown without the badge.
Client ID metadata documents
Instead of registering, a client can use the HTTPS URL of a JSON document it hosts as its client_id (draft-parecki-oauth-client-id-metadata-document). Zoie fetches the document when the user authorises.
{
"client_id": "https://assistant.acme.example/oauth/client.json",
"client_name": "Acme Assistant",
"redirect_uris": ["https://assistant.acme.example/oauth/callback"],
"logo_uri": "https://assistant.acme.example/logo.png"
}
| Rule | Detail |
|---|---|
| URL | https, with no fragment or user info, on a host that doesn’t resolve to a private, loopback or link-local address. Redirects aren’t followed. |
| Fetch | 5-second timeout, 16 KB maximum, must return 2xx JSON. |
client_id | Optional in the document, but if present it must equal the URL. |
redirect_uris | Required. Each must be https, http on localhost or 127.0.0.1, or a custom scheme, and must not contain a fragment. |
client_uri, logo_uri, policy_uri, tos_uri | Optional, https only. |
client_name | Optional, up to 256 characters. |
contacts, scope | Optional. |
| Authentication | Always treated as a public client, whatever token_endpoint_auth_method the document declares. |
| Caching | A valid document is cached for 1 hour, a failure for 5 minutes. |
A document hosted on a verified host counts as verified even if its redirect URIs use a custom scheme. A document Zoie can’t fetch or validate makes the authorisation request fail with invalid_client.
Authorising the user
PKCE
Only S256 is accepted; plain is refused. Create a random verifier and send its unpadded base64url SHA-256 hash as the challenge:
const base64url = (bytes) =>
btoa(String.fromCharCode(...new Uint8Array(bytes)))
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=+$/, '');
const codeVerifier = base64url(crypto.getRandomValues(new Uint8Array(32)));
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(codeVerifier));
const codeChallenge = base64url(digest);
The authorisation request
Open this URL in the user’s browser:
https://api-us.zoie.ai/oauth/authorize
?response_type=code
&client_id=kq3Zt0X1u8vYd4Lr9mWb2sNfH6pJcE7a
&redirect_uri=https%3A%2F%2Fassistant.acme.example%2Foauth%2Fcallback
&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
&code_challenge_method=S256
&state=af0ifjsldkj
&resource=https%3A%2F%2Fmcp-us.zoie.ai
&scope=mcp%3Atools
| Parameter | Required | Notes |
|---|---|---|
response_type | Yes | code |
client_id | Yes | From registration, or your metadata document URL. |
redirect_uri | Yes | Must exactly match a registered redirect URI. |
code_challenge | Yes | The PKCE challenge. |
code_challenge_method | No | S256, the default. |
state | Recommended | Returned unchanged on the callback. |
resource | Recommended | https://mcp-us.zoie.ai. It becomes the token’s audience; if you leave it out, the MCP server URL is used. |
scope | No | Stored and echoed back as the token response’s scope. It doesn’t choose permissions — the user does that on the consent screen. |
A request that fails these checks gets an HTTP 400 JSON error in the browser. Zoie doesn’t redirect these errors back to your client.
error | error_description |
|---|---|
invalid_request | response_type is required (or whichever parameter is missing), code_challenge_method must be S256., redirect_uri is not registered for this client. |
unsupported_response_type | Only response_type=code is supported. |
invalid_client | Unknown client_id., or the reason a metadata document was rejected. |
Consent
A valid request is redirected to Zoie’s consent screen in the web app. Zoie signs the user in if needed, then the user picks:
- One business, or, with Multiple, up to 50 businesses. The token is bound to that choice for its whole life.
- Permissions for Leads & contacts, Conversations, Appointments and Campaigns — see Scopes.
Zoie only offers businesses where the user is an active member. The consent screen is described in Authentication in the MCP guides.
The callback
When the user clicks Allow access, the browser is sent to your redirect URI:
https://assistant.acme.example/oauth/callback?code=Vt3hQx9LkP0aZ2mN8cR5wY1uJ7sD4fG6&state=af0ifjsldkj&iss=https%3A%2F%2Fapi-us.zoie.ai
Check state and iss, then exchange the code. A code is valid for 10 minutes and can be used once.
When the user clicks Cancel:
https://assistant.acme.example/oauth/callback?error=access_denied&error_description=The+user+denied+the+request.&state=af0ifjsldkj
Exchanging the code
The token endpoint accepts application/x-www-form-urlencoded or JSON. There’s no client authentication.
curl -X POST https://api-us.zoie.ai/oauth/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'code=Vt3hQx9LkP0aZ2mN8cR5wY1uJ7sD4fG6' \
--data-urlencode 'client_id=kq3Zt0X1u8vYd4Lr9mWb2sNfH6pJcE7a' \
--data-urlencode 'redirect_uri=https://assistant.acme.example/oauth/callback' \
--data-urlencode 'code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'const res = await fetch('https://api-us.zoie.ai/oauth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
grant_type: 'authorization_code',
code,
client_id: clientId,
redirect_uri: 'https://assistant.acme.example/oauth/callback',
code_verifier: codeVerifier,
}),
});
const tokens = await res.json();{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2FwaS11cy56b2llLmFpIi…",
"token_type": "Bearer",
"expires_in": 28800,
"refresh_token": "pD8sK2vX0qLmN4rT7yB1cF6hJ9wZ3aE5gU2iO8kM0nQ4tR6vY1xC3bH7jL9",
"scope": "mcp:tools"
}
All five parameters are required. Zoie re-checks the user’s business memberships at this point: in a multi-business grant, businesses the user has left since consenting are dropped from the token.
| Status | error | error_description |
|---|---|---|
400 | invalid_request | code, client_id, redirect_uri, and code_verifier are required. |
400 | unsupported_grant_type | Only authorization_code and refresh_token are supported. |
400 | invalid_grant | Authorization code is invalid or already used., Authorization code has expired., client_id mismatch., redirect_uri mismatch., PKCE verification failed., User no longer active., Grant has been revoked. |
403 | access_denied | User is no longer a member of the selected business. or … of any of the consented businesses. |
Refreshing
curl -X POST https://api-us.zoie.ai/oauth/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=refresh_token' \
--data-urlencode 'refresh_token=pD8sK2vX0qLmN4rT7yB1cF6hJ9wZ3aE5gU2iO8kM0nQ4tR6vY1xC3bH7jL9' \
--data-urlencode 'client_id=kq3Zt0X1u8vYd4Lr9mWb2sNfH6pJcE7a'const res = await fetch('https://api-us.zoie.ai/oauth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({
grant_type: 'refresh_token',
refresh_token: storedRefreshToken,
client_id: clientId,
}),
});
const tokens = await res.json(); // store tokens.refresh_token — the old one is now spentThe response has the same shape as the code exchange, always with a new refresh_token.
- Rotation. Each refresh token works once. Save the new one before you use the new access token.
- Replay detection. Presenting a refresh token that was already used is treated as theft: Zoie revokes the whole connection and every refresh token in it, and the user has to connect again. Don’t refresh the same token from two places at once.
- Rolling expiry. Each refresh token lasts 30 days, so a connection stays alive as long as it is used at least once every 30 days.
- Same grant, same limits. A refresh can’t widen the business binding or the scopes. Memberships are re-checked, as for the code exchange.
| Status | error | error_description |
|---|---|---|
400 | invalid_request | refresh_token and client_id are required. |
400 | invalid_grant | Unknown refresh token., client_id mismatch., Refresh token has been revoked., Refresh token has expired., Refresh token replay detected; grant revoked., Grant has been revoked., User no longer active. |
403 | access_denied | User is no longer a member of the granted business. or … of any of the consented businesses. |
Token lifetimes
| Credential | Lifetime |
|---|---|
| Authorisation code | 10 minutes, single use |
| Access token | 8 hours (expires_in: 28800) |
| Refresh token | 30 days from issue, replaced on every refresh |
Using the access token
Send the access token to https://mcp-us.zoie.ai only, in the Authorization header, on every request — including initialize.
The token is a JWT signed by Zoie (HS256), which only Zoie can verify. Treat it as opaque: the claims below explain the server’s behaviour but aren’t a stable contract.
| Claim | Meaning |
|---|---|
iss | https://api-us.zoie.ai |
aud | The resource you sent when authorising, normally https://mcp-us.zoie.ai. |
sub, id, email | The Zoie user the connection acts as. |
user.business_id or user.business_ids | The single business, or the list of businesses, the connection is bound to. Exactly one of the two is present. |
client_id, grant_id | Your client and the connection (grant) in Zoie. |
scope | The requested OAuth scope string, normally mcp:tools. |
scopes | The permissions the user granted, for example ["leads:read","conversations:read","notes:read","notes:write","team:read","search:read"]. |
iat, exp | Issued and expiry times. |
Scopes
Zoie has two kinds of scope:
mcp:toolsis the OAuth scope a client requests and the token response returns. It doesn’t gate anything by itself.- Per-area scopes such as
leads:readare what the MCP server enforces on each tool call. The user chooses them on the consent screen, so thescopeparameter can’t narrow or widen them.
Consent screen rows
Each row on the consent screen controls a read and a write scope. Read + Write grants both, Read only the read scope, Write only the write scope and Not allowed neither.
| Row | Read scope | Write scope |
|---|---|---|
| Leads & contacts | leads:read | leads:write |
| Conversations | conversations:read | conversations:write |
| Appointments | appointments:read | appointments:write |
| Campaigns | campaigns:read | campaigns:write |
notes:read, notes:write, team:read and search:read have no row. Every connection approved on the consent screen includes them.
Scopes required by each tool
Each tool needs exactly one scope.
| Scope | Tools |
|---|---|
| None | list_my_businesses |
team:read | list_team_members |
leads:read | search_leads, get_lead, get_lead_by_phone, get_lead_activity |
leads:write | create_lead, update_lead, assign_lead, bulk_update_leads |
search:read | global_search |
notes:read | get_lead_notes |
notes:write | add_lead_note, update_lead_note |
conversations:read | get_conversation_by_lead, list_conversation_channels |
conversations:write | send_message |
appointments:read | appointment_calendar, appointment_overview, list_appointment_leads |
appointments:write | No tool uses it yet. |
campaigns:read | list_campaigns, get_campaign, preview_campaign_audience, list_campaign_options |
campaigns:write | create_campaign, update_campaign, start_campaign, pause_campaign, resume_campaign |
A tool with no entry in the server’s scope map is refused, so a new tool can’t run without a scope check.
When a scope is missing
tools/list still lists the tool. Calling it returns a tool error before anything reaches the Zoie API:
{
"isError": true,
"content": [
{
"type": "text",
"text": "Scope conversations:write is required for send_message; this connection was not granted it."
}
],
"_meta": {
"error": "insufficient_scope",
"required_scope": "conversations:write",
"granted_scopes": ["leads:read", "conversations:read", "notes:read", "notes:write", "team:read", "search:read"]
}
}
To change permissions, send the user through the authorisation flow again. If they approve the same client for the same business (or the same set of businesses), Zoie updates that connection’s scopes instead of creating a new one. Users can also revoke the connection and connect again, as described in Access permissions.
The 401 challenge
Every 401 from https://mcp-us.zoie.ai/ carries a WWW-Authenticate header in this form:
Bearer realm="https://mcp-us.zoie.ai", resource_metadata="https://mcp-us.zoie.ai/.well-known/oauth-protected-resource", error="invalid_token", error_description="Token expired"
error_description | Cause | What to do |
|---|---|---|
Missing bearer token, Empty bearer token | No token was sent. | Start the flow. |
Token expired | The access token is more than 8 hours old. | Refresh it. |
A token-library message such as jwt malformed or invalid signature | The token isn’t a Zoie token, or was altered. | Start the flow. |
Token missing required claims | The token has no user. | Start the flow. |
Token is not bound to a business. Re-authorize via /oauth/authorize. | The token isn’t an MCP token for a business. | Start the flow. |
MCP grant revoked | The connection was revoked, or the user lost access to Zoie. The body is {"error":"invalid_token","message":"MCP access has been revoked. Reconnect to continue."}. | Refreshing will fail too. Start the flow. |
Because the revocation check runs on every request, including initialize and tools/list, a revoked connection surfaces at the transport layer rather than only inside a tool result.
Revocation
Zoie has no token revocation endpoint and doesn’t advertise one. Connections end when:
- The user revokes it in Zoie under Settings → Claude, Settings → ChatGPT or Settings → Other MCP (see Revoking access). Every refresh token is revoked immediately, and the MCP server starts refusing the access token, usually within a minute.
- A used refresh token is replayed — see Refreshing.
- The user loses access. If they are removed from the business, or their account is deactivated, the Zoie API stops accepting their tokens and refreshes fail. On a multi-business connection, a refresh instead drops the businesses they no longer belong to, and fails only when none are left.
- The connection goes unused for 30 days, so the last refresh token expires.
If your client disconnects on its side, discard both tokens. The connection stays listed in Zoie until the user revokes it or it lapses, and reconnecting the same client to the same business re-activates it.
Rate limits on OAuth endpoints
/oauth/register, /oauth/authorize, /oauth/token and the consent screen’s own submit share one limit: 20 requests per 15 minutes per IP address, by default. Refreshes count towards it. The discovery documents aren’t covered by this limit.
Responses carry RateLimit-Policy and RateLimit headers. Over the limit, Zoie answers 429 with Retry-After:
{
"success": false,
"error": "Too many requests",
"message": "Too many OAuth requests, please try again later.",
"limit": "oauth",
"retryAfter": 840
}
Refresh only when the access token has expired or is about to, rather than before every request.