Overview
FIM One API supports two authentication methods:- API Keys — Simple, long-lived tokens for service-to-service integration
- JWT Tokens — Short-lived tokens from user login (for SSE endpoints)
API Keys
API keys are long-lived credentials tied to your user account. They’re ideal for:- Server-to-server integrations
- Scheduled scripts and automation
- External applications accessing FIM One
Creating an API Key
- Log in to your FIM One portal
- Go to Settings → API Keys
- Click Create API Key
- Enter a name (e.g., “Production Integration”)
- (Optional) Set scopes to limit access
- (Optional) Set an expiration date
- Click Create
- Copy the key immediately — it’s only shown once
fim_your44characterkeystringhere (starts with fim_ prefix)
Using API Keys
Include the key in theAuthorization header as a Bearer token:
API Key Features
Visibility: Each key shows:- Key prefix (first 8 chars for identification)
- Creation date
- Last used timestamp
- Total request count
- Active status
- Expiration date (if set)
- Enable/disable keys without deleting them
- Set automatic expiration dates
- Delete keys permanently
- Track usage patterns
Scopes
Scopes limit what an API key can access. If no scopes are set, the key has full access. A key with scopes can call only the endpoints its scopes allow. Every other endpoint answers403, including API key management under /api/me/api-keys, which needs a key without scopes or a signed-in session. A key can never create a key with broader scopes than its own.
Available scopes:
Create a key with scopes:
JWT Tokens
JWT tokens are short-lived and issued at login. They’re used for:- SSE Streaming Endpoints: Pass tokens in the request body for
/api/react,/api/dagand/api/auto - Portal Session: Frontend authentication
Getting a JWT Token
JWT tokens are automatically issued when you log in through the web portal or call the authentication endpoint:Two-factor authentication
When the account has two-factor authentication enabled, sign-in does not return tokens.POST /api/auth/login and POST /api/auth/login-with-code answer with a short-lived temporary token instead:
429 with error_code 2fa_too_many_attempts; starting a new sign-in does not reset the count.
Using JWT for Streaming
For SSE endpoints, include the token in the request body. The field accepts a JWT access token or an API key (a scoped key needs thechat scope):
fetch with a readable stream (the endpoint is POST-only, so native EventSource which only supports GET cannot be used):
Token Refresh
Access tokens expire after 2 hours. Use the refresh token to get a new access token without re-logging in:Security Best Practices
API Keys
-
Store in environment variables:
Then reference in code:
-
Use key rotation:
- Create a new key
- Update your application
- Delete the old key
- Repeat quarterly
-
Set expiration dates:
- Use short-lived keys for temporary integrations
- Require re-authentication periodically
-
Use scoped keys:
- Don’t use “full access” keys unless necessary
- Create separate keys for different services
- Limits damage if a key is compromised
-
Monitor usage:
- Check “last used” timestamps
- Review request counts
- Delete unused keys
JWT Tokens
- Keep short-lived: Access tokens expire after 2 hours
- Secure storage:
- In browsers: use HttpOnly cookies (safer than localStorage)
- In servers: use secure session storage
- Never expose in logs: Log only the token prefix, not the full token
- Use HTTPS only: Never send tokens over unencrypted connections
Rate Limits
Per-key rate limiting is planned for a future release. Currently there are no enforced per-key request limits.Troubleshooting
Every error response has the shape{"detail", "error_code", "error_args"}. Errors raised while checking the Authorization header carry error_code: null; tell them apart by the status code and detail.
Invalid Token Error
401; detail is Invalid token, Invalid API key, API key is disabled or API key has expired):
- API key prefix is wrong (must start with
fim_) - Token is malformed or corrupted
- API key has been deleted, disabled, or is past its expiration date
Unauthorized Error
401):
- Token is missing from the request body (SSE endpoints return the body above)
- No
Authorizationheader provided (other endpoints answerNot authenticatedwitherror_code: null)
Forbidden Error
403):
- API key has scoped access and lacks the required scope (
api_key_scope_denied) - The client address is refused by the instance’s IP rules (
ip_not_allowed, see below) - The account is disabled (
detail:Account disabled) or lacks the role the endpoint needs
IP Rules
Administrators can restrict API access by client address under admin Security → IP Rules. A request from an address that matches a deny rule, or that matches no allow rule when allow rules exist, is refused before authentication:/api/version, /api/webhooks/ and CORS preflight requests are exempt. Behind a reverse proxy the instance must be told which proxy to trust (FORWARDED_ALLOW_IPS), otherwise every request appears to come from the proxy; see Environment Variables.
Expired Token
error_code token_expired.
Solution: Use the refresh token to get a new access token:
Environment Variable Setup
Python
Node.js
Bash
Support
For authentication issues:- Check the API Overview for response format details
- Check that a token is still accepted with
GET /api/auth/me - Contact support if you believe a key has been compromised