API Keys
API keys authenticate your requests to create attestations. This guide covers how to get keys, manage them securely, and handle common scenarios.Getting Your First Key
Step 1: Request a Verification Code
Step 2: Verify and Get Your Key
Using Your Key
Environment Variable (Recommended)
Python SDK
CLI
Direct API
Managing Keys
Check Key Status
Revoke a Key
If a key is compromised or no longer needed:Rate Limits
| Limit | Value |
|---|---|
| Attestations per day | 1,000 |
| Attestations per minute | 100 |
- Response:
429 Too Many Requests - Header:
Retry-After: <seconds>
Best Practices
Do
Use Environment Variables
Never hardcode keys in source code.
Use Different Keys Per Environment
Separate keys for dev, staging, prod.
Rotate Keys Regularly
Generate new keys periodically.
Monitor Usage
Check
/keys/info to track attestation counts.Don’t
Commit Keys to Git
Add
.env to .gitignore.Share Keys Across Services
Each service should have its own key.
Log Full Keys
Log only key prefixes:
ts_live_a1b2....Ignore Revocation
Revoke keys immediately if compromised.
Key Format
Treeship keys follow this format:ts_- Treeship identifierlive_- Environment (live = production)- Remaining: 256 bits of cryptographically random data
- Easy to identify in logs and code
- Hard to accidentally expose (distinct prefix)
- Impossible to guess (256-bit entropy)
Multiple Keys
You can have multiple active keys. Common patterns:| Pattern | Keys |
|---|---|
| Per environment | dev-key, staging-key, prod-key |
| Per service | agent-a-key, agent-b-key |
| Per team member | Individual keys for testing |