Documentation menu

Top-ups

Customers buying credit through Stripe Checkout on the environment's Stripe connection.

OperationMethodSDK
List a customer's top-upsGEThixel.topUps.listForCustomer
Create a top-upPOSThixel.topUps.create
List top-upsGEThixel.topUps.list
Get a top-upGEThixel.topUps.get

List a customer's top-ups#

GET/v1/customers/{external_id}/top_upshixel.topUps.listForCustomer

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

NameInTypeDescription
external_id requiredpathstringYour id for the customer.
statusquery"creating" | "pending" | "processing" | "succeeded" | "failed" | "expired"Only top-ups with this status.
cursorquerystringThe next_cursor of the previous page, to read the next one; left out for the first page. Pass the same filters with it.
limitqueryintegerHow many items the page holds: an integer from 1 to 100; 50 when left out.

Response 200: TopUpList

FieldTypeDescription
data requiredarray of TopUp
data[].id requiredstringThe id of a top-up (tup_…).
data[].organization_id requiredstringThe id of your organization (org_…).
data[].project_id requiredstringThe id of a project (proj_…).
data[].environment_id requiredstringThe id of an environment (env_…).
data[].customer requiredstringYour id for the customer (its external_id), as every path takes it.
data[].member requiredstring | nullThe customer's member who asked for it; null for none.
data[].amount_micros requiredstringWhat 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 requiredstring | nullStripe Checkout's page to pay on, while the session is open; null otherwise.
data[].expires_at requiredstring | nullWhen the Checkout session expires.
data[].save_payment_method requiredbooleanWhether Stripe was asked to save the payment method for auto-refill.
data[].metadata requiredobjectYour own strings, kept as given; never sent to Stripe.
data[].stripe_account_id requiredstring
data[].stripe_session_id requiredstring | null
data[].stripe_payment_intent_id requiredstring | null
data[].stripe_customer_id requiredstring | null
data[].stripe_invoice_id requiredstring | null
data[].invoice_url requiredstring | nullStripe's hosted invoice and receipt, once paid.
data[].invoice_pdf_url requiredstring | null
data[].ledger_entry_id requiredstring | nullThe ledger entry that credited it, once succeeded.
data[].refunded_micros requiredstringTaken back by refunds, positive.
data[].disputed_micros requiredstringTaken back by an open or lost dispute, positive.
data[].dispute_status required"inquiry" | "open" | "won" | "lost" | null
data[].last_error requiredstring | nullWhy the payment failed, or why the platform could not apply what Stripe said; never a secret.
data[].succeeded_at requiredstring | null
data[].created_at requiredstring (date-time)
data[].updated_at requiredstring (date-time)
next_cursor requiredstring | nullPass back as cursor for the next page; null on the last page.

Errors

  • 400
    • invalid_request: The request is malformed or fails validation; param names the field.
    • invalid_cursor: The cursor is not one this list gave.
    • environment_required: a project key was sent without x-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 the management scope.
    • management_scope_required: the environment's key does not have the management scope.
  • 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-environment names 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"

Create a top-up#

POST/v1/customers/{external_id}/top_upshixel.topUps.create

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

NameInTypeDescription
external_id requiredpathstringYour id for the customer.

Request body: CreateTopUpBody

FieldTypeDescription
amount_micros requiredstringMicro-USD, a whole number of cents, from 1 to 10,000 USD.
success_url requiredstringWhere Checkout sends the customer after paying: https://.
cancel_url requiredstringWhere Checkout's back button goes: https://.
memberstringThe customer's member who asked for it.
metadataobjectUp to 20 keys of 40 characters, values of 500, kept by the platform and never sent to Stripe.
save_payment_methodbooleanAsk Stripe to save the payment method for later charges (auto-refill). Getting the customer's consent for that is your responsibility.

Response 200: TopUp

FieldTypeDescription
id requiredstringThe id of a top-up (tup_…).
organization_id requiredstringThe id of your organization (org_…).
project_id requiredstringThe id of a project (proj_…).
environment_id requiredstringThe id of an environment (env_…).
customer requiredstringYour id for the customer (its external_id), as every path takes it.
member requiredstring | nullThe customer's member who asked for it; null for none.
amount_micros requiredstringWhat 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 requiredstring | nullStripe Checkout's page to pay on, while the session is open; null otherwise.
expires_at requiredstring | nullWhen the Checkout session expires.
save_payment_method requiredbooleanWhether Stripe was asked to save the payment method for auto-refill.
metadata requiredobjectYour own strings, kept as given; never sent to Stripe.
stripe_account_id requiredstring
stripe_session_id requiredstring | null
stripe_payment_intent_id requiredstring | null
stripe_customer_id requiredstring | null
stripe_invoice_id requiredstring | null
invoice_url requiredstring | nullStripe's hosted invoice and receipt, once paid.
invoice_pdf_url requiredstring | null
ledger_entry_id requiredstring | nullThe ledger entry that credited it, once succeeded.
refunded_micros requiredstringTaken back by refunds, positive.
disputed_micros requiredstringTaken back by an open or lost dispute, positive.
dispute_status required"inquiry" | "open" | "won" | "lost" | null
last_error requiredstring | nullWhy the payment failed, or why the platform could not apply what Stripe said; never a secret.
succeeded_at requiredstring | null
created_at requiredstring (date-time)
updated_at requiredstring (date-time)

Errors

  • 400
    • invalid_amount, invalid_url, invalid_parameter, stripe_refused: The request is malformed or fails validation; param names the field.
    • invalid_idempotency_key: an Idempotency-Key is 1 to 255 characters of visible ASCII.
    • environment_required: a project key was sent without x-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 the management scope.
    • management_scope_required: the environment's key does not have the management scope.
    • role_not_allowed: the project key's member role does not allow this; it takes admin.
  • 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-environment names 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"
  }'

List top-ups#

GET/v1/top_upshixel.topUps.list

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

NameInTypeDescription
statusquery"creating" | "pending" | "processing" | "succeeded" | "failed" | "expired"Only top-ups with this status.
cursorquerystringThe next_cursor of the previous page, to read the next one; left out for the first page. Pass the same filters with it.
limitqueryintegerHow many items the page holds: an integer from 1 to 100; 50 when left out.

Response 200: TopUpList

FieldTypeDescription
data requiredarray of TopUp
data[].id requiredstringThe id of a top-up (tup_…).
data[].organization_id requiredstringThe id of your organization (org_…).
data[].project_id requiredstringThe id of a project (proj_…).
data[].environment_id requiredstringThe id of an environment (env_…).
data[].customer requiredstringYour id for the customer (its external_id), as every path takes it.
data[].member requiredstring | nullThe customer's member who asked for it; null for none.
data[].amount_micros requiredstringWhat 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 requiredstring | nullStripe Checkout's page to pay on, while the session is open; null otherwise.
data[].expires_at requiredstring | nullWhen the Checkout session expires.
data[].save_payment_method requiredbooleanWhether Stripe was asked to save the payment method for auto-refill.
data[].metadata requiredobjectYour own strings, kept as given; never sent to Stripe.
data[].stripe_account_id requiredstring
data[].stripe_session_id requiredstring | null
data[].stripe_payment_intent_id requiredstring | null
data[].stripe_customer_id requiredstring | null
data[].stripe_invoice_id requiredstring | null
data[].invoice_url requiredstring | nullStripe's hosted invoice and receipt, once paid.
data[].invoice_pdf_url requiredstring | null
data[].ledger_entry_id requiredstring | nullThe ledger entry that credited it, once succeeded.
data[].refunded_micros requiredstringTaken back by refunds, positive.
data[].disputed_micros requiredstringTaken back by an open or lost dispute, positive.
data[].dispute_status required"inquiry" | "open" | "won" | "lost" | null
data[].last_error requiredstring | nullWhy the payment failed, or why the platform could not apply what Stripe said; never a secret.
data[].succeeded_at requiredstring | null
data[].created_at requiredstring (date-time)
data[].updated_at requiredstring (date-time)
next_cursor requiredstring | nullPass back as cursor for the next page; null on the last page.

Errors

  • 400
    • invalid_request: The request is malformed or fails validation; param names the field.
    • invalid_cursor: The cursor is not one this list gave.
    • environment_required: a project key was sent without x-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 the management scope.
    • management_scope_required: the environment's key does not have the management scope.
  • 404 environment_not_found: x-hixel-environment names 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"

Get a top-up#

GET/v1/top_ups/{id}hixel.topUps.get

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

NameInTypeDescription
id requiredpathstringThe top-up's id (tup_…).

Response 200: TopUp

FieldTypeDescription
id requiredstringThe id of a top-up (tup_…).
organization_id requiredstringThe id of your organization (org_…).
project_id requiredstringThe id of a project (proj_…).
environment_id requiredstringThe id of an environment (env_…).
customer requiredstringYour id for the customer (its external_id), as every path takes it.
member requiredstring | nullThe customer's member who asked for it; null for none.
amount_micros requiredstringWhat 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 requiredstring | nullStripe Checkout's page to pay on, while the session is open; null otherwise.
expires_at requiredstring | nullWhen the Checkout session expires.
save_payment_method requiredbooleanWhether Stripe was asked to save the payment method for auto-refill.
metadata requiredobjectYour own strings, kept as given; never sent to Stripe.
stripe_account_id requiredstring
stripe_session_id requiredstring | null
stripe_payment_intent_id requiredstring | null
stripe_customer_id requiredstring | null
stripe_invoice_id requiredstring | null
invoice_url requiredstring | nullStripe's hosted invoice and receipt, once paid.
invoice_pdf_url requiredstring | null
ledger_entry_id requiredstring | nullThe ledger entry that credited it, once succeeded.
refunded_micros requiredstringTaken back by refunds, positive.
disputed_micros requiredstringTaken back by an open or lost dispute, positive.
dispute_status required"inquiry" | "open" | "won" | "lost" | null
last_error requiredstring | nullWhy the payment failed, or why the platform could not apply what Stripe said; never a secret.
succeeded_at requiredstring | null
created_at requiredstring (date-time)
updated_at requiredstring (date-time)

Errors

  • 400
    • invalid_request: The request is malformed or fails validation; param names the field.
    • environment_required: a project key was sent without x-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 the management scope.
    • management_scope_required: the environment's key does not have the management scope.
  • 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-environment names 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"