Skip to content
Join our SlackContact usGet started

Cancel Subscription

client.Subscriptions.Cancel(ctx, subscriptionID, body) (*SubscriptionResource, error)
post/subscriptions/{subscription_id}/cancel

Cancel Subscription

ParametersExpand Collapse
subscriptionID string
body SubscriptionCancelParams
CancelAtEndOfCycle param.Field[bool]optional

Whether to cancel the subscription at end of cycle.

const SubscriptionCancelParamsCancelAtEndOfCycleTrue SubscriptionCancelParamsCancelAtEndOfCycle = true
Reason param.Field[string]optional

The reason for cancelling the subscription.

ReturnsExpand Collapse
type SubscriptionResource struct{…}
ID string

The ID of the subscription.

CancelsAtEndOfCycle bool

Whether the subscription will be cancelled at the end of the current cycle.

CurrentPeriod SubscriptionResourceCurrentPeriod

The current period of the subscription if it is active.

End Time
formatdate-time
Start Time
formatdate-time
InclusiveEnd booloptional
InclusiveStart booloptional
CyclesNextAt Time

The date and time the next cycle of the subscription will start.

formatdate-time
EffectiveAt Time

The date and time the subscription became effective.

formatdate-time
Metadata map[string, string]
RateCardID string

The ID of the rate card of the subscription.

Status SubscriptionResourceStatus

The status of the subscription.

Accepts one of the following:
const SubscriptionResourceStatusActive SubscriptionResourceStatus = "active"
const SubscriptionResourceStatusCancelled SubscriptionResourceStatus = "cancelled"
const SubscriptionResourceStatusPaused SubscriptionResourceStatus = "paused"
SubjectID string

The ID of the subject that the subscription is for.

Cancel Subscription
package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/-go"
  "github.com/stainless-sdks/-go/option"
)

func main() {
  client := lark.NewClient(
    option.WithAPIKey("My API Key"),
  )
  subscriptionResource, err := client.Subscriptions.Cancel(
    context.TODO(),
    "subscription_id",
    lark.SubscriptionCancelParams{
      CancelAtEndOfCycle: true,
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", subscriptionResource.ID)
}
{
  "id": "rc_sub_PuLvkNSP3IBCvjayBD3TXNQ6",
  "cancels_at_end_of_cycle": false,
  "current_period": {
    "end": "2025-11-01T00:00:00Z",
    "start": "2025-10-01T00:00:00Z",
    "inclusive_end": false,
    "inclusive_start": true
  },
  "cycles_next_at": "2025-11-01T00:00:00Z",
  "effective_at": "2025-10-01T00:00:00Z",
  "metadata": {},
  "rate_card_id": "rc_jQK2n0wutCj6bBcAIrL6o07g",
  "status": "active",
  "subject_id": "subj_VyX6Q96h5avMho8O7QWlKeXE"
}
Returns Examples
{
  "id": "rc_sub_PuLvkNSP3IBCvjayBD3TXNQ6",
  "cancels_at_end_of_cycle": false,
  "current_period": {
    "end": "2025-11-01T00:00:00Z",
    "start": "2025-10-01T00:00:00Z",
    "inclusive_end": false,
    "inclusive_start": true
  },
  "cycles_next_at": "2025-11-01T00:00:00Z",
  "effective_at": "2025-10-01T00:00:00Z",
  "metadata": {},
  "rate_card_id": "rc_jQK2n0wutCj6bBcAIrL6o07g",
  "status": "active",
  "subject_id": "subj_VyX6Q96h5avMho8O7QWlKeXE"
}