Complete guide to authenticating with CognexiaAI APIs
Three secure ways to authenticate: API Keys, OAuth 2.0, and JWT tokens
The simplest method for server-to-server communication.
curl -X GET https://api.cognexiaai.com/v1/crm/contacts \ -H "Authorization: Bearer sk_live_YOUR_API_KEY" \ -H "Content-Type: application/json"
Security: Never expose API keys in client-side code or public repositories
For user-authorized access to resources.
https://auth.cognexiaai.com/oauth/authorize? client_id=YOUR_CLIENT_ID& redirect_uri=https://yourapp.com/callback& response_type=code& scope=crm:read crm:write
POST https://auth.cognexiaai.com/oauth/token
{
"grant_type": "authorization_code",
"code": "AUTH_CODE",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET"
}For session-based authentication in web applications.
// Login and receive JWT
const response = await fetch('/api/auth/login', {
method: 'POST',
body: JSON.stringify({ email, password })
});
const { token } = await response.json();
// Use token in subsequent requests
fetch('/api/user/profile', {
headers: {
'Authorization': `Bearer ${token}`
}
});Rotate Keys Regularly
Change API keys every 90 days
Use Environment Variables
Store credentials securely
Implement Rate Limiting
Protect against abuse