Token API
Public REST endpoint for consuming brand tokens as CSS variables or JSON
Token API
Brand Studio exposes a public REST endpoint that serves inheritance-resolved tokens for any brand. Applications, standalone HTML pages, and no-code embeds consume tokens through this API.
The endpoint operates in two modes based on the format query parameter.
CSS Mode (No Auth Required)
Request tokens as a CSS stylesheet containing :root custom properties. No authentication is needed -- tokens are not secret.
Response (Content-Type: text/css):
Token names have underscores converted to dashes in CSS mode. The inheritance chain is walked and merged before output -- child brand values override parent values.
CORS: Access-Control-Allow-Origin: *
Cache: s-maxage=60, stale-while-revalidate=300 -- tokens are cached at the CDN edge for 60 seconds and served stale for up to 5 minutes while revalidating.
If the slug does not match any brand entity, the response is an empty :root {} block with a 200 status code.
Token Variable Structure
Colors produce a single CSS variable per token:
Typography tokens produce up to three variables per token:
Spacing tokens produce a single variable:
JSON Mode (Auth Required)
Request the full structured token payload. Requires a Bearer token in the Authorization header.
The API key is the value of the BRAND_STUDIO_API_KEY environment variable configured on the Brand Studio deployment.
Response (Content-Type: application/json):
Response Fields
| Field | Type | Description |
|---|---|---|
entity | object | The resolved brand entity with id, slug, display_name, tagline, parent_entity_slug |
chain | string[] | Slug array from leaf to root, showing the full inheritance path |
colors | BrandColorRow[] | Merged color tokens (child wins over parent) |
typography | BrandTypographyRow[] | Merged typography tokens |
spacing | BrandSpacingRow[] | Merged spacing tokens |
css_variables | string | Pre-built CSS :root block string with --brand- prefixed variable names |
json_tokens | object | Flat map of { token_name: { value, type } } for programmatic consumption |
Error Responses
| Status | Body | Cause |
|---|---|---|
| 401 | { "error": "Unauthorized" } | Missing or invalid Bearer token |
| 404 | { "error": "Brand not found" } | No brand entity matches the slug |
| 500 | { "error": "Internal error" } | Server-side failure |
Inheritance Chain Resolution
Both modes walk the brand entity inheritance chain before returning tokens. The walk proceeds:
- Fetch the target brand entity by slug
- Follow
parent_entity_slugto the parent entity - Continue until reaching an entity with no parent or an
is_globalentity - Guard against circular references using a visited set
All token tables (brand_colors, brand_typography, brand_spacing) are fetched for every entity in the chain. Tokens are then merged using a priority map: the leaf entity (the requested brand) has highest priority. When multiple entities define the same token_name, the entity closest to the leaf wins.
For example, if PRT defines brand_green as #548235 and the global base also defines brand_green as #333333, the PRT value is returned.
Consumption Patterns
Pattern A -- Next.js Server Component
Fetch tokens at build time with ISR revalidation:
Pattern B -- Standalone HTML
Inject tokens via script tag with hardcoded fallback values:
Pattern C -- No-Code Embed
Single script tag with data-studio-slug attribute:
CORS Preflight
The endpoint handles OPTIONS requests for CORS preflight, returning:
Access-Control-Allow-Origin: *Access-Control-Allow-Methods: GET, OPTIONSAccess-Control-Allow-Headers: Content-Type, Authorization
Brand Slug Reference
| App | Brand Slug |
|---|---|
| PRT Portal | prt |
| RDC Marketing Engine | rdc |
| Place Fund | place_fund |
| Life AI | life_ai |
| RCCS Admin | rccs |
| Zoen | zoen |
| Regenity | rdc |
To discover all available slugs, query the brand_entities table: