Customer portal
What a customer's admin governs in the hosted portal, which your backend can read and change too.
the customer's team policy, its members' own budgets and models, portal sessions and the portal's look.
| Operation | Method | SDK |
|---|---|---|
| Get a customer's team policy | GET | hixel.customerPolicy.get |
| Update a customer's team policy | PATCH | hixel.customerPolicy.update |
| List a customer's members | GET | hixel.members.list |
| Get a member | GET | hixel.members.get |
| Create or update a member | PUT | hixel.members.put |
| Remove a member | DELETE | hixel.members.remove |
| Get a member's effective policy | GET | hixel.members.effectivePolicy |
| Create a portal session | POST | hixel.portalSessions.create |
| Revoke portal sessions | DELETE | hixel.portalSessions.revoke |
| Get the portal settings | GET | hixel.portalSettings.get |
| Update the portal settings | PATCH | hixel.portalSettings.update |
| List the portal files | GET | hixel.portalAssets.list |
| Upload a portal file | POST | hixel.portalAssets.upload |
| Remove a portal file | DELETE | hixel.portalAssets.remove |
Get a customer's team policy#
The team budget, the default member budget and the models the team may use; all null when none is set.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
Response 200: CustomerPolicy
| Field | Type | Description |
|---|---|---|
customer required | string | Your id for the customer (its external_id), as every path takes it. |
team_budget_micros required | BudgetMicros | null | A cap on the customer's spend per calendar month (UTC); null for none. |
member_budget_micros required | BudgetMicros | null | Every member's budget per calendar month (UTC), unless the member has its own; null for none. |
allowed_models required | array of string | null | Exact model names, each one the tenant allows the customer; null allows every model the level above allows. |
updated_at required | string | null | When it last changed; null when never set. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-hixel-environment.invalid_params: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/customers/org_42/policy" \
-H "Authorization: Bearer $HIXEL_API_KEY"const customerPolicy = await hixel.customerPolicy.get("org_42");Update a customer's team policy#
Sets the fields given; null clears one. Budgets are per calendar month (UTC) and only restrict further: one above your own limits changes nothing, and none is refused for it. Each model must be one you allow the customer today (model_not_available).
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
Request body: UpdateCustomerPolicyBody
| Field | Type | Description |
|---|---|---|
team_budget_micros | BudgetMicros | null | The team budget; null removes it. |
member_budget_micros | BudgetMicros | null | The default member budget; null removes it. |
allowed_models | array of string | null | Exact model names the team may use, each one the tenant allows the customer today (model_not_available otherwise); null allows every one. |
Response 200: CustomerPolicy
| Field | Type | Description |
|---|---|---|
customer required | string | Your id for the customer (its external_id), as every path takes it. |
team_budget_micros required | BudgetMicros | null | A cap on the customer's spend per calendar month (UTC); null for none. |
member_budget_micros required | BudgetMicros | null | Every member's budget per calendar month (UTC), unless the member has its own; null for none. |
allowed_models required | array of string | null | Exact model names, each one the tenant allows the customer; null allows every model the level above allows. |
updated_at required | string | null | When it last changed; null when never set. |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.model_not_available: This model is not one the customer may use.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_params,invalid_payload,malformed_body,body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 409
project_archived: This project is archived.environment_archived: This environment is archived.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
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": "5000000"
}'const customerPolicy = await hixel.customerPolicy.update("org_42", {
team_budget_micros: "5000000",
});List a customer's members#
A page of the customer's member rows, oldest first. Members that only made requests have no row.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
cursor | query | string | The next_cursor of the previous page, to read the next one; left out for the first page. Pass the same filters with it. |
limit | query | integer | How many items the page holds: an integer from 1 to 100; 50 when left out. |
Response 200: MemberList
| Field | Type | Description |
|---|---|---|
data required | array of Member | |
data[].id required | string | The platform's id of the member row (mem_…); every path takes your id for it. |
data[].external_id required | string | Your id for the member, unique within the customer: what x-hixel-member names. |
data[].name required | string | null | A display name; null for none. |
data[].email required | string | null | An email address; null for none. |
data[].budget required | any | {"type": "inherit"} takes the team's default member budget, {"type": "unlimited"} sets none, {"type": "limit", "limit_micros": "…"} sets the member's own, per calendar month (UTC). |
data[].allowed_models required | array of string | null | Exact model names, each one the tenant allows the customer; null allows every model the level above allows. |
data[].created_at required | string (date-time) | |
data[].updated_at required | string (date-time) | |
data[].customer required | string | Your id for the customer (its external_id), as every path takes it. |
next_cursor required | string | null | Pass back as cursor for the next page; null on the last page. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_cursor: The cursor is not one this list gave.environment_required: a project key was sent withoutx-hixel-environment.invalid_params,invalid_query: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/customers/org_42/members" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const item of hixel.members.list("org_42")) {
console.log(item);
}Get a member#
The member's row; member_not_found when the customer has none for it.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
member required | path | string | Your id for the member, as x-hixel-member names it. |
Response 200: Member
| Field | Type | Description |
|---|---|---|
id required | string | The platform's id of the member row (mem_…); every path takes your id for it. |
external_id required | string | Your id for the member, unique within the customer: what x-hixel-member names. |
name required | string | null | A display name; null for none. |
email required | string | null | An email address; null for none. |
budget required | any | {"type": "inherit"} takes the team's default member budget, {"type": "unlimited"} sets none, {"type": "limit", "limit_micros": "…"} sets the member's own, per calendar month (UTC). |
allowed_models required | array of string | null | Exact model names, each one the tenant allows the customer; null allows every model the level above allows. |
created_at required | string (date-time) | |
updated_at required | string (date-time) | |
customer required | string | Your id for the customer (its external_id), as every path takes it. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-hixel-environment.invalid_params: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
customer_not_found,member_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/customers/org_42/members/member_123" \
-H "Authorization: Bearer $HIXEL_API_KEY"const member = await hixel.members.get("org_42", "member_123");Create or update a member#
Creates the member's row with the fields given (201), or changes the fields given of the existing one (200). A customer has at most 2,000 members with a budget or model list of their own (member_overrides_limit_reached).
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
member required | path | string | Your id for the member, as x-hixel-member names it. |
Request body: PutMemberBody
| Field | Type | Description |
|---|---|---|
name | string | null | A display name, at most 255 characters; null removes it. |
email | string | null | An email address; null removes it. |
budget | any | {"type": "inherit"} takes the team's default member budget, {"type": "unlimited"} sets none, {"type": "limit", "limit_micros": "…"} sets the member's own, per calendar month (UTC). |
allowed_models | array of string | null | Exact model names the member may use, each one the tenant allows the customer today (model_not_available otherwise); null allows every one the team allows. |
Response 200, 201: Member
200: The row existed and was changed. 201: The row was created.
| Field | Type | Description |
|---|---|---|
id required | string | The platform's id of the member row (mem_…); every path takes your id for it. |
external_id required | string | Your id for the member, unique within the customer: what x-hixel-member names. |
name required | string | null | A display name; null for none. |
email required | string | null | An email address; null for none. |
budget required | any | {"type": "inherit"} takes the team's default member budget, {"type": "unlimited"} sets none, {"type": "limit", "limit_micros": "…"} sets the member's own, per calendar month (UTC). |
allowed_models required | array of string | null | Exact model names, each one the tenant allows the customer; null allows every model the level above allows. |
created_at required | string (date-time) | |
updated_at required | string (date-time) | |
customer required | string | Your id for the customer (its external_id), as every path takes it. |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.model_not_available: This model is not one the customer may use.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_params,invalid_payload,malformed_body,body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 409
project_archived: This project is archived.environment_archived: This environment is archived.member_overrides_limit_reached: This customer has the most members with a budget or model list of their own (2,000). Return one to the team's defaults first.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X PUT "https://api.hixel.dev/v1/customers/org_42/members/member_123" \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Inc."
}'const member = await hixel.members.put("org_42", "member_123", {
name: "Acme Inc.",
});Remove a member#
Deletes the member's row, and with it its own budget and models; the member can still make requests, held to the team's defaults. Answers 204 with no body.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
member required | path | string | Your id for the member, as x-hixel-member names it. |
Response 204
No body.
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_params: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
customer_not_found,member_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 409
project_archived: This project is archived.environment_archived: This environment is archived.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X DELETE "https://api.hixel.dev/v1/customers/org_42/members/member_123" \
-H "Authorization: Bearer $HIXEL_API_KEY"await hixel.members.remove("org_42", "member_123");Get a member's effective policy#
What applies to the member right now, every layer merged, whether it has a row or not: the models it may request, its budget and the team's with what is spent, and your spend limits that apply. A spent amount is null when it cannot be read.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
member required | path | string | Your id for the member, as x-hixel-member names it. |
Response 200: MemberEffectivePolicy
| Field | Type | Description |
|---|---|---|
member required | string | Your id for the member. |
models required | array of string | Every model the member may request now, by name: what every layer allows. |
member_budget required | EffectiveMemberBudget | null | null when neither the member nor the team sets a member budget. |
member_budget.source required | "member" | "team" | member: the member's own budget; team: the team's default member budget. |
member_budget.limit_micros required | BudgetMicros | null | null when the member's own budget is unlimited. |
member_budget.spent_micros required | string | null | Spent in the current window, as the customer's limiter counts it; null when it cannot be read. |
team_budget required | EffectiveTeamBudget | null | null when the team sets no budget. |
team_budget.limit_micros required | any | Micro-USD as a decimal string, from "0" (refuses every request that costs anything) to 2^63 − 1. |
team_budget.spent_micros required | string | null | Spent in the current window, as the customer's limiter counts it; null when it cannot be read. |
limits required | array of EffectiveSpendLimit | Your own spend limits that apply to the member, the customer's first. |
limits[].id required | string | The spend limit's id, as the tenant named it. |
limits[].applies_to required | "customer" | "member" | customer: the customer's own limits or the environment's customer limits; member: the environment's member limits. |
limits[].window required | "day" | "week" | "month" | "total" | |
limits[].limit_micros required | UnsignedMicros | |
limits[].spent_micros required | string | null | Spent in the current window, as the customer's limiter counts it; null when it cannot be read. |
limits[].resets_at required | string | null | When the window starts again; null for a total limit, which never does. |
resets_at required | string (date-time) | When the budgets start again: the first instant of the next calendar month (UTC). |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-hixel-environment.invalid_params: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/customers/org_42/members/member_123/policy" \
-H "Authorization: Bearer $HIXEL_API_KEY"const memberEffectivePolicy = await hixel.members.effectivePolicy("org_42", "member_123");Create a portal session#
A session of the hosted portal for a member of the customer you have signed in, with the role you assert (admin or member). Send the browser to url: it works once, within five minutes. Creates the customer and the member's row when needed, and writes name and email to the row when sent. Answered once (cache-control: no-store); a replayed response's url is null.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
Request body: CreatePortalSessionBody
| Field | Type | Description |
|---|---|---|
member required | string | Your id for the member the session acts for: 1 to 256 characters of visible ASCII, as x-hixel-member takes it. |
role required | "admin" | "member" | admin: governs the customer's budgets, models and members; member: sees its own policy and usage. |
name | string | The member's display name, written to its row when sent. |
email | string | The member's email address, written to its row when sent. |
return_url | string | Where the portal sends the member back to: an https:// URL of at most 2,048 characters; the environment's default when left out. |
expires_in_seconds | integer | How long the session lasts once created: 300 to 86,400; 3,600 when left out. |
Response 201: PortalSession
| Field | Type | Description |
|---|---|---|
id required | string | The id of a portal session (ps_…). |
url required | string | null | Where to send the member's browser: usable once, for five minutes. null in a replayed response (Idempotent-Replayed: true): create another session. |
expires_at required | string (date-time) | When the session ends. |
Errors
- 400
invalid_parameter,invalid_url: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_params,invalid_payload,malformed_body,body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.customer_blocked: the customer is blocked; unblock it before opening its portal.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own. - 409
project_archived: This project is archived.environment_archived: This environment is archived.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable,portal_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl -X POST "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"
}'const portalSession = await hixel.portalSessions.create("org_42", {
member: "user_7",
role: "admin",
});Revoke portal sessions#
Ends the customer's portal sessions, or only member's, entered or not: their next call in the portal is signed out and an unused url no longer works. Use it when you remove a member or change its role. Answers how many were ended; repeating it ends none. Removing a member (DELETE …/members/{member}) ends its sessions too.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
member | query | string | Your id for the member whose sessions end; every member's when left out. |
Response 200: PortalSessionsRevoked
| Field | Type | Description |
|---|---|---|
revoked required | integer | How many sessions were ended: those not yet ended, entered or not. 0 when there were none. |
Errors
- 400
invalid_parameter: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_params,invalid_query: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
customer_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 409
idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running. - 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X DELETE "https://api.hixel.dev/v1/customers/org_42/portal_sessions" \
-H "Authorization: Bearer $HIXEL_API_KEY"const portalSessionsRevoked = await hixel.portalSessions.revoke("org_42");Get the portal settings#
The portal's display name, default return address and theme; null (or a theme field left out) where the default applies.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Response 200: PortalSettings
| Field | Type | Description |
|---|---|---|
environment_id required | string | The id of an environment (env_…). |
display_name required | string | null | The name the portal shows; the project's name when null. |
return_url required | string | null | Where a member goes back to when its session names none; null for none. |
theme required | any | How the portal looks. Every field is optional and one left out is the default: {} is the portal as it ships. |
updated_at required | string | null | When it last changed; null when never set. |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-hixel-environment.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own. - 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/portal_settings" \
-H "Authorization: Bearer $HIXEL_API_KEY"const portalSettings = await hixel.portalSettings.get();Update the portal settings#
Sets the fields given; null restores a field's default. A theme sent replaces the whole theme (null resets it); a field of it at fault is invalid_request naming its path in param (theme.links.footer.2.url).
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment. Accepts an Idempotency-Key header: a retry with the same key runs once.
Request body: UpdatePortalSettingsBody
| Field | Type | Description |
|---|---|---|
display_name | string | null | |
return_url | string | null | |
theme | object | null | The whole theme, in the shape theme is answered in: it replaces the one set, and a field left out is the default. null resets every field. A field at fault is invalid_request naming its path in param (theme.colors.dark.primary). |
Response 200: PortalSettings
| Field | Type | Description |
|---|---|---|
environment_id required | string | The id of an environment (env_…). |
display_name required | string | null | The name the portal shows; the project's name when null. |
return_url required | string | null | Where a member goes back to when its session names none; null for none. |
theme required | any | How the portal looks. Every field is optional and one left out is the default: {} is the portal as it ships. |
updated_at required | string | null | When it last changed; null when never set. |
Errors
- 400
invalid_parameter,invalid_url: The request is malformed or fails validation;paramnames the field.invalid_idempotency_key: anIdempotency-Keyis 1 to 255 characters of visible ASCII.environment_required: a project key was sent withoutx-hixel-environment.invalid_payload,malformed_body,body_too_large: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own. - 409
project_archived: This project is archived.environment_archived: This environment is archived.idempotency_key_reused,idempotency_key_in_use: the key was used for another request (method, path or body), or the first request with it is still running.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: the stored response to the key could not be read or written; retry later.
curl -X PATCH "https://api.hixel.dev/v1/portal_settings" \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"display_name": "…"
}'const portalSettings = await hixel.portalSettings.update({
display_name: "…",
});List the portal files#
Every file uploaded in the environment, newest first; there are at most 100.
Takes an environment key with the management scope, or a project key with the member role or higher, naming the environment in x-hixel-environment.
Response 200: PortalAssetList
| Field | Type | Description |
|---|---|---|
data required | array of PortalAsset | |
data[].id required | string | The id of an uploaded portal file (pas_…). |
data[].environment_id required | string | The id of an environment (env_…). |
data[].kind required | "image" | "font" | image: PNG, JPEG, WebP, GIF, ICO or SVG, at most 1 MiB; font: WOFF2, at most 2 MiB. |
data[].content_type required | string | The type read from the file's bytes, which it is served with (image/png, font/woff2, …). |
data[].size_bytes required | integer | The file's size in bytes. |
data[].sha256 required | string | The lowercase hex SHA-256 of the file. |
data[].filename required | string | The name the file was uploaded with, for display only; never part of its URL. |
data[].url required | string | Where the file is served from, publicly and unchanging: put it in a field of the portal's theme (logo.light_url, icon_url, typography.body.url, …). |
data[].created_at required | string (date-time) |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-hixel-environment.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.
- 404
environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own. - 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable,assets_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl "https://api.hixel.dev/v1/portal_assets" \
-H "Authorization: Bearer $HIXEL_API_KEY"const portalAssetList = await hixel.portalAssets.list();Upload a portal file#
Stores an image or a font for the portal's theme and answers it with its url, which you then put in the theme (PATCH /v1/portal_settings). Send the file's bytes as the body with Content-Type: application/octet-stream; its type is read from the bytes, never from the name. An SVG with script, event handlers, javascript: URLs, a foreignObject, a DOCTYPE or references to other files is refused (unsafe_svg). An environment keeps at most 100 files (asset_limit_reached). Idempotency-Key does not apply: every upload is a new file, and a retried upload makes a second one, which is removed once it is a day old and no saved theme names it.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
filename | query | string | The file's name, for display only: kept without its folders or control characters, cut at 255 characters; file when left out. |
Response 201: PortalAsset
| Field | Type | Description |
|---|---|---|
id required | string | The id of an uploaded portal file (pas_…). |
environment_id required | string | The id of an environment (env_…). |
kind required | "image" | "font" | image: PNG, JPEG, WebP, GIF, ICO or SVG, at most 1 MiB; font: WOFF2, at most 2 MiB. |
content_type required | string | The type read from the file's bytes, which it is served with (image/png, font/woff2, …). |
size_bytes required | integer | The file's size in bytes. |
sha256 required | string | The lowercase hex SHA-256 of the file. |
filename required | string | The name the file was uploaded with, for display only; never part of its URL. |
url required | string | Where the file is served from, publicly and unchanging: put it in a field of the portal's theme (logo.light_url, icon_url, typography.body.url, …). |
created_at required | string (date-time) |
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.empty_file: The file is empty: send its bytes as the request body.unsupported_file_type: The file is not one the portal takes: a PNG, JPEG, WebP, GIF, ICO or SVG image, or a WOFF2 font. Its type is read from its contents, not its name.unsafe_svg: The SVG contains script, an event handler, a javascript: URL, a foreignObject, a DOCTYPE or a reference to another file. Export it as a plain image and upload it again.file_too_large: An image may be at most 1 MiB and a font at most 2 MiB.environment_required: a project key was sent withoutx-hixel-environment.invalid_query,unsupported_content_type,malformed_body: the request's query does not match its schema, the body is not sent asapplication/octet-stream, or it cannot be read.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own. - 409
asset_limit_reached: This environment keeps the most uploaded files it may (100). Remove one it no longer uses first.project_archived: This project is archived.environment_archived: This environment is archived.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable,assets_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl -X POST "https://api.hixel.dev/v1/portal_assets" \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/octet-stream" \
--data-binary @logo.pngconst portalAsset = await hixel.portalAssets.upload(new Blob([/* the file's bytes */]), {
filename: "logo.png",
});Remove a portal file#
Deletes the file; its URL stops serving. A file the saved theme names is refused (asset_in_use): save a theme without it first. Answers 204 with no body.
Takes an environment key with the management scope, or a project key with the admin role, naming the environment in x-hixel-environment.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The file's id, pas_…. |
Response 204
No body.
Errors
- 400
invalid_request: The request is malformed or fails validation;paramnames the field.environment_required: a project key was sent withoutx-hixel-environment.invalid_params: the request's path, query or body does not match its schema, or the body is not JSON or is over 1 MiB.
- 401
api_key_required,invalid_api_key,expired_api_key: no key was sent; the key is unknown or revoked, or its project or environment is archived; or it has expired. - 403
key_inactive: the key was revoked or expired while the request ran, or an environment's key lost themanagementscope.management_scope_required: the environment's key does not have themanagementscope.role_not_allowed: the project key'smemberrole does not allow this; it takesadmin.
- 404
portal_asset_not_found: The resource does not exist in the key's environment; a resource outside it reads the same.environment_not_found:x-hixel-environmentnames an environment outside the project key's project, an archived one, or another than the environment key's own.
- 409
asset_in_use: The portal's saved theme uses this file. Save a theme without it first.project_archived: This project is archived.environment_archived: This environment is archived.
- 500
internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned. - 503
database_unavailable: A dependency, such as the database or Stripe, cannot be reached; retry later.
curl -X DELETE "https://api.hixel.dev/v1/portal_assets/pas_123" \
-H "Authorization: Bearer $HIXEL_API_KEY"await hixel.portalAssets.remove("pas_123");