Skip to content

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

NameInTypeDescription
orgID (required)pathstringOrganization ID

Responses

StatusDescriptionBody
200OKdata: billing.billingOverviewResponse
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror 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

NameInTypeDescription
orgID (required)pathstringOrganization ID

Responses

StatusDescriptionBody
200OKdata: billing.billingCardResponse[]
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror 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

NameInTypeDescription
orgID (required)pathstringOrganization ID

Request body (application/json)

Schema: billing.createCardSessionRequest.

FieldTypeDescription
phonestring
redirect_decline_urlstring
redirect_urlstring

Responses

StatusDescriptionBody
200OKdata: billing.cardSessionResponse
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
422Unprocessable Entityerror envelope
502Bad Gatewayerror 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

NameInTypeDescription
orgID (required)pathstringOrganization ID
cardID (required)pathintegerCard ID

Responses

StatusDescriptionBody
204No Content
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
502Bad Gatewayerror 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

NameInTypeDescription
orgID (required)pathstringOrganization ID
cardID (required)pathintegerCard ID

Responses

StatusDescriptionBody
200OKdata: billing.billingCardResponse
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
409Conflicterror 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

NameInTypeDescription
orgID (required)pathstringOrganization ID
sessionID (required)pathstringCard-binding session ID

Responses

StatusDescriptionBody
200OKdata: billing.bindingStatusResponse
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
502Bad Gatewayerror 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

NameInTypeDescription
orgID (required)pathstringOrganization ID

Responses

StatusDescriptionBody
200OKdata: billing.billingChargeResponse[]
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror 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

NameInTypeDescription
orgID (required)pathstringOrganization ID
chargeID (required)pathintegerCharge ID

Request body (application/json)

Schema: billing.confirmChargeRequest.

FieldTypeDescription
otpstring

Responses

StatusDescriptionBody
200OKdata: billing.billingChargeResponse
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
409Conflicterror envelope
410Goneerror envelope
422Unprocessable Entityerror envelope
502Bad Gatewayerror 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

NameInTypeDescription
orgID (required)pathstringOrganization ID
chargeID (required)pathintegerCharge ID

Responses

StatusDescriptionBody
200OKdata: billing.billingChargeResponse
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
409Conflicterror envelope
502Bad Gatewayerror 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

NameInTypeDescription
orgID (required)pathstringOrganization ID

Request body (application/json)

Schema: billing.setBillingPayerRequest.

FieldTypeDescription
innstring
payer_typestring

Responses

StatusDescriptionBody
204No Content
400Bad Requesterror envelope
401Unauthorizederror envelope
403Forbiddenerror envelope
404Not Founderror envelope
422Unprocessable Entityerror 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

NameInTypeDescription
orgID (required)pathstringOrganization ID

Responses

StatusDescriptionBody
200OKdata
403Forbiddenerror envelope
404Not Founderror envelope