Overview
API keys provide project-scoped authentication for programmatic access to Orquestra. Unlike JWTs, which are user-scoped and short-lived, API keys are permanent (or have custom expiration) and tied to a specific project.Use Cases
CI/CD Pipelines
Automate transaction building and testing in your deployment workflows.
Backend Services
Server-to-server API calls without user authentication.
Bots & Automation
Automated scripts and tools that interact with your Solana program.
Third-Party Integrations
Share access with external services without exposing user credentials.
Authentication
API keys use theX-API-Key header for authentication:
Create API Key
Generate a new API key for a project.Endpoint
Authentication
Requires JWT authentication. Only project owners can create API keys.Request Body
Optional expiration time in days. If not provided, the key never expires.Example:
90 for a 90-day expirationResponse
API key ID
The API key (only shown once)
Creation timestamp (ISO 8601)
Expiration timestamp (ISO 8601) or null if never expires
Warning to store the key securely
Example
Response Example
List API Keys
Retrieve all API keys for a project.Endpoint
Authentication
Requires JWT authentication. Only project owners can list API keys.Response
List of API keys
Example
cURL
Response Example
Delete API Key
Revoke an API key immediately.Endpoint
Authentication
Requires JWT authentication. Only project owners can delete API keys.Example
cURL
Response Example
Rotate API Key
Generate a new key value for an existing key ID.Endpoint
Authentication
Requires JWT authentication. Only project owners can rotate API keys.Response
API key ID (unchanged)
New API key value (only shown once)
Warning to store the new key
Example
cURL
Response Example
Using API Keys
API keys are validated using theapiKeyMiddleware and provide project-scoped access.
Middleware Behavior
- Extracts the API key from the
X-API-Keyheader - Queries the database for a matching key
- Checks expiration (
expires_atmust be null or in the future) - Updates
last_usedtimestamp - Sets context variables:
apiKeyProjectId: The project IDapiKeyUserId: The user ID who owns the project
Supported Endpoints
Currently, API keys are primarily used for project management endpoints. Transaction building and PDA derivation endpoints are public and don’t require authentication.
apiKeyMiddleware. Check individual endpoint documentation for authentication requirements.
Example: Building a Transaction with API Key
Key Format
API keys are generated using cryptographically secure random bytes:- Prefix:
b58_(for identification) - Length: 68 characters total (4 prefix + 64 hex)
- Entropy: 32 bytes (256 bits) of randomness
Security Best Practices
Store API keys securely
Store API keys securely
- Use environment variables or secret management services
- Never commit API keys to version control
- Use
.envfiles and add them to.gitignore - Rotate keys if accidentally exposed
Use expiration for temporary access
Use expiration for temporary access
- Set
expiresInDayswhen creating keys for temporary use - Short-lived keys reduce risk if compromised
- Review and delete expired keys regularly
Limit key scope
Limit key scope
- Create separate keys for different services
- One key per project for easier tracking
- Delete keys when no longer needed
Monitor key usage
Monitor key usage
- Check
last_usedtimestamps to detect unused keys - Track which services are using which keys
- Investigate unexpected usage patterns
Rotate keys regularly
Rotate keys regularly
- Rotate keys every 90 days as a best practice
- Rotate immediately if you suspect compromise
- Update all services using the old key
Error Responses
401 Unauthorized
Missing API Key
401 Unauthorized
Invalid or Expired API Key
403 Forbidden
Insufficient Permissions
404 Not Found
Project or Key Not Found
Comparison: API Keys vs JWT
| Feature | API Key | JWT |
|---|---|---|
| Scope | Project-specific | User-wide |
| Lifetime | Permanent or custom | 7 days |
| Revocation | Immediate (delete anytime) | Cannot revoke |
| Use Case | Programmatic access | User authentication |
| Header | X-API-Key: <key> | Authorization: Bearer <token> |
| Creation | Owner via API | OAuth flow |
| Best For | CI/CD, bots, backend services | Web apps, mobile apps |
| Tracking | Last used timestamp | No tracking |
Implementation Reference
API key authentication is implemented in/packages/worker/src/middleware/auth.ts:
Related Endpoints
- JWT Authentication - User authentication
- GitHub OAuth - Obtain a JWT token
- Build Transaction - Use API keys for transaction building