Read one end user's spend
import requests
url = "https://app.langwatch.ai/api/gateway/v1/end-users/{id}/spend"
headers = {"X-Auth-Token": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-Auth-Token': '<api-key>'}};
fetch('https://app.langwatch.ai/api/gateway/v1/end-users/{id}/spend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request GET \
--url https://app.langwatch.ai/api/gateway/v1/end-users/{id}/spend \
--header 'X-Auth-Token: <api-key>'{
"data": {
"end_user_id": "<string>",
"window": "<string>",
"from": "<string>",
"to": "<string>",
"cost": {
"total_usd": "<string>",
"nano_usd": 123
},
"request_count": 123,
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_read_input_tokens": 123,
"cache_creation_input_tokens": 123,
"reasoning_tokens": 123
},
"caps": [
{
"budget_id": "<string>",
"anchor_id": "<string>",
"window": "<string>",
"limit_usd": "<string>",
"spent_usd": "<string>",
"period_started_at": "<string>"
}
]
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}Gateway: Spend
Read one end user's spend
Windowed spend rollup for one external end user across the organization (the /customer/info-style read a rebilling integration polls). cap is the applicable attributed-user budget cap and its remaining headroom once such a budget template applies; null until then.
GET
/
api
/
gateway
/
v1
/
end-users
/
{id}
/
spend
Read one end user's spend
import requests
url = "https://app.langwatch.ai/api/gateway/v1/end-users/{id}/spend"
headers = {"X-Auth-Token": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-Auth-Token': '<api-key>'}};
fetch('https://app.langwatch.ai/api/gateway/v1/end-users/{id}/spend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request GET \
--url https://app.langwatch.ai/api/gateway/v1/end-users/{id}/spend \
--header 'X-Auth-Token: <api-key>'{
"data": {
"end_user_id": "<string>",
"window": "<string>",
"from": "<string>",
"to": "<string>",
"cost": {
"total_usd": "<string>",
"nano_usd": 123
},
"request_count": 123,
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"cache_read_input_tokens": 123,
"cache_creation_input_tokens": 123,
"reasoning_tokens": 123
},
"caps": [
{
"budget_id": "<string>",
"anchor_id": "<string>",
"window": "<string>",
"limit_usd": "<string>",
"spent_usd": "<string>",
"period_started_at": "<string>"
}
]
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}Authorizations
Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.
Path Parameters
Query Parameters
Available options:
day, week, month Required string length:
1 - 100Response
Spend and standing for one end user
Show child attributes
Show child attributes
Was this page helpful?
⌘I