Skip to content
Skip to Content
Coder Docs

Get user AI spend by organization

GET
/api/v2/users/{user}/ai/spend/organizations

Returns the user's effective AI budget and current-period spend in each organization that the user is a current member of and that the caller can read. Organizations the caller cannot read are omitted, so the response for a given user can differ between callers. Each organization's effective group is resolved the same way AI Gateway resolves a budget for a request in that organization, falling back to the organization's Everyone group. organization_id is the organization of the user's site-wide effective group, as reported by GET /users/{user}/ai/spend, and is null when that organization is not in organizations. Access requires permission to read the user, as for GET /users/{user}/ai/spend.

Authorization

CoderSessionToken
headerCoder-Session-Token<token>

Path Parameters

user*string

User ID, username, or me

Response Body

OK

application/json
  1. response
organization_id?string

OrganizationID is the organization of the user's site-wide effective group, as reported by UserAISpendStatus. Null when no group resolves or when that organization is not in Organizations.

Formatuuid
organizations?array<>

Organizations is the spend per organization the user is a current member of and the caller can read, ordered by organization name.

period_end?string

PeriodEnd is the exclusive upper bound of the applied period.

Formatdate-time
period_start?string

PeriodStart is the inclusive lower bound of the applied period.

Formatdate-time

The samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.

curl -X GET \	"$CODER_URL/api/v2/users/{user}/ai/spend/organizations" \	-H "Coder-Session-Token: $CODER_SESSION_TOKEN"
Example Response200
{  "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",  "organizations": [    {      "current_spend_micros": 0,      "effective_budget": {        "limit_source": "user_override",        "spend_limit_micros": 0      },      "effective_group_id": "85e2b926-ddfb-4c66-b68e-b66e5acec6c0",      "organization": {        "display_name": "string",        "icon": "string",        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",        "name": "string"      }    }  ],  "period_end": "2019-08-24T14:15:22Z",  "period_start": "2019-08-24T14:15:22Z"}