Claudio.Admin (Claudio v0.6.0)

View Source

Anthropic 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:admin OAuth 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.

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

result()

@type result() :: {:ok, map()} | {:error, Claudio.APIError.t() | term()}

Functions

archive_workspace(client, id)

@spec archive_workspace(Req.Request.t(), String.t()) :: result()

Archives a workspace.

cost_report(client, opts \\ [])

@spec cost_report(
  Req.Request.t(),
  keyword()
) :: result()

Organization cost report. Opts pass through as query params.

create_invite(client, body)

@spec create_invite(Req.Request.t(), map()) :: result()

Creates an invite, e.g. %{"email" => "x@y.com", "role" => "developer"}.

create_workspace(client, body)

@spec create_workspace(Req.Request.t(), map()) :: result()

Creates a workspace, e.g. %{"name" => "Production"}.

delete_invite(client, invite_id)

@spec delete_invite(Req.Request.t(), String.t()) :: result()

Deletes a pending invite by id.

get_api_key(client, id)

@spec get_api_key(Req.Request.t(), String.t()) :: result()

Retrieves a single API key by id.

get_invite(client, invite_id)

@spec get_invite(Req.Request.t(), String.t()) :: result()

Retrieves a single invite by id.

get_organization(client)

@spec get_organization(Req.Request.t()) :: result()

Returns the organization the admin key belongs to (GET /v1/organizations/me).

get_user(client, user_id)

@spec get_user(Req.Request.t(), String.t()) :: result()

Retrieves a single organization member by id.

get_workspace(client, id)

@spec get_workspace(Req.Request.t(), String.t()) :: result()

Retrieves a single workspace by id.

list_api_keys(client, opts \\ [])

@spec list_api_keys(
  Req.Request.t(),
  keyword()
) :: result()

Lists API keys. Opts (:limit/:status/:workspace_id) become query params.

list_invites(client, opts \\ [])

@spec list_invites(
  Req.Request.t(),
  keyword()
) :: result()

Lists organization invites.

list_users(client, opts \\ [])

@spec list_users(
  Req.Request.t(),
  keyword()
) :: result()

Lists organization members. Opts (:limit/:before_id/:after_id) become query params.

list_workspaces(client, opts \\ [])

@spec list_workspaces(
  Req.Request.t(),
  keyword()
) :: result()

Lists workspaces.

remove_user(client, user_id)

@spec remove_user(Req.Request.t(), String.t()) :: result()

Removes a member from the organization. (Admins cannot be removed via the API.)

update_api_key(client, id, body)

@spec update_api_key(Req.Request.t(), String.t(), map()) :: result()

Updates an API key, e.g. %{"status" => "inactive"} or %{"name" => "…"}.

update_user(client, user_id, body)

@spec update_user(Req.Request.t(), String.t(), map()) :: result()

Updates a member's role, e.g. %{"role" => "developer"}.

update_workspace(client, id, body)

@spec update_workspace(Req.Request.t(), String.t(), map()) :: result()

Updates a workspace (e.g. rename).

usage_report(client, opts \\ [])

@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.