Open in Freestyle
One anchor and one script. A visitor who taps the button signs in or creates a Freestyle account, agrees to join your organization and share the listed data, and ends up in a new, empty project they own inside your organization. A signed launch link minted by your backend can also carry the visitor's file, which is imported into that project automatically.
The snippet
The organization dashboard at /org/apps (your app → Embed) generates exactly this:
<a href="https://freestyle.audio/open?client_id=fst_org_EXAMPLE0000000000000000000000"
class="freestyle-open-button"
data-freestyle-client="fst_org_EXAMPLE0000000000000000000000">Open in Freestyle</a>
<script async src="https://freestyle.audio/embed/v1/open-in-freestyle.js"></script>- The
hrefis a working fallback: it launches Freestyle before the script loads, or if your page blocks it. The script then rewrites it to add the current page asreturn_to, injects the branded mark and styles, and wires the attributes below. - The script derives the Freestyle origin from its own
src, so the same file works on every environment. - It is dependency-free and idempotent (including it twice just rescans), never reads cookies or storage, and only touches anchors matching
a.freestyle-open-button, a[data-freestyle-client], a[data-freestyle-launch].
See it live: /embed/v1/demo.html renders both themes, three sizes, a signed-launch example with a placeholder token and the raw snippet.
Attributes
| Attribute | Values | Effect |
|---|---|---|
data-freestyle-client | client id | Unsigned launch: /open?client_id=… |
data-freestyle-launch | signed token (fst_launch_…) | Signed launch: /open?launch=… (wins over client) |
data-freestyle-return | absolute http(s) URL | Where "Back to <Org>" goes. Defaults to location.href. Must be on one of the app's allowed origins or it is dropped server-side. |
data-freestyle-user | partner user id | Untrusted hint passed as user=; the server ignores it for unsigned launches. Use a signed launch to bind a user id. |
data-freestyle-theme | dark (default) | light | Dark button for light pages; light button for dark pages. |
data-freestyle-size | sm | md (default) | lg | 32 / 40 / 50 px tall. |
data-freestyle-label | text | Replaces "Open in Freestyle". |
data-freestyle-target | _self (default) | _blank | Same tab or a new one (rel="noopener" is always set). |
Single-page apps
const a = document.createElement("a");
container.appendChild(a);
window.FreestyleEmbed.render(a, {
client: "fst_org_EXAMPLE0000000000000000000000", theme: "light", size: "lg",
returnTo: location.href, user: "your-user-id", label: "Record this in Freestyle",
});
// or, after adding anchors with the data attributes:
window.FreestyleEmbed.scan(containerOrDocument);
// pure helper, no DOM:
window.FreestyleEmbed.buildLaunchUrl("https://freestyle.audio", { client: "fst_org_EXAMPLE0000000000000000000000" });Files
| Path | Purpose |
|---|---|
/embed/v1/open-in-freestyle.js | The embed script (about 11 KB, includes the mark as a data URI). |
/embed/v1/open-in-freestyle.css | Standalone button styles for partners who render the button themselves, or with data-freestyle-css="link" (below). |
/embed/v1/logo.svg | The Freestyle mark in the app's round white tile (128 px). |
/embed/v1/demo.html | Demo page. |
Everything under /embed/ is a cacheable public static file with no authentication.
Styling the button
The default is the branded pill with the Freestyle mark; pick data-freestyle-theme and data-freestyle-size to fit your page and data-freestyle-label for your own wording. If your site's Content-Security-Policy blocks the injected <style>, either add a nonce to the script tag (the script copies it onto the style element) or set data-freestyle-css="link" on the script tag so it loads /embed/v1/open-in-freestyle.css instead — then allow the Freestyle origin in style-src. To render the button entirely yourself, link that stylesheet and use the same class names, or ignore it and style the plain anchor; the launch URL is all that matters.
What the visitor sees
- Opening Freestyle… while the link is checked.
- Signed out — a hero with your organization's mark next to the Freestyle mark: "Create your Freestyle account inside <Org>", with Create your account and I already have an account · Sign in. The normal sign-in sheet (email, phone, Google, Apple) opens; a provider redirect or an email link returns to the same launch.
- @username onboarding — a brand-new account picks a username first, then the tab is handed back to the launch.
- Consent — "Join <Org> on Freestyle" (or "Open a new project in <Org>" for an existing member): what happens next (member of <Org>; a new project opens; the file is imported; you can get back to <Org>), then one row per requested scope with a short description, a writes badge on write scopes and a locked required row for
profile:read; optional rows are on by default. Buttons: Join <Org> / Not now. - Setting up your studio… then the browser navigates to the new project's Studio. A small Back to <Org> link stays available.
- Not now → "No changes made" with Back to <Org> / Go to Freestyle.
Invalid, expired, already-used, paused-partner and rate-limited links get friendly pages with a "Go to Freestyle" link; an already-used link that this same account completed re-opens its project.
Signed launches
Unsigned launches identify only the organization. To bind the visitor to your own user id, pass a display name, pre-attach a file and control the return URL, your backend mints a signed launch link with a partner token carrying org:launch:
POST https://freestyle.audio/api/enterprise/v1/launch-links
Authorization: Bearer fst_pat_…
Content-Type: application/json
Idempotency-Key: review-7-open
{
"externalUserId": "acme-7",
"displayName": "Ada",
"returnUrl": "https://partner.example/reviews/7",
"scopes": ["profile:read", "projects:list", "projects:read", "projects:write", "media:upload"],
"import": {
"fileUrl": "https://cdn.partner.example/takes/7.wav",
"kind": "vocal",
"title": "Review take 7",
"mimeType": "audio/wav",
"externalId": "take-7"
}
}The response carries launchUrl (https://freestyle.audio/open?launch=fst_launch_…). Put it in data-freestyle-launch or redirect to it. Rules:
- Single use, expires after 900 seconds (15 minutes). Mint it when the visitor taps, not at page render.
- The raw token is returned once; Freestyle stores only its SHA-256.
returnUrlmust be on one of the app's allowed origins or minting fails.scopesis intersected with the app's ceiling; omit it for the launch default (profile:read projects:list projects:read projects:write media:upload exports:read).profile:readis always required on the consent screen; the member may untick the rest.- Reuse the same
Idempotency-Keyonly to retry a lost response: it returns the same session and re-issues its link, invalidating the earlier one.
The full endpoint contract (status polling, errors, rate limits) is on the Enterprise page.
Return URL rules
- Unsigned launch: the page URL the button sits on (
return_to, defaultlocation.href; the browser'sReferer/Originare the fallback). - Signed launch: the
returnUrlgiven at mint time. - Either way the server keeps it only if its origin is in the app's allowed origins (exact scheme, host and port;
httponly for localhost). Otherwise it is dropped silently and the launch context reportsreturnUrlRejected: true— the visitor simply does not see "Back to <Org>". - Keep the allowed-origins list in the console current when your site moves (staging hosts, CDN previews).
Import payload
{"fileUrl": "https://…", "kind": "vocal" | "backing" | "audio",
"title": "…", "mimeType": "audio/…", "externalId": "…"}A signed launch can instead (or additionally) carry a whole project seed — title, lyrics, a backing file and up to eight lanes, each with an optional file and a vocal effects choice — and an intent of project or login; see the launch-link contract. The rules below apply to every file in it.
fileUrlmust behttps://, publicly resolvable (DNS to a public IP; no private ranges, no credentials, no non-443 port) and fetchable without cookies. Use a short-lived signed CDN URL.kind:vocal→ a new vocal lane with the file as its first take (the member's default chain is seeded unless the seed nameseffects; for a native-profile organization that is the native EQ + effects rack, and a lane markedcleanstill receives the engine's native defaults on first open);audio→ an audio lane with the file as its clip;backing→ the project's backing track (private to the member).- Validation is the same as a browser upload: malware scan, probe, full decode, canonicalization (48 kHz WAV for lanes, m4a for a backing).
- Synchronous, capped at 50 MB. Larger files answer
{"status": "too_large"}; nothing is queued. - The import runs after the membership, consent and project are committed — a failed download or rejected file never undoes the join. The completion response and the organization's audit log (
launch.import) carry{"status": "imported" | "failed" | "too_large" | "unsupported", "reason": …}.
Launch endpoints (reference)
The /open page is driven by two public JSON endpoints. Partners do not call them directly, but they explain the states above.
GET /api/enterprise/launch/context?launch=<token>or?client_id=<id>[&session=<id>][&return_to=<url>]. Returns the session (sessionId,kind,status,expiresAt), the organization and app,externalUserId,displayName,email,returnUrl,intent,import,project,requestedScopes,organizationSignIn(name, description, write),requiredScopes, and the visitor's state (signedIn,hasUsername,alreadyMember,otherOrganization,returnUrlRejected). A bareclient_idmints an anonymous session (rate limited per IP, 30/min, and per app).POST /api/enterprise/launch/complete- Signed-in user with a username (
428otherwise). Body:{"launch": "…"}or{"sessionId": "…", "clientId": "…"},"decision": "approve" | "deny", optional"scopes": [...]subset. Nobody signed in? A signed launch accepts"firebaseIdToken"of an anonymous Firebase identity and signs the person in with the organization account (session: {token, user}in the answer; see the Enterprise page). Approve returnsintent,userId,account,redirectPath(/<projectId>/studio, the login launch's same-origin return path, or/),projectId,studioPath,returnUrl,organization,alreadyMember,scopes,importandseed; deny returns{"denied": true, "returnUrl": …}.
Errors are {"error", "code"}: launch_not_found (404); launch_expired, launch_completed, launch_denied, launch_revoked (410 — launch_completed also carries projectId and studioPath when the same account completed it); launch_client_unavailable (403); launch_other_organization (409); launch_rate_limited (429). Everything is Cache-Control: no-store.
Troubleshooting
| Symptom | Cause / fix |
|---|---|
| Button renders unstyled (plain link) | Your CSP blocks the injected <style>. Add a nonce to the script tag, or set data-freestyle-css="link" and allow the Freestyle origin in style-src. |
| Button never appears / plain "Open in Freestyle" text | CSP script-src does not allow the Freestyle origin. The plain href fallback still works. |
| "This link is not valid" | Wrong client_id, a client that is not an organization app, or a signed token that was mistyped or minted on another environment. The demo page's placeholder token is expected to show this. |
| "This partner app is paused" | The app is disabled or the organization is suspended. |
| "This link has expired" | Signed links live 15 minutes and are single use. Mint on tap. |
| No "Back to <Org>" link | The return URL's origin is not in the app's allowed origins (returnUrlRejected: true). |
| "Already part of another organization" | One organization per account; the visitor must sign in with a different account. |
Import failed with download_failed:… / file_url_not_allowed | The file URL did not resolve to a public IP, used a non-443 port, or carried credentials. Use a public signed CDN URL. |
Import too_large | Over 50 MB; downsample or trim the file before launching. |
Import failed with media_rejected | The file did not pass validation (not decodable audio, too long, malware scan). |
Checklist before going live
- Your app in the organization console lists the production site in allowed origins.
- The snippet is placed with the production origin and the demo page renders in both themes under your site's CSP.
- If you use signed launches: partner token with
org:launch, links minted per tap,returnUrlon an allowed origin, import files on a publichttpsCDN under 50 MB. - A test account walks the whole flow: signed out → create account → username → consent → Studio → "Back to <Org>".