Skip to main content
BunShip provides API key management for programmatic access. Keys are scoped to organizations, support granular permissions, and track usage automatically.

Key Format

API keys follow the format bunship_live_<32 hex characters>:
The prefix 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:
API call:
The full API key is returned only once in the creation response. BunShip stores a SHA-256 hash of the key, not the key itself. There is no way to retrieve the full key after creation.
Response:

Scopes and Permissions

API keys use a scope-based permission model. Each scope follows the pattern action: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 the X-API-Key header:
BunShip validates the key by:
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

Revocation is immediate. Any in-flight requests using the old key will fail after revocation.

Usage Tracking

Each API key tracks when it was last used. Query usage statistics for a specific key:
Response:
API key actions are also recorded in the audit log. Every request authenticated with an API key creates an audit entry with actorType: "api_key".

Security Details

BunShip applies several measures to protect API keys:
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.
After creation, the API only shows the key prefix (e.g., bunship_live_a1b2c3d4). The full key is never returned again.
Keys can be given an expiration date. Expired keys are rejected during validation without any manual intervention.
Each key can have an individual rate limit. The middleware enforces this alongside global rate limits.

Plan Limits

API key counts are enforced per plan: