# Billing dunning

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

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/customers/{customer_id}/dunning

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

billing.payment.v1.DunningService/GetCustomerDunning (38-payments-and-tax.md, API Surface, Dunning; Customer dunning state). The same state the Customer object carries as dunning; a send_invoice Customer is always none.

Operation ID: `GetCustomerDunning` · Capability: `billing`

### Path parameters

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

### Responses

- `200` A customer_dunning object: { status, started_at, invoice_ids, next_action }: 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}/dunning/retry

```http
POST https://api.{region}.pontive.com/v1/billing/customers/{customer_id}/dunning/retry
```

billing.payment.v1.DunningService/RetryCustomerDunning (38-payments-and-tax.md, API Surface, Dunning). Tries every overdue invoice at once, oldest first, as the client; the schedule does not move.

Operation ID: `RetryCustomerDunning` · 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 customer_dunning object after the retries: 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/dunning-policy

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

billing.payment.v1.DunningService/GetDunningPolicy (38-payments-and-tax.md, API Surface, Dunning; Dunning policy). The instance's policy, with 38's defaults until it is changed.

Operation ID: `GetDunningPolicy` · Capability: `billing`

### Responses

- `200` A DunningPolicy 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

## PATCH /v1/billing/dunning-policy

```http
PATCH https://api.{region}.pontive.com/v1/billing/dunning-policy
```

billing.payment.v1.DunningService/UpdateDunningPolicy (38-payments-and-tax.md, API Surface, Dunning; Dunning policy). A field left out keeps its value; retries and steps replace their lists; send_invoice is merged field by field, and null turns a field off (null on send_invoice turns every field in it off). More than 6 retries or 20 steps is field_too_long and changes nothing.

Operation ID: `UpdateDunningPolicy` · Capability: `billing`

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `X-Idempotency-Key` | string |  | Idempotency key |
| `If-Match` | string |  | The ETag the document was read with, checked by billing-svc in the update: a stale one is refused 412 precondition_failed (D42) |

### Responses

- `200` The updated DunningPolicy object: object
- `401` Unauthorized: ErrResponse
- `403` module_required: the instance's billing capability is off: ErrResponse
- `404` Not Found: ErrResponse
- `409` Conflict: ErrResponse
- `412` precondition_failed: the document changed since it was read: 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. |
