AnkraDocs
Console

API reference · Account and billing

Payments

5 operations of the Ankra Cloud API: Payment methods and the Stripe webhook.

Whether card payments through Stripe are available#

GET/v1/account/billing
Operation
get_payment_configuration
Credentials
API token, Portal session
Requires
Permission billing.read

When payments_configured is false the other /v1/account/billing/* routes answer 503 and invoices stay unbilled. standing says whether the account may create billable resources (the same reason a refused create answers 402 with).

Responses

200The payment configuration.application/json · PaymentConfiguration

200 response fields
FieldTypeDescription
payments_configuredrequiredboolean
publishable_keyrequiredstring | nullStripe publishable key (pk_…), when configured.
standingrequiredAccountStandingWhether the account may create billable resources; a refused create answers 402 with the same reason.
requires_billing_approvalrequiredbooleanSaving a card does not authorise paid usage.
can_create_resourcesrequiredboolean
reasonrequiredstring | nullWhy the account may not create billable resources; null while it may. account_suspended covers both suspensions; the two timestamps say which hold.One of payment_method_required, owner_approval_required, account_suspended
suspended_for_payment_atrequiredstring (date-time) | nullWhen an invoice overdue past the grace period suspended the account; null while it is in good standing.
suspended_by_staff_atrequiredstring (date-time) | nullWhen Ankra staff suspended the account; null while they have not. Paying an invoice does not lift it; contact support.
  • 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/account/billing' \
  -H "Authorization: Bearer $ANKRA_CLOUD_TOKEN"

The account's saved payment methods#

GET/v1/account/billing/payment-methods
Operation
list_payment_methods
Credentials
API token, Portal session
Requires
Permission billing.read
Note
Reveals a credential or a live view; read-only support sessions are refused.

Parameters

Parameters
NameInTypeDescription
cursorquerystringThe next_cursor of the previous page.
limitqueryintegerPage size; the server applies its default and maximum.

Responses

200A page of payment methods.application/json · PaymentMethodList

200 response fields
FieldTypeDescription
itemsrequiredarray of PaymentMethod
idrequiredstring
typerequiredstring
brandrequiredstringCard brand; empty for other types.
last4requiredstring
exp_monthrequiredinteger
exp_yearrequiredinteger
is_defaultrequiredboolean
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).
  • 503Payments are not configured on this control plane (payments not configured).
  • defaultAny other error, usually 500.

Example

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

Detach a saved payment method#

DELETE/v1/account/billing/payment-methods/{id}
Operation
remove_payment_method
Credentials
API token, Portal session
Requires
Permission billing.manage

Parameters

Parameters
NameInTypeDescription
idrequiredpathstring

Responses

204Removed.

  • 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).
  • 404No such resource in the caller's account.
  • 503Payments are not configured on this control plane (payments not configured).
  • defaultAny other error, usually 500.

Example

bash
curl -X DELETE 'https://cloud.ankra.app/v1/account/billing/payment-methods/<id>' \
  -H "Authorization: Bearer $ANKRA_CLOUD_TOKEN"

Charge invoices to this payment method#

POST/v1/account/billing/payment-methods/{id}/default
Operation
set_default_payment_method
Credentials
API token, Portal session
Requires
Permission billing.manage

Parameters

Parameters
NameInTypeDescription
idrequiredpathstring

Responses

204It is the default now.

  • 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).
  • 404No such resource in the caller's account.
  • 503Payments are not configured on this control plane (payments not configured).
  • defaultAny other error, usually 500.

Example

bash
curl -X POST 'https://cloud.ankra.app/v1/account/billing/payment-methods/<id>/default' \
  -H "Authorization: Bearer $ANKRA_CLOUD_TOKEN"

Start Stripe's hosted page for saving a payment method#

POST/v1/account/billing/setup-session
Operation
create_payment_setup_session
Credentials
API token, Portal session
Requires
Permission billing.manage

Creates the account's Stripe customer on first use and a Checkout session in setup mode (nothing is charged). Redirect the customer to url; Stripe sends them back to /settings/billing.

Responses

201The hosted page to redirect to.application/json · PaymentSetupSession

201 response fields
FieldTypeDescription
urlrequiredstring (uri)
  • 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).
  • 503Payments are not configured on this control plane (payments not configured).
  • defaultAny other error, usually 500.

Example

bash
curl -X POST 'https://cloud.ankra.app/v1/account/billing/setup-session' \
  -H "Authorization: Bearer $ANKRA_CLOUD_TOKEN"