Skip to main content
PUT
/
subscriptions
/
{external_id}
/
lifetime_usage
Update a subscription lifetime usage
curl --request PUT \
  --url https://api.getlago.com/api/v1/subscriptions/{external_id}/lifetime_usage \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "lifetime_usage": {
    "external_historical_usage_amount_cents": 100
  }
}
'
import requests

url = "https://api.getlago.com/api/v1/subscriptions/{external_id}/lifetime_usage"

payload = { "lifetime_usage": { "external_historical_usage_amount_cents": 100 } }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({lifetime_usage: {external_historical_usage_amount_cents: 100}})
};

fetch('https://api.getlago.com/api/v1/subscriptions/{external_id}/lifetime_usage', 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.getlago.com/api/v1/subscriptions/{external_id}/lifetime_usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'lifetime_usage' => [
'external_historical_usage_amount_cents' => 100
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.getlago.com/api/v1/subscriptions/{external_id}/lifetime_usage"

payload := strings.NewReader("{\n \"lifetime_usage\": {\n \"external_historical_usage_amount_cents\": 100\n }\n}")

req, _ := http.NewRequest("PUT", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
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.put("https://api.getlago.com/api/v1/subscriptions/{external_id}/lifetime_usage")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"lifetime_usage\": {\n \"external_historical_usage_amount_cents\": 100\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.getlago.com/api/v1/subscriptions/{external_id}/lifetime_usage")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"lifetime_usage\": {\n \"external_historical_usage_amount_cents\": 100\n }\n}"

response = http.request(request)
puts response.read_body
{
  "lifetime_usage": {
    "lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "lago_subscription_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "external_subscription_id": "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
    "external_historical_usage_amount_cents": 100,
    "invoiced_usage_amount_cents": 100,
    "current_usage_amount_cents": 100,
    "from_datetime": "2024-01-01T00:00:00Z",
    "to_datetime": "2024-12-31T23:59:59Z",
    "usage_thresholds": [
      {
        "amount_cents": 100,
        "completion_ratio": 0.5,
        "reached_at": "2024-01-01T00:00:00Z"
      }
    ]
  }
}
{
"status": 400,
"error": "Bad request"
}
{
"status": 401,
"error": "Unauthorized"
}
{
"status": 404,
"error": "Not Found",
"code": "object_not_found"
}
{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {}
}

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"

Body

application/json

Update the lifetime usage of a subscription

lifetime_usage
object
required

Response

Subscription lifetime usage updated

lifetime_usage
object
required