# Update Subscription — SureCart

> Update an existing subscription. See the documentation

- Key: `surecart-update-subscription`
- Type: Action (Write)
- Version: 0.0.3
- App: SureCart (`surecart`) — https://pipedream.com/apps/surecart.md
- This page (HTML): https://pipedream.com/apps/surecart/actions/update-subscription
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/surecart/actions/update-subscription/update-subscription.mjs

## Description

Update an existing subscription. [See the documentation](https://developer.surecart.com/api-reference/subscriptions/update)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `subscriptionId` | `string` | Yes | The unique identifier of the subscription. Use List Subscriptions to retrieve a list of available subscriptions. |
| `refreshPriceVersion` | `boolean` | No | Update the subscription to use the most recent version of its price. |
| `skipProductGroupValidation` | `boolean` | No | Allow price updates regardless of product group restrictions. |
| `skipProration` | `boolean` | No | Prevent proration charges on the next billing period. |
| `updateBehavior` | `string` | No | When to apply the update. Defaults to the account subscription protocol setting. |
| `price` | `string` | No | UUID of the new price to switch to. Example: price_abc123 |
| `customer` | `string` | Yes | The unique identifier of the customer. Use List Customers to retrieve a list of available customers. |
| `paymentMethod` | `string` | No | UUID of the new payment method. Example: pm_abc123 |
| `cancelAtPeriodEnd` | `boolean` | No | Set to true to cancel the subscription at the end of the current billing period. |
| `trialEndAt` | `integer` | No | Unix timestamp to end the trial early or extend it. Example: 1710000000 |
| `quantity` | `integer` | No | New subscription quantity. Example: 3 |
| `adHocAmount` | `integer` | No | Custom billing amount in cents for ad hoc prices. Example: 9900 |
| `discount` | `object` | No | New coupon or promotion code. Example: { "coupon": "coup_abc123" } |
| `variant` | `string` | No | UUID of the new product variant. Example: var_abc123 |
| `shippingMethod` | `string` | No | UUID of the shipping method. Example: sm_abc123 |
| `taxEnabled` | `boolean` | No | Enable or disable tax collection for this subscription. |
| `restoreAt` | `integer` | No | Unix timestamp for automatic subscription restoration after cancellation. Example: 1720000000 |
| `metadata` | `object` | No | Updated key-value metadata. Example: { "plan": "enterprise" } |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "surecart",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "surecart-update-subscription",
  arguments: {
    subscriptionId: "Subscription ID",
    refreshPriceVersion: true,
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "surecart-update-subscription",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    surecart: { authProvisionId: "apn_xxxxxxx" },
    subscriptionId: "Subscription ID",
    refreshPriceVersion: true,
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "surecart-update-subscription",
    "configured_props": {
      "surecart": { "authProvisionId": "apn_xxxxxxx" },
      "subscriptionId": "Subscription ID",
      "refreshPriceVersion": true
    }
  }'
```

---

- App: https://pipedream.com/apps/surecart.md · All apps: https://pipedream.com/apps
