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

Documentation

Getting StartedAuthenticationError CodesChangelog

Resources

API ReferenceSystem StatusSupport
Home
Documentation
Authentication

Authentication

Learn how to authenticate with the OneApp API.

Overview

The OneApp API supports two authentication methods:

Bearer Token

Short-lived tokens for user sessions. Best for web/mobile apps.

API Key

Long-lived keys for server-to-server. Best for backend services.

Bearer Token Authentication

Include the token in the Authorization header:

HTTP Header
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
cURL Example
curl -X GET "https://api.oneapp.io/api/v1/auth/user" \
  -H "Authorization: Bearer YOUR_TOKEN"
TypeScript Example
const response = await fetch('https://api.oneapp.io/api/v1/auth/user', {
  headers: {
    'Authorization': `Bearer ${token}`,
  },
});

API Key Authentication

Include the API key in the X-API-Key header:

HTTP Header
X-API-Key: oa_live_abc123...
cURL Example
curl -X GET "https://api.oneapp.io/api/v1/auth/user" \
  -H "X-API-Key: YOUR_API_KEY"

Creating API Keys

  1. Go to Dashboard → Settings → API Keys
  2. Click "Create New Key"
  3. Give it a name and select scopes
  4. Copy the key immediately (it won't be shown again)

Important: API keys are shown only once at creation. Store them securely and never commit them to version control.

API Key Scopes

Limit API key permissions with scopes:

ScopeDescription
read:usersRead user profiles
write:usersUpdate user profiles
read:conversationsRead AI conversations
write:conversationsCreate/update conversations
read:knowledge-basesRead RAG knowledge bases
write:knowledge-basesManage knowledge bases
adminFull access (use with caution)

Best Practices

Use Environment Variables

# .env.local
ONEAPP_API_KEY=oa_live_abc123...

# Access in code
const apiKey = process.env.ONEAPP_API_KEY;

Rotate Keys Regularly

Create new keys periodically and revoke old ones. Set expiration dates on keys.

Use Minimal Scopes

Only request the scopes you need. Avoid using admin scope unless absolutely necessary.

Never Expose Keys

Don't commit keys to git, log them, or expose them in client-side code.

Troubleshooting

401 Unauthorized

Check that your token/key is correct and not expired.

403 Forbidden

Your key doesn't have the required scope for this operation.

Key not working

Ensure you're using the correct header format and the key hasn't been revoked.