How to Use the Company Endpoint in the Claude API: A Practical Guide
Learn how to leverage the Company endpoint in the Claude API to retrieve organization-level metadata, manage team resources, and streamline your AI workflow with practical code examples.
This guide explains how to use the Company endpoint in the Claude API to access organization details, manage API keys, and retrieve usage statistics. You'll get practical code examples in Python and TypeScript, plus best practices for integrating this endpoint into your workflow.
How to Use the Company Endpoint in the Claude API: A Practical Guide
When building applications with the Claude API, understanding how to manage your organization's resources is just as important as crafting the perfect prompt. The Company endpoint is a powerful but often overlooked feature that lets you retrieve metadata about your organization, manage API keys, and monitor usage—all from within your code.
In this guide, you'll learn what the Company endpoint is, how to call it, and how to integrate it into your Claude AI workflow with practical examples.
What Is the Company Endpoint?
The Company endpoint (/v1/organizations/company) provides programmatic access to your organization's profile within the Anthropic ecosystem. Think of it as the administrative dashboard for your Claude API usage, accessible via API calls.
Key capabilities include:
- Retrieving organization name, ID, and settings
- Listing active API keys associated with your organization
- Viewing usage quotas and current consumption
- Managing team members (in enterprise plans)
- Automated monitoring: Track API usage without logging into the console
- Multi-tenant applications: Dynamically switch between organizations
- CI/CD pipelines: Validate API key permissions before deployment
- Billing integrations: Pull usage data for internal cost tracking
Prerequisites
Before you start, make sure you have:
- An Anthropic API key – Get one from the Anthropic Console
- API access enabled – Your organization must have API access (most paid plans do)
- Appropriate permissions – You need admin or billing-level permissions to access certain Company endpoint data
Making Your First Company Endpoint Call
Let's start with a simple request to retrieve your organization's information.
Python Example
import requests
API_KEY = "sk-ant-..." # Replace with your actual API key
headers = {
"x-api-key": API_KEY,
"anthropic-version": "2023-06-01"
}
response = requests.get(
"https://api.anthropic.com/v1/organizations/company",
headers=headers
)
if response.status_code == 200:
company_data = response.json()
print(f"Organization: {company_data['name']}")
print(f"ID: {company_data['id']}")
print(f"Plan: {company_data['plan']}")
else:
print(f"Error: {response.status_code} - {response.text}")
TypeScript Example
const API_KEY = "sk-ant-...";
async function getCompanyInfo() {
const response = await fetch(
"https://api.anthropic.com/v1/organizations/company",
{
headers: {
"x-api-key": API_KEY,
"anthropic-version": "2023-06-01"
}
}
);
if (response.ok) {
const data = await response.json();
console.log(Organization: ${data.name});
console.log(Plan: ${data.plan});
return data;
} else {
console.error(Error: ${response.status});
}
}
getCompanyInfo();
Expected Response
A successful response looks like this:
{
"id": "org_abc123",
"name": "Acme Corp",
"plan": "enterprise",
"created_at": "2024-01-15T10:30:00Z",
"settings": {
"rate_limits": {
"requests_per_minute": 1000,
"tokens_per_minute": 100000
},
"features": ["extended_thinking", "structured_outputs"]
}
}
Advanced Usage: Listing API Keys and Usage
Beyond basic metadata, the Company endpoint can help you manage API keys and track usage.
Retrieving API Keys
response = requests.get(
"https://api.anthropic.com/v1/organizations/company/api_keys",
headers=headers
)
if response.status_code == 200:
keys = response.json()['data']
for key in keys:
print(f"Key: {key['id'][:8]}... - Status: {key['status']}")
print(f" Created: {key['created_at']}")
print(f" Last used: {key.get('last_used_at', 'Never')}")
Checking Usage Quotas
response = requests.get(
"https://api.anthropic.com/v1/organizations/company/usage",
headers=headers
)
if response.status_code == 200:
usage = response.json()
print(f"Tokens used this month: {usage['tokens_used']}")
print(f"Tokens remaining: {usage['tokens_remaining']}")
print(f"Reset date: {usage['reset_date']}")
Practical Use Cases
1. Automated Cost Monitoring
Set up a cron job that checks your usage daily and alerts you if you're approaching your limit:
import smtplib
def check_usage_and_alert():
usage = get_usage() # Using the function above
threshold = 0.8 # 80% usage
if usage['tokens_used'] / usage['tokens_limit'] > threshold:
send_alert_email(
subject="Claude API Usage Alert",
body=f"You've used {usage['tokens_used']} of {usage['tokens_limit']} tokens."
)
2. Multi-Environment Management
If you have separate organizations for development, staging, and production, use the Company endpoint to validate which environment you're targeting:
def validate_environment(expected_org_name):
company = get_company_info()
if company['name'] != expected_org_name:
raise ValueError(
f"Expected organization '{expected_org_name}', "
f"but got '{company['name']}'"
)
print("Environment validated successfully")
3. Dynamic Rate Limit Handling
Retrieve your organization's rate limits and adjust your request pacing accordingly:
import time
def get_rate_limits():
company = get_company_info()
return company['settings']['rate_limits']
def paced_request(url, headers, data):
limits = get_rate_limits()
delay = 60 / limits['requests_per_minute']
time.sleep(delay)
return requests.post(url, headers=headers, json=data)
Best Practices
- Cache the response – Company metadata doesn't change often. Cache it for 5-10 minutes to reduce API calls.
- Handle errors gracefully – The endpoint may return 403 if your API key lacks permissions. Always check for errors.
- Use environment variables – Never hardcode API keys. Use
.envfiles or secret managers.
- Respect rate limits – Even administrative endpoints have rate limits. Use exponential backoff for retries.
- Log responsibly – Don't log full API keys. Mask them as
sk-ant-...xxxx.
Troubleshooting Common Issues
| Error | Likely Cause | Solution |
|---|---|---|
403 Forbidden | Insufficient permissions | Check your API key role in the Console |
404 Not Found | Wrong endpoint URL | Verify the URL: https://api.anthropic.com/v1/organizations/company |
429 Too Many Requests | Rate limit exceeded | Implement retry with backoff |
401 Unauthorized | Invalid API key | Regenerate your key in the Console |
Conclusion
The Company endpoint is a valuable tool for any developer building with the Claude API. Whether you're monitoring costs, managing multi-environment setups, or building internal tooling, this endpoint gives you programmatic access to the administrative data you need.
Start by integrating the basic metadata retrieval into your application, then expand to usage monitoring and key management as your needs grow.
Key Takeaways
- The Company endpoint provides programmatic access to your organization's metadata, API keys, and usage data
- Use it for automated cost monitoring, multi-environment validation, and dynamic rate limit handling
- Always cache responses and handle errors gracefully to build robust integrations
- The endpoint requires appropriate permissions—check your API key role in the Anthropic Console
- Combine the Company endpoint with other Claude API features like prompt caching and extended thinking for a complete workflow