OneApp
API ReferenceGuidesGitHub
Checking status...Status
⌘KSearch
DashboardGet API Key

Documentation

Getting StartedAuthenticationError CodesChangelog

Resources

API ReferenceSystem StatusSupport
Home
Documentation
Error Codes

Error Codes

Reference guide for API error codes and how to handle them.

Error Response Format

All API errors follow a consistent JSON format:

{
  "error": {
    "code": "AUTH_TOKEN_EXPIRED",
    "message": "Token has expired",
    "status": 401,
    "details": {
      "expiredAt": "2024-01-15T10:30:00Z"
    },
    "requestId": "req_abc123xyz"
  }
}

code

Machine-readable error identifier. Use this for programmatic error handling.

message

Human-readable error description. Safe to display to users.

details

Additional context about the error. Structure varies by error type.

requestId

Unique request identifier. Include this when contacting support.

401AUTH_TOKEN_MISSING

Authentication required

Description

No authentication token was provided in the request.

Solution

Include a valid Bearer token in the Authorization header or an API key in the X-API-Key header.

401AUTH_TOKEN_INVALID

Invalid authentication token

Description

The provided token is malformed or has been tampered with.

Solution

Obtain a new token by authenticating again. Ensure the token is copied correctly.

401AUTH_TOKEN_EXPIRED

Token has expired

Description

The authentication token has exceeded its validity period.

Solution

Refresh your token using the refresh token endpoint or authenticate again.

401AUTH_API_KEY_INVALID

Invalid API key

Description

The provided API key does not exist or has been revoked.

Solution

Check that your API key is correct. Generate a new key if needed.

403FORBIDDEN

Access forbidden

Description

You do not have permission to access this resource.

Solution

Verify your account has the required permissions or contact an administrator.

403SCOPE_INSUFFICIENT

Insufficient scope

Description

Your API key does not have the required scope for this operation.

Solution

Create a new API key with the required scopes or use a token with broader permissions.

403ORGANIZATION_ACCESS_DENIED

Organization access denied

Description

You are not a member of this organization.

Solution

Request access to the organization from an administrator.

404RESOURCE_NOT_FOUND

Resource not found

Description

The requested resource does not exist.

Solution

Verify the resource ID is correct. The resource may have been deleted.

404USER_NOT_FOUND

User not found

Description

No user exists with the specified identifier.

Solution

Check the user ID or email. The user may not have registered.

404CONVERSATION_NOT_FOUND

Conversation not found

Description

The specified conversation does not exist.

Solution

Verify the conversation ID. Create a new conversation if needed.

404KNOWLEDGE_BASE_NOT_FOUND

Knowledge base not found

Description

The specified knowledge base does not exist.

Solution

Check the knowledge base ID. It may have been deleted.

400VALIDATION_ERROR

Validation failed

Description

The request body failed validation.

Solution

Check the error details for specific field validation failures.

400INVALID_JSON

Invalid JSON

Description

The request body is not valid JSON.

Solution

Ensure your request body is properly formatted JSON.

400MISSING_REQUIRED_FIELD

Missing required field

Description

A required field is missing from the request.

Solution

Include all required fields in your request body.

400INVALID_FIELD_TYPE

Invalid field type

Description

A field has an incorrect data type.

Solution

Ensure field types match the API specification (string, number, boolean, etc.).

429RATE_LIMIT_EXCEEDED

Rate limit exceeded

Description

You have made too many requests in a short period.

Solution

Wait before making more requests. Check the Retry-After header for timing.

429QUOTA_EXCEEDED

Quota exceeded

Description

You have exceeded your API usage quota for the billing period.

Solution

Upgrade your plan or wait for the quota to reset.

409RESOURCE_ALREADY_EXISTS

Resource already exists

Description

A resource with the same identifier already exists.

Solution

Use a different identifier or update the existing resource.

409EMAIL_ALREADY_REGISTERED

Email already registered

Description

An account with this email already exists.

Solution

Use a different email or sign in to the existing account.

409CONCURRENT_MODIFICATION

Concurrent modification

Description

The resource was modified by another request.

Solution

Fetch the latest version and retry your update.

500INTERNAL_SERVER_ERROR

Internal server error

Description

An unexpected error occurred on the server.

Solution

Retry the request. If the problem persists, contact support.

503SERVICE_UNAVAILABLE

Service unavailable

Description

The service is temporarily unavailable.

Solution

Wait and retry. Check our status page for updates.

502AI_PROVIDER_ERROR

AI provider error

Description

The AI provider returned an error.

Solution

Retry the request. The AI provider may be experiencing issues.

Error Handling Best Practices

Always check the error code

Use the code field for programmatic error handling:

try {
  const response = await oneapp.ai.messages.create({...});
} catch (error) {
  switch (error.code) {
    case 'AUTH_TOKEN_EXPIRED':
      await refreshToken();
      // Retry the request
      break;
    case 'RATE_LIMIT_EXCEEDED':
      const retryAfter = error.details?.retryAfter ?? 60;
      await sleep(retryAfter * 1000);
      // Retry the request
      break;
    default:
      console.error('Unexpected error:', error.message);
  }
}

Implement exponential backoff

For rate limits and transient errors (429, 500, 502, 503), retry with exponential backoff. Start with 1 second and double the delay after each retry, up to a maximum.

Log the requestId

Always log the requestId from error responses. This helps our support team quickly identify and resolve issues.