POST
/
api
/
subscriptions
/
curl --request POST \
  --url https://api.uselotus.io/api/subscriptions/ \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "auto_renew": true,
  "component_fixed_charges_initial_units": [
    {
      "metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "units": 123
    }
  ],
  "customer_id": "<string>",
  "end_date": "2023-11-07T05:31:56Z",
  "is_new": true,
  "metadata": {},
  "plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "start_date": "2023-11-07T05:31:56Z",
  "subscription_filters": [
    {
      "property_name": "<string>",
      "value": "<string>"
    }
  ]
}'
{
  "addons": [
    {
      "addon": {
        "addon_id": "<string>",
        "addon_name": "<string>",
        "addon_type": "flat",
        "billing_frequency": "one_time"
      },
      "addon_subscription_id": "<string>",
      "end_date": "2023-11-07T05:31:56Z",
      "fully_billed": true,
      "start_date": "2023-11-07T05:31:56Z"
    }
  ],
  "auto_renew": true,
  "billing_plan": {
    "plan_id": "<string>",
    "plan_name": "<string>",
    "version": 123,
    "version_id": "<string>"
  },
  "customer": {
    "customer_id": "<string>",
    "customer_name": "<string>",
    "email": "jsmith@example.com"
  },
  "end_date": "2023-11-07T05:31:56Z",
  "fully_billed": true,
  "is_new": true,
  "metadata": {},
  "start_date": "2023-11-07T05:31:56Z",
  "subscription_filters": [
    {
      "property_name": "<string>",
      "value": "<string>"
    }
  ],
  "subscription_id": "<string>"
}

A subscription associates one of your customers with one of your billing plans. You can safely give a customer multiple subscriptions to different plans.

If you want to give a single customer multiple subscriptions to the same plan (for example, one for each of their environments), you can do that using subscription_filters. For more details on how to use them and what they do, see the subscription filters documentation.

If any of your usage components has a prepaid charge associated with it, you can specify how many units they prepaid for as part of this call. If you don’t specify a value, the component’s default value will be used. If there was no default value, the susbcription creation will fail.

lotus.create_subscription(
  customer_id='cust_6c237d6c149c47db8f64246b78ecac13',
  plan_id='plan_f17c6153807d4f4b812265a09cf06680',
  start_date='2022-02-23 03:30:00+00:00',
)

Authorizations

Authorization
string
headerrequired

Token-based authentication with required prefix "Token"

Body

auto_renew
boolean

Whether the subscription automatically renews. Defaults to true.

component_fixed_charges_initial_units
object[]

The initial units for the plan components' prepaid fixed charges. This is only required if the plan has plan components where you did not specify the initial units.

customer_id
string | null
required

The id provided when creating the customer

end_date
string

The date the subscription ends. This should be a string in YYYY-MM-DD format of the date in UTC time. If you don’t set it (recommended), we will use the information in the billing plan to automatically calculate this.

is_new
boolean
metadata
object

A JSON object containing additional information about the subscription.

plan_id
string | null

The Lotus plan_id, found in the billing plan object. We will make a best-effort attempt to find the correct plan version (matching preferred currencies, prioritizing custom plans), but if more than one plan version or no plan version matches these criteria this will return an error.

start_date
string
required

The date the subscription starts. This should be a string in YYYY-MM-DD format of the date in UTC time.

subscription_filters
object[]

Add filter key, value pairs that define which events will be applied to this plan subscription.

Response

201 - application/json
addons
object[]
required
auto_renew
boolean
required

Whether the subscription automatically renews. Defaults to true.

billing_plan
object
required
customer
object
required
end_date
string
required

The time the subscription starts. This will be a string in yyyy-mm-dd HH:mm:ss format in UTC time.

fully_billed
boolean
required
is_new
boolean
required

Whether this subscription came from a renewal or from a first-time. Defaults to true on creation.

metadata
object
required
start_date
string
required

The time the subscription starts. This will be a string in yyyy-mm-dd HH:mm:ss format in UTC time.

subscription_filters
object[]
required
subscription_id
string
required