Skip to main content
Docs

cancelSubscriptionItem()

Warning

This API is experimental and subject to change while Clerk Billing is under Beta. To mitigate potential disruptions, we recommend pinning your SDK and clerk-js package versions.

Cancels a subscription item. Returns the updated CommerceSubscriptionItem.

function cancelSubscriptionItem(
  subscriptionItemId: string,
  params?: CancelSubscriptionItemParams,
): Promise<CommerceSubscriptionItem>
  • Name
    endNow?
    Type
    boolean
    Description

    If true, the subscription item will be canceled immediately. If false or omitted, it will be canceled at the end of the current billing period.

Note

Importing clerkClient varies based on your framework. Refer to the Backend SDK overview for usage details, including guidance on how to access the userId and other properties.

const response = await clerkClient.billing.cancelSubscriptionItem('subi_123', { endNow: true })

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint DELETE /commerce/subscription_items/{id}. See the BAPI reference for more information.

Feedback

What did you think of this content?

Last updated on