# Create a Subscription

Create a Subscription resource to charge a Payment Instrument regularly. 

If there is no trial period, the subscription will create a Transfer shortly after creation (within 60 minutes).

The following options are available when creating a subscription.

### Adding a trial period

You can create a subscription with a trial period by providing trial_details in the request body. After creating a subscription, a Transfer will occur after the trial period has elapsed. The first_charge_at property in the response determines when the transfer will take place.

### Adding a discount phase

To apply a discount, include discount_phase_details in the request body. Set discount_phase_details.amount as the discounted price and discount_phase_details.billing_interval_count to specify how many billing intervals the discount applies. After this period, the customer is charged the full amount from the Subscription.

### Using a Subscription Plan

Think of a Subscription Plan as a template for the Subscription resource. When creating a subscription, you can use a Subscription Plan by providing a subscription_plan_id. Doing so lets you base a subscription on existing values for amount, billing_interval, and more.

### Future Subscription

Schedule a subscription by setting start_subscription_at to a future timestamp. The response will show subscription_phase as NONE and state as NOT_STARTED, indicating it has not started. This applies to both subscriptions with or without a subscription plan.

### Fixed-Length Subscription

You can set a subscription to expire by specifying the total_billing_intervals, which indicates the number of recurring billing cycles in months or weeks. You can set subscriptions created from subscription plans to expire.

### Card Validation with $0 Authorization

When creating a subscription using a card-type Payment Instrument, Finix performs a $0 Authorization to validate the card. This check confirms that the card is active and verifies the billing address and security code (AVS and CVV).

If the card fails validation, the API returns a 422 Unprocessable Entity error and the subscription is not created. This protects against invalid or risky cards, helping reduce failed payments and fraud.

Endpoint: POST /subscriptions
Version: 2022-02-01
Security: BasicAuth

## Header parameters:

  - `Finix-Version` (string)
    Specify the API version of your request. For more details, see Versioning.
    Example: "2022-02-01"

  - `Content-Type` (string)
    The data type being sent in the request body must be application/json.
    Example: "application/json"

## Response 201 fields (application/json):

  - `id` (string)
    The ID of the resource.

  - `created_at` (string)
    Timestamp of when the object was created.

  - `updated_at` (string)
    Timestamp of when the object was last updated.

  - `application_id` (string)
    The ID of the Application associated with the Subscription.

  - `first_charge_at` (string)
    Timestamp when the first [Transfer](#Transfers) will occur.

  - `next_billing_date` (object)
    Details when the next [Transfer](#Transfers) will occur.

  - `next_billing_date.year` (integer)
    The year the next Transfer will occur.

  - `next_billing_date.month` (integer)
    The month the next Transfer will occur.

  - `next_billing_date.day` (integer)
    The day the next Transfer will occur.

  - `amount` (integer)
    The total amount that will be debited in cents (e.g. 100 cents to debit $1.00).
    Example: 5000

  - `buyer_details` (object)
    An object containing details about the buyer.

  - `buyer_details.identity_id` (string)
    The [identity ID](/api/identities) of the buyer.

  - `buyer_details.instrument_id` (any)
    The ID of the [Payment Instrument](/api/payment-instruments) from which the subscription payments get debited.

  - `buyer_details.requested_delivery_methods` (array)
    A list of requested delivery methods. Each method specifies 
the type of delivery and the destination(s) where the receipt should be sent.

  - `buyer_details.requested_delivery_methods.type` (string, required)
    The method of receipt delivery.
    Enum: "EMAIL", "SMS", "PRINT"

  - `buyer_details.requested_delivery_methods.destinations` (array, required)
    A list of destination addresses or identifiers where the receipt should be sent.

  - `buyer_details.shipping_address` (object,null)

  - `buyer_details.shipping_address.line1` (string,null, required)
    First line of the address (max 35 characters).

  - `buyer_details.shipping_address.line2` (string,null)
    Second line of the address (max 35 characters).

  - `buyer_details.shipping_address.city` (string,null, required)
    City (max 20 characters).

  - `buyer_details.shipping_address.region` (string,null, required)
    2-letter State code.

  - `buyer_details.shipping_address.postal_code` (string,null, required)
    Zip or Postal code (max 7 characters).

  - `buyer_details.shipping_address.country` (string,null, required)
    Enum: "ABW", "AFG", "AGO", "AIA", "ALA", "ALB", "AND", "ARE", "ARG", "ARM", "ASM", "ATA", "ATF", "ATG", "AUS", "AUT", "AZE", "BDI", "BEL", "BEN", "BES", "BFA", "BGD", "BGR", "BHR", "BHS", "BIH", "BLM", "BLR", "BLZ", "BMU", "BOL", "BRA", "BRB", "BRN", "BTN", "BVT", "BWA", "CAF", "CAN", "CCK", "CHE", "CHL", "CHN", "CIV", "CMR", "COD", "COG", "COK", "COL", "COM", "CPV", "CRI", "CUB", "CUW", "CXR", "CYM", "CYP", "CZE", "DEU", "DJI", "DMA", "DNK", "DOM", "DZA", "ECU", "EGY", "ERI", "ESH", "ESP", "EST", "ETH", "FIN", "FJI", "FLK", "FRA", "FRO", "FSM", "GAB", "GBR", "GEO", "GGY", "GHA", "GIB", "GIN", "GLP", "GMB", "GNB", "GNQ", "GRC", "GRD", "GRL", "GTM", "GUF", "GUM", "GUY", "HKG", "HMD", "HND", "HRV", "HTI", "HUN", "IDN", "IMN", "IND", "IOT", "IRL", "IRN", "IRQ", "ISL", "ISR", "ITA", "JAM", "JEY", "JOR", "JPN", "KAZ", "KEN", "KGZ", "KHM", "KIR", "KNA", "KOR", "KWT", "LAO", "LBN", "LBR", "LBY", "LCA", "LIE", "LKA", "LSO", "LTU", "LUX", "LVA", "MAC", "MAF", "MAR", "MCO", "MDA", "MDG", "MDV", "MEX", "MHL", "MKD", "MLI", "MLT", "MMR", "MNE", "MNG", "MNP", "MRT", "MSR", "MTQ", "MUS", "MWI", "MYS", "MYT", "NAM", "NCL", "NER", "NFK", "NGA", "NIC", "NIU", "NLD", "NOR", "NPL", "NRU", "NZL", "OMN", "PAK", "PAN", "PCN", "PER", "PHL", "PLW", "PNG", "POL", "PRI", "PRK", "PRT", "PRY", "PSE", "PYF", "QAT", "REU", "ROU", "RUS", "RWA", "SAU", "SDN", "SEN", "SGP", "SGS", "SHN", "SJM", "SLB", "SLE", "SLV", "SMR", "SOM", "SPM", "SRB", "SSD", "STP", "SUR", "SVK", "SVN", "SWE", "SWZ", "SXM", "SYC", "SYR", "TCA", "TCD", "TGO", "THA", "TJK", "TKL", "TKM", "TLS", "TON", "TTO", "TUN", "TUR", "TUV", "TWN", "TZA", "UGA", "UKR", "UMI", "URY", "USA", "UZB", "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF", "WSM", "XKX", "YEM", "ZAF", "ZMB", "ZWE"

  - `currency` (string)
    ISO 4217 3-letter currency code.
    Enum: "USD", "CAD"

  - `linked_to` (string)
    The ID of the [Merchant](#Merchants) resource that you wish to link to the Subscription (i.e., the merchant that the subscription belongs to).

At this time, only approved merchants with one of the following processors are valid: 

- DUMMY_V1
- FINIX_V1

  - `linked_type` (string)
    The type of the resource that is specified in the linked_to field.
    Enum: "MERCHANT"

  - `nickname` (string)
    A human-readable name for the resource.

  - `billing_interval` (string)
    How often the buyer is billed. The possible billing intervals are as follows:

- DAILY: every day
- WEEKLY: every week
- BIWEEKLY: every 2 weeks
- MONTHLY: every month
- BIMONTHLY: every 2 months
- QUARTERLY: each quarter
- SEMIYEARLY: twice a year
- YEARLY: every year
- BIYEARLY: every 2 years
- TRIYEARLY: every 3 years
    Enum: "DAILY", "WEEKLY", "BIWEEKLY", "BIWEEKLY", "MONTHLY", "BIMONTHLY", "BIMONTHLY", "QUARTERLY", "SEMIYEARLY", "SEMIYEARLY", "YEARLY", "BIYEARLY", "TRIYEARLY"

  - `subscription_details` (object)
    An object containing subscription details.

  - `subscription_details.collection_method` (string, required)
    The method by which subscription payments are collected. Currently, automatic billing of the Payment Instrument is the only available method.
    Enum: "BILL_AUTOMATICALLY"

  - `subscription_details.send_invoice` (boolean)
    Whether to send the user an invoice.

  - `subscription_details.send_receipt` (boolean)
    Whether to send the user a receipt.

  - `subscription_details.trial_details` (object)
    Object containing trial details.

  - `subscription_details.trial_details.interval_type` (string)
    The unit of time for the trial period.
    Enum: "DAY", "WEEK", "MONTH", "YEAR"

  - `subscription_details.trial_details.interval_count` (integer)
    The number of intervals of interval_type used to describe the duration of the trial.

  - `subscription_details.trial_details.trial_started_at` (string,null)
    A timestamp indicating when the trial period began.

  - `subscription_details.trial_details.trial_expected_start_at` (string)
    A timestamp indicating when the trial period is expected to start.

  - `subscription_details.trial_details.trial_expected_end_at` (string)
    A timestamp indicating when the trial period ends.

  - `subscription_details.discount_phase_details` (object)
    Object containing discount phase details.

  - `subscription_details.discount_phase_details.amount` (integer)
    The discounted amount (in cents) that the buyer is charged during the discount phase.

  - `subscription_details.discount_phase_details.billing_interval_count` (integer)
    The number of billing intervals the discount applies. After this period, the buyer is charged the full amount from the Subscription.

  - `subscription_details.discount_phase_details.discount_phase_started_at` (string,null)
    A timestamp indicating when the discount phase began.

  - `subscription_details.discount_phase_details.discount_phase_expected_start_at` (string)
    A timestamp indicating when the discount phase is expected to start.

  - `subscription_details.discount_phase_details.discount_phase_expected_end_at` (string)
    A timestamp indicating when the discount phase is expected to end.

  - `subscription_details.notification_preferences` (object)
    Object containing notification preferences.

  - `subscription_details.notification_preferences.send_confirmation` (boolean)
    Whether to send a confirmation email to the user.

  - `subscription_link_id` (string,null)
    The ID of the Subscription Link that created the Subscription.

  - `subscription_phase` (string)
    Indicates the period within a subscription where specific rules apply.  

- EVERGREEN - The buyer is billed continuously for the subscription until the subscription is canceled.  
- DISCOUNT - The buyer receives a discounted price for a limited billing interval, after which the customer is charged the full subscription amount.
- FIXED state - Applicable to fixed-length subscriptions.
- NONE - Indicates that when the start_subscription_at timestamp is set during subscription creation, the subscription is not yet in any phase, and billing has not started.
- TRIAL - The period during which the buyer is not billed; after this phase, the buyer will begin being billed.
    Enum: "EVERGREEN", "DISCOUNT", "FIXED", "NONE", "TRIAL"

  - `state` (string)
    The state of the Subscription. 

- The NOT_STARTED state occurs when the subscription has not yet started, typically indicated by a start_subscription_at timestamp set during creation.
- A subscription in the PAST_DUE state is unpaid but has not yet been canceled.
    Enum: "ACTIVE", "CANCELED", "EXPIRED", "NOT_STARTED", "PAST_DUE"

  - `subscription_plan_id` (string)
    The ID of the Subscription Plan from which to create the Subscription.

  - `start_subscription_at` (string)
    Indicates that the subscription is scheduled to begin in the future. The timestamp specifies the exact start date for subscription billing.

  - `total_billing_intervals` (integer)
    The total number of billing intervals for the Subscription. This represents the total count of recurring billing cycles, such as months or weeks, depending on the billing frequency.

  - `expires_at` (string)
    The date-time that the Subscription expires if total_billing_intervals is set for the Subscription.

  - `canceled_via` (string)
    If the subscription was canceled, this field shows how the cancellation was initiated.

Possible values:

- MERCHANT - The customer (merchant) canceled the subscription themselves. The linked_to field indicates the related Merchant.
- AUTOMATED_OVERDUE - The subscription was canceled by the overdue system.
- SUPPORT - The subscription was canceled by Finix Support.
    Enum: "MERCHANT", "AUTOMATED_OVERDUE", "SUPPORT"

  - `tags` (object,null)
    Include up to 50 key: value pairs to annotate requests with custom metadata.
- Maximum character length for individual keys is 40.
- Maximum character length for individual values is 500.
(For example, order_number: 25, item_type: produce, department: sales)

  - `_links` (object)
    An object containing link(s) relevant to the request. You can store these links for follow-up requests.

  - `_links.self` (object)
    Link to the resource that was used in the request.

  - `_links.self.href` (string)

## Response 400 fields (application/json):

  - `total` (integer, required)
    Total number of errors returned.

  - `_embedded` (object, required)
    Container for embedded error objects.

  - `_embedded.errors` (array)
    List of individual error objects.

  - `_embedded.errors.code` (string)
    The error code. The UNKNOWN error code is returned for a 401 Unauthorized or 403 Forbidden request.

  - `_embedded.errors.logref` (string)
    A log reference identifier for the error, useful for debugging and support purposes.

  - `_embedded.errors.message` (string)
    A human-friendly error message.

  - `_embedded.errors._links` (object)
    Links related to this error.

  - `_embedded.errors._links.self` (object)
    Link to the resource related to the error.

  - `_embedded.errors._links.self.href` (string)
    URL of the related resource.

## Response 401 fields (application/json):

  - `total` (integer, required)
    Total number of errors returned.

  - `_embedded` (object, required)
    Container for embedded error objects.

  - `_embedded.errors` (array)
    List of individual error objects.

  - `_embedded.errors.code` (string)
    The error code. The UNKNOWN error code is returned for a 401 Unauthorized or 403 Forbidden request.

  - `_embedded.errors.logref` (string)
    A log reference identifier for the error, useful for debugging and support purposes.

  - `_embedded.errors.message` (string)
    A human-friendly error message.

  - `_embedded.errors._links` (object)
    Links related to this error.

  - `_embedded.errors._links.self` (object)
    Link to the resource related to the error.

  - `_embedded.errors._links.self.href` (string)
    URL of the related resource.

## Response 403 fields (application/json):

  - `total` (integer, required)
    Total number of errors returned.

  - `_embedded` (object, required)
    Container for embedded error objects.

  - `_embedded.errors` (array)
    List of individual error objects.

  - `_embedded.errors.code` (string)
    The error code. The UNKNOWN error code is returned for a 401 Unauthorized or 403 Forbidden request.

  - `_embedded.errors.logref` (string)
    A log reference identifier for the error, useful for debugging and support purposes.

  - `_embedded.errors.message` (string)
    A human-friendly error message.

  - `_embedded.errors._links` (object)
    Links related to this error.

  - `_embedded.errors._links.self` (object)
    Link to the resource related to the error.

  - `_embedded.errors._links.self.href` (string)
    URL of the related resource.

## Response 406 fields (application/json):

  - `total` (integer, required)
    Total number of errors returned.

  - `_embedded` (object, required)
    Container for embedded error objects.

  - `_embedded.errors` (array)
    List of individual error objects.

  - `_embedded.errors.code` (string)
    The error code. The UNKNOWN error code is returned for a 401 Unauthorized or 403 Forbidden request.

  - `_embedded.errors.logref` (string)
    A log reference identifier for the error, useful for debugging and support purposes.

  - `_embedded.errors.message` (string)
    A human-friendly error message.

  - `_embedded.errors._links` (object)
    Links related to this error.

  - `_embedded.errors._links.self` (object)
    Link to the resource related to the error.

  - `_embedded.errors._links.self.href` (string)
    URL of the related resource.


