Learn how to authenticate with TengineAI APIs and manage your credentials securely.
All TengineAI API requests require authentication using your API key.
Include your API key in the Authorization header:
curl -H "Authorization: Bearer YOUR_API_KEY" \
https://app.tengine.ai/api/v1/projects
const response = await fetch('https://app.tengine.ai/api/v1/projects', {
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
});
import requests
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
response = requests.get('https://app.tengine.ai/api/v1/projects', headers=headers)
Via Dashboard
Via API
curl -X POST https://app.tengine.ai/api/v1/projects/{project_id}/api-keys \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My API Key",
"permissions": ["read", "write"],
"expires_at": "2024-12-31T23:59:59Z"
}'
API keys support granular permissions:
read: View projects, analytics, and settingswrite: Create and update projectsadmin: Full administrative accesswebhook: Manage webhooks and integrationsFor security, rotate your API keys regularly:
Generate New Key
Revoke Old Key
Configure Provider
Provider Setup
// 1. Redirect user to authorization URL
const authUrl = `https://app.tengine.ai/api/v1/oauth/authorize?client_id=${clientId}&redirect_uri=${redirectUri}&scope=${scope}`;
// 2. Handle callback and exchange code for token
const tokenResponse = await fetch('https://app.tengine.ai/api/v1/oauth/token', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
code: authorizationCode,
client_id: clientId,
client_secret: clientSecret
})
});
# .env file
TENGINE_API_KEY=your-api-key-here
TENGINE_SERVER_URL=https://api.tengineai.com
// ✅ Good: Server-side only
const apiKey = process.env.TENGINE_API_KEY;
// ❌ Bad: Client-side exposure
const apiKey = 'your-api-key-here';
const response = await fetch(url, options);
if (response.status === 429) {
const retryAfter = response.headers.get('Retry-After');
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
// Retry request
}
401 Unauthorized: Invalid or missing API key403 Forbidden: Insufficient permissions429 Too Many Requests: Rate limit exceeded500 Internal Server Error: Server error{
"error": {
"code": "INVALID_API_KEY",
"message": "The provided API key is invalid",
"details": {
"field": "authorization",
"value": "invalid_key"
}
}
}
import { TengineAI } from '@tengineai/sdk';
const client = new TengineAI({
apiKey: process.env.TENGINE_API_KEY
});
from tengineai import TengineAI
client = TengineAI(api_key=os.getenv('TENGINE_API_KEY'))
TengineAI signs webhook payloads for verification:
const crypto = require('crypto');
function verifyWebhookSignature(payload, signature, secret) {
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return signature === expectedSignature;
}
"Invalid API Key"
"Insufficient Permissions"
"Rate Limit Exceeded"
Enable debug logging:
const client = new TengineAI({
apiKey: process.env.TENGINE_API_KEY,
debug: true
});
Need help with authentication? Contact our support team or check our Discord community.