AnkraDocs
Console

API reference · Account and billing

Usage and invoices

3 operations of the Ankra Cloud API: Usage, the billing log and invoices.

Invoices, newest month first#

GET/v1/invoices
Operation
list_invoices
Credentials
API token, Portal session
Requires
Permission billing.read

Parameters

Parameters
NameInTypeDescription
cursorquerystringThe next_cursor of the previous page.

Responses

200A page of invoices.application/json · InvoiceList

200 response fields
FieldTypeDescription
itemsrequiredarray of Invoice
idrequiredstring
periodrequiredstring
period_startrequiredstring (date-time)
period_endrequiredstring (date-time)
currencyrequiredstring
total_centsrequiredintegerThe usage total, before credits.
credit_applied_centsintegerThe part of the total account credits paid.
amount_due_centsintegerWhat is charged: total_cents - credit_applied_cents. An invoice credits pay in full is paid and never sent to Stripe.
created_atrequiredstring (date-time)
linesrequiredarray of InvoiceLine
kindrequiredstringcredit lines are credits applied to the invoice: a negative amount_cents, the credit's label as name (for example "Welcome credit WELCOME500") and its id as resource_id.One of usage, credit
resource_typerequiredstring
resource_idrequiredstring
namerequiredstring
planrequiredstring
hoursrequiredinteger
amount_centsrequiredinteger
cap_centsrequiredinteger
payment_statusstringunbilled until Stripe has the invoice (or when payments are not configured or it totals nothing); overdue after a failed charge.One of unbilled, open, paid, overdue
hosted_invoice_urlstring | nullStripe's page to view and pay the invoice.
next_cursorrequiredstring | nullPass as ?cursor= for the next page; null on the last page.
  • 400The request is invalid; detail says why.
  • 401Not signed in, or the credential is invalid or expired.
  • 403The role lacks the permission, the token is read-only (a read-only token also gets reason: read_only_token_cannot_read_credentials on every credential read), the CSRF header is missing, a support session may not do this, or the route needs a verified email address and the caller's is not (reason: email_unverified).
  • defaultAny other error, usually 500.

Example

bash
curl 'https://cloud.ankra.app/v1/invoices' \
  -H "Authorization: Bearer $ANKRA_CLOUD_TOKEN"

One line per resource per day, newest day first#

GET/v1/usage/billing-log
Operation
list_billing_log
Credentials
API token, Portal session
Requires
Permission billing.read

Parameters

Parameters
NameInTypeDescription
cursorquerystringThe next_cursor of the previous page.
limitqueryinteger

Responses

200A page of billing-log lines.application/json · BillingLogEntryList

200 response fields
FieldTypeDescription
itemsrequiredarray of BillingLogEntry
daterequiredstring (date)
resource_typerequiredstring
resource_idrequiredstring
namerequiredstring
planrequiredstring
hoursrequiredinteger
hourly_price_millicentsrequiredinteger
amount_centsrequiredinteger
next_cursorrequiredstring | nullPass as ?cursor= for the next page; null on the last page.
  • 400The request is invalid; detail says why.
  • 401Not signed in, or the credential is invalid or expired.
  • 403The role lacks the permission, the token is read-only (a read-only token also gets reason: read_only_token_cannot_read_credentials on every credential read), the CSRF header is missing, a support session may not do this, or the route needs a verified email address and the caller's is not (reason: email_unverified).
  • defaultAny other error, usually 500.

Example

bash
curl 'https://cloud.ankra.app/v1/usage/billing-log' \
  -H "Authorization: Bearer $ANKRA_CLOUD_TOKEN"

This month's usage and estimate#

GET/v1/usage/summary
Operation
get_usage_summary
Credentials
API token, Portal session
Requires
Permission billing.read

Responses

200The usage summary.application/json · UsageSummary

200 response fields
FieldTypeDescription
currencyrequiredstring
period_startrequiredstring (date-time)
period_endrequiredstring (date-time)
metered_throughrequiredstring (date-time) | null
month_to_date_centsrequiredinteger
estimated_month_centsrequiredinteger
resourcesrequiredarray of UsageResource
resource_typerequiredstring
resource_idrequiredstring
namerequiredstring
planrequiredstring
hoursrequiredinteger
amount_centsrequiredinteger
cap_centsrequiredinteger
hourly_price_millicentsrequiredinteger
is_activerequiredboolean
dailyrequiredarray of UsageDayThe last 90 days including today, oldest first, zero-filled.
daterequiredstring (date)
amount_centsrequiredinteger
credit_balance_centsintegerWhat the account's live credits have left; the next invoice spends it before charging.
credit_next_expirystring (date-time) | nullThe soonest expiry of a live credit.
  • 401Not signed in, or the credential is invalid or expired.
  • 403The role lacks the permission, the token is read-only (a read-only token also gets reason: read_only_token_cannot_read_credentials on every credential read), the CSRF header is missing, a support session may not do this, or the route needs a verified email address and the caller's is not (reason: email_unverified).
  • defaultAny other error, usually 500.

Example

bash
curl 'https://cloud.ankra.app/v1/usage/summary' \
  -H "Authorization: Bearer $ANKRA_CLOUD_TOKEN"