Auto-refill
Charging a customer's saved payment method off-session when its balance runs low, within a monthly cap.
| Operation | Method | SDK |
|---|---|---|
| Get a customer's auto-refill settings | GET | hixel.autoRefills.getSettings |
| Set a customer's auto-refill | PUT | hixel.autoRefills.putSettings |
| Delete a customer's auto-refill | DELETE | hixel.autoRefills.deleteSettings |
| List a customer's auto-refills | GET | hixel.autoRefills.listForCustomer |
| List auto-refills needing attention | GET | hixel.autoRefills.listAttention |
| List auto-refills | GET | hixel.autoRefills.list |
| Get an auto-refill | GET | hixel.autoRefills.get |
| Re-check an auto-refill | POST | hixel.autoRefills.recheck |
| Resolve an auto-refill as not charged | POST | hixel.autoRefills.resolve |
| Count auto-refills needing attention | GET | hixel.autoRefillAttentionCounts.get |
Get a customer's auto-refill settings#
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
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
Response 200: AutoRefillSettings
| Field | Type | Description |
|---|---|---|
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. |
enabled required | boolean | Whether a refill starts when the balance falls below the threshold. |
threshold_micros required | string | null | A refill starts when the balance falls below it; null until set. |
amount_micros required | string | null | What one refill charges and credits; null until set. |
monthly_cap_micros required | string | null | The most refills charge in a calendar month (UTC); null until set. |
payment_method required | object | null | The method refills charge; null until a Checkout top-up saved one. |
payment_method.id required | string | Stripe's id (pm_…). |
payment_method.brand required | string | null | The card's brand (visa, …), when it is a card. |
payment_method.lastFour required | string | null | |
payment_method.savedAt required | string (date-time) | |
refilled_this_month_micros required | string | This calendar month's refills that succeeded or are in flight. |
consecutive_failures required | integer | Failed refills since the last success. |
retry_after required | string | null | After a failure, no refill starts before this; null for no wait. |
cap_reached_month required | string | null | The month (YYYY-MM, UTC) whose cap stopped a refill: none starts again in it. |
disabled_reason required | "failures" | "payment_method" | "dispute" | null | Why the platform turned it off; null unless it did. |
disabled_at required | string | null | |
last_failure_code required | string | null | Stripe's decline code (or the platform's own) of the last failure: a code, never card data. |
last_failure_at required | string | null | |
updated_at required | string | null | null while 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/auto_refill" \
-H "Authorization: Bearer $HIXEL_API_KEY"const autoRefillSettings = await hixel.autoRefills.getSettings("org_42");Set a customer's auto-refill#
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
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
Request body: PutAutoRefillBody
| Field | Type | Description |
|---|---|---|
enabled required | boolean | |
threshold_micros required | string | Micro-USD, positive, at most 10,000 USD. |
amount_micros required | string | Micro-USD, a whole number of cents, from 1 to 10,000 USD. |
monthly_cap_micros required | string | Micro-USD, at least amount_micros, at most 100,000 USD. |
Response 200: AutoRefillSettings
| Field | Type | Description |
|---|---|---|
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. |
enabled required | boolean | Whether a refill starts when the balance falls below the threshold. |
threshold_micros required | string | null | A refill starts when the balance falls below it; null until set. |
amount_micros required | string | null | What one refill charges and credits; null until set. |
monthly_cap_micros required | string | null | The most refills charge in a calendar month (UTC); null until set. |
payment_method required | object | null | The method refills charge; null until a Checkout top-up saved one. |
payment_method.id required | string | Stripe's id (pm_…). |
payment_method.brand required | string | null | The card's brand (visa, …), when it is a card. |
payment_method.lastFour required | string | null | |
payment_method.savedAt required | string (date-time) | |
refilled_this_month_micros required | string | This calendar month's refills that succeeded or are in flight. |
consecutive_failures required | integer | Failed refills since the last success. |
retry_after required | string | null | After a failure, no refill starts before this; null for no wait. |
cap_reached_month required | string | null | The month (YYYY-MM, UTC) whose cap stopped a refill: none starts again in it. |
disabled_reason required | "failures" | "payment_method" | "dispute" | null | Why the platform turned it off; null unless it did. |
disabled_at required | string | null | |
last_failure_code required | string | null | Stripe's decline code (or the platform's own) of the last failure: a code, never card data. |
last_failure_at required | string | null | |
updated_at required | string | null | null while never set. |
Errors
- 400
invalid_amount,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_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.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"
}'const autoRefillSettings = await hixel.autoRefills.putSettings("org_42", {
enabled: true,
threshold_micros: "5000000",
amount_micros: "5000000",
monthly_cap_micros: "5000000",
});Delete a customer's auto-refill#
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
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
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: 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/auto_refill" \
-H "Authorization: Bearer $HIXEL_API_KEY"await hixel.autoRefills.deleteSettings("org_42");List a customer's auto-refills#
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
| Name | In | Type | Description |
|---|---|---|---|
external_id required | path | string | Your id for the customer. |
status | query | "pending" | "processing" | "succeeded" | "failed" | "skipped_cap" | "canceled" | … | Only auto-refills 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: AutoRefillList
| Field | Type | Description |
|---|---|---|
data required | array of AutoRefill | |
data[].id required | string | The id of one auto-refill of a wallet (arf_…). |
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[].amount_micros required | string | What 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 required | string | |
data[].stripe_customer_id required | string | |
data[].payment_method_id required | string | |
data[].stripe_payment_intent_id required | string | null | |
data[].ledger_entry_id required | string | null | The ledger entry that credited it, once succeeded. |
data[].refunded_micros required | string | An 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 required | string | An 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 required | string | null | Stripe's decline code, or the platform's own code, of a failed or canceled refill. |
data[].last_error required | string | null | |
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/auto_refills" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const item of hixel.autoRefills.listForCustomer("org_42")) {
console.log(item);
}List auto-refills needing attention#
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
| Name | In | Type | Description |
|---|---|---|---|
state | query | "disabled" | "retrying" | Only customers in this state. |
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: AutoRefillAttentionList
| Field | Type | Description |
|---|---|---|
data required | array of AutoRefillAttention | |
data[].state required | "disabled" | "retrying" | |
data[].customer required | string | Your id for the customer (its external_id), as every path takes it. |
data[].customer_name required | string | null | |
data[].enabled required | boolean | |
data[].threshold_micros required | string | An 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 required | string | An 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 required | integer | |
data[].retry_after required | string | null | |
data[].disabled_reason required | "failures" | "payment_method" | "dispute" | null | |
data[].disabled_at required | string | null | |
data[].last_failure_code required | string | null | |
data[].last_failure_at required | string | null | |
data[].since 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/auto_refills/attention" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const item of hixel.autoRefills.listAttention()) {
console.log(item);
}List auto-refills#
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
| Name | In | Type | Description |
|---|---|---|---|
status | query | "pending" | "processing" | "succeeded" | "failed" | "skipped_cap" | "canceled" | … | Only auto-refills 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: AutoRefillList
| Field | Type | Description |
|---|---|---|
data required | array of AutoRefill | |
data[].id required | string | The id of one auto-refill of a wallet (arf_…). |
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[].amount_micros required | string | What 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 required | string | |
data[].stripe_customer_id required | string | |
data[].payment_method_id required | string | |
data[].stripe_payment_intent_id required | string | null | |
data[].ledger_entry_id required | string | null | The ledger entry that credited it, once succeeded. |
data[].refunded_micros required | string | An 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 required | string | An 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 required | string | null | Stripe's decline code, or the platform's own code, of a failed or canceled refill. |
data[].last_error required | string | null | |
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/auto_refills" \
-H "Authorization: Bearer $HIXEL_API_KEY"for await (const item of hixel.autoRefills.list()) {
console.log(item);
}Get an auto-refill#
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
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The auto-refill's id (arf_…). |
Response 200: AutoRefill
| Field | Type | Description |
|---|---|---|
id required | string | The id of one auto-refill of a wallet (arf_…). |
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. |
amount_micros required | string | What 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 required | string | |
stripe_customer_id required | string | |
payment_method_id required | string | |
stripe_payment_intent_id required | string | null | |
ledger_entry_id required | string | null | The ledger entry that credited it, once succeeded. |
refunded_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
disputed_micros required | string | An 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 required | string | null | Stripe's decline code, or the platform's own code, of a failed or canceled refill. |
last_error required | string | null | |
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
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-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/auto_refills/arf_123" \
-H "Authorization: Bearer $HIXEL_API_KEY"const autoRefill = await hixel.autoRefills.get("arf_123");Re-check an auto-refill#
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
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The auto-refill's id (arf_…). |
Response 200: AutoRefill
| Field | Type | Description |
|---|---|---|
id required | string | The id of one auto-refill of a wallet (arf_…). |
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. |
amount_micros required | string | What 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 required | string | |
stripe_customer_id required | string | |
payment_method_id required | string | |
stripe_payment_intent_id required | string | null | |
ledger_entry_id required | string | null | The ledger entry that credited it, once succeeded. |
refunded_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
disputed_micros required | string | An 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 required | string | null | Stripe's decline code, or the platform's own code, of a failed or canceled refill. |
last_error required | string | null | |
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.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
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-environmentnames 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"const autoRefill = await hixel.autoRefills.recheck("arf_123");Resolve an auto-refill as not charged#
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
| Name | In | Type | Description |
|---|---|---|---|
id required | path | string | The auto-refill's id (arf_…). |
Request body: ResolveAutoRefillBody
| Field | Type | Description |
|---|---|---|
note required | string | |
acknowledge_possible_payment | boolean | Required when Stripe cannot be read: the payment may exist, and is credited if it shows. |
Response 200: AutoRefill
| Field | Type | Description |
|---|---|---|
id required | string | The id of one auto-refill of a wallet (arf_…). |
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. |
amount_micros required | string | What 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 required | string | |
stripe_customer_id required | string | |
payment_method_id required | string | |
stripe_payment_intent_id required | string | null | |
ledger_entry_id required | string | null | The ledger entry that credited it, once succeeded. |
refunded_micros required | string | An amount of micro-USD (millionths of a US dollar) as a decimal string: "1500000" is 1.50 USD. Never a JSON number. |
disputed_micros required | string | An 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 required | string | null | Stripe's decline code, or the platform's own code, of a failed or canceled refill. |
last_error required | string | null | |
succeeded_at required | string | null | |
created_at required | string (date-time) | |
updated_at required | string (date-time) |
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_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
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-environmentnames 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."
}'const autoRefill = await hixel.autoRefills.resolve("arf_123", {
note: "Checked in Stripe: no payment was made.",
});Count auto-refills needing attention#
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
| Field | Type | Description |
|---|---|---|
disabled required | integer | The environment's customers in the disabled state. |
retrying required | integer | The environment's customers in the retrying state. |
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/auto_refill_attention_counts" \
-H "Authorization: Bearer $HIXEL_API_KEY"const autoRefillAttentionCounts = await hixel.autoRefillAttentionCounts.get();