code: import stripe
  stripe.api_key = "sk_test_your_key"
  
  stripe.Subscription.create(
    customer="cus_8TEMHVY5moxIPI",
    items=[
      {"price": "price_1LSTX02eZvKYlo2CrKMGl6Dy"},
    ],
  )
  '''Response {
    "id": "sub_1JbiLB2eZvKYlo2CNHnqfMzf",
    "object": "subscription",
    "application": null,
    "application_fee_percent": null,
    "automatic_tax": {
      "enabled": false
    },
    "billing_cycle_anchor": 1633337949,
    "billing_thresholds": null,
    "cancel_at": null,
    "cancel_at_period_end": false,
    "canceled_at": null,
    "collection_method": "charge_automatically",
    "created": 1632128349,
    "currency": "usd",
    "current_period_end": 1660553949,
    "current_period_start": 1658739549,
    "customer": "cus_8TEMHVY5moxIPI",
    "days_until_due": null,
    "default_payment_method": "pm_1JbiL92eZvKYlo2CuiUB2nL1",
    "default_source": null,
    "default_tax_rates": [],
    "description": null,
    "discount": null,
    "ended_at": null,
    "items": {
      "object": "list",
      "data": [
        {
          "id": "si_KGEo6oKuLzcuYw",
          "object": "subscription_item",
          "billing_thresholds": null,
          "created": 1632128350,
          "metadata": {},
          "price": {
            "id": "15",
            "object": "price",
            "active": true,
            "billing_scheme": "per_unit",
            "created": 1386685951,
            "currency": "usd",
            "custom_unit_amount": null,
            "livemode": false,
            "lookup_key": null,
            "metadata": {
              "charset": "utf-8",
              "content": "15"
            },
            "nickname": null,
            "product": "prod_BTdpcRLIUTfsFR",
            "recurring": {
              "aggregate_usage": null,
              "interval": "week",
              "interval_count": 3,
              "usage_type": "licensed"
            },
            "tax_behavior": "unspecified",
            "tiers_mode": null,
            "transform_quantity": null,
            "type": "recurring",
            "unit_amount": 444,
            "unit_amount_decimal": "444"
          },
          "quantity": 1,
          "subscription": "sub_1JbiLB2eZvKYlo2CNHnqfMzf",
          "tax_rates": []
        }
      ],
      "has_more": false,
      "url": "/v1/subscription_items?subscription=sub_1JbiLB2eZvKYlo2CNHnqfMzf"
    },
    "latest_invoice": "in_1LPN8U2eZvKYlo2C2h002pSa",
    "livemode": false,
    "metadata": {},
    "next_pending_invoice_item_invoice": null,
    "pause_collection": null,
    "payment_settings": {
      "payment_method_options": null,
      "payment_method_types": null,
      "save_default_payment_method": null
    },
    "pending_invoice_item_interval": null,
    "pending_setup_intent": null,
    "pending_update": null,
    "schedule": null,
    "start_date": 1632128349,
    "status": "active",
    "test_clock": null,
    "transfer_data": null,
    "trial_end": 1633337949,
    "trial_start": 1632128349
  }'''
nl: Create a subscriptionCreates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions.
  When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request.
  The payment_behavior parameter determines the exact behavior of the initial payment.
  To start subscriptions where the first invoice always begins in a draft status, use subscription schedules instead.
  Schedules provide the flexibility to model more complex billing configurations that change over time.Parameters customer required The identifier of the customer to subscribe. items required A list of up to 20 subscription items, each with an attached price.Show child parameters cancel_at_period_end optional Boolean indicating whether this subscription should cancel at the end of the current period. currency optional preview feature Three-letter ISO currency code, in lowercase. Must be a supported currency. default_payment_method optional ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over default_source. If neither are set, invoices will use the customer’s invoice_settings.default_payment_method or default_source. description optional The subscription’s description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces. metadata optional dictionary 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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to metadata. payment_behavior optional enum Use allow_incomplete to create subscriptions with status=incomplete if the first invoice cannot be paid. Creating subscriptions with this status allows you to manage scenarios where additional user actions are needed to pay a subscription’s invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the SCA Migration Guide for Billing to learn more. This is the default behavior.
  Use default_incomplete to create Subscriptions with status=incomplete when the first invoice requires payment, otherwise start as active. Subscriptions transition to status=active when successfully confirming the payment intent on the first invoice. This allows simpler management of scenarios where additional user actions are needed to pay a subscription’s invoice. Such as failed payments, SCA regulation, or collecting a mandate for a bank debit payment method. If the payment intent is not confirmed within 23 hours subscriptions transition to status=incomplete_expired, which is a terminal state.
  Use error_if_incomplete if you want Stripe to return an HTTP 402 status code if a subscription’s first invoice cannot be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further user action is needed, this parameter does not create a subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the changelog to learn more.
  pending_if_incomplete is only used with updates and cannot be passed when creating a subscription.Possible enum valuesallow_incomplete error_if_incomplete pending_if_incomplete default_incomplete More parametersExpand all  add_invoice_items optional array of hashes   application_fee_percent optional Connect only   automatic_tax optional dictionary   backdate_start_date optional   billing_cycle_anchor optional   billing_thresholds optional dictionary   cancel_at optional   collection_method optional   coupon optional   days_until_due optional   default_source optional   default_tax_rates optional   off_session optional   payment_settings optional dictionary   pending_invoice_item_interval optional dictionary   promotion_code optional   proration_behavior optional enum   transfer_data optional dictionary Connect only   trial_end optional   trial_from_plan optional   trial_period_days optional ReturnsThe newly created Subscription object, if the call succeeded. If the attempted charge fails, the subscription is created in an incomplete status