Skip to content
Book a demoContact usGet started

Start Subscription Timeline

client.SubscriptionTimelines.Start(ctx, subscriptionTimelineID, body) (*SubscriptionTimelineStartResponse, error)
post/subscription-timelines/{subscription_timeline_id}/start

Start Subscription Timeline

ParametersExpand Collapse
subscriptionTimelineID string
body SubscriptionTimelineStartParams
CheckoutCallbackURLs param.Field[CheckoutCallback]

The URLs to redirect to after the checkout is completed or cancelled, if a checkout is required.

CreateCheckoutSession param.Field[SubscriptionTimelineStartParamsCreateCheckoutSession]optional

Determines whether a checkout session is always required even if the subject has a payment method on file. By default, if the subject has a payment method on file, the subscription will be created and billed for immediately.

const SubscriptionTimelineStartParamsCreateCheckoutSessionWhenRequired SubscriptionTimelineStartParamsCreateCheckoutSession = "when_required"
const SubscriptionTimelineStartParamsCreateCheckoutSessionAlways SubscriptionTimelineStartParamsCreateCheckoutSession = "always"
EffectiveAt param.Field[Time]optional

When the subscription should become active. If not provided, the current date and time will be used.

formatdate-time
ReturnsExpand Collapse
type SubscriptionTimelineStartResponse struct{…}
Result SubscriptionTimelineStartResponseResultUnion

The result of the request. If the request is successful, the subscription timeline resource will be returned. If the request is requires action, the action to take to complete the request will be returned.

Accepts one of the following:
type SubscriptionTimelineStartResponseResultRequiresAction struct{…}
Action SubscriptionTimelineStartResponseResultRequiresActionAction

The action to take to complete the request.

CheckoutURL string

The URL of the checkout page to redirect to in order to complete the request.

RequiresActionType Checkout
ResultType RequiresAction
type SubscriptionTimelineStartResponseResultSuccess struct{…}
ResultType Success
SubscriptionTimeline SubscriptionTimelineStartResponseResultSuccessSubscriptionTimeline

The subscription timeline resource.

ID string
CreatedAt Time
formatdate-time
RateCardID string
Status string
Accepts one of the following:
const SubscriptionTimelineStartResponseResultSuccessSubscriptionTimelineStatusDraft SubscriptionTimelineStartResponseResultSuccessSubscriptionTimelineStatus = "draft"
const SubscriptionTimelineStartResponseResultSuccessSubscriptionTimelineStatusPending SubscriptionTimelineStartResponseResultSuccessSubscriptionTimelineStatus = "pending"
const SubscriptionTimelineStartResponseResultSuccessSubscriptionTimelineStatusActive SubscriptionTimelineStartResponseResultSuccessSubscriptionTimelineStatus = "active"
const SubscriptionTimelineStartResponseResultSuccessSubscriptionTimelineStatusCompleted SubscriptionTimelineStartResponseResultSuccessSubscriptionTimelineStatus = "completed"
SubjectID string
SubscriptionID string
UpdatedAt Time
formatdate-time
Start Subscription Timeline
package main

import (
  "context"
  "fmt"

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

func main() {
  client := lark.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.SubscriptionTimelines.Start(
    context.TODO(),
    "subscription_timeline_id",
    lark.SubscriptionTimelineStartParams{
      CheckoutCallbackURLs: lark.CheckoutCallbackParam{
        CancelledURL: "https://example.com/callback",
        SuccessURL: "https://example.com/callback",
      },
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Result)
}
{
  "result": {
    "action": {
      "checkout_url": "checkout_url",
      "requires_action_type": "checkout"
    },
    "result_type": "requires_action"
  }
}
Returns Examples
{
  "result": {
    "action": {
      "checkout_url": "checkout_url",
      "requires_action_type": "checkout"
    },
    "result_type": "requires_action"
  }
}