Skip to content

five-on-it / apps/api/src/admin

apps/api/src/admin ​

The admins' routes: the accounts' daily limits (limits.ts) and the platform's settings (settings.ts: the spending limits, the creation's caps, the models offered). An admin is an account FOI_ADMINS names, a list kept apart from the moderators'; anyone else signed in gets 403, nobody signed in 401. Every change of an account's limits goes to the audit log (action: 'limits': who, when, the account, its override before and after, the note), which the moderators read too, and so does every change of the settings (action: 'settings': the settings before and after).

RouteWhat
GET /admin/limitsEvery account's override, the latest set first, each saying whether it ran out.
GET /admin/accounts?q=The accounts the API has seen (drafts' owners, quotas' spenders, overrides) whose id or name holds the words, 20 at most, each with its limits now, today's usage and its override; an id typed in whole that it has not seen comes first (when nothing else matches, or when it reads as an id: a - or an @ in it), so any account can be given limits before it ever builds.
GET /admin/accounts/:id/limitsOne account, the same way.
PUT /admin/accounts/:id/limits {builds?, rooms?, creations?, creationUsd?, creationBuilds?, budgetExempt?, unlimited?, until?, note?}Sets the account's override, replacing the one it had: a number a day of each limit given (0 blocks), what one of its creations may spend (USD) and the builds it may run, or no limit at all (unlimited: no daily quota, the budget skipped, its creations' caps the platform's maximums), until a date (through that day, UTC) or a time to come.
DELETE /admin/accounts/:id/limits {note?}Takes the override away: the defaults again.
GET /admin/audit?limit=The changes of limits and of the settings, newest first (100 by default, at most 500).
GET /admin/settingsThe platform's settings: what holds (effective), the configuration's defaults, and what an admin set over them (overrides, or null).
PUT /admin/settings {monthlyUsd?, quotaBuilds?, quotaRooms?, quotaCreations?, creationUsd?, creationBuilds?, turnMinutes?, turnCalls?, turnInputTokens?, turnOutputTokens?, turnMaxTokens?, concurrency?, modelChoices?, defaultModel?, note?}Sets the keys given (null resets one), each within its bounds (settings.ts); answers as GET does.
DELETE /admin/settings/:key {note?}, DELETE /admin/settings {note?}Resets one key, or every one: its default again. 404 when it was not set.

Functions ​