The billing state of the organization.
const url = 'https://api.opdns.io/v1/account/billing';const options = { method: 'GET', headers: {cookie: '__Host-opdns_session=<__Host-opdns_session>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://api.opdns.io/v1/account/billing \ --cookie __Host-opdns_session=<__Host-opdns_session>Token scope: billing:read. Only the owner of the organization can read it
(403 owner_required for another member, with a session or a token). Solutions
Opero Inc sells the plans and Stripe takes the payments. enabled is
false until the deployment has its Stripe secret key and webhook signing secret.
Until then, every billing write answers 503 billing_unavailable. offers are
the plans and intervals that POST /v1/account/billing/checkout sells.
subscription is the one subscription of the organization, as the last webhook
left it (null before the first checkout). past_due is set while a payment is
failed. The plan stays until grace_ends_at (7 days after the first failure,
with two emails to the owners). Then the organization moves to free and keeps
everything it holds, until a payment goes through. customer says whether the
Stripe customer portal opens (card, plan change, cancellation, invoices). The
API reads this from the database of the control plane, not from Stripe.
Authorizations
Section titled “Authorizations”Responses
Section titled “Responses”The billing state.
object
The deployment accepts payments (its Stripe secret key and webhook signing secret are set).
The Stripe test mode. Only test cards work, and nothing is charged.
The plans and intervals that Checkout sells, in upgrade order.
object
The organization is a Stripe customer, so the portal (card, plan, invoices) opens.
object
The Stripe subscription status.
The plan that the product of the subscription sells (empty if unknown).
Monthly or yearly (empty if unknown).
The next charge. Null when the subscription ends at the end of the period, or already ended.
object
The first failed payment.
When the organization moves to free, unless a payment goes through.
The grace period ended. The organization is on free until a payment restores the plan.
Example
{ "enabled": true, "test_mode": true, "offers": [ { "plan": "personal", "interval": "monthly" }, { "plan": "personal", "interval": "yearly" } ], "customer": true, "subscription": { "status": "active", "plan": "personal", "interval": "yearly", "current_period_end": "2027-10-03T12:00:00Z", "renews_at": "2027-10-03T12:00:00Z", "cancel_at_period_end": false }, "past_due": null}Not authenticated.
object
Stable machine code.
object
Seconds, the same value as the Retry-After header (rate limits, offline nodes).
The plan limit that a plan_limit problem reached.
object
The value of the limit in the plan.
Where to change to a larger plan.
The scope that the API token did not have (insufficient_scope).
Example
{ "type": "https://opdns.io/problems/unauthenticated", "title": "Unauthorized", "status": 401, "code": "unauthenticated", "detail": "You are not signed in, or your sign-in ended. Sign in again to continue.", "request_id": "5f2c9a0e7b1d4c38"}Authenticated but not allowed: insufficient_scope, session_required, csrf_rejected, reauth_required (sign in again within five minutes), account_pending_deletion (the account is in its deletion cooling-off period), email_unverified (creating a profile before the email address is verified).
object
Stable machine code.
object
Seconds, the same value as the Retry-After header (rate limits, offline nodes).
The plan limit that a plan_limit problem reached.
object
The value of the limit in the plan.
Where to change to a larger plan.
The scope that the API token did not have (insufficient_scope).
Example
{ "type": "https://opdns.io/problems/insufficient_scope", "title": "Forbidden", "status": 403, "code": "insufficient_scope", "detail": "This API token does not have the profiles:write scope that this request needs. Create a token with this scope, then try again.", "required_scope": "profiles:write", "request_id": "5f2c9a0e7b1d4c38"}