Subscriptions
Create a subscription
This endpoint assigns a plan to a customer, creating or modifying a subscription. Ideal for initial subscriptions or plan changes (upgrades/downgrades).
POST
/api/v1/subscriptions
Bearer*
{
"subscription": {
"billing_time": "anniversary",
"canceled_at": "2022-09-14T16:35:31Z",
"created_at": "2022-08-08T00:00:00Z",
"downgrade_plan_date": "null",
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"external_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "Repository A",
"next_plan_code": "null",
"plan_code": "premium",
"previous_plan_code": "null",
"started_at": "2022-08-08T00:00:00Z",
"status": "active",
"subscription_at": "2022-08-08T00:00:00Z",
"terminated_at": "2022-09-14T16:35:31Z"
}
}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/subscriptions" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"subscription": {
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"plan_code": "startup_plan",
"external_id": "sub_id_123456789",
"name": "Repository A",
"subscription_at": "2022-08-08T00:00:00Z",
"ending_at": "2023-08-08T00:00:00Z",
"billing_time": "anniversary"
}
}'
Authorizations
Authorizationheaderrequired
string
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
application/json
subscriptionrequired
object
Response
200 - application/json
subscriptionrequired
object
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
curl --location --request POST "$LAGO_URL/api/v1/subscriptions" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"subscription": {
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"plan_code": "startup_plan",
"external_id": "sub_id_123456789",
"name": "Repository A",
"subscription_at": "2022-08-08T00:00:00Z",
"ending_at": "2023-08-08T00:00:00Z",
"billing_time": "anniversary"
}
}'
{
"subscription": {
"billing_time": "anniversary",
"canceled_at": "2022-09-14T16:35:31Z",
"created_at": "2022-08-08T00:00:00Z",
"downgrade_plan_date": "null",
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"external_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "Repository A",
"next_plan_code": "null",
"plan_code": "premium",
"previous_plan_code": "null",
"started_at": "2022-08-08T00:00:00Z",
"status": "active",
"subscription_at": "2022-08-08T00:00:00Z",
"terminated_at": "2022-09-14T16:35:31Z"
}
}