Securely authenticate your business integrations with Oquira.
The Oquira Business API uses API Keys for server-to-server integrations and Session Tokens for dashboard-like client applications. This page explains how to use each method securely.
API keys are the recommended way to authenticate your backend servers. They provide secure, long-lived access to the API.
Important: API keys are shown only once. Store them securely immediately after creation.
You should provide your API key using the X-API-Key header:
curl -X GET "https://api.oquira.com/v1/business/services" \
-H "X-API-Key: your_api_key_here"curl -X GET "https://api.oquira.com/v1/business/services" \
-H "X-API-Key: your_api_key_here" \
-H "Content-Type: application/json"When creating an API key, you can limit its permissions:
| Scope | Description |
|---|---|
read:services | Read service information |
write:services | Create, update, delete services |
read:queues | Read queue status and tickets |
write:queues | Manage queues and call tickets |
read:analytics | Access analytics and reports |
manage:webhooks | Create and manage webhook subscriptions |
For client-side applications (like custom dashboards), you can use session-based authentication.
Authenticate a user and receive a session:
curl -X POST "https://api.oquira.com/v1/auth/login" \
-H "Content-Type: application/json" \
-d '{
"email": "admin@yourbusiness.com",
"password": "yourpassword"
}'{
"success": true,
"data": {
"user": {
"id": "clsh8b4c5000308l2bh3z6p9k",
"email": "admin@yourbusiness.com",
"firstName": "Jane",
"lastName": "Doe",
"role": "admin",
"accountType": "business"
},
"session": {
"token": "sess_clsh8n4p5000708l2bh3z6p9k",
"expiresAt": "2024-03-22T10:00:00.000Z"
}
}
}Web clients should use the better-auth.session_token cookie for subsequent requests. The cookie is automatically set after a successful login.
For API access with sessions:
curl -X GET "https://api.oquira.com/v1/business/dashboard" \
-H "Cookie: better-auth.session_token=sess_xyz789..."Sessions expire after a period of inactivity. To keep the session alive:
curl -X POST "https://api.oquira.com/v1/auth/session/refresh" \
-H "Cookie: better-auth.session_token=sess_xyz789..."End a session explicitly:
curl -X POST "https://api.oquira.com/v1/auth/logout" \
-H "Cookie: better-auth.session_token=sess_xyz789..."If you suspect a key has been compromised:
Authentication errors return standard error responses:
| HTTP Code | Error Code | Description |
|---|---|---|
401 | AUTHENTICATION_ERROR | Missing or invalid credentials |
401 | TOKEN_EXPIRED | Session token has expired |
403 | AUTHORIZATION_ERROR | Insufficient permissions |
403 | KEY_REVOKED | The API key has been revoked |
{
"success": false,
"error": {
"code": "AUTHENTICATION_ERROR",
"message": "Invalid or expired API key",
"timestamp": "2024-03-20T10:00:00.000Z",
"requestId": "req_5f2b8c9d1e"
}
}