Skip to main content
DELETE
/
subscriptions
/
{external_id}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
EXTERNAL_ID="__YOUR_SUBSCRIPTION_ID__"

curl --location --request DELETE "$LAGO_URL/api/v1/subscriptions/$EXTERNAL_ID?status=pending" \
  --header "Authorization: Bearer $API_KEY"
{
  "subscription": {
    "lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "external_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
    "lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "external_customer_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
    "billing_time": "anniversary",
    "name": "Repository A",
    "plan_code": "premium",
    "status": "active",
    "created_at": "2022-08-08T00:00:00Z",
    "canceled_at": "2022-09-14T16:35:31Z",
    "started_at": "2022-08-08T00:00:00Z",
    "ending_at": "2022-10-08T00:00:00Z",
    "subscription_at": "2022-08-08T00:00:00Z",
    "terminated_at": "2022-09-14T16:35:31Z",
    "previous_plan_code": null,
    "next_plan_code": null,
    "downgrade_plan_date": "2022-04-30",
    "trial_ended_at": "2022-08-08T00:00:00Z",
    "current_billing_period_started_at": "2022-08-08T00:00:00Z",
    "current_billing_period_ending_at": "2022-09-08T00:00:00Z",
    "on_termination_credit_note": "credit",
    "on_termination_invoice": "generate",
    "plan_amount_cents": 10000,
    "plan_amount_currency": "USD",
    "applied_invoice_custom_sections": [
      {
        "lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
        "invoice_custom_section_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
        "created_at": "2023-07-06T14:35:58Z"
      }
    ],
    "payment_method": {
      "payment_method_type": "provider",
      "payment_method_id": "1a901a90-1a90-1a90-1a90-1a901a901a90"
    }
  }
}
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"
EXTERNAL_ID="__YOUR_SUBSCRIPTION_ID__"

curl --location --request DELETE "$LAGO_URL/api/v1/subscriptions/$EXTERNAL_ID?status=pending" \
  --header "Authorization: Bearer $API_KEY"

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

external_id
string
required

External ID of the existing subscription

Example:

"5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba"

Query Parameters

status
string

If the field is not defined, Lago will terminate only active subscriptions. However, if you wish to cancel a pending subscription, please ensure that you include status=pending in your request.

Example:

"pending"

on_termination_credit_note
enum<string>

When a pay-in-advance subscription is terminated before the end of its billing period, we generate a credit note for the unused subscription time by default. This field allows you to control the behavior of the credit note generation:

  • credit: A credit note is generated for the unused subscription time. The unused amount is credited back to the customer.
  • refund: A credit note is generated for the unused subscription time. If the invoice is paid or partially paid, the unused paid amount is refunded; any unpaid unused amount is credited back to the customer.
  • skip: No credit note is generated for the unused subscription time.

Note: This field is only applicable to pay-in-advance plans and is ignored for pay-in-arrears plans.

Available options:
credit,
refund,
skip
Example:

"credit"

on_termination_invoice
enum<string>

When a subscription is terminated before the end of its billing period, we generate an invoice for the unbilled usage. This field allows you to control the behavior of the invoice generation:

  • generate: An invoice is generated for the unbilled usage.
  • skip: No invoice is generated for the unbilled usage.
Available options:
generate,
skip
Example:

"generate"

Response

Subscription terminated

subscription
object
required