Charges the user's saved Stripe payment method and immediately credits the account. The purchase is subject to the per-purchase and monthly limits set in the Agent API Billing configuration.
RequestPOST https://payments.builtwith.com/v1/billing/api-purchase
Send the Agent API Key as the Authorization: Bearer header or as a ?KEY= query parameter. The request body must be JSON.
Request Body| Field | Type | Required | Description |
|---|
credits | number | Yes | Number of credits to purchase. Minimum 2,000. Must not exceed max_per_purchase or the remaining monthly allowance. |
Success Response (HTTP 200)| Field | Type | Description |
|---|
success | boolean | true |
credits_purchased | number | Credits added to the account. |
cost_usd | number | Amount charged in USD. |
payment_id | string | Stripe PaymentIntent ID for reconciliation. |
credits_available | number | Updated available credit balance after the purchase. |
Example Request Body{ "credits": 2000 }Example Success Response{
"success": true,
"credits_purchased": 2000,
"cost_usd": 99.00,
"payment_id": "pi_3abc123xyz",
"credits_available": 10766
}Error Responses| HTTP | Meaning |
|---|
| 400 | Validation failure - credits below 2,000, exceeds per-purchase limit, or monthly limit would be breached. |
| 401 | Missing or invalid Agent API Key. |
| 402 | Stripe payment failed or no chargeable payment method on file. |
| 403 | Account billing suspended. |
| 405 | Method not allowed - endpoint requires POST. |