Billing
Plans, subscriptions, and billing management
4 endpoints
Endpoints
| Method | Path | Description |
| POST | /v1/billing/checkout | Create a Stripe Checkout session for upgrading to a paid plan. |
| Returns the checkout URL that the client should redirect to. | | |
| GET | /v1/billing/plans | List all available plans with their prices and limits. |
| POST | /v1/billing/portal | Create a Stripe Customer Portal session for managing the subscription. |
| Returns the portal URL. | | |
| GET | /v1/billing/subscription | Get 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
| Field | Type | Required | Description |
billing_period | `string | null` | No |
cancel_url | string | Yes | |
plan | string | Yes | |
success_url | string | Yes | |
Responses
| Status | Description |
| 200 | Checkout session created, with the URL to redirect to |
| 401 | Unauthorized |
| 403 | No billing access (an API key without account:admin, or a session below admin), or a sub-account, whose billing the parent manages |
| 422 | Unknown 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
| Status | Description |
| 200 | Available 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
| Field | Type | Required | Description |
return_url | string | Yes | |
Responses
| Status | Description |
| 200 | Portal session created, with the URL to redirect to |
| 401 | Unauthorized |
| 403 | No billing access (an API key without account:admin, or a session below admin), or a sub-account, whose billing the parent manages |
| 422 | The 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
| Status | Description |
| 200 | Current subscription details |
| 401 | Unauthorized |
| 403 | No 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)