Skip to main content
POST
/
api
/
v1
/
subscriptions
Create Subscription
curl --request POST \
  --url https://app.flowglad.com/api/v1/subscriptions \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "customerId": "<string>",
  "customerExternalId": "<string>",
  "priceId": "<string>",
  "priceSlug": "<string>",
  "quantity": 123,
  "startDate": "<string>",
  "interval": "day",
  "intervalCount": 123,
  "trialEnd": 123,
  "metadata": {},
  "name": "<string>",
  "defaultPaymentMethodId": "<string>",
  "backupPaymentMethodId": "<string>"
}'
{
  "subscription": {
    "id": "<string>",
    "createdAt": 0,
    "updatedAt": 0,
    "livemode": true,
    "startDate": 0,
    "customerId": "<string>",
    "organizationId": "<string>",
    "status": "trialing",
    "defaultPaymentMethodId": "<string>",
    "backupPaymentMethodId": "<string>",
    "trialEnd": 0,
    "currentBillingPeriodStart": 0,
    "currentBillingPeriodEnd": 0,
    "metadata": {},
    "canceledAt": 0,
    "cancelScheduledAt": 0,
    "cancellationReason": "<string>",
    "replacedBySubscriptionId": "<string>",
    "isFreePlan": true,
    "priceId": "<string>",
    "runBillingAtPeriodStart": true,
    "interval": "day",
    "intervalCount": 123,
    "billingCycleAnchorDate": 0,
    "name": "<string>",
    "renews": true,
    "current": true
  }
}

Authorizations

Authorization
string
header
required

Body

application/json
customerId
string

The internal ID of the customer. If not provided, customerExternalId is required.

customerExternalId
string

The external ID of the customer. If not provided, customerId is required.

priceId
string

The id of the price to subscribe to. If not provided, priceSlug is required. Used to determine whether the subscription is usage-based or not, and set other defaults such as trial period and billing intervals.

priceSlug
string

The slug of the price to subscribe to. If not provided, priceId is required. Price slugs are scoped to the customer's pricing model. Used to determine whether the subscription is usage-based or not, and set other defaults such as trial period and billing intervals.

quantity
number

The quantity of the price purchased. If not provided, defaults to 1.

startDate
string

The time when the subscription starts. If not provided, defaults to current time.

interval
enum<string>

The interval of the subscription. If not provided, defaults to the interval of the price provided by priceId or priceSlug.

Available options:
day,
week,
month,
year
intervalCount
number

The number of intervals that each billing period will last. If not provided, defaults to 1

trialEnd
number

Epoch time in milliseconds of when the trial ends. If not provided, defaults to startDate + the associated price's trialPeriodDays

metadata
object

JSON object

name
string

The name of the subscription. If not provided, defaults to the name of the product associated with the price provided by 'priceId' or 'priceSlug'.

defaultPaymentMethodId
string

The default payment method to use when attempting to run charges for the subscription.If not provided, the customer's default payment method will be used. If no default payment method is present, charges will not run. If no default payment method is provided and there is a trial period for the subscription, the subscription will enter 'trial_ended' status at the end of the trial period.

backupPaymentMethodId
string

The payment method to try if charges for the subscription fail with the default payment method.

Response

Successful response

subscription
object
required
  • Option 1
  • Option 2