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

PurposeEndpoint
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
AuthorisationGET https://api-us.zoie.ai/oauth/authorize
TokenPOST https://api-us.zoie.ai/oauth/token
Token revocation (RFC 7009)Not offered — see Revocation.

The flow

  1. Call the MCP server without a token and receive 401 with a WWW-Authenticate header naming the metadata document.
  2. Fetch the protected resource metadata, then the authorisation server metadata it points to.
  3. Register the client, once, with dynamic client registration — or use a client ID metadata document instead.
  4. 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.
  5. Receive the code on your redirect URI and exchange it, with the PKCE verifier, for an access token and a refresh token.
  6. 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"]
}
FieldUse
resourceSend this as the resource parameter (RFC 8707) when you authorise.
authorization_serversThe one authorisation server, https://api-us.zoie.ai.
scopes_supportedmcp:tools is the OAuth-level scope. The per-area permissions are chosen on the consent screen — see Scopes.
bearer_methods_supportedTokens 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_access is 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_supported field.
  • iss on callbacks (RFC 9207). Check that the iss parameter on the redirect equals https://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"
}
FieldRequiredNotes
redirect_urisYesA non-empty array of absolute URIs. The redirect_uri you send later must match one exactly.
token_endpoint_auth_methodNoOnly none is accepted. Anything else is refused with invalid_client_metadata.
client_nameNoShown on the consent screen as Authorize followed by the name.
logo_uriNoShown on the consent screen.
client_uri, policy_uri, tos_uri, contactsNoStored with the client.
scopeNoDefaults 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.

Statuserrorerror_description
400invalid_redirect_uriredirect_uris must be a non-empty array. or Invalid URI: …
400invalid_client_metadataOnly 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"
}
RuleDetail
URLhttps, 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.
Fetch5-second timeout, 16 KB maximum, must return 2xx JSON.
client_idOptional in the document, but if present it must equal the URL.
redirect_urisRequired. 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_uriOptional, https only.
client_nameOptional, up to 256 characters.
contacts, scopeOptional.
AuthenticationAlways treated as a public client, whatever token_endpoint_auth_method the document declares.
CachingA 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
ParameterRequiredNotes
response_typeYescode
client_idYesFrom registration, or your metadata document URL.
redirect_uriYesMust exactly match a registered redirect URI.
code_challengeYesThe PKCE challenge.
code_challenge_methodNoS256, the default.
stateRecommendedReturned unchanged on the callback.
resourceRecommendedhttps://mcp-us.zoie.ai. It becomes the token’s audience; if you leave it out, the MCP server URL is used.
scopeNoStored 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.

errorerror_description
invalid_requestresponse_type is required (or whichever parameter is missing), code_challenge_method must be S256., redirect_uri is not registered for this client.
unsupported_response_typeOnly response_type=code is supported.
invalid_clientUnknown client_id., or the reason a metadata document was rejected.

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.

Statuserrorerror_description
400invalid_requestcode, client_id, redirect_uri, and code_verifier are required.
400unsupported_grant_typeOnly authorization_code and refresh_token are supported.
400invalid_grantAuthorization 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.
403access_deniedUser 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 spent

The 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.
Statuserrorerror_description
400invalid_requestrefresh_token and client_id are required.
400invalid_grantUnknown 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.
403access_deniedUser is no longer a member of the granted business. or … of any of the consented businesses.

Token lifetimes

CredentialLifetime
Authorisation code10 minutes, single use
Access token8 hours (expires_in: 28800)
Refresh token30 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.

ClaimMeaning
isshttps://api-us.zoie.ai
audThe resource you sent when authorising, normally https://mcp-us.zoie.ai.
sub, id, emailThe Zoie user the connection acts as.
user.business_id or user.business_idsThe single business, or the list of businesses, the connection is bound to. Exactly one of the two is present.
client_id, grant_idYour client and the connection (grant) in Zoie.
scopeThe requested OAuth scope string, normally mcp:tools.
scopesThe permissions the user granted, for example ["leads:read","conversations:read","notes:read","notes:write","team:read","search:read"].
iat, expIssued and expiry times.

Scopes

Zoie has two kinds of scope:

  • mcp:tools is the OAuth scope a client requests and the token response returns. It doesn’t gate anything by itself.
  • Per-area scopes such as leads:read are what the MCP server enforces on each tool call. The user chooses them on the consent screen, so the scope parameter can’t narrow or widen them.

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.

RowRead scopeWrite scope
Leads & contactsleads:readleads:write
Conversationsconversations:readconversations:write
Appointmentsappointments:readappointments:write
Campaignscampaigns:readcampaigns: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.

ScopeTools
Nonelist_my_businesses
team:readlist_team_members
leads:readsearch_leads, get_lead, get_lead_by_phone, get_lead_activity
leads:writecreate_lead, update_lead, assign_lead, bulk_update_leads
search:readglobal_search
notes:readget_lead_notes
notes:writeadd_lead_note, update_lead_note
conversations:readget_conversation_by_lead, list_conversation_channels
conversations:writesend_message
appointments:readappointment_calendar, appointment_overview, list_appointment_leads
appointments:writeNo tool uses it yet.
campaigns:readlist_campaigns, get_campaign, preview_campaign_audience, list_campaign_options
campaigns:writecreate_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_descriptionCauseWhat to do
Missing bearer token, Empty bearer tokenNo token was sent.Start the flow.
Token expiredThe access token is more than 8 hours old.Refresh it.
A token-library message such as jwt malformed or invalid signatureThe token isn’t a Zoie token, or was altered.Start the flow.
Token missing required claimsThe 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 revokedThe 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.