> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Create Subscription

> Enrolls a customer in a subscription.

`square.createSubscription` enrolls a customer in a subscription.

## Example

```ts automations/square-create-subscription.automation.ts theme={null}
import { automation, onDashboardRun } from "automate.ax"
import { square } from "automate.ax/square"

export default automation("Create Square Subscription", () => {
  onDashboardRun({ title: "Create Square Subscription" })

  square.createSubscription({
    idempotencyKey: "8193148c-9586-11e6-99f9-28cfe92138cf",
    locationId: "S8GWD5R9QB376",
    planVariationId: "6JHXF3B2CW3YKHDV4XEM674H",
    customerId: "CHFGVKYY8RSV93M5KCYTG4PN0G",
    startDate: "2023-06-20",
    cardId: "ccof:qy5x8hHGYsgLrp4Q4GB",
    timezone: "America/Los_Angeles",
    source: {
      name: "My Application",
    },
    phases: [
      {
        ordinal: BigInt("0"),
        orderTemplateId: "U2NaowWxzXwpsZU697x7ZHOAnCNZY",
      },
    ],
  })
})
```

## Inputs

Every input accepts a compatible signal. It requires `CUSTOMERS_READ` and `INVOICES_WRITE` and `ITEMS_READ` and `ORDERS_WRITE` and `PAYMENTS_WRITE` and `SUBSCRIPTIONS_WRITE`.

| Field                      | Type                        | Required | Default               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| -------------------------- | --------------------------- | -------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `idempotencyKey`           | `string`                    | No       | —                     | A unique string that identifies this `CreateSubscription` request. If you do not provide a unique string (or provide an empty string as the value), the endpoint treats each request as independent. For more information, see [Idempotency keys](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).                                                                                                                                                                                                                                                                                                                                               |
| `locationId`               | `string`                    | Yes      | —                     | The ID of the location the subscription is associated with.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `planVariationId`          | `string`                    | No       | —                     | The ID of the [subscription plan variation](https://developer.squareup.com/docs/subscriptions-api/plans-and-variations#plan-variations) created using the Catalog API.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `customerId`               | `string`                    | Yes      | —                     | The ID of the customer subscribing to the subscription plan variation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `startDate`                | `string`                    | No       | —                     | The `YYYY-MM-DD`-formatted date to start the subscription. If it is unspecified, the subscription starts immediately.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `canceledDate`             | `string`                    | No       | —                     | The `YYYY-MM-DD`-formatted date when the newly created subscription is scheduled for cancellation. This date overrides the cancellation date set in the plan variation configuration. If the cancellation date is earlier than the end date of a subscription cycle, the subscription stops at the canceled date and the subscriber is sent a prorated invoice at the beginning of the canceled cycle. When the subscription plan of the newly created subscription has a fixed number of cycles and the `canceled_date` occurs before the subscription plan completes, the specified `canceled_date` sets the date when the subscription stops through the end of the last cycle. |
| `taxPercentage`            | `string`                    | No       | —                     | The tax to add when billing the subscription. The percentage is expressed in decimal form, using a `'.'` as the decimal separator and without a `'%'` sign. For example, a value of 7.5 corresponds to 7.5%.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `priceOverrideMoney`       | `Square.Money`              | No       | —                     | A custom price which overrides the cost of a subscription plan variation with `STATIC` pricing. This field does not affect itemized subscriptions with `RELATIVE` pricing. Instead, you should edit the Subscription's [order template](https://developer.squareup.com/docs/subscriptions-api/manage-subscriptions#phases-and-order-templates).                                                                                                                                                                                                                                                                                                                                    |
| `cardId`                   | `string`                    | No       | —                     | The ID of the subscriber's card to charge. If it is not specified, the subscriber receives an invoice via email with a link to pay for their subscription.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `timezone`                 | `string`                    | No       | the location timezone | The timezone that is used in date calculations for the subscription. If unset, defaults to the location timezone. If a timezone is not configured for the location, defaults to `America/New_York`. Format: the IANA Timezone Database identifier for the location timezone. For a list of time zones, see [List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).                                                                                                                                                                                                                                                                         |
| `source`                   | `Square.SubscriptionSource` | No       | —                     | The origination details of the subscription.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `monthlyBillingAnchorDate` | `number`                    | No       | —                     | The day-of-the-month to change the billing date to.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `phases`                   | `Square.Phase[]`            | No       | —                     | array of phases for this subscription                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |

Use the official [CreateSubscription reference](https://developer.squareup.com/reference/square/subscriptions-api/create-subscription) for provider field semantics and limits.

## Output

Returns the official `Square.CreateSubscriptionResponse` response as a codec-safe object. Square integer money amounts remain `bigint` values.
