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

# Swap Plan

> Schedules a `SWAP_PLAN` action to swap a subscription plan variation in an existing subscription.

`square.swapPlan` schedules a `SWAP_PLAN` action to swap a subscription plan variation in an existing subscription.

## Example

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

export default automation("Swap Square Plan", () => {
  onDashboardRun({ title: "Swap Square Plan" })

  square.swapPlan({
    subscriptionId: "subscription_id",
    newPlanVariationId: "FQ7CDXXWSLUJRPM3GFJSJGZ7",
    phases: [
      {
        ordinal: BigInt("0"),
        orderTemplateId: "uhhnjH9osVv3shUADwaC0b3hNxQZY",
      },
    ],
  })
})
```

## 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                                                                 |
| -------------------- | ----------------------------- | -------- | ------- | --------------------------------------------------------------------------- |
| `subscriptionId`     | `string`                      | Yes      | —       | The ID of the subscription to swap the subscription plan for.               |
| `newPlanVariationId` | `string \| null`              | No       | —       | The ID of the new subscription plan variation. This field is required.      |
| `phases`             | `Square.PhaseInput[] \| null` | No       | —       | A list of PhaseInputs, to pass phase-specific information used in the swap. |

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

## Output

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