save_auto_topup
Create or replace the auto top-up rule for (user, credit type): whenever a deduct leaves the balance below threshold, cred buys one pack of pricing_tier_id on the user's saved card (at most max_per_day charges per 24h). If enabled and the balance is already below threshold, a charge starts right away. Saving also clears a rule cred disabled after failures. Requires a saved card to charge (a warning is returned if none); the tier must not be recurring-only. 404 USER_NOT_FOUND if the user does not exist. Costs 1 CRD (platform credit) per call, charged even when the call is then rejected (a 429 RATE_LIMITED costs nothing). Error results include request_id; quote it to support.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | No | Cred API key (optional if set via the x-api-key header) | |
| enabled | No | Default true | |
| user_id | Yes | External user ID of the card holder | |
| threshold | Yes | Top up when the balance falls below this | |
| project_id | No | Cred project ID (optional; the API key already identifies the project) | |
| max_per_day | No | Charge cap per rolling 24h (default 5) | |
| x402_payment | No | Base64 x402 PaymentPayload, only when a previous call failed with an x402 PaymentRequired because the account is out of CRD | |
| credit_type_id | No | Credit type to watch. Required when the tier allows several types (400 CREDIT_TYPE_REQUIRED otherwise) | |
| pricing_tier_id | Yes | One-time (or both) pricing tier to buy |