Skip to content
Book a demoContact usGet started

Create Subscription

subscriptions.create(SubscriptionCreateParams**kwargs) -> SubscriptionCreateResponse
post/subscriptions

Create Subscription

ParametersExpand Collapse
rate_card_id: str

The ID of the rate card to use for the subscription.

subject_id: str

The ID or external ID of the subject to create the subscription for.

checkout_callback_urls: Optional[CheckoutCallbackParam]

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

cancelled_url: str

The URL to redirect to after the checkout is cancelled.

minLength1
formaturi
success_url: str

The URL to redirect to after the checkout is successful.

minLength1
formaturi
create_checkout_session: Optional[Literal["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 or the subscription is for a free plan, the subscription will be created and billed for immediately (if for a paid plan).

Accepts one of the following:
"when_required"
"always"
fixed_rate_quantities: Optional[Dict[str, Union[float, str]]]

The quantities of the fixed rates to use for the subscription. Each quantity should be specified as a key-value pair, where the key is the code of the fixed rate and the value is the quantity. All fixed rates must have a quantity specified.

Accepts one of the following:
float
str
metadata: Optional[Dict[str, str]]

Additional metadata about the subscription. You may use this to store any custom data about the subscription.

rate_price_multipliers: Optional[Dict[str, Union[float, str]]]

Pricing multipliers to apply to the rate amounts. Each price multiplier should be specified as a key-value pair, where the key is the code of the rate and the value is the price multiplier. Typically, pricing multipliers are used to apply a discount to a rate. For example, if a rate is $10 per seat and the price multiplier for the seats rate is 0.5, the discounted rate amount will be $5 per seat.

Accepts one of the following:
float
str
subscription_timeline_id: Optional[str]

The ID of the subscription timeline to use for the subscription.

ReturnsExpand Collapse
class SubscriptionCreateResponse:
result: Result

The result of the request. If the request is successful, the subscription 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:
class ResultCreateSubscriptionRequiresActionResponse:
action: ResultCreateSubscriptionRequiresActionResponseAction

The action to take to complete the request.

checkout_url: str

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

requires_action_type: Literal["checkout"]
result_type: Literal["requires_action"]
class ResultCreateSubscriptionSuccessResponse:
result_type: Literal["success"]
subscription: SubscriptionResource

The created subscription resource.

id: str

The ID of the subscription.

cancels_at_end_of_cycle: bool

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

current_period: Optional[CurrentPeriod]

The current period of the subscription if it is active.

end: datetime
formatdate-time
start: datetime
formatdate-time
inclusive_end: Optional[bool]
inclusive_start: Optional[bool]
cycles_next_at: Optional[datetime]

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

formatdate-time
effective_at: datetime

The date and time the subscription became effective.

formatdate-time
fixed_rate_quantities: Dict[str, str]

The quantities of the fixed rates of the subscription.

metadata: Dict[str, str]
rate_card_id: str

The ID of the rate card of the subscription.

rate_price_multipliers: Dict[str, str]

The price multipliers of the rates of the subscription.

status: Literal["active", "cancelled", "paused"]

The status of the subscription.

Accepts one of the following:
"active"
"cancelled"
"paused"
subject_id: str

The ID of the subject that the subscription is for.

Create Subscription
import os
from lark import Lark

client = Lark(
    api_key=os.environ.get("LARK_API_KEY"),  # This is the default and can be omitted
)
subscription = client.subscriptions.create(
    rate_card_id="rc_AJWMxR81jxoRlli6p13uf3JB",
    subject_id="subj_VyX6Q96h5avMho8O7QWlKeXE",
    checkout_callback_urls={
        "cancelled_url": "https://example.com/try-again",
        "success_url": "https://example.com/welcome",
    },
    fixed_rate_quantities={
        "seats": "2",
        "addon_storage": "0",
    },
    metadata={},
    rate_price_multipliers={
        "seats": "0.5"
    },
)
print(subscription.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"
  }
}