Claudio.Admin (Claudio v0.6.0)
View SourceAnthropic Admin API client — programmatic management of an organization's members, invites, workspaces, API keys, and usage/cost reports.
Authentication
The Admin API requires an Admin API key (sk-ant-admin…), provisioned by
an organization admin in the Console. It travels in the same x-api-key
header as a regular key, so build the client the usual way — just pass the
admin key:
client = Claudio.Client.new(%{token: "sk-ant-admin-...", version: "2023-06-01"})
{:ok, org} = Claudio.Admin.get_organization(client)GA — no beta header. All functions return the raw decoded body
({:ok, map()}); a non-2xx response maps to {:error, %Claudio.APIError{}}
and a transport error to {:error, term()}, consistent with
Claudio.Models / Claudio.Files.
Not covered
- Workspace-member, service-account, and federation endpoints require an
org:adminOAuth token (not an admin key) — see S8. - Creating/deleting API keys is Console-only by design.
Summary
Functions
Archives a workspace.
Organization cost report. Opts pass through as query params.
Creates an invite, e.g. %{"email" => "x@y.com", "role" => "developer"}.
Creates a workspace, e.g. %{"name" => "Production"}.
Deletes a pending invite by id.
Retrieves a single API key by id.
Retrieves a single invite by id.
Returns the organization the admin key belongs to (GET /v1/organizations/me).
Retrieves a single organization member by id.
Retrieves a single workspace by id.
Lists API keys. Opts (:limit/:status/:workspace_id) become query params.
Lists organization invites.
Lists organization members. Opts (:limit/:before_id/:after_id) become query params.
Lists workspaces.
Removes a member from the organization. (Admins cannot be removed via the API.)
Updates an API key, e.g. %{"status" => "inactive"} or %{"name" => "…"}.
Updates a member's role, e.g. %{"role" => "developer"}.
Updates a workspace (e.g. rename).
Organization message usage report. Opts (e.g. :starting_at, :ending_at,
:group_by, :bucket_width) pass through as query params.
Types
@type result() :: {:ok, map()} | {:error, Claudio.APIError.t() | term()}
Functions
@spec archive_workspace(Req.Request.t(), String.t()) :: result()
Archives a workspace.
@spec cost_report( Req.Request.t(), keyword() ) :: result()
Organization cost report. Opts pass through as query params.
@spec create_invite(Req.Request.t(), map()) :: result()
Creates an invite, e.g. %{"email" => "x@y.com", "role" => "developer"}.
@spec create_workspace(Req.Request.t(), map()) :: result()
Creates a workspace, e.g. %{"name" => "Production"}.
@spec delete_invite(Req.Request.t(), String.t()) :: result()
Deletes a pending invite by id.
@spec get_api_key(Req.Request.t(), String.t()) :: result()
Retrieves a single API key by id.
@spec get_invite(Req.Request.t(), String.t()) :: result()
Retrieves a single invite by id.
@spec get_organization(Req.Request.t()) :: result()
Returns the organization the admin key belongs to (GET /v1/organizations/me).
@spec get_user(Req.Request.t(), String.t()) :: result()
Retrieves a single organization member by id.
@spec get_workspace(Req.Request.t(), String.t()) :: result()
Retrieves a single workspace by id.
@spec list_api_keys( Req.Request.t(), keyword() ) :: result()
Lists API keys. Opts (:limit/:status/:workspace_id) become query params.
@spec list_invites( Req.Request.t(), keyword() ) :: result()
Lists organization invites.
@spec list_users( Req.Request.t(), keyword() ) :: result()
Lists organization members. Opts (:limit/:before_id/:after_id) become query params.
@spec list_workspaces( Req.Request.t(), keyword() ) :: result()
Lists workspaces.
@spec remove_user(Req.Request.t(), String.t()) :: result()
Removes a member from the organization. (Admins cannot be removed via the API.)
@spec update_api_key(Req.Request.t(), String.t(), map()) :: result()
Updates an API key, e.g. %{"status" => "inactive"} or %{"name" => "…"}.
@spec update_user(Req.Request.t(), String.t(), map()) :: result()
Updates a member's role, e.g. %{"role" => "developer"}.
@spec update_workspace(Req.Request.t(), String.t(), map()) :: result()
Updates a workspace (e.g. rename).
@spec usage_report( Req.Request.t(), keyword() ) :: result()
Organization message usage report. Opts (e.g. :starting_at, :ending_at,
:group_by, :bucket_width) pass through as query params.