Troubleshooting
Solutions to common issues when working with the CORTEX API.
Authentication Issues
"Invalid or expired access token"
Cause: The access token has expired or is malformed.
Solution:
- Check if the token has expired (15-minute lifetime)
- Use the refresh token to get a new access token
- If refresh fails, log in again
if (response.status === 401) {
try {
await refreshTokens();
// Retry request
} catch {
// Redirect to login
}
}
"Account is temporarily locked"
Cause: Too many failed login attempts (5 within 15 minutes).
Solution:
- Wait 15 minutes for the lockout to expire
- Ensure you're using the correct password
- Contact admin if you've forgotten your password
"The email or password provided is incorrect"
Cause: Invalid credentials.
Solution:
- Verify the email address is correct
- Check for typos in the password
- Ensure Caps Lock is not on
- Use password reset if necessary
Permission Issues
"You do not have permission to perform this action"
Cause: Your role doesn't include the required permission.
Solution:
- Check your current roles:
GET /auth/me - Request the necessary role from your administrator
- Verify you're in the correct organization context
"Required permission: users:create"
Cause: Specific permission is missing.
Solution:
- Identify the required permission from the error
- Check if your role should have this permission
- Contact admin to grant the permission
Resource Issues
"The requested resource was not found" (404)
Causes:
- Resource doesn't exist
- Resource is in a different tenant
- Resource is in a different organization (and you don't have access)
Solution:
- Verify the resource ID is correct
- Check you're authenticated as the correct user
- Verify you have access to the organization containing the resource
"A user with this email already exists" (409)
Cause: Attempting to create a duplicate resource.
Solution:
- Check if the user already exists
- Use a different email address
- If the existing user should be updated, use PATCH instead
Validation Issues
"One or more fields failed validation"
Cause: Request body contains invalid data.
Solution:
- Check the
errorsarray in the response - Fix each validation error
- Ensure all required fields are present
{
"errors": [
{ "field": "email", "message": "must be a valid email" },
{ "field": "password", "message": "must be at least 8 characters" }
]
}
"Password must contain at least one..."
Cause: Password doesn't meet policy requirements.
Solution: Ensure password contains:
- Minimum 8 characters
- At least 1 uppercase letter (A-Z)
- At least 1 lowercase letter (a-z)
- At least 1 number (0-9)
- At least 1 special character (!@#$%^&*)
Rate Limiting
"Rate limit exceeded. Try again in X seconds"
Cause: Too many requests in a short time period.
Solution:
- Check the
Retry-Afterheader orretryAfterfield - Wait the specified time before retrying
- Implement exponential backoff
- Consider caching responses
async function retryWithBackoff(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (error.status === 429) {
const delay = error.details.retryAfter * 1000 || 1000 * Math.pow(2, i);
await sleep(delay);
} else {
throw error;
}
}
}
throw new Error('Max retries exceeded');
}
Connection Issues
"Service Unavailable" (503)
Cause: Server is temporarily unavailable.
Solution:
- Wait a few seconds and retry
- Check the status page
- Contact support if the issue persists
Network Errors
Cause: Network connectivity issues.
Solution:
- Check your internet connection
- Verify the API URL is correct
- Check if a firewall is blocking requests
- Ensure CORS is configured correctly
Debugging Tips
Enable Request Logging
async function apiCall(url, options) {
console.log('Request:', { url, ...options });
const response = await fetch(url, options);
const data = await response.json();
console.log('Response:', { status: response.status, data });
return data;
}
Check Request Headers
Ensure your requests include:
Content-Type: application/json
Authorization: Bearer <token>
Verify Token Payload
Decode your JWT to check its contents:
function decodeToken(token) {
const payload = token.split('.')[1];
return JSON.parse(atob(payload));
}
const payload = decodeToken(accessToken);
console.log('Token expires:', new Date(payload.exp * 1000));
console.log('Tenant:', payload.tenantId);
Getting Help
If you're still stuck:
- Check the API Reference
- Review the error code in Error Codes
- Contact support with:
- The full error response
- The request that caused it
- Your user ID and tenant ID