Customer portal
Let each customer's admin set team and member budgets and choose models, in a portal in your brand, or build those screens yourself.
The customer portal is a small hosted site, in your brand, where an admin of one of your customers governs that customer's members: a monthly budget for the whole team, a budget for each member, which models the team may use, and usage by member. You open it from your own product for a person you have already signed in; there is nothing for your customers to sign up for.
Everything the portal does, the management API does too, so you can build these screens into your own product instead, or both. Budgets and model lists are enforced at the gateway, before the provider is called, whichever way they were set.
Three layers, strictest wins#
What a member may do is decided by three layers. A request must fit all of them.
| Layer | Who sets it | What it holds |
|---|---|---|
| You | You, in the dashboard or the API | The environment's and the customer's limits and allowed models |
| Team | The customer's admin in the portal, or you | The team policy: a team budget, a default budget for every member, the team's models |
| Member | The customer's admin in the portal, or you | One member's own budget and models |
The team and member layers only ever add restrictions. A team budget is one more spend limit beside yours, and a model list is one more list a model must be on, so nothing a customer's admin saves can loosen what you allow, whatever you change later. Nothing is refused for being looser than your own limits either: a team budget above your monthly limit for the customer is stored, and simply never binds. The effective policy shows what applies.
Budgets are amounts spent per calendar month (UTC), counted the way
spend limits count: what each request was
billed. A budget of "0" refuses every request that would cost anything.
Open the portal for a member#
Your backend creates a portal session for the person who is signed in to your product, then
redirects their browser to the session's url. You decide their role: admin governs the
team, member sees only their own budget, models and usage.
curl https://api.hixel.dev/v1/customers/org_42/portal_sessions \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"member": "user_7",
"role": "admin",
"name": "Ada Lovelace",
"email": "ada@acme.example",
"return_url": "https://app.example.com/settings/team"
}'const session = await hixel.portalSessions.create("org_42", {
member: "user_7",
role: "admin",
name: "Ada Lovelace",
email: "ada@acme.example",
return_url: "https://app.example.com/settings/team",
});It answers 201:
{
"id": "ps_x8k2m4q9w1e7r3t5y6u0i2o4",
"url": "https://portal.…/enter/4fJ9kQ2mX7vR1tY8wZ3nB6cD0eG5hL2pS9uA4iK7oM1",
"expires_at": "2026-11-25T11:00:00.000Z"
}| Field | Rules |
|---|---|
member | Your id for the person, as you send it in x-hixel-member: 1 to 256 characters of visible ASCII, no spaces, not . or ... |
role | admin or member. You assert it; the portal trusts it. |
name, email | Optional. Written to the member's row when sent, so the admin sees who is who. A name is 1 to 255 characters, an email at most 254. |
return_url | Optional. Where the portal sends the member back to: an https:// URL of at most 2,048 characters. Left out, the environment's default. |
expires_in_seconds | Optional. How long the session lasts: 300 to 86,400. Default 3,600 (one hour). |
Creating a session also creates the customer and the member's row if they do not exist yet, so you can call it the first time a customer's admin clicks "Manage team" in your product.
The link works once, for five minutes#
url is a single-use sign-in link: the first visit within five minutes signs the browser in and
sets a cookie on the portal's own host, and every later visit, or one after five minutes, shows
a page saying the link has expired. Create the session when the person clicks, and redirect at
once; never email the link or store it.
The session itself then lasts until expires_at. When it ends, or the member signs out, the
portal sends them to the session's return_url, else to the environment's default return
address, else shows a page saying they are signed out.
url is answered once. A retried request with the same Idempotency-Key gets the stored
response with "url": null (and Idempotent-Replayed: true): create another session.
From your backend#
A route in your product that opens the portal for the signed-in user:
interface SignedInUser {
id: string;
name: string;
email: string;
organizationId: string;
isOrganizationAdmin: boolean;
}
declare function signedInUser(request: Request): Promise<SignedInUser>;
export async function openTeamSettings(request: Request): Promise<Response> {
const user = await signedInUser(request);
const session = await hixel.portalSessions.create(user.organizationId, {
member: user.id,
role: user.isOrganizationAdmin ? "admin" : "member",
name: user.name,
email: user.email,
return_url: "https://app.example.com/settings",
});
if (session.url === null) throw new Error("A replayed session has no URL; create another.");
return Response.redirect(session.url, 303);
}What each role sees#
| Page | admin | member |
|---|---|---|
| Overview | Team spend against the team budget this month, top members and models | Their own spend against their budget, the models they may use |
| Members | Every member: budget, models and usage; edit budgets and models | No |
| Budgets | The team budget and the default member budget | No |
| Models | The models you allow the customer, each on or off for the team | No |
| Usage | By day, member and model | Their own |
Usage in the portal is what the customer was billed, never your own cost. An admin sets a member's budget and models only: names and emails come from you.
End a member's portal access#
A session keeps the role you gave it until it ends, up to a day. When you remove a person from a
customer, or take away their admin role, end their sessions: their next click in the portal signs
them out, and a url not used yet stops working. Leave out member to end every session of the
customer.
curl -X DELETE "https://api.hixel.dev/v1/customers/org_42/portal_sessions?member=user_7" \
-H "Authorization: Bearer $HIXEL_API_KEY"const { revoked } = await hixel.portalSessions.revoke("org_42", { member: "user_7" });It answers 200 with how many sessions it ended, { "revoked": 1 }; ending them again ends none
({ "revoked": 0 }). Removing a member's row ends that member's sessions too.
To give someone a new role, end their sessions and create a new one with that role.
Brand the portal#
The portal can look like your own product: its name, logos, colors for light and dark, fonts, corners, navigation and footer links, set once per environment. Developers › Branding in the dashboard edits them beside a live preview of the portal; your backend sets the same through the API.
curl -X PATCH https://api.hixel.dev/v1/portal_settings \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"display_name": "Acme AI",
"return_url": "https://app.example.com/settings",
"theme": {
"appearance": "system",
"logo": {
"light_url": "https://cdn.example.com/logo.svg",
"dark_url": "https://cdn.example.com/logo-dark.svg",
"height": 28,
"show_name": false
},
"icon_url": "https://cdn.example.com/favicon.png",
"colors": {
"light": { "primary": "#4F46E5", "navigation": "#F8F8FB" },
"dark": { "background": "#0B0B10", "primary": "#818CF8" }
},
"typography": {
"body": { "type": "preset", "name": "dm_sans" },
"heading": {
"type": "custom",
"family": "Acme Display",
"url": "https://cdn.example.com/fonts/acme-display.woff2",
"bold_url": "https://cdn.example.com/fonts/acme-display-bold.woff2"
}
},
"shape": { "radius": 8 },
"layout": { "navigation": "top" },
"links": {
"support": { "label": "Help", "url": "https://example.com/help" },
"footer": [
{ "label": "Terms", "url": "https://example.com/terms" },
{ "label": "Privacy", "url": "https://example.com/privacy" }
]
}
}
}'const settings = await hixel.portalSettings.update({
display_name: "Acme AI",
return_url: "https://app.example.com/settings",
theme: {
appearance: "system",
logo: {
light_url: "https://cdn.example.com/logo.svg",
dark_url: "https://cdn.example.com/logo-dark.svg",
height: 28,
show_name: false,
},
icon_url: "https://cdn.example.com/favicon.png",
colors: {
light: { primary: "#4F46E5", navigation: "#F8F8FB" },
dark: { background: "#0B0B10", primary: "#818CF8" },
},
typography: {
body: { type: "preset", name: "dm_sans" },
heading: {
type: "custom",
family: "Acme Display",
url: "https://cdn.example.com/fonts/acme-display.woff2",
bold_url: "https://cdn.example.com/fonts/acme-display-bold.woff2",
},
},
shape: { radius: 8 },
layout: { navigation: "top" },
links: {
support: { label: "Help", url: "https://example.com/help" },
footer: [
{ label: "Terms", url: "https://example.com/terms" },
{ label: "Privacy", url: "https://example.com/privacy" },
],
},
},
});The answer is the settings with the theme as stored, colors lowercased:
{
"environment_id": "env_…",
"display_name": "Acme AI",
"return_url": "https://app.example.com/settings",
"theme": {
"appearance": "system",
"colors": {
"light": { "primary": "#4f46e5", "navigation": "#f8f8fb" },
"dark": { "background": "#0b0b10", "primary": "#818cf8" }
},
"…": "the other fields as sent"
},
"updated_at": "2026-11-25T10:00:00.000Z"
}| Field | Rules |
|---|---|
display_name | 1 to 255 characters. null: the project's name. |
return_url | The default return address of sessions that name none: an https:// URL of at most 2,048 characters, without a user name or password. null: none. |
theme | How the portal looks, below. It replaces the whole theme; null resets it to the defaults. |
display_name and return_url keep their value when you leave them out. theme is replaced as a
whole: to change one color, send the theme you read back with that color changed. Every field of
the theme is optional, and one you leave out is the portal's default, so {} is the portal as it
ships. GET /v1/portal_settings reads them all.
| Theme field | Rules | Left out |
|---|---|---|
appearance | system follows the member's device and lets it switch; light or dark offers that scheme only | system |
logo.light_url, logo.dark_url | The logo on a light and on a dark background | no logo; dark: the light |
logo.height | Display height in px, 16 to 48 | 24 |
logo.show_name | Whether the display name shows beside the logo | true |
icon_url | The browser tab's icon | the portal's |
browser_title | The browser tab's title, 1 to 60 characters | the display name |
colors.light, colors.dark | A palette for each color scheme (below) | the portal's colors |
typography.body, .heading | {"type": "preset", "name": …}, or {"type": "custom", "family", "url", "bold_url"} for a font you host | Inter; heading: the body |
typography.base_size | The base font size in px, 14 to 18; every size scales with it | 16 |
shape.radius | Corner radius in px, 0 to 24 | square (0) |
layout.navigation | sidebar or top | sidebar |
links.support | {"label", "url"}: where a member asks for help, shown in the navigation | none |
links.footer | Up to 4 {"label", "url"} in the footer, in order: terms, privacy, … | none |
links.show_powered_by | Whether the footer says the portal is powered by Hixel | true |
A palette sets any of background, foreground (text on the page), surface (cards, menus and
dialogs) and surface_foreground, muted (quiet fills) and muted_foreground (secondary text),
border, primary (primary actions, the current page, focus) and primary_foreground,
navigation (the sidebar or top bar) and navigation_foreground, danger, and chart: up to 8
colors for the chart series, in order. Each color is #rrggbb, in any case, stored lowercase.
When you set a color but not its text color, the portal picks the text color that contrasts more
with it, so text stays readable.
The presets are inter, dm_sans, space_grotesk, fraunces, geist_mono, and the
device's own system_sans, system_serif, system_mono and system_rounded: none loads
anything from a third party. A custom font is a .woff2 file at an https:// URL, served with
CORS (Access-Control-Allow-Origin) so the portal can load it; family is 1 to 64 letters,
digits, spaces and hyphens. Until it loads, and if it cannot, the portal shows Inter.
Every URL of the theme follows the rules of return_url. Labels are 1 to 40 characters of plain
text. A field that breaks its rules is 400 with param naming its path: invalid_url for a
URL (theme.links.footer.1.url), invalid_parameter for anything else
(theme.colors.dark.primary), including a field the theme does not have.
Upload your logo and fonts#
Instead of hosting a logo, the tab icon or a font yourself, upload the file and put the url you
get back in the theme. Developers › Branding does this when you choose a file; your backend
sends the file's bytes as the body:
curl https://api.hixel.dev/v1/portal_assets?filename=logo.svg \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/octet-stream" \
--data-binary @logo.svgimport { readFile } from "node:fs/promises";
const logo = await hixel.portalAssets.upload(await readFile("logo.svg"), {
filename: "logo.svg",
});
// In a browser or a Worker, a `File` from a form works as it is:
// await hixel.portalAssets.upload(file);It answers 201:
{
"id": "pas_k3m9q2w8e4r7t1y6u5i0o3p2",
"environment_id": "env_…",
"kind": "image",
"content_type": "image/svg+xml",
"size_bytes": 2048,
"sha256": "…",
"filename": "logo.svg",
"url": "https://api.hixel.dev/assets/portal/env_…/pas_k3m9q2w8e4r7t1y6u5i0o3p2.svg",
"created_at": "2026-11-25T10:00:00.000Z"
}Then name it in the theme, as any URL:
curl -X PATCH https://api.hixel.dev/v1/portal_settings \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "theme": { "logo": { "light_url": "https://api.hixel.dev/assets/portal/env_…/pas_k3m9q2w8e4r7t1y6u5i0o3p2.svg" } } }'import type { PortalAsset } from "@hixel/sdk";
declare const logo: PortalAsset; // the upload's answer, above
await hixel.portalSettings.update({ theme: { logo: { light_url: logo.url } } });| What | Rules |
|---|---|
| Images | PNG, JPEG, WebP, GIF, ICO or SVG, at most 1 MiB: for logo.light_url, logo.dark_url and icon_url |
| Fonts | WOFF2, at most 2 MiB: for typography.body and .heading (url, bold_url) |
| The type | Read from the file's contents, never from its name or Content-Type: a PNG named logo.svg is kept and served as a PNG |
| SVG | No script, event handlers, javascript: URLs, foreignObject, DOCTYPE, or references to other files (unsafe_svg); export it plain |
filename | For display only, never part of the URL; file when left out |
| Files per environment | At most 100 (asset_limit_reached); remove one you no longer use |
A file's url never changes and is served publicly to anyone who has it, cached for a year: to
change a logo, upload a new file and save the theme with its URL. Each environment has its own
files, as it has its own theme.
GET /v1/portal_assets lists the environment's files (hixel.portalAssets.list()), and
DELETE /v1/portal_assets/{id} removes one (hixel.portalAssets.remove(id)); a file the saved
theme names is refused (409 asset_in_use) until you save a theme without it. Files no saved
theme names are removed by themselves once they are a day old, the next time a theme is saved, so
an upload you never used does not count against the 100. An upload is not retried with an
Idempotency-Key: a retried upload keeps a second file, which goes the same way.
Set a team policy#
The team policy is what the customer's admin sets in the portal. Set it yourself to give every new customer a default, or to build your own team settings page.
curl -X PATCH https://api.hixel.dev/v1/customers/org_42/policy \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"team_budget_micros": "250000000",
"member_budget_micros": "20000000",
"allowed_models": ["claude-sonnet-5-5", "gpt-6.2-sol"]
}'const policy = await hixel.customerPolicy.update("org_42", {
team_budget_micros: "250000000", // $250.00 a month for the whole customer
member_budget_micros: "20000000", // $20.00 a month for each member, unless set otherwise
allowed_models: ["claude-sonnet-5-5", "gpt-6.2-sol"],
});{
"customer": "org_42",
"team_budget_micros": "250000000",
"member_budget_micros": "20000000",
"allowed_models": ["claude-sonnet-5-5", "gpt-6.2-sol"],
"updated_at": "2026-11-25T10:00:00.000Z"
}| Field | Rules |
|---|---|
team_budget_micros | What the whole customer may spend in a calendar month, every member and requests that name none together. "0" to 2^63 − 1. null: no team budget. |
member_budget_micros | What each member may spend in a calendar month, unless the member has a budget of its own. null: none. |
allowed_models | Up to 256 exact model names, each one you allow this customer today. Patterns such as openai/* are not accepted here. null: every model you allow. |
Only the fields you send change; null clears one. GET /v1/customers/{external_id}/policy
reads it, all null for a customer without one. A model you do not allow the customer is
refused with 400 model_not_available, and param names the entry (allowed_models.1). A
model you stop allowing later stays on the list and simply no longer matters. The customer
must exist: an unknown one is 404 customer_not_found.
Manage members#
A member needs no row to make requests: it is held to the team's defaults. A row gives it a name, an email, a budget of its own or a model list of its own.
curl -X PUT https://api.hixel.dev/v1/customers/org_42/members/user_9 \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Grace Hopper",
"budget": { "type": "limit", "limit_micros": "50000000" },
"allowed_models": ["claude-sonnet-5-5"]
}'const { data: member, response } = await hixel.members
.put("org_42", "user_9", {
name: "Grace Hopper",
budget: { type: "limit", limit_micros: "50000000" },
allowed_models: ["claude-sonnet-5-5"],
})
.withResponse();
const created = response.status === 201;It answers 201 when it created the row and 200 when it changed one:
{
"id": "mem_p2o9i8u7y6t5r4e3w2q1a0s9",
"external_id": "user_9",
"name": "Grace Hopper",
"email": null,
"budget": { "type": "limit", "limit_micros": "50000000" },
"allowed_models": ["claude-sonnet-5-5"],
"created_at": "2026-11-25T10:00:00.000Z",
"updated_at": "2026-11-25T10:00:00.000Z",
"customer": "org_42"
}| Field | Rules |
|---|---|
member | In the path: your id for the member, what x-hixel-member sends. |
name, email | Optional; null removes one. |
budget | {"type": "inherit"} (the team's member_budget_micros, the default), {"type": "unlimited"} (no member budget at all), or {"type": "limit", "limit_micros": "…"}. |
allowed_models | Exact model names, as the team's list. null: every model the team allows. |
Fields you leave out keep their value, or their default on a new row. A customer has at most
2,000 members with a budget or model list of their own; one more is 409
member_overrides_limit_reached. Rows that only hold a name or an email do not count.
curl "https://api.hixel.dev/v1/customers/org_42/members?limit=50" \
-H "Authorization: Bearer $HIXEL_API_KEY"
curl https://api.hixel.dev/v1/customers/org_42/members/user_9 \
-H "Authorization: Bearer $HIXEL_API_KEY"
curl -X DELETE https://api.hixel.dev/v1/customers/org_42/members/user_9 \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const member of hixel.members.list("org_42", { limit: 50 })) {
console.log(member.external_id, member.budget.type);
}
const member = await hixel.members.get("org_42", "user_9");
await hixel.members.remove("org_42", "user_9");The list holds member rows, oldest first, paginated with cursor and
limit; members that only ever made requests have no row (find them in
usage by member). Reading a member without a row is 404 member_not_found.
Removing a row (204) removes its own budget and models with it, and ends the member's portal
sessions; the member can still make requests, held to the team's defaults.
Read a member's effective policy#
GET /v1/customers/{external_id}/members/{member}/policy answers what applies to a member right
now, every layer merged, whether it has a row or not. Use it to disable what the member cannot
choose before they send a request: grey out models that are not in models, and warn when a
budget is nearly spent.
curl https://api.hixel.dev/v1/customers/org_42/members/user_9/policy \
-H "Authorization: Bearer $HIXEL_API_KEY"const policy = await hixel.members.effectivePolicy("org_42", "user_9");
const choosable = new Set(policy.models);
const budget = policy.member_budget;
const nearlySpent =
budget?.limit_micros != null &&
budget.spent_micros != null &&
BigInt(budget.spent_micros) * 10n >= BigInt(budget.limit_micros) * 9n;{
"member": "user_9",
"models": ["claude-sonnet-5-5"],
"member_budget": { "source": "member", "limit_micros": "50000000", "spent_micros": "12500000" },
"team_budget": { "limit_micros": "250000000", "spent_micros": "181000000" },
"limits": [
{
"id": "monthly",
"applies_to": "customer",
"window": "month",
"limit_micros": "300000000",
"spent_micros": "181000000",
"resets_at": "2026-12-01T00:00:00.000Z"
}
],
"resets_at": "2026-12-01T00:00:00.000Z"
}| Field | What it is |
|---|---|
models | Every model the environment serves that the member may request now, by name: on your lists, the team's and the member's. |
member_budget | The member budget that binds: source member (its own) or team (the default). limit_micros is null for an unlimited member. null when there is no member budget. |
team_budget | The team budget and what the whole customer spent this month; null when there is none. |
limits | Your own spend limits that apply to the member, the customer's first (applies_to customer), then the environment's member limits (member), each with its spend. |
resets_at | When the budgets start again: the first instant of the next month, UTC. |
spent_micros is what the gateway has counted, and null when it cannot be read at that moment
(the policy itself is still answered). A member who has spent nothing this month reads "0".
The gateway stays the authority: a request can still be refused between your read and the
request.
How the gateway enforces it#
Budgets are spend limits under two reserved ids, checked beside yours before the provider is called:
| Limit id | Counts |
|---|---|
hixel:team_budget | Every request of the customer this month, whichever member it names, or none |
hixel:member_budget | The requests of the member a request names: its own budget, or the team's default |
A request over either is refused with 402, the same as any spend limit, and the message names
the id:
{
"error": {
"type": "payment_required",
"code": "spend_limit_reached",
"message": "the spend limit `hixel:member_budget` has been reached",
"param": null
}
}The first refusal in a month sends a
wallet.spend_limit_reached webhook with
limit_id hixel:team_budget (and member null) or hixel:member_budget (and the member).
A model that is not on the team's list, or on the named member's, is refused with 403
permission_denied / model_not_allowed, and GET /v1/models lists
only the models that pass, for the member in x-hixel-member.
Name the member, and pin it#
A member's budget and models apply to requests that name the member in x-hixel-member.
A request that names no member is held to your limits, the team budget and the team's models
only.
Whoever holds a secret key can name any member, so a member budget is only as strong as the
code that sets the header. When a browser or an app calls the gateway itself, give it a
client token minted with member: the token carries the member,
and the app cannot change it.
// On your server, with a key that has the `inference` scope.
const { token } = await hixel.clientTokens.create({
customer: "org_42",
member: "user_9",
expires_in: 600,
});Reserved limit ids#
Your own spend limits may not use an id starting with hixel:; such an id is refused when you
set it. A team or member budget never takes one of the 16 spend limits a customer or member may
have: it is checked in addition to them.
Errors#
| Status | code | When |
|---|---|---|
400 | invalid_parameter | A field breaks its rules; param names it |
400 | invalid_url | return_url or a URL of the theme is not an https:// URL of at most 2,048 characters; param names it |
400 | model_not_available | A model list names a model you do not allow the customer; param names the entry |
400 | empty_file | An upload with no bytes |
400 | unsupported_file_type | An upload that is not a PNG, JPEG, WebP, GIF, ICO or SVG image or a WOFF2 font |
400 | unsafe_svg | An SVG with script, event handlers, javascript: URLs, a foreignObject or references to other files |
400 | file_too_large | An image over 1 MiB or a font over 2 MiB |
403 | customer_blocked | Opening the portal for a blocked customer |
404 | customer_not_found | The customer does not exist (creating a portal session creates it instead), or ending sessions of one that does not |
404 | member_not_found | Reading or removing a member that has no row |
409 | member_overrides_limit_reached | A 2,001st member with a budget or model list of its own |
409 | asset_limit_reached | A 101st file in the environment |
409 | asset_in_use | Removing a file the saved theme names |
Reading a policy, a member, the settings or the files needs a key with the management scope, or
a project key with any role; changing them, uploading or removing a file, and creating or ending portal
sessions, a project key with the admin role. A blocked customer's open portal sessions stop working until it is unblocked.
Related#
- API reference: Customer portal: every operation and field.
- Limits: your own rate and spend limits.
- Client tokens: pin a browser's requests to a member.