# Create Subscription

<Note>
**Creating the subscription together with its first payment**

This endpoint starts a subscription from a `vaulted_token` you already hold. If the customer is signing up and paying at the same time, you can instead send a `subscription` block on [Create Payment](/reference/payments/create-payment) — one call charges the card and creates the subscription from that same charge. That route is documented for frictionless card payments only. See [Start a subscription with the first payment](/docs/payment-features/subscriptions/start-with-payment).
</Note>

<Warning>
**Subscription Completion**

The fields `billing_cycles` and `availability.finish_at` have an impact on each other. If both are completed during the subscription creation, it will transition to the `COMPLETED` state upon reaching the nearest event defined in these fields, whether it is the billing cycle or the corresponding `finish_at`.
</Warning>

<Warning>
**Credential Usage for Previous CIT**

If you create a CIT payment (e.g. Apple Pay or card) *before* creating the subscription and pass the resulting vaulted token into the subscription, you **must** include `payment_method.card.usage` to indicate whether this is the first or a subsequent use. Without this, rebills will be treated as CITs and declined by the provider.

Required payload for new subscriptions:

```json
{
  "payment_method": {
    "type": "CARD",
    "vaulted_token": "{{vaulted_token}}",
    "card": {
      "usage": "USED"
    }
  }
}
```
</Warning>

Refer to the [HTTP Response Codes](/reference/getting-started/response-codes) section for details on possible error outcomes.

**POST** `/subscriptions`

Base URL: `https://api-sandbox.whitelabel.com/v1`

Create Subscription

## Authorization

- public-api-key (apiKey in header)
- private-secret-key (apiKey in header)

## Header parameters

- `x-idempotency-key` (string)
  A unique identifier for the request. Must be different each time (UUID). See [authentication](/reference/authentication#idempotency).

## Body

Content type: `application/json`

- `name` (string, required)
  The subscription plan name (MAX 255; MIN 3).
- `description` (string)
  The subscription plan description (MAX 255; MIN 3).
- `account_id` (string, required)
  The unique identifier of the account that will have the subscription plan available to use (UUID, 36 chars).
- `merchant_reference` (string)
  Identification of the subscription plan (MAX 255; MIN 3).
- `soft_descriptor` (string)
  Statement descriptor shown on the cardholder's bank statement. When set, it is persisted on the subscription and propagated to every rebill payment generated by the subscription engine. Length and formatting limits vary by provider (for example, Unlimit truncates to 22 characters and Airwallex to 30). Worldpay does not read this field; it builds the statement narrative from `payment_description` instead.
- `country` (string, required)
  The subscription's country (MAX 2; MIN 2; [ISO 3166-1](/reference/country-reference)).
- `amount` (object)
  Specifies the `amount` object, with the value of each subscription payment and the used currency. Mutually exclusive with `plan_id` — send exactly one of the two.
  - `currency` (string, required)
    The currency used to make the payment (MAX 3; MIN 3; [ISO 4217](/reference/country-reference)).
  - `value` (number<float>, required)
    The value of each payment of the subscription (multiple of 0.0001).
- `plan_id` (string)
  The unique identifier of a [plan](/reference/plans/the-plan-object) to subscribe this customer to. Mutually exclusive with `amount` — send exactly one of the two. Omit `trial_period` and `billing_date` when set: both are inherited from the plan and the request is rejected with `400 BAD_REQUEST` if you send them. Also omit `frequency` — it's inherited from the plan too, but sending it anyway is not rejected: it's silently ignored and overridden by the plan's frequency.
- `additional_data` (object)
  Specifies the additional_data object. This object is not mandatory. However, if you send this information, the payment experience will be enhanced for your user.
  - `order` (object)
    Specifies the order object.
    - `items` (object[])
      Specifies the item's object.
      - `id` (string)
        The unique identifier of the item (MAX 255; MIN 3).
      - `name` (string)
        The name of the item (MAX 255; MIN 3).
      - `quantity` (integer<int32>)
        The quantity of the item.
      - `unit_amount` (number)
        The unit amount of the item (multiple of 0.0001).
      - `category` ("art" | "baby" | "coupons" | "beauty_&_personal_care" | "donations" | "computing" | "books" | "grocery_&_gourmet_food" | "cameras" | "video_games" | "television" | "car_electronics" | "electronics" | "automotive" | "toys_&_games" | "musical_instruments" | "handmade" | "garden_&_outdoor" | "entertainment" | "industrial_&_scientific" | "fashion" | "games" | "pet_supplies" | "home" | "musical" | "phones" | "services" | "learnings" | "tickets" | "travels" | "virtual_goods" | "others")
        The category of the item. Check the Item category reference.
      - `brand` (string)
        The brand of the item (MAX 255; MIN 3).
      - `sku_code` (string)
        The stock keeping unit (SKU) of the item (MAX 255; MIN 3).
      - `manufacture_part_number` (string)
        The manufacture part number of the item.
- `frequency` (object)
  Specifies the `frequency` object. Defines the billing frequency for the subscription. Including type and value.
  - `type` ("DAY" | "WEEK" | "MONTH" | "YEAR", required)
    The type of interval the subscription will have in time (DAY, WEEK, MONTH, YEAR). If not set, defaults to MONTH. When `payment_method.type` is `PIX_AUTOMATIC`, only `WEEK`, `MONTH` and `YEAR` with `value` `1` are legal — every other type, and every other value, is rejected with `400 INVALID_PARAMETERS`. See [Pix Automático](/docs/payment-features/subscriptions/pix-automatico#accepted-billing-cadences).
  - `value` (integer<int32>)
    The value between each interval. Min 1. Defaults to 1 if not set.
- `billing_cycles` (object)
  Specifies the `billing_cycles` object. Defines the number of charges associated to the subscription.
  - `total` (integer<int32>)
    The total number of billing cycles for the subscription (MIN 1).
- `customer_payer` (object, required)
  Specifies the `customer_payer` object to identify the customer. Required. Note that validation errors on this object name the field `customer_payer.code`, not `customer_payer.id` — for example `400 BAD_REQUEST` ("customer_payer.code field is required") when it is omitted.
  - `id` (string)
    The unique identifier of the customer (UUID, 36 chars).
- `payment_method` (object, required)
  Specifies the `payment_method` object. Supported types are `CARD`, `PAYPAL_ENROLLMENT` and `PIX_AUTOMATIC`, all using previously enrolled payment methods (`vaulted_token`)
  - `type` ("CARD" | "PAYPAL_ENROLLMENT" | "PIX_AUTOMATIC", required)
    Payment method type. `PIX_AUTOMATIC` bills a Brazilian Pix Automático mandate, is matched case-insensitively, and restricts the billing cadence — see [Pix Automático](/docs/payment-features/subscriptions/pix-automatico).
  - `vaulted_token` (string)
    The vaulted token (UUID, 36 chars).
  - `card` (object)
    - `installments` (integer)
      The number of installments (MAX 50; MIN 1).
    - `network_transaction_id` (string)
      The ID provided by Visa/Mastercard in the response of the initial payment (MAX 256; MIN 1).
    - `usage` ("FIRST" | "USED")
      Indicates whether this stored credential is being used for the first time (FIRST) or has been used before (USED). Required if a CIT payment was created before the subscription — without it, rebills are treated as CITs and may be declined.
- `trial_period` (object)
  Specifies the trial period object
  - `billing_cycles` (integer<int32>)
    The amount of cycles the trial period will have in time. If not set, defaults to 1 (MIN 1).
  - `amount` (object)
    Amount to be discounted for the trial period
    - `currency` (string, required)
      The currency used to make the payment (MAX 3; MIN 3; [ISO 4217](/reference/country-reference)).
    - `value` (number<float>, required)
      The value of each payment of the subscription (multiple of 0.0001).
- `availability` (object)
  Specifies the `availability` object. Defines a date interval based on starting and ending dates when the subscription is available to use.
  - `start_at` (string<date-time>)
    The start date that the subscription plan will be available to use. If not set, the subscription is available from the moment it is created.
  - `finish_at` (string<date-time>)
    The end date until the subscription plan will be available to use. If not defined, the subscription does not have an expiration date.
- `metadata` (object[])
  Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Keys can be unset by posting an empty value to metadata. You can add up to 50 metadata objects.
  - `key` (string)
    The metadata key (MAX 48).
  - `value` (string)
    The metadata key value (MAX 512).
- `retries` (object)
  Specified the 'retries' object. If we need to retry declined transactions in WHITELABEL and the amount if necessary
  - `retry_on_decline` (boolean)
    If we should retry a payment or not after a first decline. False by default.
  - `amount` (integer<int32>)
    The number of retries that the subscription plan will have to complete. 6 will be defined as default if this value is not set or higher than 6. (MAX 6).
  - `strategy` ("DEFAULT" | "SMART" | "CUSTOM_SCHEDULE")
    The retry strategy. Allowed values: DEFAULT (the fixed retry schedule), SMART (machine-learning-based retry timing, applied from the second retry onward) or CUSTOM_SCHEDULE (uses the per-attempt schedule array you provide).
  - `schedule` (object[])
    Object that define the schedule strategy for each retry event, the amounts of objects should match the amount of retries defined. Up to 7 attempts; attempt numbers must run sequentially from 1, and each delay_seconds must be between 1 and 604800 (7 days). The schedule can be replaced later via Update Subscription.
    - `attempt` (number)
      Number of the retry attempt
    - `delay_seconds` (number)
      Specifies the amount of seconds between each retry.
  - `stop_on_hard_decline` (boolean)
    When true, the retry schedule stops for the current billing cycle after a hard decline. On its own, the subscription remains ACTIVE and billing advances to the next cycle; no subscription is canceled or paused and no subscription webhook is emitted. If cancel_on_exhausted_retries is also true, the subscription is canceled instead.
  - `cancel_on_exhausted_retries` (boolean)
    When true, the subscription is canceled once retries for a billing cycle end without a successful payment, instead of remaining ACTIVE and advancing to the next cycle. The subscription status becomes CANCELED, cancellation_source is set to RETRIES_EXHAUSTED, future billing stops, and a single SUBSCRIPTION.CANCEL webhook is emitted. Applies both when the retry schedule runs out and when stop_on_hard_decline ends the cycle early. Defaults to false, which preserves the existing behavior. Create-only: it cannot be changed later — Update Subscription rejects a different value with 400. The cancellation itself is final, so Retry Subscription is rejected afterwards.
- `initial_payment_validation` (boolean)
  Flag to identify if the subscription should wait for the first payment in order to continue. False by default.
- `billing_date` (object)
  Specifies the `billing_date` object. Defines the type of date use for the subscription logic. Mutually exclusive with the frequency object.
  - `type` (string)
    The type of billing_date the subscription will have in time. PREPAID, POSTDATE, DAY. If not set, the creation date for the plan will be set  by default.
  - `day` (integer)
    [Conditional] The day of the month to charge the subscription if type is DAY. Default is 1. Range 1 - 31.
- `subscription_agreement_id` (string)
  Links this subscription to the initial payment created with the same agreement ID. Used for tracking, reconciliation, and chargeback handling. Must exactly match the `subscription_agreement_id` sent in `payment_method.detail.card.stored_credentials.subscription_agreement_id` on the originating payment (MAX 255).

Example:

```json
{
  "name": "string",
  "description": "string",
  "account_id": "string",
  "merchant_reference": "string",
  "soft_descriptor": "string",
  "country": "string",
  "amount": {
    "currency": "string",
    "value": 0
  },
  "plan_id": "string",
  "additional_data": {
    "order": {
      "items": [
        {
          "id": "string",
          "name": "string",
          "quantity": 0,
          "unit_amount": 0,
          "category": "art",
          "brand": "string",
          "sku_code": "string",
          "manufacture_part_number": "string"
        }
      ]
    }
  },
  "frequency": {
    "type": "DAY",
    "value": 0
  },
  "billing_cycles": {
    "total": 0
  },
  "customer_payer": {
    "id": "string"
  },
  "payment_method": {
    "type": "CARD",
    "vaulted_token": "string",
    "card": {
      "installments": 0,
      "network_transaction_id": "string",
      "usage": "FIRST"
    }
  },
  "trial_period": {
    "billing_cycles": 0,
    "amount": {
      "currency": "string",
      "value": 0
    }
  },
  "availability": {
    "start_at": "1970-01-01T00:00:00.000Z",
    "finish_at": "1970-01-01T00:00:00.000Z"
  },
  "metadata": [
    {
      "key": "string",
      "value": "string"
    }
  ],
  "retries": {
    "retry_on_decline": true,
    "amount": 0,
    "strategy": "DEFAULT",
    "schedule": [
      {
        "attempt": 0,
        "delay_seconds": 0
      }
    ],
    "stop_on_hard_decline": true,
    "cancel_on_exhausted_retries": true
  },
  "initial_payment_validation": true,
  "billing_date": {
    "type": "string",
    "day": 0
  },
  "subscription_agreement_id": "string"
}
```

## Responses

### 201

201

- `id` (string)
- `name` (string)
- `account_id` (string)
- `country` (string)
- `description` (string)
- `merchant_reference` (string)
- `soft_descriptor` (string)
- `status` (string)
- `amount` (object)
  - `currency` (string)
  - `value` (number)
- `frequency` (object)
  - `type` (string)
  - `value` (integer)
- `billing_cycles` (object)
  - `total` (integer)
  - `current` (integer)
  - `next_at` (string)
- `customer_payer` (object)
  - `id` (string)
- `payment_method` (object)
  - `type` (string)
  - `vaulted_token` (string)
- `availability` (object)
  - `start_at` (string)
  - `finish_at` (any)
- `trial_period` (object)
  - `billing_cycles` (integer)
  - `amount` (object)
    - `value` (number)
    - `currency` (string)
- `metadata` (any)
- `plan_id` (string)
  Only present when the subscription is linked to a plan.
- `plan_assigned_at` (string)
  Only present on plan-linked subscriptions. The moment the plan was attached — at creation from a plan, migration onto a plan, or a plan change.
- `previous_subscription_id` (string)
  Only present when this subscription was created by a plan change (switching an existing subscription to a different plan).
- `current_phase` (string)
  Only present on plan-linked subscriptions.
- `billing_phases` (object[])
  Only present on plan-linked subscriptions whose plan has phases. Contains the leading TRIAL phases only, snapshotted at creation — the terminal REGULAR phase is never included, since its price isn't pinned and instead resolves from the plan at every billing.
  - `order` (integer)
  - `type` (string)
    Always TRIAL — the terminal REGULAR phase is never in this array.
  - `name` (string)
  - `amount` (object)
    - `currency` (string)
    - `value` (number)
  - `frequency` (object)
    - `type` (string)
    - `value` (integer)
  - `start_cycle` (integer)
  - `end_cycle` (integer)
- `subscription_agreement_id` (string)
- `created_at` (string)
- `updated_at` (string)

Example:

```json
{
  "id": "0c7fed3e-ee0d-4d34-9547-778be4ec0798",
  "name": "Test Subscription",
  "account_id": "493e9374-510a-4201-9e09-de669d75f256",
  "country": "US",
  "description": "Subscription Test",
  "merchant_reference": "subscription-ref-merchant-AA01",
  "soft_descriptor": "ACME SUBSCRIPTION",
  "status": "ACTIVE",
  "amount": {
    "currency": "USD",
    "value": 15000
  },
  "frequency": {
    "type": "MONTH",
    "value": 1
  },
  "billing_cycles": {
    "total": 12,
    "current": 1,
    "next_at": "2024-09-30T12:04:23.265393Z"
  },
  "customer_payer": {
    "id": "a1d3b664-e32a-4508-9da1-9ede3e62a60c"
  },
  "payment_method": {
    "type": "CARD",
    "vaulted_token": "d4aa3586-def2-4705-b7cd-fe064bb764e6"
  },
  "availability": {
    "start_at": "2024-09-30T12:04:23.265393Z",
    "finish_at": null
  },
  "trial_period": {
    "billing_cycles": 1,
    "amount": {
      "value": 0,
      "currency": ""
    }
  },
  "metadata": null,
  "plan_id": "string",
  "plan_assigned_at": "string",
  "previous_subscription_id": "string",
  "current_phase": "string",
  "billing_phases": [
    {
      "order": 0,
      "type": "string",
      "name": "string",
      "amount": {
        "currency": "string",
        "value": 0
      },
      "frequency": {
        "type": "string",
        "value": 0
      },
      "start_cycle": 0,
      "end_cycle": 0
    }
  ],
  "subscription_agreement_id": "sa_6af2dfcd-44c0-4f16-a331-8bed3ed9c9fa",
  "created_at": "2024-09-30T12:04:23.265372Z",
  "updated_at": "2024-09-30T12:04:23.265372Z"
}
```

### 400

400