← All API sections

Billing

Plans, subscriptions, and billing management

4 endpoints

Endpoints

MethodPathDescription
POST/v1/billing/checkoutCreate a Stripe Checkout session for upgrading to a paid plan.
Returns the checkout URL that the client should redirect to.
GET/v1/billing/plansList all available plans with their prices and limits.
POST/v1/billing/portalCreate a Stripe Customer Portal session for managing the subscription.
Returns the portal URL.
GET/v1/billing/subscriptionGet the current account's subscription status.

POST /v1/billing/checkout

If the account has never subscribed (no stripe_subscription_id), a trial period is attached when TRIAL_PERIOD_DAYS is configured.

Request Body

FieldTypeRequiredDescription
billing_period`stringnull`No
cancel_urlstringYes
planstringYes
success_urlstringYes

Responses

StatusDescription
200Checkout session created, with the URL to redirect to
401Unauthorized
403No billing access (an API key without account:admin, or a session below admin), or a sub-account, whose billing the parent manages
422Unknown plan or billing_period

Example

curl -X POST https://api.euromail.dev/v1/billing/checkout \
  -H "X-EuroMail-Api-Key: em_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "cancel_url": "https://example.com/webhook", "plan": "...", "success_url": "https://example.com/webhook" }'
import { EuroMail } from "@euromail/sdk";

const euromail = new EuroMail({ apiKey: "em_live_..." });

const result = await euromail.createBilling({
    cancel_url: "https://example.com/webhook",
    plan: "...",
    success_url: "https://example.com/webhook",
  });
from euromail import EuroMail

client = EuroMail(api_key="em_live_...")

result = client.create_billing(
    cancel_url="https://example.com/webhook",
    plan="...",
    success_url="https://example.com/webhook",
)
use euromail::EuroMail;

let client = EuroMail::new("em_live_...");

let result = client.create_billing(&CreateBillingParams {
    cancel_url: "https://example.com/webhook".into(),
    plan: "...".into(),
    success_url: "https://example.com/webhook".into(),
    ..Default::default()
}).await?;
client := euromail.NewClient("em_live_...")

result, err := client.CreateBilling(ctx, euromail.CreateBillingParams{
    CancelUrl: "https://example.com/webhook",
    Plan: "...",
    SuccessUrl: "https://example.com/webhook",
})

GET /v1/billing/plans

List all available plans with their prices and limits.

Responses

StatusDescription
200Available billing plans

Example

curl -X GET https://api.euromail.dev/v1/billing/plans \
  -H "X-EuroMail-Api-Key: em_live_..."
import { EuroMail } from "@euromail/sdk";

const euromail = new EuroMail({ apiKey: "em_live_..." });

const result = await euromail.getBilling();
from euromail import EuroMail

client = EuroMail(api_key="em_live_...")

result = client.get_billing()
use euromail::EuroMail;

let client = EuroMail::new("em_live_...");

let result = client.get_billing().await?;
client := euromail.NewClient("em_live_...")

result, err := client.GetBilling(ctx)

POST /v1/billing/portal

Create a Stripe Customer Portal session for managing the subscription. Returns the portal URL.

Request Body

FieldTypeRequiredDescription
return_urlstringYes

Responses

StatusDescription
200Portal session created, with the URL to redirect to
401Unauthorized
403No billing access (an API key without account:admin, or a session below admin), or a sub-account, whose billing the parent manages
422The account has no Stripe customer yet

Example

curl -X POST https://api.euromail.dev/v1/billing/portal \
  -H "X-EuroMail-Api-Key: em_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "return_url": "https://example.com/webhook" }'
import { EuroMail } from "@euromail/sdk";

const euromail = new EuroMail({ apiKey: "em_live_..." });

const result = await euromail.createBilling({
    return_url: "https://example.com/webhook",
  });
from euromail import EuroMail

client = EuroMail(api_key="em_live_...")

result = client.create_billing(
    return_url="https://example.com/webhook",
)
use euromail::EuroMail;

let client = EuroMail::new("em_live_...");

let result = client.create_billing(&CreateBillingParams {
    return_url: "https://example.com/webhook".into(),
    ..Default::default()
}).await?;
client := euromail.NewClient("em_live_...")

result, err := client.CreateBilling(ctx, euromail.CreateBillingParams{
    ReturnUrl: "https://example.com/webhook",
})

GET /v1/billing/subscription

Get the current account's subscription status.

Responses

StatusDescription
200Current subscription details
401Unauthorized
403No billing access: an API key without account:admin, or a session below admin

Example

curl -X GET https://api.euromail.dev/v1/billing/subscription \
  -H "X-EuroMail-Api-Key: em_live_..."
import { EuroMail } from "@euromail/sdk";

const euromail = new EuroMail({ apiKey: "em_live_..." });

const result = await euromail.getBilling();
from euromail import EuroMail

client = EuroMail(api_key="em_live_...")

result = client.get_billing()
use euromail::EuroMail;

let client = EuroMail::new("em_live_...");

let result = client.get_billing().await?;
client := euromail.NewClient("em_live_...")

result, err := client.GetBilling(ctx)