App öffnen
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
FieldTypeDescription
planTierreqstring · "free" | "pro" | "team" | "enterprise"
intervalstring · "month" | "year"
stripePriceIdstring
prorationBehaviorstring · "create_prorations" | "none"

Responses

200OK
Body
FieldTypeDescription
subscriptionIdreqstring
orgIdreqstring
planTierreqstring · "free" | "pro" | "team" | "enterprise"
statusreqstring · "trialing" | "active" | "past_due" | "canceled" | "incomplete" | "unpaid"
intervalreqstring · "month" | "year"
currencyreqstring
recurringAmountMinorreqnumber
trialEndsAtreqstring
currentPeriodStartreqstring
currentPeriodEndreqstring
cancelAtPeriodEndreqboolean
createdAtreqstring
updatedAtreqstring
401Unauthenticated
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
402Card declined on proration charge
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
404No active subscription
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
409Subscription not in a mutable state (e.g. unpaid)
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring
422Validation error
Body
FieldTypeDescription
errorreqobject
error.codereqstring
error.messagereqstring

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",
)