Overview
The Junis External API uses API Keys for authentication. All API requests must include a valid API key in theX-API-Key header.
API keys are organization-scoped. Each key belongs to a specific organization and can only access that organization’s resources.
API Key Authentication
Creating an API Key
1
Navigate to API Keys Page
Go to Dashboard → API Keys in the Junis dashboard
2
Click Create New API Key
Click the ”+ Create API Key” buttonFill in the form:
- Name: A descriptive name for the key (e.g., “Production API”, “Testing”)
- Description: Optional notes about the key’s purpose
- Scopes: Select permissions (default: all external API scopes enabled)
- Rate Limits: Configure requests per minute/hour (optional)
3
Copy the API Key
The key format is:
jns_live_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX (32 random characters)API Key Format
| Prefix | Purpose | Example |
|---|---|---|
jns_live_ | Production keys | jns_live_abc123... (32 chars) |
API keys are hashed using bcrypt before storage. The plaintext key cannot be retrieved after creation.
Using API Keys
Include your API key in theX-API-Key header:
cURL
API Key Permissions (Scopes)
Available Scopes
API keys can have granular permissions. Each scope grants access to specific API operations:| Scope | Description | Required For |
|---|---|---|
orchestrator:invoke | Invoke orchestrator with prompts (non-streaming) | Chat Completions (non-streaming) |
orchestrator:stream | Stream orchestrator responses (SSE) | Chat Completions (streaming) |
sessions:read | Read chat sessions | List sessions, Get session status |
sessions:messages | Read session messages | Get session messages |
content:read | Read generated content | List content, Get content detail |
content:retry | Retry failed content generation | Retry content generation |
agents:list | List available agents in organization | List agents |
agents:invoke | Invoke specific agents directly | Agent completions |
admin:read | Read admin resources (organization-scoped) | Admin endpoints (if accessible) |
admin:write | Write admin resources (organization-scoped) | Admin endpoints (if accessible) |
Default Scopes: New API keys are created with the following scopes enabled by default:
orchestrator:invokeorchestrator:streamsessions:readsessions:messagesagents:listagents:invoke
content:read, content:retry), you need to explicitly enable these scopes when creating or updating a key.Scope Requirements by Endpoint
| Endpoint | Required Scopes |
|---|---|
POST /api/external/v1/chat/completions (non-streaming) | orchestrator:invoke |
POST /api/external/v1/chat/completions (streaming) | orchestrator:invoke, orchestrator:stream |
GET /api/external/sessions | sessions:read |
GET /api/external/sessions/{id}/messages | sessions:messages |
GET /api/external/sessions/{id}/status | sessions:read |
GET /api/external/content | content:read |
GET /api/external/content/{id} | content:read |
POST /api/external/content/{id}/retry | content:retry |
GET /api/external/agents | agents:list |
POST /api/external/agents/{id}/completions (non-streaming) | agents:invoke |
POST /api/external/agents/{id}/completions (streaming) | agents:invoke |
Rate Limits
API keys are subject to rate limits to ensure fair usage and system stability.Default Rate Limits
| Limit Type | Default Value | Customizable |
|---|---|---|
| Requests per minute | 100 | Yes (when creating API key) |
| Requests per hour | 1,000 | Yes (when creating API key) |
Rate limits are configurable per API key. Contact your organization admin to adjust limits if needed.
Rate Limit Headers
All API responses include rate limit information in headers:Security Best Practices
Keep API Keys Secret
Keep API Keys Secret
- Never commit API keys to Git repositories
- Store keys in environment variables or secret management systems (e.g., AWS Secrets Manager, HashiCorp Vault)
- Use
.envfiles for local development (add to.gitignore) - Rotate keys regularly (every 90 days recommended)
Use HTTPS Only
Use HTTPS Only
- All API requests must use HTTPS
- Never send API keys over unencrypted HTTP
- Our API automatically rejects non-HTTPS requests
Separate Keys for Different Environments
Separate Keys for Different Environments
- Create separate keys for development, staging, and production
- Use descriptive names to identify key purposes (e.g., “Prod - Web App”, “Dev - Testing”)
- Revoke unused keys immediately
Monitor Key Usage
Monitor Key Usage
- Check the API Keys page for usage statistics
- Review
last_used_atandrequest_countregularly - Set up alerts for unusual activity (e.g., sudden spike in requests)
Revoke Compromised Keys
Revoke Compromised Keys
If an API key is compromised:
- Immediately revoke the key in Admin → API Keys
- Create a new key with a different name
- Update all applications to use the new key
- Review logs for suspicious activity (unusual endpoints, high request counts)
Principle of Least Privilege
Principle of Least Privilege
- Only grant scopes that are actually needed
- For read-only integrations, use
sessions:readandsessions:messagesonly - Avoid granting
admin:writeunless absolutely necessary
Error Handling
Common Authentication Errors
Handling Errors in Code
When you receive an error response, check the HTTP status code and error message to determine the cause. Common error codes:- 401 Unauthorized: Invalid or missing API key
- 403 Forbidden: Insufficient scopes/permissions
- 429 Too Many Requests: Rate limit exceeded (wait for
retry_afterseconds)
