Request Body
FlexPrice customer ID. Required if external_customer_id is not provided. Example: "cust_a1b2c3d4e5f6g7h8i9j0"
Your internal customer ID (must match the external_id used when creating the customer). Required if customer_id is not provided. Example: "customer-12345"
ID of the plan to subscribe to. Example: "plan_a1b2c3d4e5f6g7h8i9j0"
Three-letter ISO currency code (lowercase). Example: "usd"
Billing frequency. Options: "IN_ADVANCE", "IN_ARREARS"
Billing period unit. Options: "DAY", "WEEK", "MONTH", "QUARTER", "YEAR"
Number of billing periods in each billing cycle. Example: 3 (for quarterly billing with monthly periods)
billing_cycle
string
default: "ANNIVERSARY"
Determines billing date calculation. Options: "ANNIVERSARY" (uses start date), "CALENDAR" (uses calendar dates)
ISO 8601 timestamp for when the subscription starts. Defaults to now. Example: "2024-03-20T00:00:00Z"
ISO 8601 timestamp for when the subscription ends (optional). Example: "2025-03-20T00:00:00Z"
ISO 8601 timestamp for trial period start. Example: "2024-03-20T00:00:00Z"
ISO 8601 timestamp for trial period end. Example: "2024-04-20T00:00:00Z"
Optional unique identifier for programmatic lookup. Example: "customer-12345-pro-subscription"
Arbitrary key-value pairs for storing additional information. Example: {"source": "website", "campaign": "spring2024"}
collection_method
string
default: "CHARGE_AUTOMATICALLY"
How invoices are collected. Options: "CHARGE_AUTOMATICALLY", "SEND_INVOICE"
payment_behavior
string
default: "DEFAULT_ACTIVE"
Payment handling behavior. Options: "DEFAULT_ACTIVE", "DEFAULT_INCOMPLETE", "ALLOW_INCOMPLETE", "ERROR_IF_INCOMPLETE"
Initial status. Set to “DRAFT” to create without activating. Options: "ACTIVE", "DRAFT", "INCOMPLETE"
Minimum committed amount for the billing period (decimal as string). Example: "1000.00"
Time frame of the commitment. Options: "MONTH", "QUARTER", "YEAR"
Multiplier for usage beyond commitment (decimal as string). Example: "1.5"
Whether to apply true-up fee when usage is below commitment.
How proration is handled. Options: "CREATE_PRORATIONS", "NONE"
Customer’s timezone for billing calculations. Example: "America/New_York"
Parent subscription ID for hierarchy (e.g., child subscription under a parent). Example: "sub_parent123"
Payment terms for invoice due date. Options: "15_NET", "30_NET", "45_NET", "60_NET", "75_NET", "90_NET"
invoice_billing
string
default: "INVOICE_TO_SELF"
Determines which customer receives invoices. Options: "INVOICE_TO_PARENT", "INVOICE_TO_SELF"
Customize specific prices for this subscription. Show override_line_items properties
override_line_items[].price_id
ID of the plan price to override.
override_line_items[].quantity
Custom quantity (decimal as string).
override_line_items[].amount
Custom amount (decimal as string).
Additional line items to add at creation (in addition to plan prices). Show line_items properties
Quantity (decimal as string).
line_items[].display_name
Custom display name for this line item.
Subscription phases for phased pricing. ISO 8601 timestamp for phase start.
ISO 8601 timestamp for phase end (required for all phases except last).
phases[].override_line_items
Price overrides for this phase.
Response
Unique identifier for the subscription.
Current subscription status.
Number of billing periods per cycle.
ISO 8601 timestamp of the billing anchor date.
ISO 8601 timestamp when subscription starts.
ISO 8601 timestamp when subscription ends (if set).
ISO 8601 timestamp of current billing period start.
ISO 8601 timestamp of current billing period end.
ISO 8601 timestamp of trial start (if applicable).
ISO 8601 timestamp of trial end (if applicable).
ISO 8601 timestamp when the subscription was created.
ISO 8601 timestamp when the subscription was last updated.
Plan details (if included).
Customer details (if included).
Example Request
curl --request POST \
--url https://api.flexprice.io/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"customer_id": "cust_a1b2c3d4e5f6g7h8i9j0",
"plan_id": "plan_a1b2c3d4e5f6g7h8i9j0",
"currency": "usd",
"billing_cadence": "IN_ADVANCE",
"billing_period": "MONTH",
"billing_period_count": 1,
"start_date": "2024-03-20T00:00:00Z",
"metadata": {
"source": "website"
}
}'
Example Response
{
"id" : "sub_x1y2z3a4b5c6d7e8f9g0" ,
"customer_id" : "cust_a1b2c3d4e5f6g7h8i9j0" ,
"plan_id" : "plan_a1b2c3d4e5f6g7h8i9j0" ,
"subscription_status" : "ACTIVE" ,
"currency" : "usd" ,
"billing_cadence" : "IN_ADVANCE" ,
"billing_period" : "MONTH" ,
"billing_period_count" : 1 ,
"billing_anchor" : "2024-03-20T00:00:00Z" ,
"start_date" : "2024-03-20T00:00:00Z" ,
"current_period_start" : "2024-03-20T00:00:00Z" ,
"current_period_end" : "2024-04-20T00:00:00Z" ,
"metadata" : {
"source" : "website"
},
"created_at" : "2024-03-20T15:04:05Z" ,
"updated_at" : "2024-03-20T15:04:05Z"
}