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",
"billing_time": "anniversary"
}
}'

Arguments

{
"subscription": {
"external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
"plan_code": "new_code",
"name": "name",
"external_id": "sub id",
"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.
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

Responses

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

Returns a subscription object.