List usage by scope
curl --request GET \
--url https://api.writer.com/api/billing/v1/organization/{organizationId}/consumption/breakdown/{scope} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.writer.com/api/billing/v1/organization/{organizationId}/consumption/breakdown/{scope}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.writer.com/api/billing/v1/organization/{organizationId}/consumption/breakdown/{scope}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"scope": "user",
"currency": "USD",
"data": [
{
"scope_id": "42",
"scope_name": "Ada Lovelace",
"cost_in_cents": 1250,
"total_tokens": 480000
},
{
"scope_id": "17",
"scope_name": "grace.hopper@example.com",
"cost_in_cents": 120,
"total_tokens": 4500
}
],
"pagination": {
"limit": 50,
"offset": 0,
"total": 2
}
}{
"tpe": "<string>",
"errors": [
{
"key": "<string>",
"description": "<string>"
}
]
}{
"tpe": "<string>",
"errors": [
{
"key": "<string>",
"description": "<string>"
}
]
}Observability API
List usage by scope
List cost and token usage for each entity in the requested scope for one month. Rows are ordered by cost from highest to lowest, then by scope_id. With team_id, the user and playbook scopes list only usage in that team.
GET
/
api
/
billing
/
v1
/
organization
/
{organizationId}
/
consumption
/
breakdown
/
{scope}
List usage by scope
curl --request GET \
--url https://api.writer.com/api/billing/v1/organization/{organizationId}/consumption/breakdown/{scope} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.writer.com/api/billing/v1/organization/{organizationId}/consumption/breakdown/{scope}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.writer.com/api/billing/v1/organization/{organizationId}/consumption/breakdown/{scope}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"scope": "user",
"currency": "USD",
"data": [
{
"scope_id": "42",
"scope_name": "Ada Lovelace",
"cost_in_cents": 1250,
"total_tokens": 480000
},
{
"scope_id": "17",
"scope_name": "grace.hopper@example.com",
"cost_in_cents": 120,
"total_tokens": 4500
}
],
"pagination": {
"limit": 50,
"offset": 0,
"total": 2
}
}{
"tpe": "<string>",
"errors": [
{
"key": "<string>",
"description": "<string>"
}
]
}{
"tpe": "<string>",
"errors": [
{
"key": "<string>",
"description": "<string>"
}
]
}Use an organization API key (All teams). An existing legacy team key can read the
team, user, and playbook scopes for its own team only. See Export usage and spend for examples, pagination, and error handling.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your Writer API key. User keys can't read consumption data.
Path Parameters
Query Parameters
Was this page helpful?