---
title: "Billing Credits Purchase"
method: POST
path: "/billing/credits/purchase"
---

# Billing Credits Purchase

`POST /billing/credits/purchase`

## Request

- Base URL: `https://api.goodeye.dev/v1`
- URL: `https://api.goodeye.dev/v1/billing/credits/purchase`
- Auth: none declared

Buy a one-time credit top-up.

Charges the default payment method on file when one exists and returns
``{"status": "charged", "amount_usd": ..., "new_balance_usd": ...}``.
Otherwise returns ``{"status": "checkout_required", "checkout_url": ...}``
for a hosted checkout session so the purchase can complete interactively.
Errors: ``billing_not_enabled`` when self-service billing is not
configured, ``invalid_amount`` when the requested amount falls outside
the allowed range.

## Request body

- PurchaseCreditsIn: Request body for ``POST /billing/credits/purchase``.
  - `amount_usd` integer, required: Amount of credits to buy, in whole US dollars.
  - `idempotency_key` string, nullable: Optional caller-supplied key that makes a retried purchase request safe to resend without buying credits twice.

## Response `200`

Successful Response

- object

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/goodeye/apis/goodeye-api.md) · [All operations](https://skmtc.dev/goodeye/apis/goodeye-api/llms.txt) · [OpenAPI document](https://skmtc.dev/goodeye/apis/goodeye-api/revisions/547cb8bb6ede?raw)
