Enterprise organizations & partner API
An enterprise organization is a tenant on Freestyle. Its admin manages members and partner applications in the app; a partner's backend uses a partner token to list members, mint "Open in Freestyle" launch links, read usage and — with each member's consent — read or create that member's projects.
Concepts
| Term | What it is |
|---|---|
| Organization | The tenant. Has a slug, a name, a status (active or suspended) and a plugin profile: native (members' new vocal lanes get AutoTune plus the native effects rack, never an auto-instantiated Nectar) or pro (members follow their own Pro access). |
| Admin | A member with role=admin. Manages the organization at /org. An organization always keeps at least one admin. |
| Member | A Freestyle account that belongs to the organization. Joins by invite link, by a launch link, or because an admin or partner added them. One organization per account. An optional externalUserId links the member to the partner's own user id. |
| Partner app | A confidential OAuth client owned by the organization: public client_id (fst_org_…), a secret (fst_sec_…, shown once), a scope ceiling, allowed origins (for the embed button and return URLs), optional exact redirect URIs (for the per-member authorization-code flow) and an optional per-minute rate limit. |
| Partner token | Organization-level bearer token (fst_pat_…) from grant_type=client_credentials. Carries only org:* scopes. Revocable, hash-only storage. |
| Consent grant | A member's own grant to a partner app, created on the launch consent screen or through /oauth/authorize. Carries user scopes. Anything about one member's projects requires it; a partner token never stands in for a member. |
| Launch link | A single-use signed URL (/open?launch=fst_launch_…) that brings one of the partner's users into Freestyle, joins them to the organization, records their consent and — with intent: "project" — creates a project seeded from the link (title, lyrics, backing, lanes with effects). intent: "login" only signs them in. |
| Organization login | An organization can host its own sign-in (settings.sso): the app's sign-in popup lists it under "Organization" and sends the person to the partner's loginUrl, which authenticates them and redirects to a launch link. |
Getting credentials
- Freestyle sets up the organization and names its admin account.
- The admin opens /org/apps → New app, names the app, lists the allowed origins (for example
https://partner.example), optional redirect URIs, picks the scope ceiling and saves. The client secret is shown exactly once. - Store
client_idandclient_secretin your secret manager. The secret never goes to a browser or into the embed snippet — only theclient_iddoes.
From the same screen the admin can edit scopes, origins and the rate limit, rotate the secret (new secret shown once; live partner tokens are revoked), disable the app (partner tokens and every member consent revoked; the token endpoint answers unauthorized_client) and re-enable it later. Read-only partners simply get no writes scopes.
Partner tokens (client_credentials)
Token endpoint: POST /api/oauth/token. Authenticate with client_secret_basic (preferred) or client_secret_post.
curl -s https://freestyle.audio/api/oauth/token \
-u "$FREESTYLE_CLIENT_ID:$FREESTYLE_CLIENT_SECRET" \
-d grant_type=client_credentials \
-d "scope=org:read org:members:read org:launch"{
"access_token": "fst_pat_…",
"token_type": "Bearer",
"expires_in": 28800,
"scope": "org:launch org:members:read org:read"
}- Omit
scopeto receive everyorg:*scope inside the app's ceiling. - Requesting a user scope (
profile:read, …), an unknown scope, or a scope outside the ceiling answers400 invalid_scope. An app with no organization scopes enabled also answersinvalid_scope. - A disabled app, a public client or an app without
client_credentialsanswers400 unauthorized_client; a suspended organization answers403 unauthorized_client; a wrong secret answers401 invalid_client. - Minting is limited to 30 per minute per app and 30 per minute per IP (
429 temporarily_unavailable). Cache the token and reuse it until shortly beforeexpires_in. - Tokens live 28800 seconds (8 hours). Trimming the app's ceiling shrinks live tokens on their next use; rotating the secret or disabling the app revokes them.
Use the token as Authorization: Bearer fst_pat_… on every /api/enterprise/v1/* request.
Partner API basics
Base path: https://freestyle.audio/api/enterprise/v1. All responses are JSON with Cache-Control: no-store. The organization is always the one the token belongs to; ids in bodies never select an organization. {id} for members accepts the membership id or the Freestyle user id. JSON bodies are capped at 64 KiB (413 payload_too_large).
Every error uses one envelope:
{"error": {"code": "member_consent_required",
"message": "This member has not granted the projects:list scope to your app. Send them through a launch link or the authorization flow first."}}| Status | Codes |
|---|---|
| 400 | invalid_request, cursor_invalid, organization_role_invalid, launch_* validation codes (launch_intent_invalid, launch_import_url_invalid, launch_import_kind_invalid, launch_return_url_not_allowed, launch_scopes_invalid, launch_project_*) |
| 401 | invalid_token, token_expired — plus WWW-Authenticate: Bearer realm="freestyle-enterprise", error="invalid_token" |
| 403 | insufficient_scope (plus WWW-Authenticate: … error="insufficient_scope", scope="org:launch"), member_consent_required, launch_client_unavailable |
| 404 | enterprise_unavailable (surface off on this environment), member_not_found, launch_not_found |
| 409 | last_admin; on the launch completion, launch_external_user_conflict (a different Freestyle account already holds that externalUserId) |
| 413 | payload_too_large |
| 429 | rate_limited (plus Retry-After and X-RateLimit-*) |
| 503 | rate_limit_unavailable (plus Retry-After) |
Endpoints
GET /org
Scope org:read. The organization, the calling app and the token's validity.
{
"organization": {"id": "org_…", "slug": "acme-reviews", "name": "Acme Reviews", "pluginProfile": "native",
"status": "active", "counts": {"members": 42, "admins": 2, "clients": 1, "pendingInvites": 0},
"createdAt": "2026-10-01T09:00:00+00:00"},
"client": {"clientId": "fst_org_EXAMPLE0000000000000000000000", "name": "Acme web",
"scopes": ["org:launch", "org:members:read", "org:read"]},
"token": {"issuedAt": "…", "expiresAt": "…"}
}GET /members
Scope org:members:read. Query: cursor, limit (default 50, max 200), externalUserId (exact match), query (username, display name or external id), role. Keyset pagination: pass nextCursor back as cursor until it is null.
{
"members": [{
"id": "mem_…", "userId": "u_…", "username": "ada", "displayName": "Ada L", "avatarUrl": null,
"externalUserId": "acme-7", "role": "member", "joinedVia": "launch",
"joinedAt": "2026-11-02T10:00:00+00:00", "clientId": "fst_org_EXAMPLE0000000000000000000000",
"consentScopes": ["profile:read", "projects:list", "projects:read"],
"consentRevoked": false, "consentGrantedAt": "…"
}],
"nextCursor": null
}consentScopes is the member's unrevoked grant to this client (empty when there is none).
externalUserId is not unique across Freestyle accounts. It is what your launch link said, recorded on the membership of whichever account approved it, so a filter by it can return several members. Key your records on userId or the membership id. A launch approval by a different active member who would take an externalUserId another member already carries is refused with 409 launch_external_user_conflict; an organization can allow shared ids with settings.allowSharedExternalUserId: true.
GET /members/{id}
Scope org:members:read. One member in the same shape: {"member": {…}}. Unknown or inactive → 404 member_not_found.
PATCH /members/{id}
Scope org:members:write. Body: {"externalUserId": "acme-7", "role": "admin" | "member"} (either field). Demoting the last admin → 409 last_admin. Returns {"member": {…}}.
DELETE /members/{id}
Scope org:members:write. Removes the membership and revokes the member's consent grants to every app of the organization. Returns {"removed": true, "userId": "u_…", "grantsRevoked": 1}. Last admin → 409; already removed → 404.
POST /launch-links
Scope org:launch. Mints a signed "Open in Freestyle" link for one of your users.
POST /api/enterprise/v1/launch-links
Authorization: Bearer fst_pat_…
Content-Type: application/json
Idempotency-Key: review-7-attempt-1
{
"externalUserId": "acme-7",
"displayName": "Ada",
"returnUrl": "https://partner.example/reviews/7",
"intent": "project",
"project": {
"title": "Review take 7",
"lyrics": "plain text, LRC, SRT or VTT",
"backing": {"fileUrl": "https://cdn.partner.example/beats/7.wav", "title": "Beat", "mimeType": "audio/wav"},
"lanes": [
{"kind": "vocal", "name": "Lead", "fileUrl": "https://cdn.partner.example/takes/7.wav", "effects": "native_default"},
{"kind": "vocal", "name": "Double", "effects": "clean"},
{"kind": "audio", "name": "Adlibs"}
]
},
"scopes": ["profile:read", "projects:list", "projects:read", "projects:write", "media:upload"]
}HTTP/1.1 201 Created
{"launch": {
"sessionId": "ls_…", "kind": "signed", "status": "pending", "intent": "project",
"launchUrl": "https://freestyle.audio/open?launch=fst_launch_…",
"createdAt": "…", "expiresAt": "…", "consumedAt": null,
"requestedScopes": ["media:upload", "profile:read", "projects:list", "projects:read", "projects:write"],
"externalUserId": "acme-7", "displayName": "Ada", "returnUrl": "https://partner.example/reviews/7",
"import": null, "project": {…}, "userId": null, "projectId": null, "idempotencyKey": "review-7-attempt-1"
}}returnUrlmust be on one of the app's allowed origins (400 launch_return_url_not_allowed). Aloginlink may instead name a URL on the Freestyle origin itself (thereturn_tothe sign-in sheet handed you): it is stored as given and the approve answer'sredirectPathbecomes its same-origin path, so the member lands back where they were. Other hosts, lookalike hosts,//paths, other ports and plainhttpare refused.intent(defaultproject):projectcreates a project on approve and opens its Studio;loginonly signs the member in (membership + consent, no project, the page lands on/) and ignoresproject/import.projectis optional and seeds the new project — every field optional:title(≤ 128 characters),lyrics(≤ 20 000 characters; plain text, LRC, SRT or VTT, auto-detected, stored as the project's custom lyrics),backing(httpsfileUrl, optionaltitle/mimeType; the project's private backing track),lanes(≤ 8, kept in order):kindvocal|audio, optionalname(≤ 128), optional httpsfileUrl(imported as the lane's first clip) and, for vocal lanes,effects:native_default(native EQ + effects rack),clean(no partner-specified chain: today the engine still seeds its native defaults — EQ, Effects and the free pitch plugin — the first time the project opens, as for any empty vocal lane; a truly dry lane needs an engine change, so prefernative_defaultor a preset when you need a predictable chain) or the id of a vocal chain preset your organization can use (public or starter presets, or one owned by an active member); omitted = the member's default chain. Validation codes:launch_project_invalid,launch_project_title_too_long,launch_project_lyrics_invalid,launch_project_lyrics_too_long,launch_project_backing_invalid,launch_project_lanes_invalid,launch_project_lanes_too_many,launch_project_lane_invalid,launch_project_lane_kind_invalid,launch_project_lane_name_too_long,launch_project_file_url_invalid,launch_project_effects_invalid.- The legacy single
import(fileUrlhttps;kindvocal,backingoraudio; optionaltitle,mimeType,externalId) still works and may be combined withproject; it runs first. Details on the embed page. scopesdefaults to the launch consent set (profile:read projects:list projects:read projects:write media:upload exports:read) intersected with the app's ceiling; scopes outside the ceiling are dropped, and a request that leaves nothing grantable answers400 launch_scopes_invalid.- Links are single use and expire after 900 seconds (15 minutes). The raw token is returned once. Mint when the user taps, not at page render.
- Idempotency: an
Idempotency-Keyheader (oridempotencyKeyin the body; the header wins) is scoped to the app. A retry with the same key returns the same session with200andidempotentReplay: true— and, because tokens are stored hash-only, it re-issues the link for that session: the earlier link stops working. Use one key per intended launch. - Rate: 300 mints per minute per app (
429 rate_limited).
GET /launch-links/{sessionId}
Scope org:launch. The same shape with launchUrl: null. status is pending, completed (then userId, projectId — null for a login launch — and consumedAt are set), expired, denied or revoked. Sessions of other apps answer 404 launch_not_found.
GET /members/{id}/projects
Scope org:projects:read and the member's consent for projects:list (otherwise 403 member_consent_required). Query: cursor, limit.
{
"projects": [{"id": "p_…", "title": "Hook idea", "artist": "Ada L", "createdAt": "…", "updatedAt": "…",
"studioUrl": "https://freestyle.audio/p_…/studio", "shareUrl": "https://freestyle.audio/share/p_…"}],
"nextCursor": null, "memberId": "mem_…", "userId": "u_…"
}shareUrl is present only for publicly shared projects.
POST /members/{id}/projects
Scope org:projects:write and the member's consent for projects:write (plus media:upload when import or any project file URL is given). Body: {"title": "Hook idea", "import": {"fileUrl": "https://…", "kind": "vocal", "title": "Take 1"}, "project": {…}} — project is the same seed a launch link takes (title, lyrics, backing, lanes with effects; project.title wins over title), so an organization can instantiate a fully seeded project without a launch.
HTTP/1.1 201 Created
{"project": {"id": "p_…", "title": "Hook idea", "studioUrl": "…", …},
"import": {"status": "imported", "kind": "vocal", "laneId": "…", "trackId": "…", "title": "Take 1", "durationSec": 12.5},
"seed": {"title": "Hook idea", "lyrics": {"status": "set", "lines": 12, "format": "txt"},
"backing": {"status": "imported", "kind": "backing", "backingTrackId": "…", "durationSec": 180.0},
"lanes": [{"kind": "vocal", "name": "Lead", "effects": "native_default", "status": "imported", "laneId": "…", "trackId": "…", "chainRows": 2},
{"kind": "vocal", "name": "Double", "effects": "clean", "status": "created", "laneId": "…", "chainRows": 0}],
"counts": {"lanesRequested": 2, "lanesCreated": 1, "lanesImported": 1, "lanesFailed": 0, "backing": "imported", "lyrics": "set"}}}The project is owned by the member. import.status is none (no import requested), imported, failed, too_large or unsupported, with a reason on failure; seed is null without a project body and otherwise reports each part the same way (lane status created for an empty lane). The project is created even when a file fails; the lanes before it stay.
GET /usage
Scope org:usage:read.
{"usage": {
"members": 42, "admins": 2, "clients": 1, "pendingInvites": 0, "activePartnerTokens": 3,
"launches": {"last24h": {"total": 40, "completed": 31, "pending": 6, "expired": 3, "denied": 0, "revoked": 0},
"last30d": {…}},
"apiCalls": {"last24h": 120, "last30d": 2400},
"rateLimit": {"clientPerMinute": 600, "orgPerDay": 200000},
"generatedAt": "…"
}}apiCalls counts audited partner operations (token issues, launch mints, member and project mutations), not every read.
Consent-gated member data
A partner token proves you are the organization's app; it does not prove any member agreed to share anything. Reading or creating a member's projects requires that member's own consent grant to this app with the relevant user scope. Members grant it on the launch consent screen (the requested scopes are listed; profile:read is required, the rest can be unticked) or through the standard /oauth/authorize flow with your app's client_id. Members can withdraw it at any time from Account → Connected apps, after which the member-scoped endpoints answer 403 member_consent_required. Removing a member revokes all of their consents to the organization's apps.
How a launch works
- Your backend mints a link (above) and redirects the signed-in partner user to
launchUrl, or puts it in the button'sdata-freestyle-launchattribute. - Freestyle resolves the token, shows the organization, the app and the requested scopes, and the person signs in or creates an account.
- On Allow, in one transaction: membership (
joinedVia: "launch",externalUserIdrecorded), the consent grant, forintent: "project"a new project with its custom lyrics, an audit eventlaunch.complete; the session becomescompletedwithuserIdandprojectId. The seed's files run afterwards (backing first, then lanes in order; a lane without a file is created empty with its chain) so a failed download never undoes the join (launch.import/launch.seedrecord the outcome). The page then goes to the answer'sredirectPath: the project's Studio, or/for a login launch. - The person lands in the Studio; "Back to <your org>" uses
returnUrl. - You poll
GET /launch-links/{sessionId}(or look the member up withGET /members?externalUserId=) and can now call the consent-gated endpoints for that member.
Unsigned embeds (/open?client_id=…, no partner token) create an anonymous session that joins the visitor with the default consent scopes but carries no external user id.
Audit log
Every partner operation is recorded on the organization's audit trail with the acting client, the target and the caller IP: partner_token.issue, launch.mint, launch.replay, launch.complete, launch.import, member.update, member.remove, member.project.create, plus the admin's own console actions. Admins read it at /org/activity (newest first, filterable by action). Revocation records — grants, tokens, sessions — are kept, never deleted.
Rate limits and headers
| Bucket | Default | Response when exceeded |
|---|---|---|
| Per app, per minute (every partner-API call) | 600, or the app's own rateLimitPerMinute | 429 rate_limited with Retry-After, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset (seconds until the bucket is full) |
| Per organization, per day | 200000 | 429 rate_limited |
| Token mints per app / per IP, per minute | 30 / 30 | 429 temporarily_unavailable on the token endpoint |
| Launch mints per app, per minute | 300 | 429 rate_limited |
| Invalid-token probes per IP, per minute | 60 | 429 |
Every successful partner-API response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset for the per-app bucket. When the rate-limit authority itself is unavailable the API fails closed with 503 rate_limit_unavailable and Retry-After.
Revocation summary
| Who | How | Effect |
|---|---|---|
| Member | Account → Connected apps → Disconnect | Their consent grant (and its tokens) for that app is revoked; member-scoped calls answer 403 member_consent_required. |
| Member | /org → Leave organization | Membership removed, every consent grant to the organization's apps revoked. |
| Admin | Console → Members → Remove | Same as leaving, performed by the admin. |
| Admin | Console → Apps → Rotate secret | New secret shown once; all live partner tokens revoked (401 invalid_token). |
| Admin | Console → Apps → Disable | Partner tokens and every member consent revoked; the token endpoint answers unauthorized_client until re-enabled. |
| Freestyle | Suspend the organization | Every partner token and admin call fails closed. |
| Time | — | Partner tokens expire after 8 hours, launch links after 15 minutes, invites after 7 days. |
Integration walkthrough
A review platform wants its users to polish a recording in Freestyle and come back.
- Set-up (once). The organization's admin creates the partner app with the review site in allowed origins; the client id and secret go into the partner's secret manager.
- Partner token. The partner backend exchanges the credentials (
client_credentials) and caches thefst_pat_token for about 8 hours. - Button. On a review page the backend calls
POST /launch-linkswith its own user id, the review's audio file URL, the return URL and an idempotency key, and renders "Open in Freestyle" pointing atlaunchUrl— or embeds the generic snippet for anonymous launches. - Launch. The user taps, signs in (or signs up), sees the organization, app and scopes, and allows. Freestyle joins them, records consent, imports the file into a new project and opens the Studio. The link is now consumed.
- Read back. The partner polls
GET /launch-links/{sessionId}untilcompleted, lists the member's projects withGET /members/{userId}/projectsand showsstudioUrl/shareUrlin its own UI. Later uploads go throughPOST /members/{userId}/projectswith animport. - Operate. The admin watches Members, Activity and Usage in the console, trims scopes or rate limits per app, rotates the secret on schedule and disables the app if the partner is off-boarded. Members can disconnect the app or leave the organization themselves.
Organization accounts — no Freestyle signup
A person who is already authenticated at your service does not create a Freestyle account or type credentials: the consent screen is the only step. For a signed launch (the link carries your externalUserId) the consent page reports organizationSignIn: true; on OK the browser creates an anonymous Firebase identity and posts its ID token as firebaseIdToken with the approval. Freestyle then provisions an account owned by that partner identity (a generated @username from displayName, no onboarding; your email only when the organization opted in with settings.trustPartnerEmail) or, on later logins, rotates the existing organization account onto the new browser identity, and answers session: {token, user} exactly like a normal login plus account: {outcome: "provisioned" | "rotated" | "signed_in"}. A partner identity that belongs to a normal Freestyle account answers 401 launch_sign_in_required instead, and that person signs in with their own account (the signed-in path links as before). Anonymous embeds never sign anyone in this way, and an anonymous identity alone can never create an account (403 anonymous_identity_not_allowed on the regular login). Logging out and choosing "Log in with organization" later simply mints a new launch.
Organization login
An organization can host its own sign-in. The admin sets settings.sso = {"enabled": true, "loginUrl": "https://partner.example/sso/freestyle"} (PATCH /api/org/me; https only — 400 organization_sso_login_url_invalid, organization_sso_login_url_required when enabled without a URL). The app's sign-in popup then lists the organization under Organization and sends the person to loginUrl?return_to=<encoded Freestyle URL>&freestyle=1; your server authenticates them with its own session, mints a launch link (intent: "login" or "project") and redirects to its launchUrl. After consent the person is signed in and lands on / or in the project.
GET /api/enterprise/sso/organizations- Public, no auth, 60 requests per minute per IP, served from a 60-second cache (
Cache-Control: public, max-age=60). Answers{"organizations": [{"slug", "name", "logoUrl", "loginUrl"}]}for active organizations with an enabled login URL. GET /api/org/connected- Signed-in user: the organizations the account is an active member of (
via: "member") or approved a launch for (an unrevoked consent grant to one of the organization's apps,via: "grant") —{"organizations": [{"slug", "name", "logoUrl", "loginUrl", "ssoEnabled", "role", "via"}]}.
Admin console (browser session)
Admins manage everything above in the organization dashboard at /org: profile, plugin profile and organization login, members and invites (an invite link per email; the invitee's account email must match), partner apps (create, edit, rotate, disable, embed snippet), activity, usage and members' consent grants. The console's own endpoints under /api/org/* use the signed-in app session, not partner tokens, and are limited to 120 calls per minute per admin.