Stripe: Cancel a top-up
Stripe topups.postTopupsTopupCancel: arguments, response, policy and SDK examples.
← Topups operations · Get started
Operation stripe.posttopupstopupcancel
Provider route: POST /v1/topups/{topup}/cancel. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”Install @alter-ai/sdk @alter-ai/stripe with npm, or alter-sdk-stripe with pip. Supply your connected customer’s grant ID and the arguments described below.
import { App } from "@alter-ai/sdk";import { StripeIntegration } from "@alter-ai/stripe";
async function execute(input: Parameters<StripeIntegration["topups"]["postTopupsTopupCancel"]>[0]) { const app = new App({ apiKey: process.env.ALTER_API_KEY! }); try { const provider = new StripeIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! }); const call = await provider.topups.postTopupsTopupCancel(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom alter_sdk_stripe import StripeIntegration
async def execute(arguments): async with App(api_key=os.environ["ALTER_API_KEY"]) as app: provider = StripeIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]}) call = await provider.topups.post_topups_topup_cancel(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.topup | string | Required within parent | Maximum length: 5000 |
headers | object | Optional | Additional keys: not allowed |
headers.Idempotency-Key | string | Optional | Minimum length: 1 Maximum length: 255 |
body | object | Optional | Additional keys: not allowed |
body.expand | array | Optional | Specifies which fields in the response should be expanded. |
body.expand[] | string | Each item | Maximum length: 5000 |
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Cancel a top-up — response body |
Referenced models: Cancel a top-up — response body
Schemas
Section titled “Schemas”705 more schemas are linked from the tables above, on the schema pages.
Cancel a top-up — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | To top up your Stripe balance, you create a top-up object. You can retrieve individual top-ups, as well as list all top-ups. Top-ups are identified by a unique, random ID. Related guide: [Topping up your platform account](https://docs.stripe.com/connect/top-ups) |
amount | JSON | Required within parent | |
amount (anyOf 1) | integer | Alternative | Amount transferred. |
amount (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
balance_transaction | JSON | Optional | |
balance_transaction (anyOf 1) | JSON | Alternative | ID of the balance transaction that describes the impact of this top-up on your account balance. May not be specified depending on status of top-up. |
balance_transaction (anyOf 1) (anyOf 1) | string | Alternative | Maximum length: 5000 |
balance_transaction (anyOf 1) (anyOf 2) | Model | Alternative | Expand Retrieve a balance transaction — balance get Balance History Id — response body |
balance_transaction (anyOf 2) | null | Alternative | |
created | JSON | Required within parent | |
created (anyOf 1) | integer | Alternative | Time at which the object was created. Measured in seconds since the Unix epoch. Format: unix-time |
created (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
currency | string | Required within parent | Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). Maximum length: 5000 |
description | JSON | Optional | |
description (anyOf 1) | string | Alternative | An arbitrary string attached to the object. Often useful for displaying to users. Maximum length: 5000 |
description (anyOf 2) | null | Alternative | |
expected_availability_date | JSON | Optional | |
expected_availability_date (anyOf 1) | JSON | Alternative | |
expected_availability_date (anyOf 1) (anyOf 1) | integer | Alternative | Date the funds are expected to arrive in your Stripe account for payouts. This factors in delays like weekends or bank holidays. May not be specified depending on status of top-up. |
expected_availability_date (anyOf 1) (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
expected_availability_date (anyOf 2) | null | Alternative | |
failure_code | JSON | Optional | |
failure_code (anyOf 1) | string | Alternative | Error code explaining reason for top-up failure if available (see [the errors section](/api/errors) for a list of codes). Maximum length: 5000 |
failure_code (anyOf 2) | null | Alternative | |
failure_message | JSON | Optional | |
failure_message (anyOf 1) | string | Alternative | Message to user further explaining reason for top-up failure if available. Maximum length: 5000 |
failure_message (anyOf 2) | null | Alternative | |
id | string | Required within parent | Unique identifier for the object. Maximum length: 5000 |
initiated_by | JSON | Optional | |
initiated_by (anyOf 1) | string | Alternative | Indicates whether the top-up was initiated by Stripe or by the user. Known values: stripe, user |
initiated_by (anyOf 2) | null | Alternative | |
livemode | boolean | Required within parent | If the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`. |
metadata | object | Required within parent | Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Additional keys: see wildcard field |
metadata.* | string | Additional keys | Maximum length: 500 |
object | string | Required within parent | String representing the object's type. Objects of the same type share the same value. Known values: topup |
payment_method | JSON | Optional | |
payment_method (anyOf 1) | JSON | Alternative | The ID of a PaymentMethod representing the payment method used for the top-up. A PaymentMethod of type `us_bank_account` can be used. |
payment_method (anyOf 1) (anyOf 1) | string | Alternative | Maximum length: 5000 |
payment_method (anyOf 1) (anyOf 2) | Model | Alternative | Expand Create a Payment Method — response body |
payment_method (anyOf 2) | null | Alternative | |
payment_method_options | JSON | Optional | |
payment_method_options (anyOf 1) | JSON | Alternative | Payment-method-specific configuration for this top-up. |
payment_method_options (anyOf 1) (anyOf 1) | Model | Alternative | Expand Cancel a top-up — response body — payment method options value us bank account |
payment_method_options (anyOf 2) | null | Alternative | |
source | JSON | Optional | |
source (anyOf 1) | JSON | Alternative | The source field is deprecated. It might not always be present in the API response. |
source (anyOf 1) (anyOf 1) | Model | Alternative | Expand Create a source — response body |
source (anyOf 2) | null | Alternative | |
statement_descriptor | JSON | Optional | |
statement_descriptor (anyOf 1) | string | Alternative | Extra information about a top-up. This will appear on your source's bank statement. It must contain at least one letter. Maximum length: 5000 |
statement_descriptor (anyOf 2) | null | Alternative | |
status | string | Required within parent | The status of the top-up is either `canceled`, `failed`, `pending`, `reversed`, or `succeeded`. Known values: canceled, failed, pending, reversed, succeeded |
transfer_group | JSON | Optional | |
transfer_group (anyOf 1) | string | Alternative | A string that identifies this top-up as part of a group. Maximum length: 5000 |
transfer_group (anyOf 2) | null | Alternative |
Referenced models: Retrieve a balance transaction — balance get Balance History Id — response body, Create a Payment Method — response body, Create a source — response body, Cancel a top-up — response body — payment method options value us bank account
Cancel a top-up — response body — payment method options value us bank account
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
us_bank_account | JSON | Optional | |
us_bank_account (anyOf 1) | JSON | Alternative | If this top-up is to be used with a `us_bank_account` payment method, this sub-hash contains configuration for it. |
us_bank_account (anyOf 1) (anyOf 1) | Model | Alternative | Expand Cancel a top-up — response body — payment_method_options / value / us_bank_account / us_bank_account / value / network: ach |
us_bank_account (anyOf 2) | null | Alternative |
Referenced models: Cancel a top-up — response body — payment_method_options / value / us_bank_account / us_bank_account / value / network: ach
Retrieve a balance transaction — balance.getBalanceHistoryId — response body — source / This transaction relates to the Stripe object / object: connect collection transfer
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
amount | JSON | Required within parent | |
amount (anyOf 1) | integer | Alternative | Amount transferred, in cents (or local equivalent). |
amount (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
currency | string | Required within parent | Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). Format: currency |
destination | JSON | Required within parent | ID of the account that funds are being collected for. |
destination (anyOf 1) | string | Alternative | Maximum length: 5000 |
destination (anyOf 2) | Model | Alternative | Expand Create an account — response body |
id | string | Required within parent | Unique identifier for the object. Maximum length: 5000 |
livemode | boolean | Required within parent | If the object exists in live mode, the value is `true`. If the object exists in test mode, the value is `false`. |
object | string | Required within parent | String representing the object's type. Objects of the same type share the same value. Known values: connect_collection_transfer |
Referenced models: Create an account — response body
Retrieve a balance transaction — balance get Balance History Id — response body — fee details item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | |
amount | JSON | Required within parent | |
amount (anyOf 1) | integer | Alternative | Amount of the fee, in cents. |
amount (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
application | JSON | Optional | |
application (anyOf 1) | string | Alternative | ID of the Connect application that earned the fee. Maximum length: 5000 |
application (anyOf 2) | null | Alternative | |
currency | string | Required within parent | Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). Format: currency |
description | JSON | Optional | |
description (anyOf 1) | string | Alternative | An arbitrary string attached to the object. Often useful for displaying to users. Maximum length: 5000 |
description (anyOf 2) | null | Alternative | |
type | string | Required within parent | Type of the fee, one of: `application_fee`, `payment_method_passthrough_fee`, `stripe_fee`, `tax`, or `withheld_tax`. Maximum length: 5000 |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: stripe.posttopupstopupcancel. Catalog operation: PostTopupsTopupCancel. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.
Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.
Pinned headers: {"Stripe-Version": "2026-09-30.endive"}