Authentication Methods
Orquestra API supports two authentication methods:- JWT Tokens - For user sessions (web applications)
- API Keys - For programmatic access (scripts, integrations)
JWT Token Authentication
JWT (JSON Web Token) authentication is used for user sessions after GitHub OAuth login.How It Works
- User authenticates via GitHub OAuth
- API generates a JWT token valid for 7 days
- Client includes token in
Authorizationheader - API validates token signature and expiration
Token Structure
JWT tokens contain:User ID (subject)
GitHub username
Issued at timestamp (Unix seconds)
Expiration timestamp (Unix seconds)
Authorization Header Format
Example Request
GitHub OAuth Flow
Initiate Login
Redirect user to GitHub OAuth:This redirects to GitHub with:
client_id- Your GitHub OAuth application IDredirect_uri- Callback URL (/auth/github/callback)scope-user:email read:user
GitHub Authorization
User authorizes the application on GitHub. GitHub redirects back with an authorization code.
Exchange Code for Token
For web applications (browser redirect):Redirects to frontend with JWT token:For API clients (JSON response):Response:
Get Current User Profile
Retrieve authenticated user information:Token Expiration
JWT tokens expire after 7 days. When a token expires:401 Unauthorized
Users must re-authenticate via GitHub OAuth to get a new token.
Error Responses
401 - Missing Authorization
Authorization header is missing or doesn’t start with Bearer.401 - Invalid Token
API Key Authentication
API keys provide programmatic access to your projects without requiring user authentication. They’re ideal for:- CI/CD pipelines
- Backend services
- Automation scripts
- Third-party integrations
How It Works
- Owner creates API key for a specific project
- Key is shown once and must be stored securely
- Key is included in
X-API-Keyheader - API validates key and associates requests with the project
API Key Format
API keys are 64-character hex strings prefixed withb58_:
Creating an API Key
You must be the project owner and authenticated with a JWT token to create API keys.
Number of days until key expires. Omit for no expiration.
Using an API Key
Include the API key in theX-API-Key header:
Listing API Keys
List all API keys for a project (requires JWT authentication):API keys are masked in list responses, showing only the last 8 characters for identification.
Rotating an API Key
Generate a new key value while keeping the same key ID:Deleting an API Key
API Key Tracking
Each time an API key is used, thelast_used timestamp is updated. Monitor key usage to:
- Detect unauthorized access
- Identify unused keys for cleanup
- Track integration activity
Error Responses
401 - Missing API Key
X-API-Key header is not present in the request.401 - Invalid API Key
500 - Authentication Failed
Optional Authentication
Some endpoints support optional authentication. They work without authentication but provide additional features when authenticated:GET /api/projects- Shows public projects + your private projects if authenticatedGET /api/projects/:projectId- ReturnsisOwnerflag and API key count if you’re the ownerGET /api/:projectId/docs- Shows custom docs for private projects if you’re the owner
Example: Optional Auth Behavior
Security Best Practices
Store credentials securely
Store credentials securely
- Never commit JWT tokens or API keys to version control
- Use environment variables or secure secret management
- For frontend apps, use secure HTTP-only cookies when possible
Use HTTPS only
Use HTTPS only
- Always access the API over HTTPS
- Never send credentials over unencrypted connections
- The API enforces HTTPS in production
Rotate keys regularly
Rotate keys regularly
- Rotate API keys periodically (e.g., every 90 days)
- Delete unused or compromised keys immediately
- Use the rotation endpoint to update keys without downtime
Limit key scope
Limit key scope
- Create separate API keys for different integrations
- Set expiration dates on keys when possible
- Monitor
last_usedtimestamps to detect anomalies
Handle token expiration
Handle token expiration
- Implement automatic token refresh in your application
- Provide clear error messages when tokens expire
- Redirect users to re-authenticate when needed
Authentication Example: Complete Flow
Here’s a complete example of authenticating and using the API:Next Steps
Projects
Learn how to manage projects and upload IDLs
Instructions
Build transactions and interact with program instructions