> Markdown versions of all pages of this connector library are available by appending `.md` to the page URL. For the full index of connectors, see [llms.txt](https://connectors.appmixer.com/llms.txt).

# appmixer.stripe.core.CreateSubscription

- Component: `appmixer.stripe.core.CreateSubscription`
- Kind: Action
- Version: 1.0.0
- Visibility: Public
- Connector: [appmixer.stripe 3.1.0](https://connectors.appmixer.com/connector/appmixer.stripe/3.1.0.md)
- Component page: <https://connectors.appmixer.com/connector/appmixer.stripe/3.1.0/component/appmixer.stripe.core.CreateSubscription>

Creates a subscription for a customer from one or more recurring prices. Without a trial or a default payment method, the first invoice may leave the subscription incomplete until it is paid.

## Input ports

### Port `in`

| Field | Type | Description |
| --- | --- | --- |
| Customer ID (`customer`) | text | The ID of the customer to subscribe, e.g. cus_NffrFeUfNV2Hib. |
| Line Items (`items`) | expression | Up to 20 recurring prices to subscribe the customer to, each with a quantity. |
| Trial Period Days (`trialPeriodDays`) | number | Number of trial days before the customer is charged for the first time. |
| Default Payment Method ID (`defaultPaymentMethod`) | text | ID of a payment method attached to the customer, e.g. pm_1MqLiJLkdIwHu7ixUEgbFdYF. If empty, the customer's default payment method is used. |
| Collection Method (`collectionMethod`) | select | Charge the default payment method automatically, or email the customer an invoice to pay. |
| Days Until Due (`daysUntilDue`) | number | Number of days the customer has to pay each invoice. Required when the collection method is Send Invoice. |
| Description (`description`) | text | A description of the subscription shown to the customer (up to 500 characters). |
| Metadata (`metadata`) | key-value | Optional key-value pairs to store on the object, e.g. an order ID from your system. |

## Output ports

### Port `out`

| Field | Type | Description |
| --- | --- | --- |
| Subscription ID (`id`) | string | - |
| Object (`object`) | string | - |
| Status (`status`) | string | - |
| Customer ID (`customer`) | string | - |
| Collection Method (`collection_method`) | string | - |
| Currency (`currency`) | string | - |
| Created (Unix Timestamp) (`created`) | integer | - |
| Start Date (Unix Timestamp) (`start_date`) | integer | - |
| Trial Start (Unix Timestamp) (`trial_start`) | integer,null | - |
| Trial End (Unix Timestamp) (`trial_end`) | integer,null | - |
| Cancel At Period End (`cancel_at_period_end`) | boolean | - |
| Days Until Due (`days_until_due`) | integer,null | - |
| Default Payment Method ID (`default_payment_method`) | string,null | - |
| Latest Invoice ID (`latest_invoice`) | string,null | - |
| Description (`description`) | string,null | - |
| Live Mode (`livemode`) | boolean | - |
| Metadata (`metadata`) | object | - |
| Items (`items`) | object | - |

## Full metadata (component.json)

```json
{
  "name": "appmixer.stripe.core.CreateSubscription",
  "description": "Creates a subscription for a customer from one or more recurring prices. Without a trial or a default payment method, the first invoice may leave the subscription incomplete until it is paid.",
  "author": "Appmixer <info@appmixer.com>",
  "version": "1.0.0",
  "auth": {
    "service": "appmixer:stripe"
  },
  "quota": {
    "manager": "appmixer:stripe",
    "resources": "requests"
  },
  "inPorts": [
    {
      "name": "in",
      "schema": {
        "type": "object",
        "properties": {
          "customer": {
            "type": "string"
          },
          "items": {
            "type": "object"
          },
          "trialPeriodDays": {
            "type": "integer",
            "minimum": 0
          },
          "defaultPaymentMethod": {
            "type": "string"
          },
          "collectionMethod": {
            "type": "string",
            "enum": [
              "charge_automatically",
              "send_invoice"
            ]
          },
          "daysUntilDue": {
            "type": "integer",
            "minimum": 0
          },
          "description": {
            "type": "string"
          },
          "metadata": {
            "type": "string"
          }
        },
        "required": [
          "customer",
          "items"
        ]
      },
      "inspector": {
        "inputs": {
          "customer": {
            "type": "text",
            "label": "Customer ID",
            "index": 1,
            "tooltip": "The ID of the customer to subscribe, e.g. cus_NffrFeUfNV2Hib."
          },
          "items": {
            "type": "expression",
            "label": "Line Items",
            "index": 2,
            "tooltip": "Up to 20 recurring prices to subscribe the customer to, each with a quantity.",
            "levels": [
              "AND"
            ],
            "fields": {
              "price": {
                "type": "text",
                "label": "Price ID",
                "index": 1,
                "tooltip": "The ID of a Stripe Price, e.g. price_1MoBy5LkdIwHu7ixZhnattbh."
              },
              "quantity": {
                "type": "number",
                "label": "Quantity",
                "index": 2,
                "defaultValue": 1,
                "tooltip": "The quantity of the price. Defaults to 1."
              }
            }
          },
          "trialPeriodDays": {
            "type": "number",
            "label": "Trial Period Days",
            "index": 3,
            "tooltip": "Number of trial days before the customer is charged for the first time."
          },
          "defaultPaymentMethod": {
            "type": "text",
            "label": "Default Payment Method ID",
            "index": 4,
            "tooltip": "ID of a payment method attached to the customer, e.g. pm_1MqLiJLkdIwHu7ixUEgbFdYF. If empty, the customer's default payment method is used."
          },
          "collectionMethod": {
            "type": "select",
            "label": "Collection Method",
            "index": 5,
            "defaultValue": "charge_automatically",
            "tooltip": "Charge the default payment method automatically, or email the customer an invoice to pay.",
            "options": [
              {
                "label": "Charge Automatically",
                "value": "charge_automatically"
              },
              {
                "label": "Send Invoice",
                "value": "send_invoice"
              }
            ]
          },
          "daysUntilDue": {
            "type": "number",
            "label": "Days Until Due",
            "index": 6,
            "tooltip": "Number of days the customer has to pay each invoice. Required when the collection method is Send Invoice."
          },
          "description": {
            "type": "text",
            "label": "Description",
            "index": 7,
            "tooltip": "A description of the subscription shown to the customer (up to 500 characters)."
          },
          "metadata": {
            "type": "key-value",
            "label": "Metadata",
            "index": 8,
            "tooltip": "Optional key-value pairs to store on the object, e.g. an order ID from your system."
          }
        }
      }
    }
  ],
  "outPorts": [
    {
      "name": "out",
      "schema": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "title": "Subscription ID",
            "example": "sub_1MowQVLkdIwHu7ixeRlqHVzs"
          },
          "object": {
            "type": "string",
            "title": "Object",
            "example": "subscription"
          },
          "status": {
            "type": "string",
            "title": "Status",
            "example": "trialing"
          },
          "customer": {
            "type": "string",
            "title": "Customer ID",
            "example": "cus_Na6dX7aXxi11N4"
          },
          "collection_method": {
            "type": "string",
            "title": "Collection Method",
            "example": "charge_automatically"
          },
          "currency": {
            "type": "string",
            "title": "Currency",
            "example": "usd"
          },
          "created": {
            "type": "integer",
            "title": "Created (Unix Timestamp)",
            "example": 1680893993
          },
          "start_date": {
            "type": "integer",
            "title": "Start Date (Unix Timestamp)",
            "example": 1680893993
          },
          "trial_start": {
            "type": [
              "integer",
              "null"
            ],
            "title": "Trial Start (Unix Timestamp)",
            "example": 1680893993
          },
          "trial_end": {
            "type": [
              "integer",
              "null"
            ],
            "title": "Trial End (Unix Timestamp)",
            "example": 1681498793
          },
          "cancel_at_period_end": {
            "type": "boolean",
            "title": "Cancel At Period End",
            "example": false
          },
          "days_until_due": {
            "type": [
              "integer",
              "null"
            ],
            "title": "Days Until Due",
            "example": null
          },
          "default_payment_method": {
            "type": [
              "string",
              "null"
            ],
            "title": "Default Payment Method ID",
            "example": "pm_1MqLiJLkdIwHu7ixUEgbFdYF"
          },
          "latest_invoice": {
            "type": [
              "string",
              "null"
            ],
            "title": "Latest Invoice ID",
            "example": "in_1MowQWLkdIwHu7ixuzkSPfKd"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "title": "Description",
            "example": "Gold plan"
          },
          "livemode": {
            "type": "boolean",
            "title": "Live Mode",
            "example": false
          },
          "metadata": {
            "type": "object",
            "title": "Metadata",
            "example": {
              "orderId": "1001"
            }
          },
          "items": {
            "type": "object",
            "title": "Items",
            "properties": {
              "data": {
                "type": "array",
                "title": "Items.Data",
                "items": {
                  "type": "object"
                },
                "example": [
                  {
                    "id": "si_Na6dzxczY5fwHx",
                    "object": "subscription_item",
                    "price": {
                      "id": "price_1MowQULkdIwHu7ixraBm864M",
                      "unit_amount": 1000,
                      "currency": "usd"
                    },
                    "quantity": 1
                  }
                ]
              }
            }
          }
        }
      }
    }
  ],
  "icon": "(data URI omitted)"
}
```
