Client billing
Client billing operations in the Hlix API.
See the OpenAPI document for schemas and operation IDs.
Prerequisites
Section titled “Prerequisites”- Protected operations require an API key in
x-api-keyor a browser session cookie; some actions require a verified user session - Tenant-scoped operations use
X-Organization-Id; browser sessions can use their active workspace. Discovery and personal-workspace bootstrap do not require an active workspace - The base URL for your deployment,
https://server.hlix.aiby default
Operations
Section titled “Operations”| Method | Path | Operation |
|---|---|---|
GET |
/v1/api/client-billing/billables |
List the ledger |
POST |
/v1/api/client-billing/billables |
Record a billable |
GET |
/v1/api/client-billing/billables/{id} |
Get one ledger row |
POST |
/v1/api/client-billing/billables/{id}/adjust |
Append a correction to a charge |
POST |
/v1/api/client-billing/billables/{id}/void |
Reverse a charge |
List the ledger
Section titled “List the ledger”GET /v1/api/client-billing/billables · operation ID listClientBillables
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
clientAccountId |
query | no | string | Only this customer’s rows. |
projectId |
query | no | string | Limit results to this project. A client collaborator without project access receives an access error rather than an empty ledger. |
X-Organization-Id |
header | no | string | The workspace (organization) to act in. Omitted, the session’s active organization is used. |
Responses
| Status | Body | Description |
|---|---|---|
200 |
ClientBillableView[] | The matching rows, each with the derived netAmountMicros and any void that reverses it. |
400 |
ApiError | The request named no active organization. |
401 |
ApiError | No valid session or API key. |
403 |
ApiError | Authenticated, but not a member of the named organization — or a client collaborator without the required access on this project. |
404 |
ApiError | The caller cannot access the requested projectId. Project-filtered reads return an access error rather than an empty ledger; unfiltered reads omit inaccessible rows. |
Record a billable
Section titled “Record a billable”POST /v1/api/client-billing/billables · operation ID createClientBillable
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
X-Organization-Id |
header | no | string | The workspace (organization) to act in. Omitted, the session’s active organization is used. |
Request body — application/json, CreateBillable (required)
The contract does not pin this body’s properties.
Responses
| Status | Body | Description |
|---|---|---|
201 |
ClientBillable | The saved billable with its price fixed at creation. For agent_usage, token counts and model are taken from the recorded run rather than the request. |
400 |
ValidationError | ApiError | The JSON body failed schema validation (ValidationError), or the request named no active organization (ApiError). |
401 |
ApiError | No valid session or API key. |
403 |
ApiError | The caller is a client collaborator; the billable ledger is managed by the agency. |
404 |
ApiError | No such client account or project in this workspace. Never a 403 — that would confirm it exists somewhere. |
409 |
ApiError | This source was already billed. A retried request is the usual cause. |
422 |
ApiError | A database constraint prevented the row from being saved. The response identifies the constraint. |
Get one ledger row
Section titled “Get one ledger row”GET /v1/api/client-billing/billables/{id} · operation ID getClientBillable
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id |
path | yes | string | |
X-Organization-Id |
header | no | string | The workspace (organization) to act in. Omitted, the session’s active organization is used. |
Responses
| Status | Body | Description |
|---|---|---|
200 |
ClientBillableView | The row, with its derived net and void. |
400 |
ApiError | The request named no active organization. |
401 |
ApiError | No valid session or API key. |
403 |
ApiError | Authenticated, but not a member of the named organization — or a client collaborator without the required access on this project. |
404 |
ApiError | No such billable this caller may read. |
Append a correction to a charge
Section titled “Append a correction to a charge”POST /v1/api/client-billing/billables/{id}/adjust · operation ID adjustClientBillable
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id |
path | yes | string | |
X-Organization-Id |
header | no | string | The workspace (organization) to act in. Omitted, the session’s active organization is used. |
Request body — application/json, AdjustBillable (required)
| Property | Type | Required | Notes |
|---|---|---|---|
description |
string | yes | min length 1, max length 500 |
note |
string | null | no | |
quantity |
number | yes | |
unit |
string | yes | min length 1, max length 50 |
unitPriceMicros |
integer (int64) | yes | min 0, max 1000000000000 |
Responses
| Status | Body | Description |
|---|---|---|
201 |
ClientBillable | A new correction row referencing the original charge. The original charge is unchanged. |
400 |
ValidationError | ApiError | The JSON body failed validation, or the request named no active organization. |
401 |
ApiError | No valid session or API key. |
403 |
ApiError | The caller is a client collaborator; the billable ledger is managed by the agency. |
404 |
ApiError | No such billable this caller may reach. |
409 |
ApiError | A correction cannot target another correction or a voided charge. The response identifies the violated rule. |
422 |
ApiError | A database constraint prevented the row from being saved. The response identifies the constraint. |
Reverse a charge
Section titled “Reverse a charge”POST /v1/api/client-billing/billables/{id}/void · operation ID voidClientBillable
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
id |
path | yes | string | |
X-Organization-Id |
header | no | string | The workspace (organization) to act in. Omitted, the session’s active organization is used. |
Request body — application/json, VoidBillable (required)
| Property | Type | Required | Notes |
|---|---|---|---|
reason |
string | yes | min length 1, max length 500 |
Responses
| Status | Body | Description |
|---|---|---|
201 |
ClientBillable | A new reversal row covering the charge and all its corrections, so the complete net amount is reversed. |
400 |
ValidationError | ApiError | The JSON body failed validation, or the request named no active organization. |
401 |
ApiError | No valid session or API key. |
403 |
ApiError | The caller is a client collaborator; the billable ledger is managed by the agency. |
404 |
ApiError | No such billable this caller may reach. |
409 |
ApiError | The charge was already voided or cannot be voided for the rule identified in the response. A charge can be voided only once. |
422 |
ApiError | A database constraint prevented the row from being saved. The response identifies the constraint. |
If a request fails
Section titled “If a request fails”The response table for each operation lists its documented errors. Common status codes include:
400— the body failed schema validation, or the request named no active organization. AValidationErrorbody carries the failing fields; anApiErrorbody carries onlyerror.401— no valid session or API key.403— authenticated, but not a member of the named organization, or a client collaborator without the required access.404— check the resource ID and your access to the selected Workspace.409— the expected revision or state is stale, or another operation currently owns the transition.500— the operation failed server-side. Retry only where an idempotency key makes that safe.