Authentication¶
Secure your API requests with authentication.
API Key Authentication¶
Generating an API Key¶
API keys are personal access tokens for API requests.
- Log in to web interface
- Click Settings (gear icon)
- Go to API Keys
- Click Generate New Key
- Configure:
- Name: Identify the key (e.g., "Python Script")
- Expiration: When key expires (30 days, 90 days, 1 year, never)
- Permissions: Select what key can do
- Click Generate
- Copy the token (shown only once)
API Key Format¶
API keys are personal access tokens:
- Prefix:
fo_(File Organizer) - ID: unique identifier
- Token: secret portion
- Unique per key
Using Your API Key¶
Include API key in the X-API-Key header:
Security Note: Do not pass API keys in URL query parameters. Always use the
X-API-Keyheader.
API Key Permissions¶
Control what each API key can do:
Permission Levels¶
| Permission | Allows |
|---|---|
read:files | List and view files |
write:files | Upload files |
write:files:delete | Delete files |
read:organize | View organization jobs |
write:organize | Create organization jobs |
read:analyze | Run analysis |
read:search | Search files |
read:admin | View system info |
write:admin | Modify system settings |
Recommended Permissions¶
For Scripts:
read:filesread:searchread:organize
For Applications:
read:fileswrite:filesread:searchread:organize
For Admin Tools:
- All permissions (use with caution!)
Managing API Keys¶
View Your Keys¶
- Go to Settings → API Keys
- See all active keys:
- Name and creation date
- Expiration date
- Last used
- Permissions
- Actions
Revoke a Key¶
- Find key in API Keys list
- Click Revoke
- Confirm deletion
- Key is disabled immediately
- Any requests with this key fail
Rotate a Key¶
Generate a new key and revoke the old:
- Generate New Key with new permissions
- Update scripts/applications
- Revoke old key
- Verify everything works
Rate Limiting¶
API requests are rate-limited to prevent abuse.
Rate limits are configured in the application settings (ApiSettings).
- Default Limit: 1000 requests/minute
- Configurable: Administrators can adjust
rate_limit_default_requestsandrate_limit_rules.
Checking Rate Limits¶
Rate limits appear in response headers:
- Limit: Total requests per minute
- Remaining: Requests left in current window
- Reset: Unix timestamp when window resets
Handling Rate Limits¶
If you exceed the limit:
{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests",
"retryAfter": 60
}
}
Response:
- HTTP Status: 429 Too Many Requests
Retry-Afterheader indicates seconds to wait
Best Practices:
- Wait before retrying
- Use exponential backoff
- Batch requests when possible
- Consider upgrading tier
Error Responses¶
Unauthorized (401)¶
Causes:
- Missing API key
- Invalid API key
- Expired API key
- Revoked API key
Solutions:
- Check key is included
- Verify key format
- Generate new key if expired
- Check if key was revoked
Forbidden (403)¶
{
"success": false,
"error": {
"code": "FORBIDDEN",
"message": "Permission denied",
"details": {
"required": "write:files",
"granted": "read:files"
}
}
}
Causes:
- Key lacks required permission
- User lacks access to resource
Solutions:
- Regenerate key with needed permissions
- Use different key
- Contact administrator
Security Best Practices¶
Key Management¶
-
Keep Keys Secret
-
Don't commit to version control
- Don't share in messages
-
Store securely (environment variables)
-
Use Environment Variables
-
Rotate Regularly
-
Generate new keys periodically
- Revoke old keys
-
Update applications
-
Use Minimal Permissions
-
Only request needed permissions
- Create separate keys for different apps
- Review permissions regularly
Secure Storage¶
Python:
Node.js:
.env File:
API Key Expiration¶
Setting Expiration¶
When creating/regenerating key:
- Choose expiration time
- Options: 30 days, 90 days, 1 year, never
- Key expires automatically
Before Expiration¶
Receive notification:
- Email reminder (7 days before)
- Web interface warning
- API requests continue working
After Expiration¶
- Key becomes invalid
- API requests return 401
- Must generate new key
- Update applications
Scopes¶
Fine-grained permission scopes for advanced use:
Read Scopes¶
read:files- List files, view propertiesread:search- Search filesread:organize- View organization jobsread:analyze- Run analysis
Write Scopes¶
write:files- Upload fileswrite:files:delete- Delete fileswrite:organize- Create organization jobswrite:analyze- Create analysis jobs
Admin Scopes¶
read:admin- View system informationwrite:admin- Modify system settings