---
title: "Allow an API key to buy credits, with optional limits no higher than the account"
method: PUT
path: "/v1/account/billing/keys/{keyId}/purchase-grant"
---

# Allow an API key to buy credits, with optional limits no higher than the account

`PUT /v1/account/billing/keys/{keyId}/purchase-grant`

## Request

- Base URL: `https://api.roveapi.com`
- URL: `https://api.roveapi.com/v1/account/billing/keys/{keyId}/purchase-grant`
- Auth: API key in cookie `rove_session`

## Path parameters

- `keyId` string, uuid, required

## Request body

- object
  - `per_purchase_max_cents` integer, nullable: Omitted or null inherits the account limit; never above it.
  - `period_max_cents` integer, nullable: Omitted or null inherits the account limit; never above it.

## Response `200`

Successful response (Cache-Control: no-store)

- object
  - `api_key_id` string, uuid, required
  - `key_name` string, nullable, required
  - `token_prefix` 'rvp_live_' | 'rvp_test_', required
  - `state` 'none' | 'granted' | 'revoked', required: none: this key was never allowed to buy.
  - `per_purchase_max_cents` integer, nullable, required: null inherits the account limit.
  - `period_max_cents` integer, nullable, required: null inherits the account limit.
  - `period_committed_cents` integer, required: This key's purchases this period, in the key's own mode (test keys count test-mode spend).
  - `last_refusal` object, nullable, required
    - `type` string, required
    - `limit` string
    - `at` string, required

## Other responses

- `400`: RFC 7807 invalid-params
- `401`: RFC 7807 owner-session-required: sign in
- `403`: RFC 7807 owner-origin-refused (mutations only)
- `404`: RFC 7807 key-not-found: re-read the key list
- `429`: RFC 7807 billing-settings-rate-limited: 30 owner billing-settings changes per account per trailing hour; Retry-After and retry_after_seconds
- `503`: RFC 7807 account-service-unavailable; Retry-After: 30

---

[API](https://skmtc.dev/roveapi/apis/rove-api.md) · [All operations](https://skmtc.dev/roveapi/apis/rove-api/llms.txt) · [OpenAPI document](https://skmtc.dev/roveapi/apis/rove-api/revisions/0e5d69bde586?raw)
