# setCreditAutoRecharge

Save one credit type's auto-recharge, as Billing > Credits does: on, it buys `selectedPackCode` (`rechargeAmountCents` its price) on the card on file when the balance falls below `thresholdUnits`, at most `maxBudgetCents` a billing period. Switching it on saves every field: read getCreditAutoRecharge, send the rest unchanged, and take `rechargeAmountCents` from getCreditPrices for the selected pack (refused when it moved); `enabled: false` only switches it off. Org admins only. When asked first, the card of a save that turns it on names the pack's exact price (`rechargeAmountCents`, getCreditPrices', refused when it moved), the period budget, that a pack is non-refundable, the threshold and the card. Saving may buy a pack at once if the balance is already low.

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "setCreditAutoRecharge", "variables": {...} }`
- Scope: `ADMIN`
- Type: mutation
- Idempotency: honors `Idempotency-Key` (24 h)
- Rate-limited: no

## Variables

- `creditType`: `CreditType!` (required, one of `EXPORT_PROPERTIES`, `SKIPTRACE`, `EMAIL_VERIFICATION`, `AI_CREDITS`, `SMS_CREDITS`, `CALLING_MINUTES`). AI_CREDITS: AI agent usage (AI Agent Credits). Purchase-only: 1 credit = 1 cent. SMS_CREDITS: Texting credits. One credit equals one outbound carrier text segment. CALLING_MINUTES: Calling minutes: talk minutes on managed lines, both directions, rounded up per call. Plan allowance first, then purchased packs; the balance can be negative.
- `enabled`: `Boolean!` (required)
- `thresholdUnits`: `Int!` (required)
- `selectedPackCode`: `String`
- `rechargeAmountCents`: `Int!` (required)
- `maxBudgetCents`: `Int!` (required)

## Response (data, an example)

```json
{
  "orgCreditAutoRechargeMutation": {
    "update": {
      "creditType": "EXPORT_PROPERTIES",
      "enabled": true,
      "thresholdUnits": 0,
      "selectedPackCode": "…",
      "rechargeAmountCents": 0,
      "maxBudgetCents": 0,
      "spentThisPeriodCents": 0
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "operationId": "setCreditAutoRecharge",
    "variables": {
      "creditType": "EXPORT_PROPERTIES",
      "enabled": true,
      "thresholdUnits": 10,
      "rechargeAmountCents": 10,
      "maxBudgetCents": 10
    }
  }'
```
