Customers
Customer lifetime value
GET
https://thoughtmetric.io/api/v1/customer_ltv
The stored lifetime value series for your store. Each row is a point in time with lifetime value measured over several horizons.
Example request
curl -G https://thoughtmetric.io/api/v1/customer_ltv \
-H "Authorization: Bearer 2019962dcf7a7b1fedc4563b9aaf9fc87426f278" \
-d projectId=ID-bcd0aa692ce7e6b2 \
-d startDate=2024-01-01 \
-d endDate=2024-01-31 \
-d interval=day
<?php
$query = http_build_query([
'projectId' => 'ID-bcd0aa692ce7e6b2',
'startDate' => '2024-01-01',
'endDate' => '2024-01-31',
'interval' => 'day',
]);
$ch = curl_init('https://thoughtmetric.io/api/v1/customer_ltv?' . $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer 2019962dcf7a7b1fedc4563b9aaf9fc87426f278',
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
const params = new URLSearchParams({
projectId: 'ID-bcd0aa692ce7e6b2',
startDate: '2024-01-01',
endDate: '2024-01-31',
interval: 'day',
});
const response = await fetch(
`https://thoughtmetric.io/api/v1/customer_ltv?${params}`,
{ headers: { Authorization: 'Bearer 2019962dcf7a7b1fedc4563b9aaf9fc87426f278' } }
);
const data = await response.json();
Query parameters
| projectId string, required | The Project ID of the store you are querying, e.g. ID-bcd0aa692ce7e6b2. Find it under Configure → API in the dashboard. The older numeric project ID is also accepted. |
| startDate string, required | Start of the reporting window, YYYY-MM-DD. Inclusive. |
| endDate string, required | End of the reporting window, YYYY-MM-DD. Inclusive. The window may not exceed six months. |
| interval string, required | Bucket size for the over_time series: day, week, month or year. |
Response
over_time
array
One object per recorded point, oldest first.
| timestamp string | ISO 8601 timestamp for the data point. |
| ltv number | Lifetime value across all time. |
| ltv30 number | Lifetime value measured 30 days after first order. |
| ltv90 number | Lifetime value measured 90 days after first order. |
| ltv1 number | Lifetime value after one year. |
| ltv2 number | Lifetime value after two years. |
| ltv5 number | Lifetime value after five years. |
total
object
Always an empty object on this endpoint. All of the data is in over_time.
Example response
200 OK
{
"total": {},
"total_last_period": {},
"over_time": [
{
"timestamp": "2024-01-01T00:00:00.000Z",
"ltv": 184.22,
"ltv30": 110.45,
"ltv90": 142.80,
"ltv1": 171.05,
"ltv2": 180.90,
"ltv5": 184.22
}
],
"over_time_last_period": []
}
Notes
- This endpoint still returns the legacy envelope, so
total_last_periodandover_time_last_periodare present but always empty. intervalis required by the API but does not affect the result. The series comes back at its stored resolution.