client.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.GetAsyncBilling.ListPlansAsyncBilling.GetUsageAsyncBilling.ListAlertsAsyncBilling.ListCountriesAsyncBilling.GetPayAsYouGoAsyncBilling.SetPayAsYouGoAsyncBilling.SetPayAsYouGoLimitAsyncBilling.ConfirmPayAsYouGoAsyncBilling.StartCheckoutAsyncBilling.OpenPortalAsyncBilling.ListInvoicesAsyncBilling.GetInvoiceAsyncBilling.SaveInvoiceDetailsAsyncBilling.ListAddOnsAsyncBilling.StartAddOnCheckoutAsyncBilling.CancelAddOnAsync
Billing.GetAsync
Read the plan
Task<JsonObject> GetAsync(string? apiKey = null, CancellationToken cancellationToken = default)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
apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with plan, planName, interval, renewsAt, nextCharge, domains, usage and payAsYouGo.
Example
var billing = await client.Billing.GetAsync();var sends = billing["usage"]?["sends"]; Console.WriteLine($"{billing["planName"]}: {sends?["used"]} of {sends?["limit"]?.ToString() ?? "unlimited"} sends this month");Notes
A limit of
nullmeans the plan has none.
Also available in
- API
GET /billing- TypeScript
billing.get()- Python
billing.get()- Ruby
billing.get- PHP
billing->get- Go
Billing.Get- Java
billing().get- CLI
nextmail billing get
Billing.ListPlansAsync
List the plans
Task<JsonObject> ListPlansAsync( string? apiKey = null, CancellationToken cancellationToken = default)Returns every plan, cheapest first, with its price in US cents and what it includes, the older plans kept only for the workspaces already on them among them. available says whether it is on sale, and intervals the billing intervals it is sold at. A plan with customPricing is priced in a contract, so its prices read 0. usageRates gives what pay as you go bills on each plan, past its allowances and for the API and MCP requests of keys and connected apps,, and the rates for sends, received emails, storage and API requests differ from plan to plan.
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
apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with data, a list with one object per plan: its prices and customPricing, the monthly sends and received emails it includes (monthlySends, monthlyReceived), dailySends, the sends a day while no card is on file, what pay as you go can buy past them (extraSends, extraReceived, extraAiActions, extraStorage) and whether it bills API and MCP requests (extraApiRequests) and payAsYouGoLimitCents, the monthly pay as you go limit it starts with. usageRates holds what pay as you go bills on that plan: sends, received, aiActions, addressChecks, storage and apiRequests, each with unit and priceCents.
Example
var plans = await client.Billing.ListPlansAsync(); Console.WriteLine(plans.ToJsonString());Also available in
Billing.GetUsageAsync
Read the usage history
Task<JsonObject> GetUsageAsync( string? days = null, string? apiKey = null, DateTimeOffset? since = null, DateTimeOffset? until = null, CancellationToken cancellationToken = default)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. since: and until: set the window outright instead of days:. Usage is kept per UTC day, so that window covers whole days: from the day since: falls on to the day of the last moment before until:, and months ends with the month of that day.
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
daysstring?How many days back to go, from 1 to 3,660, or
all(BillingUsageWindows.All) for every day since the workspace was made. The server defaults to 30.apiKeystring?Overrides the client's API key for this call only.
sinceDateTimeOffset?Where the window starts, a
DateTimeOffset. It wins overdays:, and the window spans at most 3,660 days.untilDateTimeOffset?Where the window ends, a
DateTimeOffset, now by default. It needssince:and has to be later than it.cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with days, months, dailyAiActions and monthlySends.
Example
var usage = await client.Billing.GetUsageAsync(days: "90"); Console.WriteLine($"{(usage["days"]?.AsArray() ?? []).Sum(row => (long?)row?["sends"] ?? 0)} sends in the last 90 days"); foreach (var month in usage["months"]?.AsArray() ?? []){ Console.WriteLine($"{month?["month"]}: {month?["cents"]} cents of extras");}Also available in
Billing.ListAlertsAsync
List the billing alerts
Task<JsonObject> ListAlertsAsync( string? apiKey = null, CancellationToken cancellationToken = default)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 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
apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with data, a list with one object per alert.
Example
using Nextmail.Constants; var alerts = await client.Billing.ListAlertsAsync(); foreach (var alert in alerts["data"]?.AsArray() ?? []){ if ((string?)alert?["severity"] == BillingAlertSeverities.Blocked) { Console.WriteLine($"Blocked: {alert?["kind"]}"); }}Notes
An alert keeps its
idwhile the same thing is true, so one that was dismissed can stay dismissed.
Also available in
Billing.ListCountriesAsync
List the billing countries
Task<JsonObject> ListCountriesAsync( string? apiKey = null, CancellationToken cancellationToken = default)Returns every country a billing address can be in, as the two-letter ISO 3166 codes SaveInvoiceDetailsAsync 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
apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with the codes in data, a list of strings.
Example
var countries = await client.Billing.ListCountriesAsync(); Console.WriteLine(countries.ToJsonString());Also available in
Billing.GetPayAsYouGoAsync
Read pay as you go
Task<JsonObject> GetPayAsYouGoAsync( string? apiKey = null, CancellationToken cancellationToken = default)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 rates of the plan of the workspace. It also counts every request a key or a connected app makes to the REST API or the MCP server, billed at prices.apiRequests while pay as you go is on, apart from requests refused with 429 rate_limited, requests that failed on our side and the ones made before pay as you go started.
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
apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with the state, what it covers (coversSends, coversReceived, coversAiActions, coversAddressChecks, coversStorage, coversApiRequests), viaPlan when the plan subscription itself bills the extras, the extras of this month, limits, prices, the rates of the plan of the workspace, and period.
Example
var payAsYouGo = await client.Billing.GetPayAsYouGoAsync(); Console.WriteLine($"{((bool?)payAsYouGo["enabled"] == true ? "On" : "Off")}, {payAsYouGo["spentCents"]} of {payAsYouGo["limitCents"]} cents spent");Console.WriteLine($"Limits on offer: {string.Join(", ", payAsYouGo["limits"]?.AsArray() ?? [])}");Notes
Amounts are in US cents.
Also available in
Billing.SetPayAsYouGoAsync
Turn pay as you go on or off
Task<JsonObject> SetPayAsYouGoAsync( IReadOnlyDictionary<string, object?> body, string? apiKey = null, CancellationToken cancellationToken = default)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 ConfirmPayAsYouGoAsync 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
enabledboolRequiredtrueto turn it on,falseto turn it off.themestringlightordark, for the page the link opens, as inNextmail.Constants.BillingThemes.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with enabled, suspended, activating and checkoutUrl.
Example
var result = await client.Billing.SetPayAsYouGoAsync(new Body { ["enabled"] = true, ["theme"] = "dark" }); if (result["checkoutUrl"] is not null){ Console.WriteLine($"Add a card here: {result["checkoutUrl"]}");}Notes
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. 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
Billing.SetPayAsYouGoLimitAsync
Set the pay as you go limit
Task<JsonObject> SetPayAsYouGoLimitAsync( IReadOnlyDictionary<string, object?> body, string? apiKey = null, CancellationToken cancellationToken = default)Sets the monthly spending limit of pay as you go, in US cents, one of the amounts GetPayAsYouGoAsync 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
limitCentsintRequiredThe limit in US cents: 1,000, 2,500, 5,000, 10,000, 25,000, 50,000, 100,000, 250,000 or 500,000, the amounts in
Nextmail.Constants.PayAsYouGoLimitsCents.All.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with limitCents.
Example
var saved = await client.Billing.SetPayAsYouGoLimitAsync(new Body { ["limitCents"] = 10000 }); Console.WriteLine(saved.ToJsonString());Notes
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. 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
Billing.ConfirmPayAsYouGoAsync
Confirm pay as you go
Task<JsonObject> ConfirmPayAsYouGoAsync( string? apiKey = null, CancellationToken cancellationToken = default)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
apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with enabled.
Example
var confirmation = await client.Billing.ConfirmPayAsYouGoAsync(); Console.WriteLine($"{((bool?)confirmation["enabled"] == true ? "Pay as you go is on" : "No card was saved")}");Notes
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. An API key is never asked.It is safe to call again.
The SDK does not retry it.
Also available in
Billing.StartCheckoutAsync
Start a checkout
Task<JsonObject> StartCheckoutAsync( IReadOnlyDictionary<string, object?> body, string? apiKey = null, CancellationToken cancellationToken = default)Starts buying a paid plan for a workspace that pays for none yet, 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 OpenPortalAsync 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
planstringRequiredA plan on sale, as
ListPlansAsyncmarks it withavailable, such asprofessionalorbusiness, also inNextmail.Constants.PaidPlanIds.intervalstringOne of the
intervalsthe plan is sold at, as inNextmail.Constants.BillingIntervals. Defaults tomonth.themestringlightordark, for the page the link opens, as inNextmail.Constants.BillingThemes.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with url.
Example
using Nextmail.Constants; var checkout = await client.Billing.StartCheckoutAsync(new Body { ["plan"] = PaidPlanIds.Professional }); Console.WriteLine($"Pay here: {checkout["url"]}");Notes
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. 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 422plan_unavailable.The SDK does not retry it.
Also available in
Billing.OpenPortalAsync
Open the billing portal
Task<JsonObject> OpenPortalAsync( IReadOnlyDictionary<string, object?>? body = null, string? apiKey = null, CancellationToken cancellationToken = default)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.
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
themestringlightordark, for the page the link opens, as inNextmail.Constants.BillingThemes.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with url.
Example
var portal = await client.Billing.OpenPortalAsync(body: new Body { ["theme"] = "dark" }); Console.WriteLine($"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 is refused with 403
step_up_required. An API key is never asked.The SDK does not retry it.
Also available in
Billing.ListInvoicesAsync
List the charges
Task<JsonObject> ListInvoicesAsync( int? page = null, int? limit = null, string? sort = null, string? search = null, string? apiKey = null, CancellationToken cancellationToken = default)Returns every charge of the workspace with the state of its invoice, a page at a time, as History on Billing lists them. 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.
sortstring?newest, the default, oroldest, as inNextmail.Constants.BillingInvoiceSorts.searchstring?Words to look for, up to 120 characters.
apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with data, total, page, limit, hasMore and metered.
Example
var invoices = await client.Billing.ListInvoicesAsync(limit: 10); foreach (var charge in invoices["data"]?.AsArray() ?? []){ if ((bool?)charge?["paid"] != true) { Console.WriteLine($"{charge?["id"]} {charge?["amountCents"]} cents, {charge?["status"]}"); }} Console.WriteLine($"{((bool?)invoices["hasMore"] == true ? "More on page 2" : "That is every charge")}");Notes
A provider that does not answer is 502
billing_unreachable.
Also available in
Billing.GetInvoiceAsync
Get the invoice of a charge
Task<JsonObject> GetInvoiceAsync( string orderId, string? apiKey = null, CancellationToken cancellationToken = default)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
orderIdstringRequiredThe charge id, as
ListInvoicesAsyncreturns it.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with url and fileName.
Example
var invoices = await client.Billing.ListInvoicesAsync(limit: 1); if (invoices["data"]?.AsArray().FirstOrDefault() is { } latest){ var invoice = await client.Billing.GetInvoiceAsync(latest["id"]!.GetValue<string>()); Console.WriteLine($"{invoice["fileName"]}: {invoice["url"]}");}Notes
A charge with no billing name and address is 409
billing_details_required: save them withSaveInvoiceDetailsAsync. A draft or void charge is 409invoice_unavailable, and an invoice still being written is 504invoice_not_ready.
Also available in
Billing.SaveInvoiceDetailsAsync
Save the billing details of a charge
Task<JsonObject> SaveInvoiceDetailsAsync( string orderId, IReadOnlyDictionary<string, object?> body, string? apiKey = null, CancellationToken cancellationToken = default)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
orderIdstringRequiredThe charge id, as
ListInvoicesAsyncreturns it.namestringRequiredWho is billed, up to 200 characters.
line1stringRequiredThe street address, up to 200 characters.
line2stringA flat, suite or building, up to 200 characters.
citystringRequiredUp to 120 characters.
postalCodestringUp to 40 characters.
statestringThe state or region, up to 60 characters. In the US and Canada, its two-letter code.
countrystringRequiredA two-letter ISO 3166 code, one of those
ListCountriesAsyncreturns.apiKeystring?Overrides the client's API key for this call only.
cancellationTokenCancellationTokenCancels the request.
Returns
A JsonObject with invoice and message.
Example
var result = await client.Billing.SaveInvoiceDetailsAsync("3b9f2c4e-7a1d-4e8b-9c0f-5d6a7b8c9d0e", new Body{ ["name"] = "Acme Ltd", ["line1"] = "1 Market Street", ["city"] = "London", ["postalCode"] = "EC1A 1AA", ["country"] = "GB",}); Console.WriteLine($"Invoice {result["invoice"]}");Notes
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. 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
Billing.ListAddOnsAsync
List add-ons
Task<JsonObject> ListAddOnsAsync( string? apiKey = null, CancellationToken cancellationToken = default)Returns what can be bought on top of the plan, the dedicated sending IP and white label: whether each is for sale, its price a month in priceCents (per IP for the dedicated IP), whether the workspace has it and when it ends, the IPs a dedicated IP brought, and eligibility, which says whether the workspace qualifies. White label is the web app on a domain of the workspace, its logo in the app and in the emails sent for it, and no Powered by marks on its forms and booking pages, for $10 a month each, on any plan. A dedicated IP needs 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
cancellationTokenCancellationTokenCancels the request.
apiKeystring?Overrides the client's API key for this call only.
Returns
A JsonObject with one object per add-on in data: addOn, available, status, priceCents, endsAt, eligibility and ips.
Example
var addOns = await client.Billing.ListAddOnsAsync(); foreach (var addOn in addOns["data"]?.AsArray() ?? []){ Console.WriteLine($"{addOn?["addOn"]}: {addOn?["status"]?.ToString() ?? "not bought"}, {addOn?["priceCents"]} cents a month");}Notes
statusis null until the workspace has the add-on.pendingis paid and being set up,warmingandactivesend through the dedicated IP, andreleasingis being taken down.A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client
MaxRetries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
Billing.StartAddOnCheckoutAsync
Start a checkout for an add-on
Task<JsonObject> StartAddOnCheckoutAsync( IReadOnlyDictionary<string, object?> body, string? apiKey = null, CancellationToken cancellationToken = default)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.ListDedicatedIpsAsync 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
addOnstringRequiredThe add-on to buy:
dedicated-ip(AddOns.DedicatedIp).themestringlightordark, for the page the link opens.cancellationTokenCancellationTokenCancels the request.
apiKeystring?Overrides the client's API key for this call only.
Returns
A JsonObject with addOn and url.
Example
using Nextmail.Constants; var checkout = await client.Billing.StartAddOnCheckoutAsync(new Body { ["addOn"] = AddOns.DedicatedIp, ["theme"] = BillingThemes.Dark }); Console.WriteLine($"Pay for {checkout["addOn"]} at {checkout["url"]}");Notes
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. 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 409add_on_not_eligible, and when every IP is taken it is 409add_on_sold_out. While add-ons are not on sale it is 503add_on_unavailable.The SDK does not retry it.
Also available in
Billing.CancelAddOnAsync
Cancel an add-on
Task<JsonObject> CancelAddOnAsync( string addOn, string? apiKey = null, CancellationToken cancellationToken = default)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
addOnstringRequiredThe add-on to cancel:
dedicated-ip(AddOns.DedicatedIp).cancellationTokenCancellationTokenCancels the request.
apiKeystring?Overrides the client's API key for this call only.
Returns
A JsonObject, now with endsAt set.
Example
using Nextmail.Constants; var addOn = await client.Billing.CancelAddOnAsync(AddOns.DedicatedIp); Console.WriteLine($"{addOn["addOn"]} ends {addOn["endsAt"]}");Notes
With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403
step_up_required. 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.