Subscription (billing)
/api/v1/billing/subscriptionRequest
/api/v1/billing/subscriptioncurl -X GET 'https://app.mailyte.com/api/v1/billing/subscription' \
-H 'Authorization: Bearer mk_live_YOUR_API_KEY'const response = await fetch('https://app.mailyte.com/api/v1/billing/subscription', {
method: 'GET',
headers: {
Authorization: 'Bearer mk_live_YOUR_API_KEY',
},
});
const { data } = await response.json();import requests
response = requests.get(
"https://app.mailyte.com/api/v1/billing/subscription",
headers={"Authorization": "Bearer mk_live_YOUR_API_KEY"},
)
data = response.json()["data"]<?php
$response = Http::withToken('mk_live_YOUR_API_KEY')
->get('https://app.mailyte.com/api/v1/billing/subscription');
$data = $response->json('data');require "net/http"
require "json"
uri = URI("https://app.mailyte.com/api/v1/billing/subscription")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer mk_live_YOUR_API_KEY"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }Response
Success.
dataobjectYour subscription, or null (with HTTP 200) when you have never subscribed.
objectstringsubscriptionidstringUnique identifier for the subscription.
statusstringpending | active | past_due | suspended | cancelledWhere the subscription stands.
past_duemeans a payment failed;suspendedmeans sending has stopped.product_linestringmail | send | marketingWhich product this subscription is for. An organization holds at most one live subscription per line, each with its own interval, renewal and cancellation.
currencystringISO 4217 code, e.g.
NGNorUSD. THE CURRENCY THE CUSTOMER AGREED — nothing here is converted. Every amount below is in this currency's minor unit.intervalstringmonth | yearThe billing period. (One-off prices exist for credit packs, which are bought outright and never appear on a subscription.)
itemsarray<object>What the subscription is made of, one line per product, such as 3 Standard and 4 Pro seats.
product_keystringThe stable catalogue key, and the ONLY catalogue identifier published — it is the handle you pass to
POST /billing/subscription/itemsto change quantity. Internal product and price row ids are not published.tierstringstandard | pro | workplaceThe mailbox tier this line buys seats of. Null when the line is not seats, such as a Send plan or an add-on;
product_keynames it.quantityintegerHow many of this product.
next_quantityintegerA lower quantity that starts at the next renewal. Null when no change is planned. Until then the line keeps
quantity; a reduction is not refunded.unit_amountintegerThe price of one unit per
interval, as a whole number in the smallest unit ofcurrency(kobo for NGN, cents for USD):150000NGN is ₦1,500.00. This is the price locked to this line.subtotalintegerquantitytimesunit_amount, in the smallest unit ofcurrency(kobo for NGN, cents for USD).
totalintegerThe total for one
interval, in the smallest unit ofcurrency(kobo for NGN, cents for USD):150000NGN is ₦1,500.00. Tax and payment fees are not included.current_period_startstringWhen the current billing period began. Null until the first payment succeeds (
statusis thenpending).current_period_endstringWhen the current period ends. With
auto_renewon,totalis charged again then. Null until the first payment succeeds.auto_renewbooleancancelled_atstringWhen cancellation was asked for. Null when it was not. Service continues until
current_period_end.cancel_at_period_endbooleanTrue when the customer cancelled and the subscription is still running to
current_period_end. It can be undone withPOST /billing/subscriptions/{line}/resumeuntil then.next_billing_datestringWhen you will next be charged. Null when no charge is coming: it is cancelling, waiting for its first payment, or has ended.
price_locked_untilstringPrices on this subscription will not rise before this date. Null when there is no price lock: monthly plans have none, paying a year ahead does.
created_atstringWhen the subscription was created at checkout. Billing starts at
current_period_start.updated_atstringWhen the subscription last changed.
Returned inside the standard envelope.
Errors
| Status | When |
|---|---|
401 | The API key is missing, unknown, revoked or expired. All four answer identically, on purpose: distinguishing them would confirm which keys exist. |
403 | The key is valid but may not do this: it lacks the required scope, its IP allowlist does not include you, or this endpoint does not accept API keys. |
404 | No such resource in this organization. |
422 | The request was understood but the values were not acceptable. |
429 | Too many requests, or the organization has spent its sending allowance. `Retry-After` says how long to wait. |
Every status, with what causes it and what to do, is on the error reference.