API Reference

Complete reference for the TengineAI REST API.

Base URL

https://app.tengine.ai/api/v1

Authentication

All API requests require authentication using your API key:

curl -H "Authorization: Bearer YOUR_API_KEY" \
     https://app.tengine.ai/api/v1/projects

Rate Limits

  • Free Tier: 100 requests/hour
  • Pro Tier: 1,000 requests/hour
  • Enterprise: Custom limits

Endpoints

Projects

List Projects

GET /projects

Response:

{
  "data": [
    {
      "id": "proj_123",
      "name": "My Project",
      "description": "A sample project",
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "per_page": 20,
    "total": 1
  }
}

Create Project

POST /projects

Request Body:

{
  "name": "New Project",
  "description": "Project description"
}

Response:

{
  "id": "proj_456",
  "name": "New Project",
  "description": "Project description",
  "created_at": "2024-01-01T00:00:00Z"
}

API Keys

List API Keys

GET /projects/{project_id}/api-keys

Create API Key

POST /projects/{project_id}/api-keys

Request Body:

{
  "name": "My API Key",
  "permissions": ["read", "write"],
  "expires_at": "2024-12-31T23:59:59Z"
}

Analytics

Get Usage Analytics

GET /projects/{project_id}/analytics

Query Parameters:

  • start_date: Start date (ISO 8601)
  • end_date: End date (ISO 8601)
  • granularity: hour, day, week, month

Error Handling

All errors follow this format:

{
  "error": {
    "code": "INVALID_API_KEY",
    "message": "The provided API key is invalid",
    "details": {
      "field": "authorization",
      "value": "invalid_key"
    }
  }
}

Error Codes

  • INVALID_API_KEY: API key is invalid or expired
  • RATE_LIMIT_EXCEEDED: Rate limit exceeded
  • PROJECT_NOT_FOUND: Project doesn't exist
  • INSUFFICIENT_PERMISSIONS: API key lacks required permissions
  • VALIDATION_ERROR: Request validation failed

SDKs

JavaScript/Node.js

npm install @tengineai/sdk
import { TengineAI } from '@tengineai/sdk';

const client = new TengineAI({
  apiKey: 'your-api-key'
});

// Create a project
const project = await client.projects.create({
  name: 'My Project',
  description: 'A sample project'
});

Python

pip install tengineai
from tengineai import TengineAI

client = TengineAI(api_key='your-api-key')

# Create a project
project = client.projects.create(
    name='My Project',
    description='A sample project'
)

Webhooks

Setup Webhook

POST /projects/{project_id}/webhooks

Request Body:

{
  "url": "https://your-app.com/webhook",
  "events": ["project.created", "api_key.created"],
  "secret": "webhook_secret"
}

Webhook Events

  • project.created: New project created
  • project.updated: Project updated
  • api_key.created: New API key generated
  • api_key.revoked: API key revoked
  • integration.connected: OAuth integration connected

Webhook Payload

{
  "id": "evt_123",
  "type": "project.created",
  "data": {
    "id": "proj_123",
    "name": "My Project"
  },
  "created_at": "2024-01-01T00:00:00Z"
}

Examples

Complete Project Setup

// 1. Create project
const project = await client.projects.create({
  name: 'My App',
  description: 'A sample application'
});

// 2. Generate API key
const apiKey = await client.apiKeys.create(project.id, {
  name: 'Production Key',
  permissions: ['read', 'write']
});

// 3. Set up webhook
const webhook = await client.webhooks.create(project.id, {
  url: 'https://myapp.com/webhook',
  events: ['api_key.created']
});

Support