Top-ups
Customers buying credit through Stripe Checkout on the environment's Stripe connection.
| Operation | Method | SDK |
|---|---|---|
| List a customer's top-ups | GET | hixel.topUps.listForCustomer |
| Create a top-up | POST | hixel.topUps.create |
| List top-ups | GET | hixel.topUps.list |
| Get a top-up | GET | hixel.topUps.get |
List a customer's top-ups#
A page of the customer's top-ups, newest first.
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. |
status | query | "creating" | "pending" | "processing" | "succeeded" | "failed" | "expired" | Only top-ups with this status. |
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: TopUpList
| Field | Type | Description |
|---|---|---|
data required | array of TopUp | |
data[].id required | string | The id of a top-up (tup_…). |
data[].organization_id required | string | The id of your organization (org_…). |
data[].project_id required | string | The id of a project (proj_…). |
data[].environment_id required | string | The id of an environment (env_…). |
data[].customer required | string | Your id for the customer (its external_id), as every path takes it. |
data[].member required | string | null | The customer's member who asked for it; null for none. |
data[].amount_micros required | string | What the customer pays and is credited, in micro-USD. |
data[].currency required | "usd" | |
data[].mode required | "live" | "test" | Whether a Stripe key moves real money (live) or not (test), as its prefix says. |
data[].status required | "creating" | "pending" | "processing" | "succeeded" | "failed" | "expired" | Where a top-up's payment stands: creating until Stripe answered the session's creation, pending while its Checkout session is open, processing once completed with a payment still clearing, succeeded once credited, failed (the payment failed) or expired (never paid). |
data[].checkout_url required | string | null | Stripe Checkout's page to pay on, while the session is open; null otherwise. |
data[].expires_at required | string | null | When the Checkout session expires. |
data[].save_payment_method required | boolean | Whether Stripe was asked to save the payment method for auto-refill. |
data[].metadata required | object | Your own strings, kept as given; never sent to Stripe. |
data[].stripe_account_id required | string | |
data[].stripe_session_id required | string | null | |
data[].stripe_payment_intent_id required | string | null | |
data[].stripe_customer_id required | string | null | |
data[].stripe_invoice_id required | string | null | |
data[].invoice_url required | string | null | Stripe's hosted invoice and receipt, once paid. |
data[].invoice_pdf_url required | string | null | |
data[].ledger_entry_id required | string | null | The ledger entry that credited it, once succeeded. |
data[].refunded_micros required | string | Taken back by refunds, positive. |
data[].disputed_micros required | string | Taken back by an open or lost dispute, positive. |
data[].dispute_status required | "inquiry" | "open" | "won" | "lost" | null | |
data[].last_error required | string | null | Why the payment failed, or why the platform could not apply what Stripe said; never a secret. |
data[].succeeded_at required | string | null | |
data[].created_at required | string (date-time) | |
data[].updated_at required | string (date-time) | |
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/top_ups" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const item of hixel.topUps.listForCustomer("org_42")) {
console.log(item);
}Create a top-up#
Opens a Stripe Checkout session for the customer to pay amount_micros (1 to 10,000 USD, whole cents): send the customer to checkout_url. The wallet is credited once Stripe says the payment succeeded (wallet.top_up_succeeded). Needs an enabled Stripe connection with its webhook secret.
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: CreateTopUpBody
| Field | Type | Description |
|---|---|---|
amount_micros required | string | Micro-USD, a whole number of cents, from 1 to 10,000 USD. |
success_url required | string | Where Checkout sends the customer after paying: https://. |
cancel_url required | string | Where Checkout's back button goes: https://. |
member | string | The customer's member who asked for it. |
metadata | object | Up to 20 keys of 40 characters, values of 500, kept by the platform and never sent to Stripe. |
save_payment_method | boolean | Ask Stripe to save the payment method for later charges (auto-refill). Getting the customer's consent for that is your responsibility. |
Response 200: TopUp
| Field | Type | Description |
|---|---|---|
id required | string | The id of a top-up (tup_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The id of an environment (env_…). |
customer required | string | Your id for the customer (its external_id), as every path takes it. |
member required | string | null | The customer's member who asked for it; null for none. |
amount_micros required | string | What the customer pays and is credited, in micro-USD. |
currency required | "usd" | |
mode required | "live" | "test" | Whether a Stripe key moves real money (live) or not (test), as its prefix says. |
status required | "creating" | "pending" | "processing" | "succeeded" | "failed" | "expired" | Where a top-up's payment stands: creating until Stripe answered the session's creation, pending while its Checkout session is open, processing once completed with a payment still clearing, succeeded once credited, failed (the payment failed) or expired (never paid). |
checkout_url required | string | null | Stripe Checkout's page to pay on, while the session is open; null otherwise. |
expires_at required | string | null | When the Checkout session expires. |
save_payment_method required | boolean | Whether Stripe was asked to save the payment method for auto-refill. |
metadata required | object | Your own strings, kept as given; never sent to Stripe. |
stripe_account_id required | string | |
stripe_session_id required | string | null | |
stripe_payment_intent_id required | string | null | |
stripe_customer_id required | string | null | |
stripe_invoice_id required | string | null | |
invoice_url required | string | null | Stripe's hosted invoice and receipt, once paid. |
invoice_pdf_url required | string | null | |
ledger_entry_id required | string | null | The ledger entry that credited it, once succeeded. |
refunded_micros required | string | Taken back by refunds, positive. |
disputed_micros required | string | Taken back by an open or lost dispute, positive. |
dispute_status required | "inquiry" | "open" | "won" | "lost" | null | |
last_error required | string | null | Why the payment failed, or why the platform could not apply what Stripe said; never a secret. |
succeeded_at required | string | null | |
created_at required | string (date-time) | |
updated_at required | string (date-time) |
Errors
- 400
invalid_amount,invalid_url,invalid_parameter,stripe_refused: 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.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.stripe_not_connected: This environment has no enabled Stripe connection with a webhook signing secret. Connect Stripe 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,stripe_unavailable,stripe_key_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/top_ups" \
-H "Authorization: Bearer $HIXEL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount_micros": "5000000",
"success_url": "https://app.example.com/billing/paid",
"cancel_url": "https://app.example.com/billing"
}'const topUp = await hixel.topUps.create("org_42", {
amount_micros: "5000000",
success_url: "https://app.example.com/billing/paid",
cancel_url: "https://app.example.com/billing",
});List top-ups#
A page of the environment's top-ups, newest first.
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 |
|---|---|---|---|
status | query | "creating" | "pending" | "processing" | "succeeded" | "failed" | "expired" | Only top-ups with this status. |
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: TopUpList
| Field | Type | Description |
|---|---|---|
data required | array of TopUp | |
data[].id required | string | The id of a top-up (tup_…). |
data[].organization_id required | string | The id of your organization (org_…). |
data[].project_id required | string | The id of a project (proj_…). |
data[].environment_id required | string | The id of an environment (env_…). |
data[].customer required | string | Your id for the customer (its external_id), as every path takes it. |
data[].member required | string | null | The customer's member who asked for it; null for none. |
data[].amount_micros required | string | What the customer pays and is credited, in micro-USD. |
data[].currency required | "usd" | |
data[].mode required | "live" | "test" | Whether a Stripe key moves real money (live) or not (test), as its prefix says. |
data[].status required | "creating" | "pending" | "processing" | "succeeded" | "failed" | "expired" | Where a top-up's payment stands: creating until Stripe answered the session's creation, pending while its Checkout session is open, processing once completed with a payment still clearing, succeeded once credited, failed (the payment failed) or expired (never paid). |
data[].checkout_url required | string | null | Stripe Checkout's page to pay on, while the session is open; null otherwise. |
data[].expires_at required | string | null | When the Checkout session expires. |
data[].save_payment_method required | boolean | Whether Stripe was asked to save the payment method for auto-refill. |
data[].metadata required | object | Your own strings, kept as given; never sent to Stripe. |
data[].stripe_account_id required | string | |
data[].stripe_session_id required | string | null | |
data[].stripe_payment_intent_id required | string | null | |
data[].stripe_customer_id required | string | null | |
data[].stripe_invoice_id required | string | null | |
data[].invoice_url required | string | null | Stripe's hosted invoice and receipt, once paid. |
data[].invoice_pdf_url required | string | null | |
data[].ledger_entry_id required | string | null | The ledger entry that credited it, once succeeded. |
data[].refunded_micros required | string | Taken back by refunds, positive. |
data[].disputed_micros required | string | Taken back by an open or lost dispute, positive. |
data[].dispute_status required | "inquiry" | "open" | "won" | "lost" | null | |
data[].last_error required | string | null | Why the payment failed, or why the platform could not apply what Stripe said; never a secret. |
data[].succeeded_at required | string | null | |
data[].created_at required | string (date-time) | |
data[].updated_at required | string (date-time) | |
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_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
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/top_ups" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const item of hixel.topUps.list()) {
console.log(item);
}Get a top-up#
One top-up of the environment, by its id (tup_…).
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 |
|---|---|---|---|
id required | path | string | The top-up's id (tup_…). |
Response 200: TopUp
| Field | Type | Description |
|---|---|---|
id required | string | The id of a top-up (tup_…). |
organization_id required | string | The id of your organization (org_…). |
project_id required | string | The id of a project (proj_…). |
environment_id required | string | The id of an environment (env_…). |
customer required | string | Your id for the customer (its external_id), as every path takes it. |
member required | string | null | The customer's member who asked for it; null for none. |
amount_micros required | string | What the customer pays and is credited, in micro-USD. |
currency required | "usd" | |
mode required | "live" | "test" | Whether a Stripe key moves real money (live) or not (test), as its prefix says. |
status required | "creating" | "pending" | "processing" | "succeeded" | "failed" | "expired" | Where a top-up's payment stands: creating until Stripe answered the session's creation, pending while its Checkout session is open, processing once completed with a payment still clearing, succeeded once credited, failed (the payment failed) or expired (never paid). |
checkout_url required | string | null | Stripe Checkout's page to pay on, while the session is open; null otherwise. |
expires_at required | string | null | When the Checkout session expires. |
save_payment_method required | boolean | Whether Stripe was asked to save the payment method for auto-refill. |
metadata required | object | Your own strings, kept as given; never sent to Stripe. |
stripe_account_id required | string | |
stripe_session_id required | string | null | |
stripe_payment_intent_id required | string | null | |
stripe_customer_id required | string | null | |
stripe_invoice_id required | string | null | |
invoice_url required | string | null | Stripe's hosted invoice and receipt, once paid. |
invoice_pdf_url required | string | null | |
ledger_entry_id required | string | null | The ledger entry that credited it, once succeeded. |
refunded_micros required | string | Taken back by refunds, positive. |
disputed_micros required | string | Taken back by an open or lost dispute, positive. |
dispute_status required | "inquiry" | "open" | "won" | "lost" | null | |
last_error required | string | null | Why the payment failed, or why the platform could not apply what Stripe said; never a secret. |
succeeded_at required | string | null | |
created_at required | string (date-time) | |
updated_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.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
top_up_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/top_ups/tup_123" \
-H "Authorization: Bearer $HIXEL_API_KEY"const topUp = await hixel.topUps.get("tup_123");