Skip to the documentation
Python

openemail.billing

Every method in this namespace: its signature, its parameters, what it returns and an example.

Methods

The plan of the workspace and what it costs, as Billing shows them: the plan and its usage, the plans on sale, pay as you go, every charge with its invoice, and the links that start a checkout or open the billing portal. Only the workspace owner reaches it, and nothing is paid through the API.

billing.get()

Read the plan

Scopesbilling:read
Signature
def get(*, api_key: str | None = None, timeout: float | None = None) -> BillingResource

Returns the plan of the workspace and what it includes, as Billing shows it: how it is billed, when it renews or ends and the next charge, how many domains it holds, how much of this month's sends and today's AI actions are used, and pay as you go. metered is False while billing is switched off, and then nothing is capped.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

BillingResource with plan, interval, renewsAt, nextCharge, domains, usage and payAsYouGo.

Example

from openemail import openemail billing = openemail.billing.get()sends = billing['usage']['sends']limit = 'no limit' if sends['limit'] is None else sends['limit'] print(billing['planName'], sends['used'], limit)

Notes

  • A limit of None means the plan has none.

Also available in

API
GET /billing
TypeScript
billing.get()
Ruby
billing.get
PHP
billing->get
Go
Billing.Get
Java
billing().get
C#
Billing.GetAsync
CLI
openemail billing get

billing.list_plans()

List the plans

Scopesbilling:read
Signature
def list_plans(    *,    api_key: str | None = None,    timeout: float | None = None,) -> BillingPlanListResource

Returns every plan, cheapest first, with its price in US cents and what it includes. available says whether it is on sale, and intervals the billing intervals it is sold at.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

BillingPlanListResource, a dict with one BillingPlanResource per plan in data.

Example

from openemail import openemail plans = openemail.billing.list_plans() for plan in plans['data']:    if plan['available']:        print(plan['name'], plan['monthlyPriceCents'] / 100, plan['intervals'])

Also available in

API
GET /billing/plans
TypeScript
billing.listPlans()
Ruby
billing.list_plans
PHP
billing->listPlans
Go
Billing.ListPlans
Java
billing().listPlans
C#
Billing.ListPlansAsync
CLI
openemail billing list-plans

billing.get_usage()

Read the usage history

Scopesbilling:read
Signature
def get_usage(    *,    days: BillingUsageWindow | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> BillingUsageResource

Returns the sends and AI actions of each day, and what pay as you go extras cost each month, as the Usage charts show them.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

daysBillingUsageWindow

How many days back to go, an int from 1 to 3,660, or 'all' for every day since the workspace was made. The server defaults to 30.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

BillingUsageResource with days, months, dailyAiActions and monthlySends.

Example

from openemail import openemail usage = openemail.billing.get_usage(days=90) sent = sum(day['sends'] for day in usage['days']) print(sent, 'sends in the last 90 days')

Also available in

API
GET /billing/usage
TypeScript
billing.getUsage()
Ruby
billing.get_usage
PHP
billing->getUsage
Go
Billing.GetUsage
Java
billing().getUsage
C#
Billing.GetUsageAsync
CLI
openemail billing get-usage

billing.list_alerts()

List the billing alerts

Scopesbilling:read
Signature
def list_alerts(    *,    api_key: str | None = None,    timeout: float | None = None,) -> BillingAlertListResource

Returns what the billing banner of the app would say now, most urgent first: a failed payment, paused pay as you go, sending or AI paused at a limit, a plan about to end, an allowance nearly used and a charge coming soon. An empty data list means there is nothing to say.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

BillingAlertListResource, a dict with one BillingAlertResource per alert in data.

Example

from openemail import openemail alerts = openemail.billing.list_alerts() for alert in alerts['data']:    if alert['severity'] == 'blocked':        print(alert['kind'], alert['target'], alert['at'])

Notes

  • An alert keeps its id while the same thing is true, so one that was dismissed can stay dismissed.

Also available in

API
GET /billing/alerts
TypeScript
billing.listAlerts()
Ruby
billing.list_alerts
PHP
billing->listAlerts
Go
Billing.ListAlerts
Java
billing().listAlerts
C#
Billing.ListAlertsAsync
CLI
openemail billing list-alerts

billing.list_countries()

List the billing countries

Scopesbilling:read
Signature
def list_countries(    *,    api_key: str | None = None,    timeout: float | None = None,) -> BillingCountryListResource

Returns every country a billing address can be in, as the two-letter ISO 3166 codes save_invoice_details takes as country.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

BillingCountryListResource, a dict with the codes in data.

Example

from openemail import openemail countries = openemail.billing.list_countries() print('DE' in countries['data'], len(countries['data']))

Also available in

API
GET /billing/countries
TypeScript
billing.listCountries()
Ruby
billing.list_countries
PHP
billing->listCountries
Go
Billing.ListCountries
Java
billing().listCountries
C#
Billing.ListCountriesAsync
CLI
openemail billing list-countries

billing.get_pay_as_you_go()

Read pay as you go

Scopesbilling:read
Signature
def get_pay_as_you_go(    *,    api_key: str | None = None,    timeout: float | None = None,) -> PayAsYouGoResource

Returns pay as you go on the workspace: whether usage past the allowances is billed, the monthly limit and what extras cost so far, the current billing period once it is set up, the limits that can be chosen and the prices.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

PayAsYouGoResource with the state, limits, prices and period.

Example

from openemail import openemail pay_as_you_go = openemail.billing.get_pay_as_you_go() print(pay_as_you_go['enabled'], pay_as_you_go['spentCents'], pay_as_you_go['limitCents'])

Notes

  • Amounts are in US cents.

Also available in

API
GET /billing/pay-as-you-go
TypeScript
billing.getPayAsYouGo()
Ruby
billing.get_pay_as_you_go
PHP
billing->getPayAsYouGo
Go
Billing.GetPayAsYouGo
Java
billing().getPayAsYouGo
C#
Billing.GetPayAsYouGoAsync
CLI
openemail billing get-pay-as-you-go

billing.set_pay_as_you_go()

Turn pay as you go on or off

Scopesbilling:write
Signature
def set_pay_as_you_go(    body: PayAsYouGoSet,    *,    api_key: str | None = None,    timeout: float | None = None,) -> PayAsYouGoSwitchResource

Turns pay as you go on or off, as the switch on Billing does. Off takes effect at once, and usage stops at the allowances. On takes effect at once when a card is already saved. The first time, checkoutUrl is a link where the person adds a card, and pay as you go starts once they have: call confirm_pay_as_you_go after they return.

Nothing is paid through the API: the person pays, changes the card or cancels on the billing provider's page the link opens, as they do from the app.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

body['enabled']boolRequired

True to turn it on, False to turn it off.

body['theme']BillingTheme

'light' or 'dark', for the page the link opens.

body['locale']str

A language tag such as 'de' or 'pt-PT', for the page the link opens.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

PayAsYouGoSwitchResource with enabled, suspended, activating and checkoutUrl.

Example

from openemail import openemail switch = openemail.billing.set_pay_as_you_go({'enabled': True}) if switch['checkoutUrl']:    print('Add a card here:', switch['checkoutUrl'])else:    print('Pay as you go is on:', switch['enabled'])

Notes

  • With an OAuth access token it asks for a verification code: until the app has verified one, it raises OpenEmailApiError with status 403, code step_up_required and is_step_up_required set. An API key is never asked.

  • Turning it on while pay as you go is unavailable is 503 billing_not_configured.

  • The SDK does not retry it.

Also available in

API
PATCH /billing/pay-as-you-go
TypeScript
billing.setPayAsYouGo()
Ruby
billing.set_pay_as_you_go
PHP
billing->setPayAsYouGo
Go
Billing.SetPayAsYouGo
Java
billing().setPayAsYouGo
C#
Billing.SetPayAsYouGoAsync
CLI
openemail billing set-pay-as-you-go

billing.set_pay_as_you_go_limit()

Set the pay as you go limit

Scopesbilling:write
Signature
def set_pay_as_you_go_limit(    body: PayAsYouGoLimitSet,    *,    api_key: str | None = None,    timeout: float | None = None,) -> PayAsYouGoLimitResource

Sets the monthly spending limit of pay as you go, in US cents, one of the amounts get_pay_as_you_go lists in limits. Extras stop for the rest of a calendar month once it is reached.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

body['limitCents']intRequired

The limit in US cents: 1,000, 2,500, 5,000, 10,000, 25,000, 50,000, 100,000, 250,000 or 500,000, the values in PAY_AS_YOU_GO_LIMITS_CENTS.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

PayAsYouGoLimitResource with limitCents.

Example

from openemail import openemail saved = openemail.billing.set_pay_as_you_go_limit({'limitCents': 10_000}) print(saved['limitCents'] / 100, 'US dollars a month at most')

Notes

  • With an OAuth access token it asks for a verification code: until the app has verified one, it raises OpenEmailApiError with status 403, code step_up_required and is_step_up_required set. An API key is never asked.

  • A workspace where pay as you go was never set up is 409 pay_as_you_go_not_enrolled.

  • The SDK does not retry it.

Also available in

API
PUT /billing/pay-as-you-go/limit
TypeScript
billing.setPayAsYouGoLimit()
Ruby
billing.set_pay_as_you_go_limit
PHP
billing->setPayAsYouGoLimit
Go
Billing.SetPayAsYouGoLimit
Java
billing().setPayAsYouGoLimit
C#
Billing.SetPayAsYouGoLimitAsync
CLI
openemail billing set-pay-as-you-go-limit

billing.confirm_pay_as_you_go()

Confirm pay as you go

Scopesbilling:write
Signature
def confirm_pay_as_you_go(    *,    api_key: str | None = None,    timeout: float | None = None,) -> PayAsYouGoConfirmationResource

Checks with the billing provider whether the card from a pay as you go checkout was saved, and records it, as the app does when the person comes back from the checkout. enabled says whether pay as you go is on now.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

PayAsYouGoConfirmationResource with enabled.

Example

from openemail import openemail confirmation = openemail.billing.confirm_pay_as_you_go() print('Pay as you go is on' if confirmation['enabled'] else 'No card was saved')

Notes

  • With an OAuth access token it asks for a verification code: until the app has verified one, it raises OpenEmailApiError with status 403, code step_up_required and is_step_up_required set. An API key is never asked.

  • It is safe to call again.

  • The SDK does not retry it.

Also available in

API
POST /billing/pay-as-you-go/confirm
TypeScript
billing.confirmPayAsYouGo()
Ruby
billing.confirm_pay_as_you_go
PHP
billing->confirmPayAsYouGo
Go
Billing.ConfirmPayAsYouGo
Java
billing().confirmPayAsYouGo
C#
Billing.ConfirmPayAsYouGoAsync
CLI
openemail billing confirm-pay-as-you-go

billing.start_checkout()

Start a checkout

Scopesbilling:write
Signature
def start_checkout(    body: BillingCheckoutCreate,    *,    api_key: str | None = None,    timeout: float | None = None,) -> BillingCheckoutResource

Starts buying a paid plan for a workspace on Free, as choosing a plan in the app does, and returns the link to the checkout. Nothing is charged until the person pays there, and the plan starts once they have. A workspace that already pays for a plan changes it with open_portal instead.

Nothing is paid through the API: the person pays, changes the card or cancels on the billing provider's page the link opens, as they do from the app.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

body['plan']PaidPlanIdRequired

'starter', 'business' or 'enterprise'.

body['interval']BillingInterval

'month' or 'year'. Defaults to 'month'.

body['theme']BillingTheme

'light' or 'dark', for the page the link opens.

body['locale']str

A language tag such as 'de' or 'pt-PT', for the page the link opens.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

BillingCheckoutResource with url.

Example

from openemail import openemail checkout = openemail.billing.start_checkout({'plan': 'business', 'interval': 'year'}) print('Pay here:', checkout['url'])

Notes

  • With an OAuth access token it asks for a verification code: until the app has verified one, it raises OpenEmailApiError with status 403, code step_up_required and is_step_up_required set. An API key is never asked.

  • A workspace that already pays for a plan is 409 plan_conflict, and a plan or interval that is not on sale is 422 plan_unavailable.

  • The SDK does not retry it.

Also available in

API
POST /billing/checkout
TypeScript
billing.startCheckout()
Ruby
billing.start_checkout
PHP
billing->startCheckout
Go
Billing.StartCheckout
Java
billing().startCheckout
C#
Billing.StartCheckoutAsync
CLI
openemail billing start-checkout

billing.open_portal()

Open the billing portal

Scopesbilling:write
Signature
def open_portal(    body: BillingHandoff | None = None,    *,    api_key: str | None = None,    timeout: float | None = None,) -> BillingPortalResource

Returns a link to the billing portal, where the person changes or cancels the plan, updates the card and downloads past invoices, as Manage does in the app. The body is optional.

Nothing is paid through the API: the person pays, changes the card or cancels on the billing provider's page the link opens, as they do from the app.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

body['theme']BillingTheme

'light' or 'dark', for the page the link opens.

body['locale']str

A language tag such as 'de' or 'pt-PT', for the page the link opens.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

BillingPortalResource with url.

Example

from openemail import openemail portal = openemail.billing.open_portal({'theme': 'dark'}) print('Manage the plan here:', portal['url'])

Notes

  • With an OAuth access token it asks for a verification code: until the app has verified one, it raises OpenEmailApiError with status 403, code step_up_required and is_step_up_required set. An API key is never asked.

  • The SDK does not retry it.

Also available in

API
POST /billing/portal
TypeScript
billing.openPortal()
Ruby
billing.open_portal
PHP
billing->openPortal
Go
Billing.OpenPortal
Java
billing().openPortal
C#
Billing.OpenPortalAsync
CLI
openemail billing open-portal

billing.list_invoices()

List the charges

Scopesbilling:read
Signature
def list_invoices(    *,    page: int | None = None,    limit: int | None = None,    sort: BillingInvoiceSort | None = None,    search: str | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> BillingInvoiceListResource

Returns every charge of the workspace with the state of its invoice, a page at a time, as History on Billing lists them. Pages are numbered rather than cursored: ask for the next one with page= while hasMore is True. search= matches the plan, the invoice number, the charge id and the name billed.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

pageint

Which page, from 1.

limitint

Charges per page, from 1 to 100. The server defaults to 25.

sortBillingInvoiceSort

'newest', the default, or 'oldest'.

searchstr

Words to look for, up to 120 characters.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

BillingInvoiceListResource, a dict with data, total, page, limit, hasMore and metered.

Example

from openemail import openemail charges = openemail.billing.list_invoices(limit=10) for charge in charges['data']:    if not charge['paid']:        print(charge['id'], charge['amountCents'], charge['currency'], charge['status'])

Notes

Also available in

API
GET /billing/invoices
TypeScript
billing.listInvoices()
Ruby
billing.list_invoices
PHP
billing->listInvoices
Go
Billing.ListInvoices
Java
billing().listInvoices
C#
Billing.ListInvoicesAsync
CLI
openemail billing list-invoices

billing.get_invoice()

Get the invoice of a charge

Scopesbilling:read
Signature
def get_invoice(    order_id: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> BillingInvoiceLinkResource

Returns the link to the invoice of one charge, as a PDF, and its file name. An invoice that was not written yet is written first, which can take a few seconds. The link is signed by the billing provider, downloads the PDF and stops working after a while, so fetch it again rather than keeping it.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

order_idstrRequired

The charge id, the id of a charge in list_invoices.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

BillingInvoiceLinkResource with url and fileName.

Example

from openemail import openemail charges = openemail.billing.list_invoices(limit=1) for charge in charges['data']:    invoice = openemail.billing.get_invoice(charge['id'])     print(invoice['fileName'], invoice['url'])

Notes

Also available in

API
GET /billing/invoices/{orderId}
TypeScript
billing.getInvoice()
Ruby
billing.get_invoice
PHP
billing->getInvoice
Go
Billing.GetInvoice
Java
billing().getInvoice
C#
Billing.GetInvoiceAsync
CLI
openemail billing get-invoice

billing.save_invoice_details()

Save the billing details of a charge

Scopesbilling:write
Signature
def save_invoice_details(    order_id: str,    body: BillingDetailsSet,    *,    api_key: str | None = None,    timeout: float | None = None,) -> BillingInvoiceDetailsResource

Saves the name and address billed on a charge, as the Billing address dialog does, keeps the address for later charges, and starts writing its invoice. invoice is 'ready' when the charge already had one, 'started' when it is being written, and 'refused' with the reason in message.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

order_idstrRequired

The charge id, the id of a charge in list_invoices.

body['name']strRequired

Who is billed, up to 200 characters.

body['line1']strRequired

The street address, up to 200 characters.

body['line2']str

A flat, suite or building, up to 200 characters.

body['city']strRequired

Up to 120 characters.

body['postalCode']str

Up to 40 characters.

body['state']str

The state or region, up to 60 characters. In the US and Canada, its two-letter code.

body['country']strRequired

A two-letter ISO 3166 code, one of those list_countries returns.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

BillingInvoiceDetailsResource with invoice and message.

Example

from openemail import openemail details = openemail.billing.save_invoice_details(    '3f6c2a9e-8b1d-4e7a-9c35-2d4f1b8e6a07',    {        'name': 'Acme Ltd',        'line1': '1 Market Street',        'city': 'London',        'postalCode': 'EC1A 1AA',        'country': 'GB',    },) print(details['invoice'], details['message'])

Notes

  • With an OAuth access token it asks for a verification code: until the app has verified one, it raises OpenEmailApiError with status 403, code step_up_required and is_step_up_required set. An API key is never asked.

  • An address the billing provider refuses is 422 billing_address_rejected.

  • The SDK does not retry it.

Also available in

API
PUT /billing/invoices/{orderId}/details
TypeScript
billing.saveInvoiceDetails()
Ruby
billing.save_invoice_details
PHP
billing->saveInvoiceDetails
Go
Billing.SaveInvoiceDetails
Java
billing().saveInvoiceDetails
C#
Billing.SaveInvoiceDetailsAsync
CLI
openemail billing save-invoice-details

billing.list_add_ons()

List add-ons

Scopesbilling:read
Signature
def list_add_ons(    *,    api_key: str | None = None,    timeout: float | None = None,) -> AddOnListResource

Returns what can be bought on top of the plan, today the dedicated sending IP: whether it is for sale, its price per IP a month in priceCents, whether the workspace has it and when it ends, the IPs it brought, and eligibility, which says whether the workspace qualifies. A dedicated IP needs the Business or Enterprise plan and at least 100,000 emails sent in a month, because below that volume it delivers worse than the shared IPs.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

AddOnListResource, a dict with one AddOnResource per add-on in data: addOn, available, status, priceCents, endsAt, eligibility and ips.

Example

from openemail import openemail add_ons = openemail.billing.list_add_ons() for add_on in add_ons['data']:    print(add_on['addOn'], add_on['eligibility']['eligible'], add_on['eligibility']['reason'])

Notes

  • status is None until the workspace has the add-on. 'pending' is paid and being set up, 'warming' and 'active' send through the dedicated IP, and 'releasing' is being taken down.

  • A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client's max_retries, and on a 429 only when it carries a Retry-After of a minute or less.

Also available in

API
GET /billing/add-ons
TypeScript
billing.listAddOns()
Ruby
billing.list_add_ons
PHP
billing->listAddOns
Go
Billing.ListAddOns
Java
billing().listAddOns
C#
Billing.ListAddOnsAsync
CLI
openemail billing list-add-ons

billing.start_add_on_checkout()

Start a checkout for an add-on

Scopesbilling:write
Signature
def start_add_on_checkout(    body: AddOnCheckoutCreate,    *,    api_key: str | None = None,    timeout: float | None = None,) -> AddOnCheckoutResource

Starts buying an add-on, as the button under Billing does, and returns the link to the checkout. Nothing is charged until the person pays there. Once it is paid the dedicated IP is set up and warmed up, which sending.list_dedicated_ips shows.

Nothing is paid through the API: the person pays on the billing provider's page the link opens, as they do from the app.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

body['addOn']AddOnIdRequired

The add-on to buy: 'dedicated-ip'.

body['theme']BillingTheme

'light' or 'dark', for the page the link opens.

body['locale']str

A language tag such as 'de' or 'pt-PT', for the page the link opens.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

AddOnCheckoutResource with addOn and url.

Example

from openemail import openemail checkout = openemail.billing.start_add_on_checkout({'addOn': 'dedicated-ip'}) print('Pay here:', checkout['url'])

Notes

  • With an OAuth access token it asks for a verification code: until the app has verified one, it raises OpenEmailApiError with status 403, code step_up_required and is_step_up_required set. An API key is never asked.

  • A workspace that already has the add-on is 409 add_on_already_active, one that does not qualify is 409 add_on_not_eligible, and when every IP is taken it is 409 add_on_sold_out. While add-ons are not on sale it is 503 add_on_unavailable.

  • The SDK does not retry it.

Also available in

API
POST /billing/add-ons/checkout
TypeScript
billing.startAddOnCheckout()
Ruby
billing.start_add_on_checkout
PHP
billing->startAddOnCheckout
Go
Billing.StartAddOnCheckout
Java
billing().startAddOnCheckout
C#
Billing.StartAddOnCheckoutAsync
CLI
openemail billing start-add-on-checkout

billing.cancel_add_on()

Cancel an add-on

Scopesbilling:write
Signature
def cancel_add_on(    add_on: AddOnId,    *,    api_key: str | None = None,    timeout: float | None = None,) -> AddOnResource

Cancels an add-on. It stays until the end of the month already paid for, which endsAt gives. Then the dedicated IP is released and mail leaves through the shared IPs again.

Billing belongs to the owner of the workspace: an API key acts for the owner, and an OAuth access token reaches billing only when the owner connected the app with every address. A token that acts for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

Parameters

add_onAddOnIdRequired

The add-on to cancel: 'dedicated-ip'.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

Returns

AddOnResource, now with endsAt set.

Example

from openemail import openemail add_on = openemail.billing.cancel_add_on('dedicated-ip') print('Ends at', add_on['endsAt'])

Notes

  • With an OAuth access token it asks for a verification code: until the app has verified one, it raises OpenEmailApiError with status 403, code step_up_required and is_step_up_required set. An API key is never asked.

  • A workspace that does not have the add-on, or whose add-on is already ending, is 409 add_on_not_active.

  • The SDK does not retry a delete.

Also available in

API
DELETE /billing/add-ons/{addOn}
TypeScript
billing.cancelAddOn()
Ruby
billing.cancel_add_on
PHP
billing->cancelAddOn
Go
Billing.CancelAddOn
Java
billing().cancelAddOn
C#
Billing.CancelAddOnAsync
CLI
openemail billing cancel-add-on