Overview
The Junis External API uses API Keys for authentication. All API requests must include a valid API key in theX-API-Key header.
Junis has two kinds of API keys: organization keys (
jns_live_) bound to a single
organization, and user keys (jns_user_) that work across all organizations you
belong to. See Organization vs User API Keys below.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
Organization vs User API Keys
- Organization keys (
jns_live_) always act within the organization they were created in. - User keys (
jns_user_) act as you, across every organization you belong to. Select which organization a request targets with theX-Organization-Idheader; if omitted, your current organization is used.
cURL — user key targeting a specific organization
User keys are what Junis Magic uses — one key, all your squads.
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:Default Scopes: Organization keys created from the dashboard include:
orchestrator:invoke, orchestrator:stream, sessions:read, sessions:messages,
agents:list, agents:invoke, content:read, content:retry.User keys include a broader default set covering management operations (used by Junis Magic).
Additional scopes — RAG, delete, and partner scopes — are granted by updating the key
(ask your organization admin).Scope Requirements by Endpoint
Rate Limits
API keys are subject to rate limits to ensure fair usage and system stability.Default Rate Limits
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)
Next Steps
Chat Completions API
Start sending messages to your agents
Sessions API
Retrieve and manage chat sessions
Rate Limits
Understand rate limiting and best practices
Error Codes
Full list of error codes and solutions
