Customers and members
Create and update your customers, block them, and attach your own data.
A customer is one of your own customers, identified by your id for it (external_id). It owns
a wallet, can have its own limits, allowed models and provider keys, and every request that
names it is recorded against it. Members are the people inside a customer; they need no setup.
You do not have to create customers ahead of time: the first request that names a new customer creates it. Create them yourself when you want to set a name, metadata, limits or allowed models before the first request, or to grant credit up front.
Create or update a customer#
PUT /v1/customers/{external_id} creates the customer, or changes the fields you send if it
exists. Fields you leave out are kept. It answers 201 when it created the customer and 200
when it changed one, with the customer either way. To create without ever changing an existing
customer, POST /v1/customers with external_id in the body answers 201, or 409
customer_exists when the id is taken.
curl -X PUT https://api.hixel.dev/v1/customers/org_42 \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Inc.",
"metadata": { "plan": "team", "crm_id": "0017Q00000abcde" }
}'const customer = await hixel.customers.upsert("org_42", {
name: "Acme Inc.",
metadata: { plan: "team", crm_id: "0017Q00000abcde" },
});{
"id": "cus_k3j9x2m8q1w7e4r5t6y0u2i3",
"organization_id": "org_…",
"project_id": "proj_…",
"environment_id": "env_…",
"external_id": "org_42",
"name": "Acme Inc.",
"status": "active",
"allowed_models": null,
"metadata": { "plan": "team", "crm_id": "0017Q00000abcde" },
"limits": null,
"created_at": "2026-11-25T10:00:00.000Z",
"updated_at": "2026-11-25T10:00:00.000Z"
}| Field | Rules |
|---|---|
external_id | In the path. Your id for the customer: 1 to 256 characters of visible ASCII, no spaces, not . or .., compared byte for byte. Unique in the environment. |
name | A display name, up to 100 characters. null removes it. |
metadata | Any JSON object, up to 16 KB. It replaces the stored metadata; send the whole object. |
allowed_models | Model names and prefix/* patterns this customer may use, within what the environment allows. null: everything the environment allows. |
limits | The customer's own rate and spend limits, replacing the environment's customer limits; null returns to them. See Limits. |
id (cus_…) is Hixel's id for the customer. Every call identifies the customer by
your external_id, and every other resource names its customer by it too (customer: "org_42"), so you never need to store id.
Read and list customers#
curl https://api.hixel.dev/v1/customers/org_42 \
-H "Authorization: Bearer $HIXEL_API_KEY"const customer = await hixel.customers.get("org_42");curl "https://api.hixel.dev/v1/customers?limit=50&external_id_prefix=org_" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const customer of hixel.customers.list({ limit: 50, external_id_prefix: "org_" })) {
console.log(customer.external_id, customer.name);
}The list is oldest first, and paginated with cursor and limit (1 to
100, default 50). It filters by external_id_prefix (ids starting with it, byte for byte),
name (names containing it, ignoring case), status (active or blocked),
has_own_limits and has_own_allowed_models (true or false). GET /v1/customer_counts
answers how many customers each of those filters would list. A customer that does not exist in the key's
environment reads as 404 not_found.
Block a customer#
Blocking stops a customer's requests at the gateway at once, whatever its balance, with 403 and
customer_blocked. Nothing else changes: its wallet, settings and history are kept.
curl -X POST https://api.hixel.dev/v1/customers/org_42/block \
-H "Authorization: Bearer $HIXEL_API_KEY"
curl -X POST https://api.hixel.dev/v1/customers/org_42/unblock \
-H "Authorization: Bearer $HIXEL_API_KEY"await hixel.customers.block("org_42");
await hixel.customers.unblock("org_42");Both answer the customer with its new status, and send the customer.blocked or
customer.unblocked webhook. A blocked customer cannot get a client
token, and its auto-refill does not run.
Members#
Send your id for the person who made a request in x-hixel-member, with the same rules as a
customer id (a value with a space, or . or .., is refused with 400 invalid_header). There is nothing to create: the member is recorded on the request's usage, so you
can filter and total usage by member (GET /v1/usage?member=user_7,
GET /v1/usage/series?group_by=member), and the environment's member limits apply to each
member separately.
The gateway trusts the member id your server sends. A key pinned to a customer accepts any member id; pin a key or a client token to a member when the caller should not be able to choose.
A member can also have a row of its own, with a name, an email, a monthly budget and the models it may use, beside a budget and a model list for the whole customer (its team policy). The customer's admin sets them in the hosted customer portal, and you can set them through the same API; a member without a row is held to the team's defaults.
Customers created by requests#
A customer created by its first request has no name, no metadata and the environment's
defaults. Its customer.created webhook says "source": "usage" (and "api" or "dashboard"
for one you created). Update it with PUT /v1/customers/{external_id} whenever you like.
Related#
- Wallets: the customer's balance and ledger.
- Customer provider keys: run a customer on its own provider account.
- Limits: rate and spend limits per customer and member.
- Customer portal: team and member budgets and models, set by the customer's admin or by you.