Skip to content
Book a demoContact usGet started

Start Subscription Timeline

client.subscriptionTimelines.start(stringsubscriptionTimelineID, SubscriptionTimelineStartParams { checkout_callback_urls, create_checkout_session, effective_at } body, RequestOptionsoptions?): SubscriptionTimelineStartResponse { result }
post/subscription-timelines/{subscription_timeline_id}/start

Start Subscription Timeline

ParametersExpand Collapse
subscriptionTimelineID: string
body: SubscriptionTimelineStartParams { checkout_callback_urls, create_checkout_session, effective_at }
checkout_callback_urls: CheckoutCallback { cancelled_url, success_url }

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

cancelled_url: string

The URL to redirect to after the checkout is cancelled.

minLength1
formaturi
success_url: string

The URL to redirect to after the checkout is successful.

minLength1
formaturi
create_checkout_session?: "when_required" | "always"

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.

Accepts one of the following:
"when_required"
"always"
effective_at?: string

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

formatdate-time
ReturnsExpand Collapse
SubscriptionTimelineStartResponse { result }
result: StartSubscriptionTimelineRequiresActionResponse { action, result_type } | StartSubscriptionTimelineSuccessResponse { result_type, subscription_timeline }

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:
StartSubscriptionTimelineRequiresActionResponse { action, result_type }
action: Action { checkout_url, requires_action_type }

The action to take to complete the request.

checkout_url: string

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

requires_action_type: "checkout"
result_type: "requires_action"
StartSubscriptionTimelineSuccessResponse { result_type, subscription_timeline }
result_type: "success"
subscription_timeline: SubscriptionTimeline { id, created_at, rate_card_id, 4 more }

The subscription timeline resource.

id: string
created_at: string
formatdate-time
rate_card_id: string
status: "draft" | "pending" | "active" | "completed"
Accepts one of the following:
"draft"
"pending"
"active"
"completed"
subject_id: string
subscription_id: string | null
updated_at: string
formatdate-time
Start Subscription Timeline
import Lark from 'lark-billing';

const client = new Lark({
  apiKey: process.env['LARK_API_KEY'], // This is the default and can be omitted
});

const response = await client.subscriptionTimelines.start('subscription_timeline_id', {
  checkout_callback_urls: {
    cancelled_url: 'https://example.com/callback',
    success_url: 'https://example.com/callback',
  },
});

console.log(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"
  }
}