Moonborn — API · billing
Change plan tier or billing interval (proration is config-driven)
Upgrades take effect immediately (with prorated charges by default); downgrades take effect at period end. Both behaviours are exercised through Stripe `subscription.update`.
PATCH/v1/billing/subscriptionscope · Bearer (API key or session JWT)
Request body
| Field | Type | Description |
|---|---|---|
| planTierreq | string · "free" | "pro" | "team" | "enterprise" | |
| interval | string · "month" | "year" | |
| stripePriceId | string | |
| prorationBehavior | string · "create_prorations" | "none" |
Responses
200OK
Body
| Field | Type | Description |
|---|---|---|
| subscriptionIdreq | string | |
| orgIdreq | string | |
| planTierreq | string · "free" | "pro" | "team" | "enterprise" | |
| statusreq | string · "trialing" | "active" | "past_due" | "canceled" | "incomplete" | "unpaid" | |
| intervalreq | string · "month" | "year" | |
| currencyreq | string | |
| recurringAmountMinorreq | number | |
| trialEndsAtreq | string | |
| currentPeriodStartreq | string | |
| currentPeriodEndreq | string | |
| cancelAtPeriodEndreq | boolean | |
| createdAtreq | string | |
| updatedAtreq | string |
401Unauthenticated
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
402Card declined on proration charge
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
404No active subscription
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
409Subscription not in a mutable state (e.g. unpaid)
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
422Validation error
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
Examples
cURL
curl -X PATCH https://api.moonborn.co/v1/billing/subscription \
-H "Authorization: Bearer $MOONBORN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"planTier": "free"
}'TypeScript
import Moonborn from '@moonborn/sdk';
const client = new Moonborn({ apiKey: process.env.MOONBORN_API_KEY });
const result = await client.billing.changeSubscriptionPlan({
planTier: "free",
});Python
import os
from moonborn import Moonborn
client = Moonborn(api_key=os.environ["MOONBORN_API_KEY"])
result = client.billing.change_subscription_plan(
plan_tier="free",
)