Skip to main content

Assign a plan to a customer

Route

POST
/api/v1/subscriptions

Usage

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": "code",
"external_id": "id",
"name": "display name",
"subscription_at": "2022-08-08T00:00:00Z",
"billing_time": "anniversary"
}
}'

Arguments

{
"subscription": {
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"plan_code": "new_code",
"name": "name",
"external_id": "sub id",
"subscription_at": "2022-08-08T00:00:00Z",
"billing_time": "anniversary"
}
}
AttributesTypeDescription
external_customer_idString      RequiredCustomer unique identifier in your application
plan_codeString      RequiredCode identifying the plan.
It must match the code property of one of the plans.
external_idString      RequiredUnique external identifier of the subscription. Used as an idempotency key.
nameString      OptionalSubscription display name.
subscription_atString      Optional
ISO 8601 datetime in UTC
Can be used to create a subscription that started in the past or will start in the future. Cannot be used to update the start date of a pending subscription or to schedule an upgrade/downgrade.
billing_timeString      OptionalBilling time of the subscription.
It can be anniversary or calendar
If not provided, it will default to calendar
info

If the customer is not found, it will be created with blank metadata

Deprecated arguments

AttributesTypeDescription
subscription_dateString      OptionalCan be used to create a subscription that started in the past or will start in the future. Cannot be used to update the start date of a pending subscription or to schedule an upgrade/downgrade.

Responses

The plan was succesfuly assigned to the customer. A subscription has been created.

Returns a subscription object.