Key Format
API keys follow the formatbunship_live_<32 hex characters>:
bunship_live_ (or bunship_test_ for test mode) makes keys identifiable in logs and configuration files. Only the first 8 characters of the random portion are stored as the display prefix:
Creating API Keys
Create a key by providing a name, optional scopes, and optional expiration:Scopes and Permissions
API keys use a scope-based permission model. Each scope follows the patternaction:resource:
Scope checking uses a deny-by-default model. A key with no scopes is denied access to all resources:
Grant only the scopes each key needs. A deployment pipeline that only reads project data should
not have
write:members access.Authentication
Authenticate API requests by passing the key in theX-API-Key header:
1
Hashing the provided key
The raw key is hashed with SHA-256 to produce a digest.
2
Looking up the hash
The hash is compared against stored key hashes in the database.
3
Checking key status
The key must be active and not expired.
4
Updating last used timestamp
On successful validation, the
lastUsedAt field is updated for usage tracking.Key Rotation
To rotate a key, create a new one, update your application to use it, then revoke the old key:1
Create a new API key
2
Deploy the new key
Update your application or CI/CD pipeline with the new key.
3
Revoke the old key
Usage Tracking
Each API key tracks when it was last used. Query usage statistics for a specific key:actorType: "api_key".
Security Details
BunShip applies several measures to protect API keys:SHA-256 hashing
SHA-256 hashing
Keys are hashed with SHA-256 before storage. The database never contains the raw key. Even if the database is compromised, the keys cannot be reversed.
Prefix-only display
Prefix-only display
After creation, the API only shows the key prefix (e.g.,
bunship_live_a1b2c3d4). The full key is never returned again.Automatic expiration
Automatic expiration
Keys can be given an expiration date. Expired keys are rejected during validation without any manual intervention.
Rate limiting
Rate limiting
Each key can have an individual rate limit. The middleware enforces this alongside global rate limits.

