curl --request POST \
--url https://api.uselotus.io/api/subscriptions/ \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"start_date": "2023-11-07T05:31:56Z",
"customer_id": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"auto_renew": true,
"is_new": true,
"subscription_filters": [
{
"value": "<string>",
"property_name": "<string>"
}
],
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"component_fixed_charges_initial_units": [
{
"metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"units": 5000000000
}
],
"metadata": {}
}
'import requests
url = "https://api.uselotus.io/api/subscriptions/"
payload = {
"start_date": "2023-11-07T05:31:56Z",
"customer_id": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"auto_renew": True,
"is_new": True,
"subscription_filters": [
{
"value": "<string>",
"property_name": "<string>"
}
],
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"component_fixed_charges_initial_units": [
{
"metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"units": 5000000000
}
],
"metadata": {}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
start_date: '2023-11-07T05:31:56Z',
customer_id: '<string>',
end_date: '2023-11-07T05:31:56Z',
auto_renew: true,
is_new: true,
subscription_filters: [{value: '<string>', property_name: '<string>'}],
plan_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
component_fixed_charges_initial_units: [{metric_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', units: 5000000000}],
metadata: {}
})
};
fetch('https://api.uselotus.io/api/subscriptions/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.uselotus.io/api/subscriptions/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'start_date' => '2023-11-07T05:31:56Z',
'customer_id' => '<string>',
'end_date' => '2023-11-07T05:31:56Z',
'auto_renew' => true,
'is_new' => true,
'subscription_filters' => [
[
'value' => '<string>',
'property_name' => '<string>'
]
],
'plan_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'component_fixed_charges_initial_units' => [
[
'metric_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'units' => 5000000000
]
],
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.uselotus.io/api/subscriptions/"
payload := strings.NewReader("{\n \"start_date\": \"2023-11-07T05:31:56Z\",\n \"customer_id\": \"<string>\",\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"auto_renew\": true,\n \"is_new\": true,\n \"subscription_filters\": [\n {\n \"value\": \"<string>\",\n \"property_name\": \"<string>\"\n }\n ],\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"component_fixed_charges_initial_units\": [\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"units\": 5000000000\n }\n ],\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.uselotus.io/api/subscriptions/")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"start_date\": \"2023-11-07T05:31:56Z\",\n \"customer_id\": \"<string>\",\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"auto_renew\": true,\n \"is_new\": true,\n \"subscription_filters\": [\n {\n \"value\": \"<string>\",\n \"property_name\": \"<string>\"\n }\n ],\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"component_fixed_charges_initial_units\": [\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"units\": 5000000000\n }\n ],\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.uselotus.io/api/subscriptions/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"start_date\": \"2023-11-07T05:31:56Z\",\n \"customer_id\": \"<string>\",\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"auto_renew\": true,\n \"is_new\": true,\n \"subscription_filters\": [\n {\n \"value\": \"<string>\",\n \"property_name\": \"<string>\"\n }\n ],\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"component_fixed_charges_initial_units\": [\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"units\": 5000000000\n }\n ],\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"subscription_id": "<string>",
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"auto_renew": true,
"is_new": true,
"subscription_filters": [
{
"value": "<string>",
"property_name": "<string>"
}
],
"customer": {
"customer_name": "<string>",
"email": "jsmith@example.com",
"customer_id": "<string>"
},
"billing_plan": {
"plan_name": "<string>",
"plan_id": "<string>",
"version_id": "<string>",
"version": 123
},
"fully_billed": true,
"addons": [
{
"addon_subscription_id": "<string>",
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"addon": {
"addon_name": "<string>",
"addon_id": "<string>",
"addon_type": "flat",
"billing_frequency": "one_time"
},
"fully_billed": true
}
],
"metadata": {}
}Create a subscription
Add a plan to a customer’s subscription
curl --request POST \
--url https://api.uselotus.io/api/subscriptions/ \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"start_date": "2023-11-07T05:31:56Z",
"customer_id": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"auto_renew": true,
"is_new": true,
"subscription_filters": [
{
"value": "<string>",
"property_name": "<string>"
}
],
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"component_fixed_charges_initial_units": [
{
"metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"units": 5000000000
}
],
"metadata": {}
}
'import requests
url = "https://api.uselotus.io/api/subscriptions/"
payload = {
"start_date": "2023-11-07T05:31:56Z",
"customer_id": "<string>",
"end_date": "2023-11-07T05:31:56Z",
"auto_renew": True,
"is_new": True,
"subscription_filters": [
{
"value": "<string>",
"property_name": "<string>"
}
],
"plan_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"component_fixed_charges_initial_units": [
{
"metric_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"units": 5000000000
}
],
"metadata": {}
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
start_date: '2023-11-07T05:31:56Z',
customer_id: '<string>',
end_date: '2023-11-07T05:31:56Z',
auto_renew: true,
is_new: true,
subscription_filters: [{value: '<string>', property_name: '<string>'}],
plan_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
component_fixed_charges_initial_units: [{metric_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', units: 5000000000}],
metadata: {}
})
};
fetch('https://api.uselotus.io/api/subscriptions/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.uselotus.io/api/subscriptions/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'start_date' => '2023-11-07T05:31:56Z',
'customer_id' => '<string>',
'end_date' => '2023-11-07T05:31:56Z',
'auto_renew' => true,
'is_new' => true,
'subscription_filters' => [
[
'value' => '<string>',
'property_name' => '<string>'
]
],
'plan_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'component_fixed_charges_initial_units' => [
[
'metric_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'units' => 5000000000
]
],
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.uselotus.io/api/subscriptions/"
payload := strings.NewReader("{\n \"start_date\": \"2023-11-07T05:31:56Z\",\n \"customer_id\": \"<string>\",\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"auto_renew\": true,\n \"is_new\": true,\n \"subscription_filters\": [\n {\n \"value\": \"<string>\",\n \"property_name\": \"<string>\"\n }\n ],\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"component_fixed_charges_initial_units\": [\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"units\": 5000000000\n }\n ],\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.uselotus.io/api/subscriptions/")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"start_date\": \"2023-11-07T05:31:56Z\",\n \"customer_id\": \"<string>\",\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"auto_renew\": true,\n \"is_new\": true,\n \"subscription_filters\": [\n {\n \"value\": \"<string>\",\n \"property_name\": \"<string>\"\n }\n ],\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"component_fixed_charges_initial_units\": [\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"units\": 5000000000\n }\n ],\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.uselotus.io/api/subscriptions/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"start_date\": \"2023-11-07T05:31:56Z\",\n \"customer_id\": \"<string>\",\n \"end_date\": \"2023-11-07T05:31:56Z\",\n \"auto_renew\": true,\n \"is_new\": true,\n \"subscription_filters\": [\n {\n \"value\": \"<string>\",\n \"property_name\": \"<string>\"\n }\n ],\n \"plan_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"component_fixed_charges_initial_units\": [\n {\n \"metric_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"units\": 5000000000\n }\n ],\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"subscription_id": "<string>",
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"auto_renew": true,
"is_new": true,
"subscription_filters": [
{
"value": "<string>",
"property_name": "<string>"
}
],
"customer": {
"customer_name": "<string>",
"email": "jsmith@example.com",
"customer_id": "<string>"
},
"billing_plan": {
"plan_name": "<string>",
"plan_id": "<string>",
"version_id": "<string>",
"version": 123
},
"fully_billed": true,
"addons": [
{
"addon_subscription_id": "<string>",
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z",
"addon": {
"addon_name": "<string>",
"addon_id": "<string>",
"addon_type": "flat",
"billing_frequency": "one_time"
},
"fully_billed": true
}
],
"metadata": {}
}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',
)
await lotus.createSubscription({
customer_id: "cust_6c237d6c149c47db8f64246b78ecac13",
plan_id: "plan_f17c6153807d4f4b812265a09cf06680",
start_date: "2022-02-23 03:30:00+00:00",
});
Authorizations
Token-based authentication with required prefix "Token"
Body
The date the subscription starts. This should be a string in YYYY-MM-DD format of the date in UTC time.
The id provided when creating the customer
1The 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.
Whether the subscription automatically renews. Defaults to true.
Add filter key, value pairs that define which events will be applied to this plan subscription.
Show child attributes
Show child attributes
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.
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.
Show child attributes
Show child attributes
A JSON object containing additional information about the subscription.
Show child attributes
Show child attributes
Response
The time the subscription starts. This will be a string in yyyy-mm-dd HH:mm:ss format in UTC time.
The time the subscription starts. This will be a string in yyyy-mm-dd HH:mm:ss format in UTC time.
Whether the subscription automatically renews. Defaults to true.
Whether this subscription came from a renewal or from a first-time. Defaults to true on creation.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes