# buyCreditPacks

Buy credit packs now on the card on file, as the Billing page does: one `{ creditType, packCode }` per credit type from getCreditPrices; `expectedAmountCents` is their summed `priceCents`, refused when it moved. `attemptKey` is new per purchase (8-128 of letters, digits, - or _), reused only to retry it. It never turns auto-recharge on: that is setCreditAutoRecharge, on its own card. Org admins only. When asked first, its card names the packs, the exact total, that it is non-refundable, and the card (getCreditAutoRecharge). `status`: PAID, PENDING (bank debit clearing), DECLINED (`message`), REQUIRES_ACTION (send getCreditsPurchaseUrl), NOTHING_DUE.

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

## Variables

- `items`: `[CreditPackPurchaseItemInput!]!` (required). One credit pack bought from a Dashboard alert, charged to the card on file.
  - `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.
  - `packCode`: `String!` (required). Stable fixed-pack code returned by BillingQuery.getCreditPrices.
- `attemptKey`: `String!` (required)
- `expectedAmountCents`: `Int!` (required)

## Response (data, an example)

```json
{
  "billingMutation": {
    "buyCreditPacks": {
      "status": "PAID",
      "amountCents": 0,
      "message": "…"
    }
  }
}
```

## 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": "buyCreditPacks",
    "variables": {
      "items": [
        {
          "creditType": "EXPORT_PROPERTIES",
          "packCode": "<String>"
        }
      ],
      "attemptKey": "<String>",
      "expectedAmountCents": 10
    }
  }'
```
