Assistant Billing

Checkout

Create Stripe checkout sessions for customer wallet top-ups. The payment goes to the operator's Stripe account, and the workspace balance is credited automatically after payment.

Auth: Session token or platform key. When using a platform key, pass workspace_id in the request body.

Create a Checkout Session

POST /v1/platform/wallet/checkout

Generates a Stripe checkout URL. The customer pays total_amount which includes the base amount plus any configured markup and platform fees.

Body Parameters

NameTypeRequiredDescription
amountnumberYesTop-up amount in USD
success_urlstringYesURL to redirect after payment
cancel_urlstringYesURL to redirect on cancellation
workspace_idstringNoTarget workspace (platform key only)
const checkout = await billing.checkout.create({
  amount: 25,
  successUrl: 'https://app.example.com/billing?status=success',
  cancelUrl: 'https://app.example.com/billing?status=cancelled',
})
// Redirect user to checkout.url

Response

{
  "url": "https://checkout.stripe.com/c/pay/cs_live_a1b2c3...",
  "base_amount": "25.000000",
  "platform_fee": "1.250000",
  "markup": "2.500000",
  "total_amount": "28.750000"
}

Response Fields

FieldTypeRequiredDescription
urlstringAlwaysStripe checkout URL -- redirect the user here
base_amountstringAlwaysThe requested top-up amount
platform_feestringAlwaysFee charged by Assistant Billing
markupstringAlwaysOperator markup
total_amountstringAlwaysTotal charged to customer

Fee Calculation

The total is calculated as:

total = base_amount + (base_amount x markup%) + (base_amount x platform_fee%)

For a project with 10% markup and 5% platform fee, a $25 top-up:

ComponentAmount
Base amount (credited to balance)$25.00
Markup (10%)$2.50
Platform fee (5%)$1.25
Total charged$28.75

After payment, the checkout.session.completed webhook credits the base amount ($25) to the workspace wallet.

Errors

StatusCause
400Invalid amount (< 1), missing URLs, or Stripe not configured
404Project not found