Documentation menu

Auto-refill

Charging a customer's saved payment method off-session when its balance runs low, within a monthly cap.

OperationMethodSDK
Get a customer's auto-refill settingsGEThixel.autoRefills.getSettings
Set a customer's auto-refillPUThixel.autoRefills.putSettings
Delete a customer's auto-refillDELETEhixel.autoRefills.deleteSettings
List a customer's auto-refillsGEThixel.autoRefills.listForCustomer
List auto-refills needing attentionGEThixel.autoRefills.listAttention
List auto-refillsGEThixel.autoRefills.list
Get an auto-refillGEThixel.autoRefills.get
Re-check an auto-refillPOSThixel.autoRefills.recheck
Resolve an auto-refill as not chargedPOSThixel.autoRefills.resolve
Count auto-refills needing attentionGEThixel.autoRefillAttentionCounts.get

Get a customer's auto-refill settings#

GET/v1/customers/{external_id}/auto_refillhixel.autoRefills.getSettings

The customer's auto-refill settings and their state; all null and enabled: false until 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

NameInTypeDescription
external_id requiredpathstringYour id for the customer.

Response 200: AutoRefillSettings

FieldTypeDescription
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.
enabled requiredbooleanWhether a refill starts when the balance falls below the threshold.
threshold_micros requiredstring | nullA refill starts when the balance falls below it; null until set.
amount_micros requiredstring | nullWhat one refill charges and credits; null until set.
monthly_cap_micros requiredstring | nullThe most refills charge in a calendar month (UTC); null until set.
payment_method requiredobject | nullThe method refills charge; null until a Checkout top-up saved one.
payment_method.id requiredstringStripe's id (pm_…).
payment_method.brand requiredstring | nullThe card's brand (visa, …), when it is a card.
payment_method.lastFour requiredstring | null
payment_method.savedAt requiredstring (date-time)
refilled_this_month_micros requiredstringThis calendar month's refills that succeeded or are in flight.
consecutive_failures requiredintegerFailed refills since the last success.
retry_after requiredstring | nullAfter a failure, no refill starts before this; null for no wait.
cap_reached_month requiredstring | nullThe month (YYYY-MM, UTC) whose cap stopped a refill: none starts again in it.
disabled_reason required"failures" | "payment_method" | "dispute" | nullWhy the platform turned it off; null unless it did.
disabled_at requiredstring | null
last_failure_code requiredstring | nullStripe's decline code (or the platform's own) of the last failure: a code, never card data.
last_failure_at requiredstring | null
updated_at requiredstring | nullnull while never set.

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
    • 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/auto_refill" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

Set a customer's auto-refill#

PUT/v1/customers/{external_id}/auto_refillhixel.autoRefills.putSettings

Sets the customer's auto-refill: when its balance falls below threshold_micros, its saved payment method is charged amount_micros, at most monthly_cap_micros a calendar month. Enabling it needs a payment method a Checkout top-up saved (save_payment_method); getting the customer's consent is your responsibility.

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: PutAutoRefillBody

FieldTypeDescription
enabled requiredboolean
threshold_micros requiredstringMicro-USD, positive, at most 10,000 USD.
amount_micros requiredstringMicro-USD, a whole number of cents, from 1 to 10,000 USD.
monthly_cap_micros requiredstringMicro-USD, at least amount_micros, at most 100,000 USD.

Response 200: AutoRefillSettings

FieldTypeDescription
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.
enabled requiredbooleanWhether a refill starts when the balance falls below the threshold.
threshold_micros requiredstring | nullA refill starts when the balance falls below it; null until set.
amount_micros requiredstring | nullWhat one refill charges and credits; null until set.
monthly_cap_micros requiredstring | nullThe most refills charge in a calendar month (UTC); null until set.
payment_method requiredobject | nullThe method refills charge; null until a Checkout top-up saved one.
payment_method.id requiredstringStripe's id (pm_…).
payment_method.brand requiredstring | nullThe card's brand (visa, …), when it is a card.
payment_method.lastFour requiredstring | null
payment_method.savedAt requiredstring (date-time)
refilled_this_month_micros requiredstringThis calendar month's refills that succeeded or are in flight.
consecutive_failures requiredintegerFailed refills since the last success.
retry_after requiredstring | nullAfter a failure, no refill starts before this; null for no wait.
cap_reached_month requiredstring | nullThe month (YYYY-MM, UTC) whose cap stopped a refill: none starts again in it.
disabled_reason required"failures" | "payment_method" | "dispute" | nullWhy the platform turned it off; null unless it did.
disabled_at requiredstring | null
last_failure_code requiredstring | nullStripe's decline code (or the platform's own) of the last failure: a code, never card data.
last_failure_at requiredstring | null
updated_at requiredstring | nullnull while never set.

Errors

  • 400
    • invalid_amount, invalid_parameter: 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.
    • no_saved_payment_method: This customer has no saved payment method. A paid Checkout top-up with save_payment_method saves one.
    • 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/auto_refill" \
  -H "Authorization: Bearer $HIXEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "threshold_micros": "5000000",
    "amount_micros": "5000000",
    "monthly_cap_micros": "5000000"
  }'

Delete a customer's auto-refill#

DELETE/v1/customers/{external_id}/auto_refillhixel.autoRefills.deleteSettings

Removes the customer's auto-refill settings; a refill in flight still completes. 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

NameInTypeDescription
external_id requiredpathstringYour id for the customer.

Response 204

No body.

Errors

  • 400
    • invalid_request: 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: 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.
    • 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/auto_refill" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

List a customer's auto-refills#

GET/v1/customers/{external_id}/auto_refillshixel.autoRefills.listForCustomer

A page of the customer's auto-refills, 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"pending" | "processing" | "succeeded" | "failed" | "skipped_cap" | "canceled" | …Only auto-refills 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: AutoRefillList

FieldTypeDescription
data requiredarray of AutoRefill
data[].id requiredstringThe id of one auto-refill of a wallet (arf_…).
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[].amount_micros requiredstringWhat the refill charges and credits, 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"pending" | "processing" | "succeeded" | "failed" | "skipped_cap" | "canceled" | …Where an auto-refill stands: pending until Stripe answered its payment's creation, processing while the payment clears, succeeded once credited, failed (declined, or the bank asked for authentication, which cannot happen off-session), skipped_cap (the month's cap left no room; nothing was charged), canceled (nothing was charged: the customer, the connection or the settings no longer allowed it, before Stripe was asked or after Stripe canceled its payment) or needs_attention (Stripe may hold a payment the platform could not read back in time: re-read daily and by its webhook, and no other refill of the wallet starts until it is resolved).
data[].stripe_account_id requiredstring
data[].stripe_customer_id requiredstring
data[].payment_method_id requiredstring
data[].stripe_payment_intent_id requiredstring | null
data[].ledger_entry_id requiredstring | nullThe ledger entry that credited it, once succeeded.
data[].refunded_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
data[].disputed_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
data[].dispute_status required"inquiry" | "open" | "won" | "lost" | null
data[].failure_code requiredstring | nullStripe's decline code, or the platform's own code, of a failed or canceled refill.
data[].last_error requiredstring | null
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/auto_refills" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

List auto-refills needing attention#

GET/v1/auto_refills/attentionhixel.autoRefills.listAttention

A page of the environment's customers whose auto-refill needs attention, the most recent first; GET /v1/auto_refill_attention_counts counts them by state. A refill stuck in needs_attention is listed by GET /v1/auto_refills?status=needs_attention.

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
statequery"disabled" | "retrying"Only customers in this state.
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: AutoRefillAttentionList

FieldTypeDescription
data requiredarray of AutoRefillAttention
data[].state required"disabled" | "retrying"
data[].customer requiredstringYour id for the customer (its external_id), as every path takes it.
data[].customer_name requiredstring | null
data[].enabled requiredboolean
data[].threshold_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
data[].amount_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
data[].consecutive_failures requiredinteger
data[].retry_after requiredstring | null
data[].disabled_reason required"failures" | "payment_method" | "dispute" | null
data[].disabled_at requiredstring | null
data[].last_failure_code requiredstring | null
data[].last_failure_at requiredstring | null
data[].since 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/auto_refills/attention" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

List auto-refills#

GET/v1/auto_refillshixel.autoRefills.list

A page of the environment's auto-refills, 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"pending" | "processing" | "succeeded" | "failed" | "skipped_cap" | "canceled" | …Only auto-refills 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: AutoRefillList

FieldTypeDescription
data requiredarray of AutoRefill
data[].id requiredstringThe id of one auto-refill of a wallet (arf_…).
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[].amount_micros requiredstringWhat the refill charges and credits, 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"pending" | "processing" | "succeeded" | "failed" | "skipped_cap" | "canceled" | …Where an auto-refill stands: pending until Stripe answered its payment's creation, processing while the payment clears, succeeded once credited, failed (declined, or the bank asked for authentication, which cannot happen off-session), skipped_cap (the month's cap left no room; nothing was charged), canceled (nothing was charged: the customer, the connection or the settings no longer allowed it, before Stripe was asked or after Stripe canceled its payment) or needs_attention (Stripe may hold a payment the platform could not read back in time: re-read daily and by its webhook, and no other refill of the wallet starts until it is resolved).
data[].stripe_account_id requiredstring
data[].stripe_customer_id requiredstring
data[].payment_method_id requiredstring
data[].stripe_payment_intent_id requiredstring | null
data[].ledger_entry_id requiredstring | nullThe ledger entry that credited it, once succeeded.
data[].refunded_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
data[].disputed_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
data[].dispute_status required"inquiry" | "open" | "won" | "lost" | null
data[].failure_code requiredstring | nullStripe's decline code, or the platform's own code, of a failed or canceled refill.
data[].last_error requiredstring | null
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/auto_refills" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

Get an auto-refill#

GET/v1/auto_refills/{id}hixel.autoRefills.get

One auto-refill of the environment, by its id (arf_…).

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 auto-refill's id (arf_…).

Response 200: AutoRefill

FieldTypeDescription
id requiredstringThe id of one auto-refill of a wallet (arf_…).
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.
amount_micros requiredstringWhat the refill charges and credits, 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"pending" | "processing" | "succeeded" | "failed" | "skipped_cap" | "canceled" | …Where an auto-refill stands: pending until Stripe answered its payment's creation, processing while the payment clears, succeeded once credited, failed (declined, or the bank asked for authentication, which cannot happen off-session), skipped_cap (the month's cap left no room; nothing was charged), canceled (nothing was charged: the customer, the connection or the settings no longer allowed it, before Stripe was asked or after Stripe canceled its payment) or needs_attention (Stripe may hold a payment the platform could not read back in time: re-read daily and by its webhook, and no other refill of the wallet starts until it is resolved).
stripe_account_id requiredstring
stripe_customer_id requiredstring
payment_method_id requiredstring
stripe_payment_intent_id requiredstring | null
ledger_entry_id requiredstring | nullThe ledger entry that credited it, once succeeded.
refunded_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
disputed_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
dispute_status required"inquiry" | "open" | "won" | "lost" | null
failure_code requiredstring | nullStripe's decline code, or the platform's own code, of a failed or canceled refill.
last_error requiredstring | null
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
    • auto_refill_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/auto_refills/arf_123" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

Re-check an auto-refill#

POST/v1/auto_refills/{id}/recheckhixel.autoRefills.recheck

Reads a needs_attention auto-refill's payment from Stripe again now, and applies what it shows. At most once every 10 minutes per refill.

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
id requiredpathstringThe auto-refill's id (arf_…).

Response 200: AutoRefill

FieldTypeDescription
id requiredstringThe id of one auto-refill of a wallet (arf_…).
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.
amount_micros requiredstringWhat the refill charges and credits, 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"pending" | "processing" | "succeeded" | "failed" | "skipped_cap" | "canceled" | …Where an auto-refill stands: pending until Stripe answered its payment's creation, processing while the payment clears, succeeded once credited, failed (declined, or the bank asked for authentication, which cannot happen off-session), skipped_cap (the month's cap left no room; nothing was charged), canceled (nothing was charged: the customer, the connection or the settings no longer allowed it, before Stripe was asked or after Stripe canceled its payment) or needs_attention (Stripe may hold a payment the platform could not read back in time: re-read daily and by its webhook, and no other refill of the wallet starts until it is resolved).
stripe_account_id requiredstring
stripe_customer_id requiredstring
payment_method_id requiredstring
stripe_payment_intent_id requiredstring | null
ledger_entry_id requiredstring | nullThe ledger entry that credited it, once succeeded.
refunded_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
disputed_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
dispute_status required"inquiry" | "open" | "won" | "lost" | null
failure_code requiredstring | nullStripe's decline code, or the platform's own code, of a failed or canceled refill.
last_error requiredstring | null
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.
    • 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: 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
    • auto_refill_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
    • auto_refill_not_needs_attention: This auto-refill does not need attention: Stripe's answer for it is known. Read it again to see where it stands.
    • 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.
  • 429 auto_refill_too_soon: This auto-refill was re-checked or asked of Stripe moments ago. Try again in a few minutes.
  • 500 internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned.
  • 503
    • database_unavailable, stripe_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/auto_refills/arf_123/recheck" \
  -H "Authorization: Bearer $HIXEL_API_KEY"

Resolve an auto-refill as not charged#

POST/v1/auto_refills/{id}/resolvehixel.autoRefills.resolve

Ends a needs_attention auto-refill as not charged, after Stripe, read now, shows no payment of it that may still succeed; the wallet's refills start again.

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
id requiredpathstringThe auto-refill's id (arf_…).

Request body: ResolveAutoRefillBody

FieldTypeDescription
note requiredstring
acknowledge_possible_paymentbooleanRequired when Stripe cannot be read: the payment may exist, and is credited if it shows.

Response 200: AutoRefill

FieldTypeDescription
id requiredstringThe id of one auto-refill of a wallet (arf_…).
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.
amount_micros requiredstringWhat the refill charges and credits, 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"pending" | "processing" | "succeeded" | "failed" | "skipped_cap" | "canceled" | …Where an auto-refill stands: pending until Stripe answered its payment's creation, processing while the payment clears, succeeded once credited, failed (declined, or the bank asked for authentication, which cannot happen off-session), skipped_cap (the month's cap left no room; nothing was charged), canceled (nothing was charged: the customer, the connection or the settings no longer allowed it, before Stripe was asked or after Stripe canceled its payment) or needs_attention (Stripe may hold a payment the platform could not read back in time: re-read daily and by its webhook, and no other refill of the wallet starts until it is resolved).
stripe_account_id requiredstring
stripe_customer_id requiredstring
payment_method_id requiredstring
stripe_payment_intent_id requiredstring | null
ledger_entry_id requiredstring | nullThe ledger entry that credited it, once succeeded.
refunded_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
disputed_micros requiredstringAn amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number.
dispute_status required"inquiry" | "open" | "won" | "lost" | null
failure_code requiredstring | nullStripe's decline code, or the platform's own code, of a failed or canceled refill.
last_error requiredstring | null
succeeded_at requiredstring | null
created_at requiredstring (date-time)
updated_at requiredstring (date-time)

Errors

  • 400
    • invalid_parameter: 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
    • auto_refill_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
    • auto_refill_not_needs_attention: This auto-refill does not need attention: Stripe's answer for it is known. Read it again to see where it stands.
    • auto_refill_may_be_charged: Stripe shows a payment of this auto-refill that may still succeed, or more than one: it cannot be resolved as not charged. Look at the payments in Stripe.
    • auto_refill_payment_unreadable: Stripe cannot be read with this environment's key, so a payment of this auto-refill cannot be ruled out. Check it in Stripe and acknowledge that a payment may exist to resolve it.
    • 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.
  • 429 auto_refill_too_soon: This auto-refill was re-checked or asked of Stripe moments ago. Try again in a few minutes.
  • 500 internal: an unexpected failure on the platform's side (internal_error); the details are logged, never returned.
  • 503
    • database_unavailable, stripe_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/auto_refills/arf_123/resolve" \
  -H "Authorization: Bearer $HIXEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "Checked in Stripe: no payment was made."
  }'

Count auto-refills needing attention#

GET/v1/auto_refill_attention_countshixel.autoRefillAttentionCounts.get

How many of the environment's customers have an auto-refill turned off by the platform (disabled) or failing and waiting to retry (retrying).

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: AutoRefillAttentionCounts

FieldTypeDescription
disabled requiredintegerThe environment's customers in the disabled state.
retrying requiredintegerThe environment's customers in the retrying state.

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.
  • 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/auto_refill_attention_counts" \
  -H "Authorization: Bearer $HIXEL_API_KEY"