Create Subscription

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 — 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.

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.

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:

{
  "payment_method": {
    "type": "CARD",
    "vaulted_token": "{{vaulted_token}}",
    "card": {
      "usage": "USED"
    }
  }
}

Refer to the HTTP Response Codes section for details on possible error outcomes.

POST/subscriptions

Header Parameters

x-idempotency-keystring

A unique identifier for the request. Must be different each time (UUID). See authentication.

Body application/json

namestringrequired

The subscription plan name (MAX 255; MIN 3).

descriptionstring

The subscription plan description (MAX 255; MIN 3).

account_idstringrequired

The unique identifier of the account that will have the subscription plan available to use (UUID, 36 chars).

merchant_referencestring

Identification of the subscription plan (MAX 255; MIN 3).

soft_descriptorstring

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.

countrystringrequired

The subscription’s country (MAX 2; MIN 2; ISO 3166-1).

amountobject

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.

Show amount properties
currencystringrequired

The currency used to make the payment (MAX 3; MIN 3; ISO 4217).

valuenumber<float>required

The value of each payment of the subscription (multiple of 0.0001).

plan_idstring

The unique identifier of a plan 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_dataobject

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.

Show additional_data properties
orderobject

Specifies the order object.

Show order properties
itemsobject[]

Specifies the item’s object.

Show items properties
idstring

The unique identifier of the item (MAX 255; MIN 3).

namestring

The name of the item (MAX 255; MIN 3).

quantityinteger<int32>

The quantity of the item.

unit_amountnumber

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.

brandstring

The brand of the item (MAX 255; MIN 3).

sku_codestring

The stock keeping unit (SKU) of the item (MAX 255; MIN 3).

manufacture_part_numberstring

The manufacture part number of the item.

frequencyobject

Specifies the frequency object. Defines the billing frequency for the subscription. Including type and value.

Show frequency properties
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.

valueinteger<int32>

The value between each interval. Min 1. Defaults to 1 if not set.

billing_cyclesobject

Specifies the billing_cycles object. Defines the number of charges associated to the subscription.

Show billing_cycles properties
totalinteger<int32>

The total number of billing cycles for the subscription (MIN 1).

customer_payerobjectrequired

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.

Show customer_payer properties
idstring

The unique identifier of the customer (UUID, 36 chars).

payment_methodobjectrequired

Specifies the payment_method object. Supported types are CARD, PAYPAL_ENROLLMENT and PIX_AUTOMATIC, all using previously enrolled payment methods (vaulted_token)

Show payment_method properties
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.

vaulted_tokenstring

The vaulted token (UUID, 36 chars).

cardobject
Show card properties
installmentsinteger

The number of installments (MAX 50; MIN 1).

network_transaction_idstring

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_periodobject

Specifies the trial period object

Show trial_period properties
billing_cyclesinteger<int32>

The amount of cycles the trial period will have in time. If not set, defaults to 1 (MIN 1).

amountobject

Amount to be discounted for the trial period

Show amount properties
currencystringrequired

The currency used to make the payment (MAX 3; MIN 3; ISO 4217).

valuenumber<float>required

The value of each payment of the subscription (multiple of 0.0001).

availabilityobject

Specifies the availability object. Defines a date interval based on starting and ending dates when the subscription is available to use.

Show availability properties
start_atstring<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_atstring<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.

metadataobject[]

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.

Show metadata properties
keystring

The metadata key (MAX 48).

valuestring

The metadata key value (MAX 512).

retriesobject

Specified the ‘retries’ object. If we need to retry declined transactions in WHITELABEL and the amount if necessary

Show retries properties
retry_on_declineboolean

If we should retry a payment or not after a first decline. False by default.

amountinteger<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).

scheduleobject[]

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.

Show schedule properties
attemptnumber

Number of the retry attempt

delay_secondsnumber

Specifies the amount of seconds between each retry.

stop_on_hard_declineboolean

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_retriesboolean

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_validationboolean

Flag to identify if the subscription should wait for the first payment in order to continue. False by default.

billing_dateobject

Specifies the billing_date object. Defines the type of date use for the subscription logic. Mutually exclusive with the frequency object.

Show billing_date properties
typestring

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.

dayinteger

[Conditional] The day of the month to charge the subscription if type is DAY. Default is 1. Range 1 - 31.

subscription_agreement_idstring

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).

Response

201

idstring
namestring
account_idstring
countrystring
descriptionstring
merchant_referencestring
soft_descriptorstring
statusstring
amountobject
Show amount properties
currencystring
valuenumber
frequencyobject
Show frequency properties
typestring
valueinteger
billing_cyclesobject
Show billing_cycles properties
totalinteger
currentinteger
next_atstring
customer_payerobject
Show customer_payer properties
idstring
payment_methodobject
Show payment_method properties
typestring
vaulted_tokenstring
availabilityobject
Show availability properties
start_atstring
finish_atany
trial_periodobject
Show trial_period properties
billing_cyclesinteger
amountobject
Show amount properties
valuenumber
currencystring
metadataany
plan_idstring

Only present when the subscription is linked to a plan.

plan_assigned_atstring

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_idstring

Only present when this subscription was created by a plan change (switching an existing subscription to a different plan).

current_phasestring

Only present on plan-linked subscriptions.

billing_phasesobject[]

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.

Show billing_phases properties
orderinteger
typestring

Always TRIAL — the terminal REGULAR phase is never in this array.

namestring
amountobject
Show amount properties
currencystring
valuenumber
frequencyobject
Show frequency properties
typestring
valueinteger
start_cycleinteger
end_cycleinteger
subscription_agreement_idstring
created_atstring
updated_atstring

400

Request
curl -X POST "https://api-sandbox.whitelabel.com/v1/subscriptions" \
  -H "Content-Type: application/json" \
  -H "x-idempotency-key: <x-idempotency-key>" \
  -H "public-api-key: <public-api-key>" \
  -H "private-secret-key: <private-secret-key>" \
  -d '{
  "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"
}'
Response
{
  "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"
}