BeClaude
GuideBeginnerAPI2026-05-22

How to Manage Company Resources in the Anthropic API

A practical guide to using the Anthropic API's Company resource for team-based API key management, usage tracking, and billing controls within the Claude AI ecosystem.

Quick Answer

This guide explains how to use the Anthropic API's Company resource to create and manage API keys for teams, track usage across projects, and set billing limits—all programmatically via the API.

Anthropic APIAPI key managementteam billingusage trackingClaude API

Introduction

When working with Claude AI in a team or organizational setting, managing API access, tracking usage, and controlling costs are critical. The Anthropic API provides a Company resource that allows you to perform these tasks programmatically. This guide walks you through everything you need to know to leverage the Company resource effectively.

Whether you're a developer building internal tools, a team lead managing multiple API keys, or a platform engineer integrating Claude into your product, understanding the Company resource will help you maintain control and visibility over your Claude AI usage.

What Is the Company Resource?

The Company resource in the Anthropic API represents your organization's account. It is the top-level entity under which all API keys, usage data, and billing information are organized. By interacting with the Company resource, you can:

  • Create and manage API keys for different team members or services
  • View aggregated usage statistics
  • Set spending limits and alerts
  • Manage billing details
Unlike individual API keys, the Company resource gives you a holistic view of your team's Claude AI consumption.

Prerequisites

Before you begin, ensure you have:

  • An Anthropic account with administrative privileges
  • Your Admin API Key (available in the Anthropic Console under Account Settings)
  • Basic familiarity with REST APIs and either Python or TypeScript
Important: The Company resource endpoints require an Admin API Key. Regular API keys will not work for these operations.

Getting Started: Authentication

All Company resource requests must include your Admin API Key in the x-api-key header. Here's a basic setup in Python:

import requests

ADMIN_API_KEY = "your-admin-api-key-here" BASE_URL = "https://api.anthropic.com/v1"

headers = { "x-api-key": ADMIN_API_KEY, "anthropic-version": "2023-06-01", "Content-Type": "application/json" }

And in TypeScript:

const ADMIN_API_KEY = "your-admin-api-key-here";
const BASE_URL = "https://api.anthropic.com/v1";

const headers = { "x-api-key": ADMIN_API_KEY, "anthropic-version": "2023-06-01", "Content-Type": "application/json" };

Managing API Keys

One of the most common use cases for the Company resource is creating and managing API keys for your team.

List All API Keys

To see all API keys associated with your company:

response = requests.get(f"{BASE_URL}/api_keys", headers=headers)
print(response.json())

This returns an array of API key objects, each containing:

  • id: Unique identifier
  • name: Human-readable name
  • type: Either admin or normal
  • created_at: Timestamp of creation
  • last_used_at: Timestamp of last usage

Create a New API Key

To generate a new API key for a team member or service:

new_key_data = {
    "name": "CI/CD Pipeline Key",
    "type": "normal"  # 'admin' or 'normal'
}

response = requests.post( f"{BASE_URL}/api_keys", headers=headers, json=new_key_data )

if response.status_code == 200: key_info = response.json() print(f"New API Key: {key_info['key']}") # Display once only! print(f"Key ID: {key_info['id']}") else: print(f"Error: {response.text}")

Security Note: The API key value is only returned once upon creation. Store it securely in a secrets manager.

Delete an API Key

To revoke access:

key_id = "key_id_to_delete"
response = requests.delete(f"{BASE_URL}/api_keys/{key_id}", headers=headers)

if response.status_code == 200: print("API key deleted successfully") else: print(f"Error: {response.text}")

Tracking Usage

The Company resource provides aggregated usage data, helping you monitor costs and identify trends.

Get Usage Summary

# Get usage for the current month
response = requests.get(f"{BASE_URL}/usage", headers=headers)
usage_data = response.json()

print(f"Total input tokens: {usage_data['input_tokens']}") print(f"Total output tokens: {usage_data['output_tokens']}") print(f"Total cost: ${usage_data['cost']:.2f}")

Filter by Date Range

params = {
    "start_date": "2024-01-01",
    "end_date": "2024-01-31"
}

response = requests.get(f"{BASE_URL}/usage", headers=headers, params=params) monthly_usage = response.json()

Usage by API Key

For granular tracking, you can break down usage by individual API key:

response = requests.get(f"{BASE_URL}/usage/by_api_key", headers=headers)
breakdown = response.json()

for entry in breakdown['data']: print(f"Key: {entry['api_key_name']} - Tokens: {entry['total_tokens']} - Cost: ${entry['cost']:.2f}")

Setting Spending Limits

To prevent unexpected costs, you can set spending limits at the company level.

Set a Monthly Limit

limit_data = {
    "monthly_limit_usd": 500.00  # $500 monthly cap
}

response = requests.post( f"{BASE_URL}/billing/limits", headers=headers, json=limit_data )

if response.status_code == 200: print("Monthly spending limit set successfully")

Set Alert Thresholds

Get notified before you hit your limit:

alert_data = {
    "thresholds": [
        {"percentage": 50, "email": "[email protected]"},
        {"percentage": 80, "email": "[email protected]"},
        {"percentage": 100, "email": "[email protected]"}
    ]
}

response = requests.post( f"{BASE_URL}/billing/alerts", headers=headers, json=alert_data )

Best Practices

1. Use Descriptive Key Names

When creating API keys, use names that clearly identify the purpose and owner:

keys_to_create = [
    {"name": "Production - Backend Service", "type": "normal"},
    {"name": "Staging - QA Testing", "type": "normal"},
    {"name": "Developer - Alice", "type": "normal"},
    {"name": "CI/CD - GitHub Actions", "type": "normal"}
]

2. Rotate Keys Regularly

Implement a key rotation policy:

import datetime

Find keys older than 90 days

response = requests.get(f"{BASE_URL}/api_keys", headers=headers) old_keys = [ key for key in response.json() if (datetime.datetime.now() - datetime.datetime.fromisoformat(key['created_at'])).days > 90 ]

for key in old_keys: print(f"Key {key['name']} ({key['id']}) is {key['created_at']} - consider rotating")

3. Monitor Usage Proactively

Set up a daily usage report:

import schedule
import time

def daily_usage_report(): response = requests.get(f"{BASE_URL}/usage", headers=headers) data = response.json() # Send to Slack, email, or logging system print(f"Daily Report - Cost: ${data['cost']:.2f}, Tokens: {data['total_tokens']}")

Schedule daily at 9 AM

schedule.every().day.at("09:00").do(daily_usage_report)

while True: schedule.run_pending() time.sleep(60)

4. Use Environment Variables

Never hardcode API keys in your codebase:

import os

ADMIN_API_KEY = os.environ.get("ANTHROPIC_ADMIN_API_KEY") if not ADMIN_API_KEY: raise ValueError("ANTHROPIC_ADMIN_API_KEY environment variable not set")

Troubleshooting Common Issues

"403 Forbidden" Error

This usually means you're using a regular API key instead of an Admin API Key. Verify your key type in the Anthropic Console.

"429 Too Many Requests"

You've hit the rate limit. Implement exponential backoff:

import time
import random

def make_request_with_retry(url, headers, max_retries=5): for attempt in range(max_retries): response = requests.get(url, headers=headers) if response.status_code == 429: wait_time = (2 ** attempt) + random.uniform(0, 1) print(f"Rate limited. Waiting {wait_time:.2f} seconds...") time.sleep(wait_time) else: return response raise Exception("Max retries exceeded")

Usage Data Not Updating

Usage data may have a delay of up to 5 minutes. If you need real-time data, consider implementing client-side logging in addition to API-level tracking.

Conclusion

The Company resource in the Anthropic API gives you powerful tools to manage your team's Claude AI usage at scale. By leveraging API key management, usage tracking, and spending controls, you can ensure your organization uses Claude efficiently and cost-effectively.

Start by auditing your current API keys, setting up spending limits, and implementing a monitoring dashboard. As your usage grows, these practices will save you from surprises and help you optimize your Claude AI investment.

Key Takeaways

  • Use Admin API Keys for all Company resource operations—regular keys won't work
  • Create descriptive, purpose-specific API keys for each team member or service to simplify tracking and auditing
  • Set spending limits and alert thresholds proactively to prevent unexpected costs
  • Monitor usage by API key to identify which services or team members are driving consumption
  • Rotate keys regularly and store them securely using environment variables or a secrets manager