# Create a new subscription

Creates a new subscription for a customer with specified billing plan and schedule. The subscription will be created in 'created' status and will be activated when the customer completes the first payment.
On an `as_presented` subscription, pass `split_ids` to declare your share of a dynamic pricing rule's fee. See [Dynamic Fee Split](#tag/pricing_split). The declaration applies to the first payment and to every subsequent auto debit that does not pass `split_ids` of its own. `split_ids` is rejected on a fixed-frequency subscription, because a fixed-frequency plan auto debits without you and so has no point at which to pass a split or replace one that goes stale.
If the subscription's declaration later stops resolving — Glomo deleted the underlying rule, or the rule is no longer dynamic — the next auto debit is rejected with a `400 Bad Request` until you pass a valid `split_ids` on [Create a payment](#tag/Payment).

Endpoint: POST /subscriptions
Version: 1.0.0
Security: JWT

## Request fields (application/json):

  - `customer_id` (string, required)
    Unique identifier of the customer associated with this subscription.
    Example: cust_5JU9yv0lGSUP

  - `product_name` (string, required)
    Name of the product being subscribed to.
    Example: ShieldGuard Insurance

  - `product_description` (string, required)
    Description of the product.
    Example: Flexible monthly insurance for belongings travel and digital assets easy to manage

  - `plan_name` (string)
    Name of the subscription plan.
    Example: ShieldGuard Lite

  - `plan_description` (string)
    Description of the subscription plan.
    Example: Simple, monthly insurance plan that covers your basic belongings and key digital assets

  - `amount` (number, required)
    The amount in the smallest currency unit. For example, if the amount is $299.00, then 29900 is passed in  this field. In the case of three decimal currencies, such as KWD, BHD and OMR, to represent an amount of 295.991, pass the value as 295990. And in the case of zero decimal currencies such as JPY, for amount ￥295, pass the value as 295.
    Example: 1000

  - `currency` (string, required)
    The currency code in [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) format.
    Example: USD

  - `interval_type` (string, required)
    Used in combination with interval_count to define the billing cycle frequency.
    Enum: "month", "year", "as_presented"

  - `interval_count` (integer | null)
    Number of intervals between a billing cycle, used in combination with interval_type.
Valid combinations:
- Monthly: interval_type='month', interval_count=1
- Quarterly: interval_type='month', interval_count=3
- Half-yearly: interval_type='month', interval_count=6
- Yearly: interval_type='year', interval_count=1
- As Presented: interval_type='as_presented', interval_count=null
    Enum: 1, 3, 6, null

  - `billing_cycles` (integer)
    Total number of billing cycles for the subscription. Required for regular subscriptions, must not be provided for 'as_presented' subscriptions.
A subscription can have a lifetime of 30 years.
Maximum billing cycles therefore depend on interval:
- Monthly (interval_type='month', interval_count=1): max 360 cycles
- Quarterly (interval_type='month', interval_count=3): max 120 cycles
- Half-yearly (interval_type='month', interval_count=6): max 60 cycles
- Yearly (interval_type='year', interval_count=1): max 30 cycles
    Example: 12

  - `max_amount` (integer)
    Maximum allowed amount per payment for 'as_presented' subscriptions. Required when interval_type is 'as_presented', must not be provided for regular subscriptions.
Subsequent payments on the subscription cannot exceed this amount.
    Example: 5000

  - `start_date` (string)
    Start date of the subscription in UTC timezone and ISO 8601 format (YYYY-MM-DD). Must be today or in the future.
Required for regular subscriptions, must not be provided for 'as_presented' subscriptions.
    Example: 2025-01-01

  - `expires_at` (string, required)
    Expiration date for the subscription payment link in UTC timezone and ISO 8601 format (YYYY-MM-DD). Must be >= start_date and cannot be more than 30 days from start_date.
    Example: 2025-01-07

  - `notify_customer` (boolean, required)
    Whether to send notification e-mails to customers for subscription lifecycle changes.
    Example: true

  - `reference_number` (string)
    optional identifier to be sent for reconciliations
    Example: R0001

  - `starts_with_first_payment` (boolean, required)
    Whether the subscription payment schedule should get synchronized with the first payment.
    Example: true

  - `split_ids` (array)
    Supported only when `interval_type` is `as_presented`. Sending `split_ids` on a fixed-frequency subscription returns a `400 Bad Request`, because a fixed-frequency plan auto debits without you and so has no point at which to pass a split or replace one that goes stale.
The declaration applies to the first payment, and to every subsequent auto debit that does not pass `split_ids` of its own. See [Create a payment](#tag/Payment) for the auto debit override.
    Example: ["psplit_7Kq2mXbTdLp9"]

## Response 201 fields (application/json):

  - `id` (string, required)
    Unique identifier for the subscription.
    Example: sub_5JU9yv0lGSUP

  - `customer_id` (string, required)
    Unique identifier of the customer associated with this subscription.
    Example: cust_5JU9yv0lGSUP

  - `product_name` (string, required)
    Name of the product being subscribed to.
    Example: ShieldGuard Insurance

  - `product_description` (string, required)
    Description of the product.
    Example: Flexible, monthly insurance for belongings, travel, and digital assets, easy to manage

  - `plan_name` (string)
    Name of the subscription plan.
    Example: ShieldGuard Lite

  - `plan_description` (string)
    Description of the subscription plan.
    Example: Simple, monthly insurance plan that covers your basic belongings and key digital assets

  - `reference_number` (string)
    optional identifier to be sent for reconciliations
    Example: R0001

  - `status` (string, required)
    Current status of the subscription.
    Enum: "created", "active", "paused", "expired", "failed", "halted", "cancelled", "completed", "authorized"

  - `amount` (number, required)
    The amount in the smallest currency unit. For example, if the amount is $299.00, then 29900 is passed in  this field. In the case of three decimal currencies, such as KWD, BHD and OMR, to represent an amount of 295.991, pass the value as 295990. And in the case of zero decimal currencies such as JPY, for amount ￥295, pass the value as 295.
    Example: 1000

  - `currency` (string, required)
    The currency code in [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) format.
    Example: USD

  - `interval_type` (string, required)
    Used in combination with interval_count to define the billing cycle frequency.
    Enum: "month", "year", "as_presented"

  - `interval_count` (integer | null)
    Number of intervals between a billing cycle, used in combination with interval_type.
Valid combinations:
- Monthly: interval_type='month', interval_count=1
- Quarterly: interval_type='month', interval_count=3
- Half-yearly: interval_type='month', interval_count=6
- Yearly: interval_type='year', interval_count=1
- As Presented: interval_type='as_presented', interval_count=null
    Enum: 1, 3, 6, null

  - `billing_cycles` (integer | null)
    Total number of billing cycles for the subscription. Null for 'as_presented' subscriptions.
    Example: 12

  - `max_amount` (integer | null)
    Maximum allowed amount per payment. Present only for 'as_presented' subscriptions, null for regular subscriptions.
    Example: 5000

  - `start_date` (string, required)
    Start date of the subscription in UTC timezone and ISO 8601 format (YYYY-MM-DD).
    Example: 2025-01-01

  - `end_date` (string | null)
    The date on which the subscription ends in UTC timezone and ISO 8601 format (YYYY-MM-DD).
    Example: 2025-12-01

  - `expires_at` (string, required)
    Expiration date for the subscription payment link in UTC timezone and ISO 8601 format (YYYY-MM-DD).
    Example: 2025-01-07

  - `next_payment_date` (string | null)
    Date of the next scheduled payment in UTC timezone and ISO 8601 format (YYYY-MM-DD).
    Example: 2025-02-01

  - `subscription_link_url` (string, required)
    URL for the subscription payment page. Your customer can use this URL to make the first payment and activate the subscription.
    Example: https://checkout.glomopay.com/subscription/sub_5JU9yv0lGSUP

  - `cancelled_at` (string | null)
    Date when the subscription was cancelled in UTC timezone and ISO 8601 format (YYYY-MM-DD). This field is null unless the subscription status is 'cancelled'.
    Example: 2025-01-15

## Response 400 fields (application/json):

  - `error` (string)
    Enum: "Bad Request"

  - `message` (string)
    Error message describing the validation failure
    Example: Customer not found

