Authentication
Freestyle is an OAuth 2.1 authorization server. The MCP endpoint and the Studio API v1 are its protected resources and accept the same user access tokens and scopes. MCP clients register themselves and obtain a user token with the authorization-code flow; enterprise partner apps are confidential clients that also mint organization tokens with client_credentials.
Discovery
| Endpoint | Purpose |
|---|---|
GET /.well-known/oauth-protected-resource | RFC 9728 protected-resource metadata: resource (the MCP URL), authorization_servers, scopes_supported, bearer_methods_supported: ["header"]. Also served at the path-suffixed /.well-known/oauth-protected-resource/api/mcp. |
GET /.well-known/oauth-authorization-serverGET /.well-known/openid-configuration | RFC 8414 authorization-server metadata (below). |
POST /api/oauth/register | Dynamic client registration (RFC 7591). |
GET /oauth/authorize | Consent page (browser). |
POST /api/oauth/token | authorization_code, refresh_token, client_credentials (organization clients only). |
POST /api/oauth/revoke | Token revocation (RFC 7009). |
GET /api/oauth/grants, POST /api/oauth/grants/{id}/revoke | "Connected apps" for a signed-in app session (what the account page uses). |
{
"issuer": "https://freestyle.audio",
"authorization_endpoint": "https://freestyle.audio/oauth/authorize",
"token_endpoint": "https://freestyle.audio/api/oauth/token",
"registration_endpoint": "https://freestyle.audio/api/oauth/register",
"revocation_endpoint": "https://freestyle.audio/api/oauth/revoke",
"response_types_supported": ["code"],
"response_modes_supported": ["query"],
"grant_types_supported": ["authorization_code", "refresh_token", "client_credentials"],
"code_challenge_methods_supported": ["S256"],
"token_endpoint_auth_methods_supported": ["none", "client_secret_basic", "client_secret_post"],
"revocation_endpoint_auth_methods_supported": ["none", "client_secret_basic", "client_secret_post"],
"scopes_supported": ["ai:use", "audio:listen", "daw:read", "daw:write", "exports:read", "media:upload",
"offline_access", "profile:read", "projects:list", "projects:read", "projects:write"]
}The 401 challenge
An unauthenticated call to POST /api/mcp answers 401 with a challenge that points at the resource metadata and lists the scopes the server supports, so a client can bootstrap discovery without configuration:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://freestyle.audio/.well-known/oauth-protected-resource", scope="ai:use audio:listen daw:read daw:write exports:read media:upload offline_access profile:read projects:list projects:read projects:write"
Cache-Control: no-store
{"error": "Unauthorized"}A tool call with a token that lacks the tool's scope is not a transport error: it returns a normal isError: true tool result whose _meta["mcp/www_authenticate"] carries a challenge with error="insufficient_scope" and the required scope.
Dynamic client registration
POST /api/oauth/register
Content-Type: application/json
{
"client_name": "My assistant",
"redirect_uris": ["http://localhost:8765/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"],
"token_endpoint_auth_method": "none",
"scope": "profile:read projects:list projects:read projects:write daw:read daw:write ai:use audio:listen offline_access"
}HTTP/1.1 201 Created
{
"client_id": "fst_dcr_…",
"client_id_issued_at": 1767225600,
"client_name": "My assistant",
"redirect_uris": ["http://localhost:8765/callback"],
"response_types": ["code"],
"grant_types": ["authorization_code", "refresh_token"],
"token_endpoint_auth_method": "none",
"scope": "ai:use audio:listen daw:read daw:write offline_access profile:read projects:list projects:read projects:write"
}client_nameis required (up to 128 printable characters).logo_uri, if given, must be https.redirect_uris: one to ten exact URIs, no duplicates.- Only the authorization-code flow can be registered:
response_typesmust be["code"],grant_typesmust includeauthorization_codeand may includerefresh_token. The server always stores both — every grant receives a rotating refresh token.client_credentialscannot be registered dynamically; it is reserved for organization clients created by an admin. token_endpoint_auth_method:none(public client, the default),client_secret_basicorclient_secret_post. A confidential registration returnsclient_secretexactly once (client_secret_expires_at: 0); only its SHA-256 hash is stored.scopenarrows the client's ceiling (see Scopes). Omit it to allow every user scope.- Registration is rate limited per IP (300 per hour; 3000 per hour in a separate bucket when every redirect URI is a Claude or ChatGPT callback); the body is capped at 16 KB.
Accepted redirect URIs
| Redirect URI | Accepted? |
|---|---|
RFC 8252 loopback: http://localhost…, http://127.0.0.1…, http://[::1]… (any path, any port) | Yes. The port may differ between registration and authorization. |
https://claude.ai/api/mcp/auth_callback, https://claude.com/api/mcp/auth_callback | Yes (exact). |
ChatGPT connector callbacks on https://chatgpt.com/… | Yes (the documented callback paths only). |
Any other https:// URL | Yes, as long as it has no userinfo and no fragment. |
Custom schemes (myapp://, cursor://), plain http:// on a non-loopback host, URLs with credentials or a #fragment | No — 400 invalid_client_metadata / invalid_redirect_uri. |
Authorization code with PKCE
Send the user's browser to the consent page. PKCE with S256 is mandatory; plain is not accepted.
GET /oauth/authorize
?response_type=code
&client_id=fst_dcr_…
&redirect_uri=http%3A%2F%2Flocalhost%3A8765%2Fcallback
&scope=profile%3Aread%20projects%3Alist%20projects%3Aread%20daw%3Aread%20offline_access
&state=opaque-state
&code_challenge=…
&code_challenge_method=S256
&resource=https://freestyle.audio%2Fapi%2Fmcpredirect_urimust match a registered URI exactly (loopback: scheme, host, path and query must match; the port may change).scopeis a space-separated subset of the client's ceiling. Anything outside it, or an unknown scope, is refused withinvalid_scopebefore the user sees anything. Omitscopeto request the whole ceiling.resource(RFC 8707) is optional and defaults to the MCP URL. If present it must be exactly that URL (invalid_targetotherwise). The value is bound through the code to the token and checked on every call.stateis returned untouched (up to a sane size).
The consent screen
The user must be signed in to Freestyle (the page offers sign-in; the authorize URL is remembered across the sign-in round trip, including email-link sign-in) and must have Pro access. The screen shows the client's name, its kind (AI assistant or organization app), the organization for partner apps, the host it will return to, and one row per requested scope with a short description and a writes badge on scopes that can change the user's projects. A summary line counts how many of the permissions can write. Approve redirects to redirect_uri?code=fst_ac_…&state=…; Deny redirects with error=access_denied. Codes live 10 minutes and are single use.
Token endpoint
POST /api/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=fst_ac_…
&redirect_uri=http%3A%2F%2Flocalhost%3A8765%2Fcallback
&client_id=fst_dcr_…
&code_verifier=…
&resource=https://freestyle.audio%2Fapi%2Fmcp{
"access_token": "fst_at_…",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "fst_rt_…",
"scope": "daw:read offline_access profile:read projects:list projects:read"
}- Public clients identify themselves with
client_idin the body. Confidential clients authenticate withclient_secret_basic(HTTP Basicclient_id:client_secret, preferred) orclient_secret_post(client_secretin the body). Sending a differentclient_idin the Basic header and the body is rejected as ambiguous. A wrong or missing secret answers401 invalid_clientwithWWW-Authenticate: Basic realm="freestyle-oauth". code_verifiermust hash (S256) to the challenge sent at authorization;redirect_uriandresourcemust match the authorization request.- A used, expired or mismatched code answers
400 invalid_grant.
Token lifetimes
| Token | Lifetime | Notes |
|---|---|---|
Authorization code fst_ac_ | 10 minutes | Single use. |
Access token fst_at_ | 3600 seconds (1 hour) | Issuing a new pair revokes the grant's previous access token. |
Refresh token fst_rt_ | 7776000 seconds (90 days) | Rotates on every use. |
Partner token fst_pat_ | 28800 seconds (8 hours) | client_credentials only; see Enterprise. |
Codes and tokens are stored only as SHA-256 hashes; Freestyle cannot show a token again after issuing it.
Refreshing
POST /api/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token&refresh_token=fst_rt_…&client_id=fst_dcr_…- Every refresh returns a new access token and a new refresh token; the old refresh token is revoked.
- Reuse detection: presenting a refresh token that was already rotated revokes the whole grant (
400 invalid_grant, "Refresh token reuse revoked this connected app"). The user has to authorize again. scopemay narrow the grant on refresh (never widen it);resource, if sent, must equal the grant's resource.- A refresh also fails with
invalid_grantwhen the grant was disconnected, the client was disabled, the user lost access, or the account's sessions were invalidated.
Scopes
Every tool and endpoint names exactly one required scope. A client's ceiling — set at registration through scope (default: all user scopes) or by an organization admin for partner apps — is a hard limit: a request for a scope outside it is refused at authorization time, not merely at use time. Scopes marked writes are the ones an admin leaves off for read-only partners.
User scopes
Granted by a signed-in person on the consent screen to an MCP client or to a partner app acting for that person.
| Scope | Grants | Access |
|---|---|---|
profile:read | See your Freestyle profile (name, username, avatar). | read |
projects:list | List the Freestyle projects available to your account. | read |
projects:read | Read project contents: lanes, takes, backing track, key and tempo. | read |
projects:write | Create, rename, duplicate, share and delete your projects. | writes |
media:upload | Add audio files and YouTube backing tracks to your projects. | writes |
daw:read | Read live studio state: transport, tracks, mixer, plugins and history. | read |
daw:write | Change your projects through Mozart's reviewed DAW actions. | writes |
ai:use | Run Mozart AI commands on your projects. | writes |
audio:listen | Render and listen to short excerpts of your projects. | read |
exports:read | List and download your rendered exports. | read |
social:read | Browse Discover, posts, comments, profiles, people and your notifications. | read |
social:write | Post your projects, like, comment, follow people, manage friends and blocks. | writes |
messages:read | Read your direct message conversations. | read |
messages:write | Send direct messages and start conversations. | writes |
profile:write | Edit your profile, username, avatar, settings and account (including deletion). | writes |
live:read | See your live sessions, rooms, members and queues. | read |
live:write | Create, join, manage and end live sessions and their queues. | writes |
library:read | Browse presets, sound packs, drum kits, templates and the marketplace. | read |
library:write | Save, publish and manage your presets, drum kits and marketplace assets. | writes |
organization:manage | Manage your organization as an admin: members, invites and partner apps. | writes |
offline_access | Stay connected with a refresh token (no re-login for 90 days). | read |
Organization scopes
Carried only by partner tokens minted with client_credentials. They are never shown on a consent screen and a partner token can never hold a user scope.
| Scope | Grants | Access |
|---|---|---|
org:read | Read the organization profile and settings. | read |
org:members:read | List organization members and their link to the partner's user ids. | read |
org:members:write | Add, update or remove organization members. | writes |
org:launch | Mint signed 'Open in Freestyle' launch links for the partner's users. | writes |
org:projects:read | Read projects that members have shared with the organization. | read |
org:projects:write | Create projects and import files for consenting members. | writes |
org:usage:read | Read organization usage and rate-limit statistics. | read |
Confidential clients and client_credentials
Enterprise partner apps are confidential clients created in the organization console (client id fst_org_…, secret fst_sec_…). They use the same token endpoint:
curl -s https://freestyle.audio/api/oauth/token \
-u "fst_org_EXAMPLE0000000000000000000000:fst_sec_EXAMPLE…" \
-d grant_type=client_credentials \
-d "scope=org:read org:members:read org:launch"The grant is accepted only for an enabled organization client with a secret; any other client answers unauthorized_client. Details, errors and limits are on the Enterprise page. A partner app can additionally run the authorization-code flow above to act for an individual member (its registered redirect_uris apply), which is how a member's consent grant is created outside a launch link.
Using a token
Authorization: Bearer fst_at_…On /api/mcp the token must be an access token issued for that resource; the server also re-checks, on every call, that the grant is not revoked, the client is enabled, the account still has Pro access and the account's sessions were not invalidated after the grant was created. Partner tokens (fst_pat_) are accepted only by /api/enterprise/v1/*, never by the MCP endpoint or the Studio API.
The Studio API v1 (/api/v1) accepts exactly the access tokens /api/mcp accepts, with the same checks, so one authorization serves both. Request tokens with resource omitted or set to the MCP URL. An invalid, expired or revoked token on /api/v1 answers 401 unauthorized in the Studio API error envelope with a WWW-Authenticate challenge, and a token without an operation's scope answers 403 insufficient_scope.
Revocation
POST /api/oauth/revoke
Content-Type: application/x-www-form-urlencoded
token=fst_rt_…&client_id=fst_dcr_…Answers 200 with an empty body. Revoking a refresh token revokes its grant and every token of that grant; a confidential client must authenticate to revoke. Users revoke from Account → Connected apps (Disconnect), which takes effect immediately. Organization admins can disable a partner app or rotate its secret, which revokes its partner tokens — and, for disabling, every member consent to that app.
Token and registration errors
The token, registration and revocation endpoints use the standard OAuth error body {"error": "…", "error_description": "…"}:
| Status | error | When |
|---|---|---|
| 400 | invalid_grant | Unknown, used, expired or mismatched code; invalid or rotated refresh token. |
| 400 | invalid_scope | Unknown scope, scope outside the ceiling, or a user scope requested on client_credentials. |
| 400 | invalid_target | resource is not the MCP URL. |
| 400 | invalid_client_metadata, invalid_redirect_uri | Registration rejected (see above). |
| 400 | unsupported_grant_type | Anything but the three supported grants. |
| 400 / 403 | unauthorized_client | client_credentials from a public or disabled client, or a suspended organization. |
| 401 | invalid_client | Wrong or missing client secret (plus WWW-Authenticate: Basic). |
| 429 / 503 | slow_down, temporarily_unavailable | Token-endpoint or registration budget exhausted; see Retry-After. |
| 404 | — | The OAuth surface is not enabled on this environment. |