How to Use the Company Endpoint in the Claude API: A Practical Guide
Learn how to leverage the Company endpoint in the Claude API for enterprise account management, team collaboration, and usage monitoring with practical code examples.
This guide explains how to use the Company endpoint in the Claude API to manage enterprise accounts, retrieve organization details, list team members, and monitor API usage across your company. You'll get practical code examples in Python and TypeScript.
Introduction
When integrating Claude AI into your organization, managing access, monitoring usage, and coordinating team members becomes essential. Anthropic provides a dedicated Company endpoint in the Claude API that gives enterprise users programmatic control over their organization's account settings, team members, and usage analytics.
This guide walks you through everything you need to know about the Company endpoint—from authentication to practical implementation—so you can streamline your enterprise Claude deployment.
What Is the Company Endpoint?
The Company endpoint is a set of API routes under /v1/organizations/ that allows enterprise administrators to:
- Retrieve organization details and settings
- List and manage team members
- View API usage statistics across your organization
- Manage billing information (where applicable)
Prerequisites
Before you start, make sure you have:
- An Enterprise or Team Anthropic account
- An API key with admin privileges (generated from the Anthropic Console)
- Python 3.8+ or Node.js 16+ installed
- The
anthropicSDK installed (pip install anthropicornpm install @anthropic-ai/sdk)
Authentication
All Company endpoint requests require an API key with the appropriate permissions. You can generate an admin API key from the Anthropic Console under Settings > API Keys.
Important: Store your API key securely. Never hardcode it in client-side code or commit it to version control. Use environment variables instead.
Core Endpoints & Usage
1. Get Organization Details
Retrieve information about your organization, including name, ID, and settings.
Python Example:import os
from anthropic import Anthropic
client = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))
Get organization details
org = client.organizations.retrieve()
print(f"Organization: {org.name}")
print(f"ID: {org.id}")
print(f"Created: {org.created_at}")
TypeScript Example:
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
async function getOrgDetails() {
const org = await client.organizations.retrieve();
console.log(Organization: ${org.name});
console.log(ID: ${org.id});
}
getOrgDetails();
2. List Team Members
View all users associated with your organization, including their roles and status.
Python Example:# List all team members
members = client.organizations.members.list()
for member in members:
print(f"{member.email} - Role: {member.role} - Status: {member.status}")
TypeScript Example:
async function listMembers() {
const members = await client.organizations.members.list();
members.forEach(member => {
console.log(${member.email} - Role: ${member.role} - Status: ${member.status});
});
}
3. Monitor API Usage
Track how much your organization is using the Claude API across all members.
Python Example:# Get usage stats for the current month
usage = client.organizations.usage.retrieve({
"start_date": "2025-01-01",
"end_date": "2025-01-31"
})
print(f"Total tokens used: {usage.total_tokens}")
print(f"Input tokens: {usage.input_tokens}")
print(f"Output tokens: {usage.output_tokens}")
TypeScript Example:
async function getUsage() {
const usage = await client.organizations.usage.retrieve({
start_date: "2025-01-01",
end_date: "2025-01-31"
});
console.log(Total tokens: ${usage.total_tokens});
}
4. Manage Billing (Enterprise Only)
Enterprise accounts can also access billing information programmatically.
# Retrieve billing info
billing = client.organizations.billing.retrieve()
print(f"Plan: {billing.plan}")
print(f"Current balance: ${billing.balance}")
Error Handling
When working with the Company endpoint, you may encounter these common errors:
| Error Code | Meaning | Solution |
|---|---|---|
| 401 | Unauthorized | Check your API key permissions |
| 403 | Forbidden | Your account tier doesn't support this endpoint |
| 404 | Not Found | The organization ID is incorrect |
| 429 | Rate Limited | Slow down your requests |
from anthropic import Anthropic, APIError, APIConnectionError, RateLimitError
client = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))
try:
org = client.organizations.retrieve()
print(f"Success: {org.name}")
except RateLimitError:
print("Rate limit exceeded. Retrying after delay...")
time.sleep(5)
except APIConnectionError:
print("Network error. Check your connection.")
except APIError as e:
print(f"API error {e.status_code}: {e.message}")
Best Practices
- Cache organization data – Organization details rarely change. Cache the response for 5–10 minutes to reduce API calls.
- Use pagination – When listing members or usage data, always handle pagination to avoid incomplete results.
- Set up monitoring alerts – Use the usage endpoint to trigger alerts when your organization approaches token limits.
- Rotate API keys regularly – For security, rotate admin API keys every 90 days.
- Log responsibly – Never log API keys or sensitive member data.
Real-World Use Case: Automated Usage Dashboard
Here's a complete example that builds a simple usage dashboard for your organization:
import os
from datetime import datetime, timedelta
from anthropic import Anthropic
client = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))
def generate_daily_report():
# Get organization info
org = client.organizations.retrieve()
# Get usage for last 7 days
end_date = datetime.now().strftime("%Y-%m-%d")
start_date = (datetime.now() - timedelta(days=7)).strftime("%Y-%m-%d")
usage = client.organizations.usage.retrieve(
start_date=start_date,
end_date=end_date
)
# Get member list
members = client.organizations.members.list()
print(f"=== {org.name} Usage Report ===")
print(f"Period: {start_date} to {end_date}")
print(f"Total tokens: {usage.total_tokens:,}")
print(f"Active members: {len([m for m in members if m.status == 'active'])}")
print(f"Total members: {len(members)}")
return {
"organization": org.name,
"total_tokens": usage.total_tokens,
"active_members": len([m for m in members if m.status == 'active'])
}
if __name__ == "__main__":
report = generate_daily_report()
print(f"Report generated for {report['organization']}")
Limitations & Considerations
- Rate limits: The Company endpoint has stricter rate limits than the chat completions endpoint. Check your plan's documentation for specifics.
- Data freshness: Usage data may have a delay of up to 5 minutes.
- Member management: Adding/removing members via the API may require additional permissions.
Conclusion
The Company endpoint is a powerful tool for enterprise teams using Claude AI at scale. By integrating it into your internal dashboards, monitoring systems, and CI/CD pipelines, you can maintain full visibility and control over your organization's AI usage.
Key Takeaways
- The Company endpoint provides programmatic access to organization details, team members, usage stats, and billing for enterprise accounts.
- Authentication requires an admin-level API key; always store keys securely using environment variables.
- Use the
/v1/organizations/usageendpoint to track token consumption and set up proactive monitoring alerts. - Implement proper error handling for common HTTP errors like 401 (unauthorized) and 429 (rate limited).
- Cache organization data and use pagination to optimize API calls and avoid incomplete results.