Retrieve usage for an entity
curl --request GET \
--url https://api.writer.com/api/billing/v1/organization/{organizationId}/consumption/breakdown/{scope}/{scopeId} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.writer.com/api/billing/v1/organization/{organizationId}/consumption/breakdown/{scope}/{scopeId}"
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}/{scopeId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"scope": "team",
"currency": "USD",
"data": [
{
"scope_id": "8",
"scope_name": "Marketing",
"cost_in_cents": 5320,
"total_tokens": 1925000
}
],
"pagination": {
"limit": 50,
"offset": 0,
"total": 1
}
}{
"tpe": "<string>",
"errors": [
{
"key": "<string>",
"description": "<string>"
}
]
}{
"tpe": "<string>",
"errors": [
{
"key": "<string>",
"description": "<string>"
}
]
}Observability API
Retrieve usage for an entity
Retrieve cost and token usage for one user, team, playbook, or billing group for one month. The response has the same shape as the scope breakdown with a single row. An entity with no usage in the month returns one row with zero cost and zero tokens. When a team filter applies, from team_id or a legacy team API key, a user or playbook with no usage in that team returns an empty data array and a pagination.total of 0 instead, including one that isn’t in the team.
GET
/
api
/
billing
/
v1
/
organization
/
{organizationId}
/
consumption
/
breakdown
/
{scope}
/
{scopeId}
Retrieve usage for an entity
curl --request GET \
--url https://api.writer.com/api/billing/v1/organization/{organizationId}/consumption/breakdown/{scope}/{scopeId} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.writer.com/api/billing/v1/organization/{organizationId}/consumption/breakdown/{scope}/{scopeId}"
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}/{scopeId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"scope": "team",
"currency": "USD",
"data": [
{
"scope_id": "8",
"scope_name": "Marketing",
"cost_in_cents": 5320,
"total_tokens": 1925000
}
],
"pagination": {
"limit": 50,
"offset": 0,
"total": 1
}
}{
"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?