Skip to main content

Overview

The Junis External API uses API Keys for authentication. All API requests must include a valid API key in the X-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 DashboardAPI 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

IMPORTANT: Copy the API key and store it securely. Treat it like a password — anyone with the key can act with its permissions.
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 the X-Organization-Id header; 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 the X-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 and delete — are granted by updating the key (ask your organization admin). For partner scopes, see below.
Updating scopes replaces the whole list. Send every scope the key should keep, not just the ones you are adding. Unknown scope names are rejected so a typo cannot leave a key permanently locked out, and an empty list is refused unless you explicitly confirm it — to disable a key, deactivate it instead of stripping its scopes.
Partner scopes are opt-in only: users:provision, users:delegate and sessions:delete are never included in any default scope set, and are intended for trusted partner services that manage end-user accounts.To get them, create an organization key from Dashboard → API Keys → New Key with “Connect users from my own app” ticked. A key created without that checkbox does not carry them. See User Provisioning.

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:
See Rate Limits for detailed documentation.

Security Best Practices

  • Never commit API keys to Git repositories
  • Store keys in environment variables or secret management systems (e.g., AWS Secrets Manager, HashiCorp Vault)
  • Use .env files for local development (add to .gitignore)
  • Rotate keys regularly (every 90 days recommended)
  • All API requests must use HTTPS
  • Never send API keys over unencrypted HTTP
  • Our API automatically rejects non-HTTPS requests
  • 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
  • Check the API Keys page for usage statistics
  • Review last_used_at and request_count regularly
  • Set up alerts for unusual activity (e.g., sudden spike in requests)
If an API key is compromised:
  1. Immediately revoke the key in Admin → API Keys
  2. Create a new key with a different name
  3. Update all applications to use the new key
  4. Review logs for suspicious activity (unusual endpoints, high request counts)
  • Only grant scopes that are actually needed
  • For read-only integrations, use sessions:read and sessions:messages only
  • Avoid granting admin:write unless 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_after seconds)

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