# Billing subject states

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

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.

## GET /v1/billing/subject-state

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

billing.entitlement.v1.SubjectStateService/GetSubjectState (32-billing-overview.md, API Surface, Subject states; Data Model, Subject state). The subject's current state: its package, every feature it resolves a value for by key ({ type, value } for a boolean or numeric feature, { type, allowance, per, limit, overage, exhausted } for a metered one; billing-svc docs/questions.md, P107), seat_limit, suspended and suspension_cause, with a version that increases on every change. A subject with no state yet answers the defaults with version 0: customer_id, package and seat_limit null, the values of default_features as features (a metered default not exhausted), suspended false. Needs sys:billing:read on the root, and answers while billing is off (billing-svc docs/questions.md, P41). An unknown subject_type is invalid_subject_type; a user or organization not in the instance is subject_not_found. The RPC writes nothing, so X-Idempotency-Key is not read.

Operation ID: `GetSubjectState` · Capability: `billing`

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `subject_type` | string | yes | user, organization or external |
| `subject_id` | string | yes | A user's or organization's id, or the client's own external id |

### Responses

- `200` A subject_state object: Object
- `400` Bad Request: ErrResponse
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: 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. |
