# Billing entitlements

Source: https://www.pontive.com/docs/api-reference/authz/billing-entitlements

Base URL: `https://authz.{region}.pontive.com` (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/entitlements/check

```http
POST https://authz.{region}.pontive.com/v1/entitlements/check
```

billing.entitlement.v1.EntitlementService/CheckEntitlement (39-entitlements-and-controls.md, API Surface; Check, list, consume). No side effects. A denial is a 200 with allowed false and a reason (not_entitled, allowance_exhausted, balance_exhausted, access_restricted), never an error (Error Handling). value is the feature's value: true, a decimal string, or a metered feature's allowance; when the Customer is not entitled to it, false for a boolean feature and null otherwise. limit is a metered feature's state, null for other types. Only external subjects resolve until Phase 4. The RPC writes nothing and takes no idempotency key, so X-Idempotency-Key is not read.

Operation ID: `CheckEntitlement` · Capability: `billing`

### Responses

- `200` An entitlement_check object: { allowed, value, reason, limit }: Object
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: ErrResponse
- `422` Unprocessable Entity: ErrResponse

## POST /v1/entitlements/consume

```http
POST https://authz.{region}.pontive.com/v1/entitlements/consume
```

billing.entitlement.v1.EntitlementService/ConsumeEntitlement (39-entitlements-and-controls.md, API Surface; Check, list, consume). Resolves, decides as a check would and, when allowed, records the usage event, in one transaction. Idempotent on transaction_id, not on X-Idempotency-Key, which is not read: a retry of an allowed consume answers the first decision with replayed true and consumes nothing again; a denied consume records nothing and is decided again on retry (billing-svc docs/questions.md, P9). A denial is a 200 with allowed false and a reason, never an error. properties is a JSON object, kept as sent. The usage event is checked against its event type's schema as ingest checks it: with validation warn, an allowed consume lists warnings, each { code, property, expected }; with reject, one that does not fit is refused with 422 schema_mismatch and records nothing: the error's details list each violation as { field: its property, message: its code and what was expected } (billing-svc docs/questions.md, P99, P111).

Operation ID: `ConsumeEntitlement` · Capability: `billing`

### Responses

- `200` An entitlement_consumption object: { allowed, value, reason, limit, event_id, replayed, warnings }: Object
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: ErrResponse
- `422` Unprocessable Entity: ErrResponse

## Schemas

### Object

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

### ErrResponse

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

### 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. |

### 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. |
