API Key Authentication
All API requests must include your API key in theX-API-Key header.
Key Types
| Prefix | Environment | Purpose |
|---|---|---|
pk_live_ | Production | Live shipments with real carriers |
pk_test_ | Sandbox | Testing without creating real shipments |
Getting Your API Key
1
Login to Dashboard
Visit dashboard.crbtrack.com
2
Go to API Keys
Navigate to Settings → API Keys
3
Generate Key
Click Generate New Key and configure:
- Name: A descriptive name (e.g., “Production Website”)
- Countries: Which countries this key can ship to
- IP Whitelist: Optional IP restrictions
4
Save Securely
The full key is shown only once. Save it immediately.
Key Security Best Practices
Use Environment Variables
Use Environment Variables
Never hardcode API keys in your source code.
Restrict by IP
Restrict by IP
In the dashboard, add your server’s IP addresses to the whitelist. Requests from other IPs will be rejected.
Rotate Keys Regularly
Rotate Keys Regularly
Generate new keys periodically and revoke old ones. This limits exposure if a key is compromised.
Never Expose Client-Side
Never Expose Client-Side
API keys should only be used server-side. Never include them in:
- Browser JavaScript
- Mobile app bundles
- Public repositories
Country Access Control
Each API key is restricted to specific destination countries. This is configured when generating the key.| Allowed Countries | What It Means |
|---|---|
EC, MX, CO | Can create orders shipping to Ecuador, Mexico, Colombia |
* (All) | Can ship to any supported country |
Rate Limiting Headers
Every response includes rate limit information:| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per window |
X-RateLimit-Remaining | Requests remaining in current window |
X-RateLimit-Reset | Unix timestamp when the limit resets |
Error Responses
Invalid API Key
401 Unauthorized
Missing API Key
401 Unauthorized
Rate Limit Exceeded
429 Too Many Requests