Core Concepts
Authentication
The One Tribe Carbon Offset Projects API uses API key-based authentication for all endpoints. Every request must include your API key in the headers.
Authentication Header
| Header Name | Format | Example |
|---|---|---|
Authorisation | API-Key YOUR_API_KEY_HERE | Authorisation: API-Key abc123def456 |
Example Request
Using curl
curl "https://api.onetribe.com/v1/projects/offset" \
-H "Authorisation: API-Key YOUR_API_KEY_HERE"
Using TypeScript
class OneTribeClient {
private baseUrl = 'https://api.onetribe.com/v1'
private headers: HeadersInit
constructor(apiKey: string) {
this.headers = {
Authorisation: `API-Key ${apiKey}`,
'Content-Type': 'application/json',
}
}
async fetch<T>(endpoint: string, options: RequestInit = {}): Promise<T> {
const response = await fetch(`${this.baseUrl}${endpoint}`, {
...options,
headers: {
...this.headers,
...options.headers,
},
})
if (!response.ok) {
throw new Error(`API error: ${response.status} ${response.statusText}`)
}
return response.json()
}
}
// Example usage
const client = new OneTribeClient('YOUR_API_KEY_HERE')
// Making authenticated requests
try {
const projects = await client.fetch('/projects/offset')
console.log('Projects:', projects)
} catch (error) {
console.error('Authentication error:', error)
}
Note: Never share your API key publicly or commit it to version control.
Error Responses
| Status Code | Error Code | Description |
|---|---|---|
| 401 | Unauthorized | Missing API key or invalid API key format |
| 403 | Forbidden | Valid API key format but the key is invalid or has been revoked |
| 429 | TooManyRequests | Rate limit exceeded - please wait before making more requests |
Please see our rate limiting docs for more details.
Security Guidelines
| Guideline | Description |
|---|---|
| Storage | Never store API keys in public repositories or client-side code |
| Environment Variables | Use environment variables or secure secret management systems |
| Access Control | Restrict API key access to only the necessary team members |
| Regular Rotation | Rotate API keys periodically and immediately if compromised |