---
title: "Credits the identity ledger behind a key. Idempotent by `reason`."
method: POST
path: "/admin/keys/{id}/credit"
tags: ["admin"]
---

# Credits the identity ledger behind a key. Idempotent by \`reason\`.

`POST /admin/keys/{id}/credit`

## Request

- Base URL: `https://api.mapmap.ai`
- URL: `https://api.mapmap.ai/admin/keys/{id}/credit`
- Auth: HTTP bearer

## Path parameters

- `id` string, required

## Request body

- CreditKeyRequest: Body for `POST /admin/keys/{id}/credit`.
  - `pence` integer, required: Amount to credit, in pence (>= 1).
  - `reason` string, required: Idempotency reason, e.g. `stripe:cs_…`. Repeating a reason is a no-op returning the balance the original credit produced.

## Response `200`

New (or unchanged, when the reason was replayed) balance

- CreditResponse: Response for both credit endpoints.
  - `balance_pence` integer, required: Balance after this credit, in pence.
  - `duplicate` boolean, required: `true` when the reason had already been applied (idempotent replay; nothing changed).
  - `identity_id` string, required: Identity whose ledger was credited.

## Other responses

- `401`: Missing or wrong admin token
- `404`: Unknown key id
- `409`: Key is operator-issued and has no identity ledger

---

[API](https://skmtc.dev/mapmap/apis/sn-gateway.md) · [All operations](https://skmtc.dev/mapmap/apis/sn-gateway/llms.txt) · [OpenAPI document](https://skmtc.dev/mapmap/apis/sn-gateway/revisions/2293be8b4c38?raw)
