# Billing ledger

Source: https://www.pontive.com/docs/api-reference/management/billing-ledger

Base URL: `https://api.{region}.pontive.com/v1` (operations that name another server say so).

Authentication: send `Authorization: Bearer <token>` with a secret key (`pontive_sk_…`, which implies its instance) or an access token issued for this API. A token that can reach several instances also names one with `X-Pontive-Instance-ID: inst_…`. Secret keys are for servers only.

## POST /v1/billing/customers/{customer_id}/account-credit/refund

```http
POST https://api.{region}.pontive.com/v1/billing/customers/{customer_id}/account-credit/refund
```

billing.ledger.v1.LedgerService/RefundAccountCredit (36-credits-ledger.md, API Surface; Account credit; 38-payments-and-tax.md, Refunds). Pays refundable account credit back to the provider payment it came from, never more than what is left of that payment, as refunds with reason account_credit_refund and no credit note (billing-svc docs/questions.md, P96). Credit added by hand, an invoice's surplus or an external overpayment can only be spent. More than the balance is balance_would_be_negative; more than the refundable part (the balances read's refundable) is refund_exceeds_payment.

Operation ID: `RefundAccountCredit` · Capability: `billing`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `customer_id` | string | yes | The Customer id |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `X-Idempotency-Key` | string |  | Idempotency key |

### Responses

- `200` The credit_refunded LedgerEntry object: object
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse
- `422` Unprocessable Entity: ErrResponse

## GET /v1/billing/customers/{customer_id}/balances

```http
GET https://api.{region}.pontive.com/v1/billing/customers/{customer_id}/balances
```

billing.ledger.v1.LedgerService/ListBalances (36-credits-ledger.md, API Surface).

Operation ID: `ListBalances` · Capability: `billing`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `customer_id` | string | yes | id |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `unit` | string |  | unit |
| `at` | string |  | RFC 3339 time |
| `page` | integer |  | Page number, from 1 |
| `limit` | integer |  | Items per page, 1 to 100, default 25 |

### Responses

- `200` A list of Balance objects with pagination: List
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse
- `422` Unprocessable Entity: ErrResponse

## POST /v1/billing/customers/{customer_id}/ledger-adjustments

```http
POST https://api.{region}.pontive.com/v1/billing/customers/{customer_id}/ledger-adjustments
```

billing.ledger.v1.LedgerService/CreateLedgerAdjustment (36-credits-ledger.md, API Surface).

Operation ID: `CreateLedgerAdjustment` · Capability: `billing`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `customer_id` | string | yes | id |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `X-Idempotency-Key` | string |  | Idempotency key |

### Responses

- `201` A LedgerEntry object: Object
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse
- `422` Unprocessable Entity: ErrResponse

## POST /v1/billing/customers/{customer_id}/top-ups

```http
POST https://api.{region}.pontive.com/v1/billing/customers/{customer_id}/top-ups
```

billing.ledger.v1.LedgerService/CreateTopUp (36-credits-ledger.md, API Surface).

Operation ID: `CreateTopUp` · Capability: `billing`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `customer_id` | string | yes | id |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `X-Idempotency-Key` | string |  | Idempotency key |

### Responses

- `201` The CreateTopUpResponse fields: object
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse
- `422` Unprocessable Entity: ErrResponse

## GET /v1/billing/customers/{customer_id}/wallets/{unit}

```http
GET https://api.{region}.pontive.com/v1/billing/customers/{customer_id}/wallets/{unit}
```

billing.ledger.v1.LedgerService/GetWallet (36-credits-ledger.md, API Surface).

Operation ID: `GetWallet` · Capability: `billing`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `customer_id` | string | yes | id |
| `unit` | string | yes | unit |

### Responses

- `200` A Wallet object: Object
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse
- `422` Unprocessable Entity: ErrResponse

## PUT /v1/billing/customers/{customer_id}/wallets/{unit}

```http
PUT https://api.{region}.pontive.com/v1/billing/customers/{customer_id}/wallets/{unit}
```

billing.ledger.v1.LedgerService/UpdateWalletSettings (36-credits-ledger.md, API Surface).

Operation ID: `ReplaceWalletSettings` · Capability: `billing`

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `customer_id` | string | yes | id |
| `unit` | string | yes | unit |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `X-Idempotency-Key` | string |  | Idempotency key |

### Responses

- `200` A WalletSettings object: Object
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse
- `422` Unprocessable Entity: ErrResponse

## GET /v1/billing/ledger-entries

```http
GET https://api.{region}.pontive.com/v1/billing/ledger-entries
```

billing.ledger.v1.LedgerService/ListLedgerEntries (36-credits-ledger.md, API Surface).

Operation ID: `ListLedgerEntries` · Capability: `billing`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | integer |  | Items per page, 1 to 100, default 25 |
| `after` | string |  | Cursor: a next_cursor, to continue forward |
| `before` | string |  | Cursor: a next_cursor, to read the page just before it |
| `customer_id` | string |  | A cust_ id |
| `grant_id` | string |  | A grant id |
| `account` | string |  | account |
| `type` | string |  | type |
| `invoice_id` | string |  | A binv_ id |
| `from` | string |  | RFC 3339 time |
| `to` | string |  | RFC 3339 time |

### Responses

- `200` A list of LedgerEntry objects, walked by cursor (api-route-review D41): CursorList
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse
- `422` Unprocessable Entity: ErrResponse

## Schemas

### ErrResponse

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `error` | ErrBody |  |  |

### List

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | Object[] |  |  |
| `object` | string |  |  |
| `pagination` | Pagination |  | Pagination is the page answered (api-route-review D9). |

### Object

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | ID is its prefixed id. |
| `object` | string |  | Object names the kind: customer, invoice, contract, … |

### CursorList

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | Object[] |  |  |
| `next_cursor` | string |  |  |
| `object` | string |  |  |

### ErrBody

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `code` | string |  | Code is the spec's machine-readable code for this error, in snake case: a domain code such as seat_limit_reached where the refusal has one, otherwise a generic one such as permission_denied, not_found, conflict, invalid_request or service_unavailable. |
| `details` | ErrDetail[] |  | Details are per-field findings, present only on a refusal that has them, e.g. a 422 invalid_theme names each invalid value by its path, a 422 package_invalid each problem, and a 409 capability_in_use each count by its name. |
| `doc_url` | string |  | DocURL links to documentation about this error, when available. |
| `message` | string |  | Message is a human-readable description of what went wrong. |
| `object` | string |  | Object is the discriminator; always "error". |
| `param` | string |  | Param names the request parameter this error refers to, when applicable. |
| `type` | "validation_error" \| "authentication_error" \| "authorization_error" \| "not_found" \| "conflict_error" \| "rate_limit_error" \| "internal_error" |  | Type is the error's category, set by its HTTP status: one of validation_error, authentication_error, authorization_error, not_found, conflict_error, rate_limit_error, internal_error. |

### Pagination

Pagination is the page answered (api-route-review D9).

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `limit` | integer |  | Limit is the maximum number of items per page. |
| `page` | integer |  | Page is the 1-based index of the returned page. |
| `total` | integer |  | Total is the total number of items across all pages. |
| `total_pages` | integer |  | TotalPages is the total number of pages available. |

### ErrDetail

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `field` | string |  | Field is where the finding is: for a theme, its dotted path. |
| `message` | string |  | Message is what is wrong there. |
