Appearance
Billing
11 operations. Paths are relative to https://api.frege.io.
The organization's billing account
GET/v1/orgs/{orgID}/billing
The account's status, plan, current period, whether a card is on file, the payer, and the coins the plan includes and Frege granted this period. An organization without an account answers status "none".
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data: billing.billingOverviewResponse |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
The organization's cards
GET/v1/orgs/{orgID}/billing/cards
Every card bound to the organization's billing account, the default one marked.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data: billing.billingCardResponse[] |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
Start binding a card
POST/v1/orgs/{orgID}/billing/cards
Opens a card-binding session at the payment gateway and answers the gateway's form URL; the organization's owner or admin finishes on that form, and the gateway calls back. Both redirect URLs must be on this deployment's dashboard. 404 when no payment gateway is configured; 502 when the gateway refuses.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
Request body (application/json)
Schema: billing.createCardSessionRequest.
| Field | Type | Description |
|---|---|---|
phone | string | |
redirect_decline_url | string | |
redirect_url | string |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data: billing.cardSessionResponse |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 422 | Unprocessable Entity | error envelope |
| 502 | Bad Gateway | error envelope |
Remove a card
DELETE/v1/orgs/{orgID}/billing/cards/{cardID}
Revokes the card at the payment gateway and drops it from the account. 404 when no payment gateway is configured or the card is not the organization's; 502 when the gateway refuses.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
cardID (required) | path | integer | Card ID |
Responses
| Status | Description | Body |
|---|---|---|
| 204 | No Content | |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 502 | Bad Gateway | error envelope |
Make a card the default
PATCH/v1/orgs/{orgID}/billing/cards/{cardID}/default
The default card is the one each period is charged to. 409 when the card is not active.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
cardID (required) | path | integer | Card ID |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data: billing.billingCardResponse |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 409 | Conflict | error envelope |
How a card binding stands
GET/v1/orgs/{orgID}/billing/cards/pending/{sessionID}
Reads a card-binding session back from the payment gateway: the masked card, its payment system and the session's status. 404 when no payment gateway is configured; 502 when the gateway cannot be read.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
sessionID (required) | path | string | Card-binding session ID |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data: billing.bindingStatusResponse |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 502 | Bad Gateway | error envelope |
The organization's charges
GET/v1/orgs/{orgID}/billing/charges
Every charge of the organization's billing account, newest first: the period, the plan and overage amounts in minor units, the status and the receipt.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data: billing.billingChargeResponse[] |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
Confirm a charge with the card's one-time code
POST/v1/orgs/{orgID}/billing/charges/{chargeID}/confirm
For a charge waiting for confirmation: sends the code the card's bank texted. 409 when the charge is not waiting; 422 when the code is missing or wrong; 410 when it expired (retry for a new one); 502 when the gateway refuses.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
chargeID (required) | path | integer | Charge ID |
Request body (application/json)
Schema: billing.confirmChargeRequest.
| Field | Type | Description |
|---|---|---|
otp | string |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data: billing.billingChargeResponse |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 409 | Conflict | error envelope |
| 410 | Gone | error envelope |
| 422 | Unprocessable Entity | error envelope |
| 502 | Bad Gateway | error envelope |
Retry a stuck or failed charge
POST/v1/orgs/{orgID}/billing/charges/{chargeID}/retry
Charges the default card again. 409 when the charge is neither stuck nor failed, when no active card is on file, or when another attempt is in progress; 502 when the gateway refuses.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
chargeID (required) | path | integer | Charge ID |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data: billing.billingChargeResponse |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 409 | Conflict | error envelope |
| 502 | Bad Gateway | error envelope |
Who pays
PATCH/v1/orgs/{orgID}/billing/payer
Sets the payer of the organization's account: an individual, or a legal entity with its INN. 404 when the organization has no billing account; 422 when payer_type is neither, or a legal entity has no INN.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
Request body (application/json)
Schema: billing.setBillingPayerRequest.
| Field | Type | Description |
|---|---|---|
inn | string | |
payer_type | string |
Responses
| Status | Description | Body |
|---|---|---|
| 204 | No Content | |
| 400 | Bad Request | error envelope |
| 401 | Unauthorized | error envelope |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |
| 422 | Unprocessable Entity | error envelope |
What each project spent this period
GET/v1/orgs/{orgID}/billing/usage
The organization pays, but "why is this month higher than last" is a question about a PROJECT, and an organization-wide total cannot answer it. One line per project for the account's current period, biggest first, in coins. A project that spent nothing is a zero line rather than a missing one — "we were not charged for that" is an answer. unpriced counts calls whose cost has not been read back from the gateway yet; they are NOT in coins, and they are shown rather than folded in because a total that quietly skips them reads as if those calls were free.
Authentication: bearer token.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
orgID (required) | path | string | Organization ID |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | OK | data |
| 403 | Forbidden | error envelope |
| 404 | Not Found | error envelope |