Get organization member AI spend
GET
CoderSessionTokenheader
Coder-Session-Token<token>organization*stringOrganization ID or name
user*stringUser ID, username, or me
OK
application/json- response
current_spend_micros?integerCurrentSpendMicros is the user's spend on their effective group over the current budget period.
effective_budget?EffectiveBudget is the spend limit that applies to the user in this organization. Null when no budget applies, leaving the user's spend unlimited.
effective_group_id?stringEffectiveGroupID is the group inside this organization that the spend is attributed to, falling back to the organization's Everyone group when no budget applies.
Format
uuidorganization_id?stringFormat
uuidperiod_end?stringPeriodEnd is the exclusive upper bound of the applied period.
Format
date-timeperiod_start?stringPeriodStart is the inclusive lower bound of the applied period.
Format
date-timeuser_id?stringFormat
uuidThe samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X GET \ "$CODER_URL/api/v2/organizations/{organization}/members/{user}/ai/spend" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN"const { CODER_URL, CODER_SESSION_TOKEN } = process.env;const url = `${CODER_URL}/api/v2/organizations/{organization}/members/{user}/ai/spend`;const response = await fetch(url, { method: "GET", headers: { "Coder-Session-Token": CODER_SESSION_TOKEN, },});console.log(response.status, await response.text());import osimport requestsurl = ( os.environ["CODER_URL"] + "/api/v2/organizations/{organization}/members/{user}/ai/spend")token = os.environ["CODER_SESSION_TOKEN"]response = requests.get( url, headers={ "Coder-Session-Token": token, },)print(response.status_code, response.text)package mainimport ( "fmt" "io" "net/http" "os")func main() { url := os.Getenv("CODER_URL") + "/api/v2/organizations/{organization}/members/{user}/ai/spend" token := os.Getenv("CODER_SESSION_TOKEN") req, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { panic(err) } req.Header.Set("Coder-Session-Token", token) resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, err := io.ReadAll(resp.Body) if err != nil { panic(err) } fmt.Println(resp.Status, string(out))}Example Response200
{ "current_spend_micros": 0, "effective_budget": { "limit_source": "user_override", "spend_limit_micros": 0 }, "effective_group_id": "85e2b926-ddfb-4c66-b68e-b66e5acec6c0", "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", "period_end": "2019-08-24T14:15:22Z", "period_start": "2019-08-24T14:15:22Z", "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"}