API Master Documentation
Complete API reference for technology partners and external developers. Build AI agents, integrate data sources, deploy to platforms, and manage everything programmatically.
Base URL: https://ai.craveva.com/api/v1 or /api/v1 (relative)
All API requests should be made to this base URL with the appropriate endpoint path. Most endpoints require authentication via API key or JWT token in the Authorization header.
API Test Console Available
Log in to test API endpoints directly from this page.
Authentication
Most endpoints require authentication using an API key or JWT token. Include your credentials in the Authorization header:Authorization: Bearer YOUR_API_KEY_OR_TOKEN
Authentication Endpoints
/api/v1/auth/registerRegister User
Create a new user account in the system.
Request Body Example:
{
"email": "user@example.com",
"password": "SecurePassword123!",
"full_name": "John Doe",
"company_name": "Example Corp"
}Response Example:
{
"user": {
"id": "user_id",
"email": "user@example.com",
"full_name": "John Doe",
"is_verified": false
},
"token": "jwt_token_here",
"refresh_token": "refresh_token_here"
}/api/v1/auth/loginLogin
Authenticate user and receive access tokens.
Request Body Example:
{
"email": "user@example.com",
"password": "SecurePassword123!"
}Response Example:
{
"user": {
"id": "user_id",
"email": "user@example.com",
"role": "admin",
"company_id": "company_id"
},
"token": "jwt_token_here",
"refresh_token": "refresh_token_here"
}/api/v1/auth/meGet Current User
Retrieve information about the currently authenticated user.
Response Example:
{
"user": {
"id": "user_id",
"email": "user@example.com",
"full_name": "John Doe",
"role": "admin",
"company_id": "company_id"
}
}/api/v1/auth/refreshRefresh Token
Generate a new access token using a refresh token.
Request Body Example:
{
"refresh_token": "refresh_token_here"
}Response Example:
{
"token": "new_jwt_token_here",
"refresh_token": "new_refresh_token_here"
}/api/v1/auth/logoutLogout
Log out the current user and invalidate refresh token.
Request Body Example:
{
"refresh_token": "refresh_token_here"
}Response Example:
{
"success": true,
"message": "Logged out successfully"
}/api/v1/auth/password/forgotForgot Password
Request a password reset email.
Request Body Example:
{
"email": "user@example.com"
}Response Example:
{
"success": true,
"message": "Password reset email sent"
}/api/v1/auth/password/resetReset Password
Reset password using a reset token.
Request Body Example:
{
"token": "reset_token_here",
"password": "NewSecurePassword123!"
}Response Example:
{
"success": true,
"message": "Password reset successfully"
}/api/v1/auth/verify-emailVerify Email
Verify email address using verification token.
Request Body Example:
{
"token": "verification_token_here"
}Response Example:
{
"success": true,
"message": "Email verified successfully"
}/api/v1/auth/verify-email/resendResend Verification Email
Resend email verification link.
Request Body Example:
{
"email": "user@example.com"
}Response Example:
{
"success": true,
"message": "Verification email sent"
}Agents Endpoints
/api/v1/agentsList Agents
Retrieve a list of all agents for the authenticated company.
Query Parameters:
limit: Number of results per pageoffset: Pagination offsetstatus: Filter by status: active, inactiveResponse Example:
{
"agents": [
{
"agent_id": "agent_123",
"name": "Customer Support Agent",
"type": "customer_support",
"status": "active",
"created_at": "2025-01-15T10:00:00Z"
}
],
"total": 10,
"limit": 20,
"offset": 0
}/api/v1/agentsCreate Agent
Create a new AI agent with specified configuration.
Request Body Example:
{
"name": "Sales Assistant",
"type": "sales",
"description": "Helps with sales inquiries",
"model": "gpt-4",
"temperature": 0.7,
"max_tokens": 1000
}Response Example:
{
"agent": {
"agent_id": "agent_456",
"name": "Sales Assistant",
"type": "sales",
"status": "active",
"created_at": "2025-01-15T10:00:00Z"
}
}/api/v1/agents/:agent_idGet Agent
Retrieve detailed information about a specific agent.
Response Example:
{
"agent": {
"agent_id": "agent_123",
"name": "Customer Support Agent",
"type": "customer_support",
"configuration": {
"model": "gpt-4",
"temperature": 0.7
},
"data_sources": [
"ds_1",
"ds_2"
],
"created_at": "2025-01-15T10:00:00Z"
}
}/api/v1/agents/:agent_id/executeExecute Agent
Execute an agent with input and receive AI-generated response.
Request Body Example:
{
"input": "What are my recent orders?",
"model": "gpt-4",
"output_format": "json",
"outlet_id": "outlet_123"
}Response Example:
{
"response": "Here are your recent orders...",
"execution_id": "exec_789",
"tokens_used": 150,
"data_sources_queried": [
"ds_1"
],
"execution_time_ms": 1250
}/api/v1/agents/:agent_idUpdate Agent
Update an existing agent configuration.
Request Body Example:
{
"name": "Updated Sales Assistant",
"description": "Updated description",
"config": {}
}Response Example:
{
"agent": {
"agent_id": "agent_123",
"name": "Updated Sales Assistant",
"updated_at": "2025-01-15T10:00:00Z"
}
}/api/v1/agents/:agent_idDelete Agent
Delete an agent.
Response Example:
{
"success": true,
"message": "Agent deleted"
}/api/v1/agents/:agent_id/previewPreview Agent
Get agent preview configuration and UI settings.
Response Example:
{
"agent": {
"agent_id": "agent_123",
"name": "Sales Assistant",
"config": {},
"ui_settings": {}
}
}/api/v1/agents/:agent_id/preview/testTest Agent Preview
Test agent execution without billing (preview mode).
Request Body Example:
{
"input": "Test query"
}Response Example:
{
"response": "Test response",
"preview": true
}/api/v1/agents/:agent_id/executionsGet Agent Executions
Get execution history for an agent.
Query Parameters:
limit: Number of resultsoffset: Pagination offsetResponse Example:
{
"executions": [
{
"execution_id": "exec_123",
"input": "Query",
"response": "Response",
"created_at": "2025-01-15T10:00:00Z"
}
],
"total": 10
}/api/v1/agents/:agent_id/chatChat with Agent
Chat with an agent (public endpoint for deployed agents).
Request Body Example:
{
"message": "Hello",
"conversation_id": "conv_123"
}Response Example:
{
"response": "Hello! How can I help you?",
"conversation_id": "conv_123"
}Data Sources Endpoints
/api/v1/data-sourcesList Data Sources
Retrieve all data sources connected to the company.
Response Example:
{
"data_sources": [
{
"connection_id": "ds_123",
"source_name": "MySQL Database",
"source_type": "mysql",
"status": "connected",
"created_at": "2025-01-15T10:00:00Z"
}
]
}/api/v1/data-sources/connectConnect Data Source
Connect a new data source (database, API, file).
Request Body Example:
{
"source_name": "Production Database",
"source_type": "database",
"mode": "online",
"connection_config": {
"type": "mysql",
"host": "db.example.com",
"port": 3306,
"database": "mydb",
"username": "user",
"password": "password"
},
"test_connection": true
}Response Example:
{
"data_source": {
"connection_id": "ds_123",
"source_name": "Production Database",
"source_type": "database",
"status": "connected",
"created_at": "2025-01-15T10:00:00Z"
}
}/api/v1/data-sources/:connection_idGet Data Source
Retrieve detailed information about a specific data source.
Response Example:
{
"data_source": {
"connection_id": "ds_123",
"source_name": "Production Database",
"source_type": "database",
"status": "connected",
"connection_config": {}
}
}/api/v1/data-sources/:connection_idUpdate Data Source
Update data source configuration or schema.
Request Body Example:
{
"source_name": "Updated Database",
"connection_config": {}
}Response Example:
{
"data_source": {
"connection_id": "ds_123",
"source_name": "Updated Database"
}
}/api/v1/data-sources/:connection_idDelete Data Source
Delete a data source connection.
Response Example:
{
"success": true,
"message": "Data source deleted"
}/api/v1/data-sources/:connection_id/test-connectionTest Data Source Connection
Test the connection to a data source.
Response Example:
{
"connected": true,
"message": "Connection successful",
"latency_ms": 50
}/api/v1/data-sources/uploadUpload File Data Source
Upload a file to create an offline data source.
Request Body Example:
{}Response Example:
{
"data_source": {
"connection_id": "ds_123",
"source_name": "My File",
"source_type": "file",
"status": "connected"
}
}/api/v1/data-sources/queryQuery Data Source
Execute a query against a data source.
Request Body Example:
{
"connection_id": "ds_123",
"query": "SELECT * FROM users LIMIT 10"
}Response Example:
{
"results": [],
"row_count": 10,
"execution_time_ms": 50
}Deployments Endpoints
/api/v1/deploymentsList Deployments
Retrieve all deployments for the authenticated company.
Query Parameters:
limit: Number of resultsoffset: Pagination offsetResponse Example:
{
"deployments": [
{
"deployment_id": "dep_123",
"agent_id": "agent_123",
"platform": "whatsapp",
"status": "active",
"created_at": "2025-01-15T10:00:00Z"
}
],
"total": 10
}/api/v1/deployments/messagingDeploy to Messaging Platform
Deploy an agent to a messaging platform (WhatsApp, Telegram, etc.).
Request Body Example:
{
"agent_id": "agent_123",
"platform": "whatsapp",
"config": {}
}Response Example:
{
"deployment": {
"deployment_id": "dep_123",
"agent_id": "agent_123",
"platform": "whatsapp",
"status": "active"
}
}/api/v1/deployments/ecommerceDeploy to E-commerce Platform
Deploy an agent to an e-commerce platform (Shopify, WooCommerce, etc.).
Request Body Example:
{
"agent_id": "agent_123",
"platform": "shopify",
"config": {}
}Response Example:
{
"deployment": {
"deployment_id": "dep_123",
"agent_id": "agent_123",
"platform": "shopify",
"status": "active"
}
}/api/v1/deployments/:deployment_idGet Deployment
Retrieve detailed information about a deployment.
Response Example:
{
"deployment": {
"deployment_id": "dep_123",
"agent_id": "agent_123",
"platform": "whatsapp",
"status": "active",
"config": {}
}
}/api/v1/deployments/:deployment_idUpdate Deployment
Update deployment configuration.
Request Body Example:
{
"config": {}
}Response Example:
{
"deployment": {
"deployment_id": "dep_123",
"config": {}
}
}/api/v1/deployments/:deployment_idDelete Deployment
Delete a deployment.
Response Example:
{
"success": true,
"message": "Deployment deleted"
}Billing Endpoints
/api/v1/billing/subscriptionGet Subscription
Retrieve current subscription details.
Response Example:
{
"subscription": {
"plan": "enterprise",
"status": "active",
"current_period_end": "2025-02-15T00:00:00Z",
"credits_remaining": 10000
}
}/api/v1/billing/usageGet Usage
Retrieve usage statistics and metrics.
Query Parameters:
start_date: Start date for usage period (ISO format)end_date: End date for usage period (ISO format)group_by: Group by: day, week, monthResponse Example:
{
"usage": {
"total_requests": 5000,
"total_tokens": 1000000,
"total_cost": 50,
"by_operation": {
"agent_execute": 3000,
"data_query": 2000
}
}
}/api/v1/billing/creditsGet Credits
Check remaining credits balance.
Response Example:
{
"credits": 10000,
"total_credits": 50000,
"used_credits": 40000
}/api/v1/billing/credits/topupTop Up Credits
Purchase additional credits.
Request Body Example:
{
"amount": 1000,
"payment_method_id": "pm_123"
}Response Example:
{
"credits": 11000,
"transaction_id": "txn_123"
}/api/v1/billing/invoicesList Invoices
Retrieve billing invoices.
Query Parameters:
limit: Number of resultsoffset: Pagination offsetResponse Example:
{
"invoices": [
{
"invoice_id": "inv_123",
"amount": 100,
"status": "paid",
"created_at": "2025-01-15T10:00:00Z"
}
]
}/api/v1/billing/payment-methodsList Payment Methods
Retrieve saved payment methods.
Response Example:
{
"payment_methods": [
{
"id": "pm_123",
"type": "card",
"last4": "4242",
"brand": "visa"
}
]
}Account Endpoints
/api/v1/account/profileGet Profile
Retrieve user profile information.
Response Example:
{
"user": {
"id": "user_id",
"email": "user@example.com",
"full_name": "John Doe",
"role": "admin",
"company_id": "company_id"
}
}/api/v1/account/api-keysCreate API Key
Generate a new API key for programmatic access.
Request Body Example:
{
"name": "Production Integration",
"permissions": [
"read",
"write"
]
}Response Example:
{
"api_key": {
"id": "key_123",
"name": "Production Integration",
"key": "cv_live_abc123...",
"created_at": "2025-01-15T10:00:00Z"
}
}/api/v1/account/api-keysList API Keys
Retrieve all API keys for the current user.
Response Example:
{
"api_keys": [
{
"id": "key_123",
"name": "Production Integration",
"created_at": "2025-01-15T10:00:00Z",
"last_used": "2025-01-15T10:00:00Z"
}
]
}/api/v1/account/api-keys/:key_idDelete API Key
Delete an API key.
Response Example:
{
"success": true,
"message": "API key deleted"
}Companies Endpoints
/api/v1/companies/:company_idGet Company
Retrieve company information.
Response Example:
{
"company": {
"id": 1,
"name": "Example Corp",
"created_at": "2025-01-15T10:00:00Z"
}
}/api/v1/companies/:company_id/usersList Company Users
Retrieve all users in a company.
Query Parameters:
q: Search queryResponse Example:
{
"users": [
{
"id": "user_123",
"email": "user@example.com",
"full_name": "John Doe",
"role": "admin"
}
]
}/api/v1/companies/:company_id/outletsList Company Outlets
Retrieve all outlets for a company.
Response Example:
{
"outlets": [
{
"outlet_id": "outlet_123",
"name": "Main Store",
"address": "123 Main St"
}
]
}Webhooks Endpoints
/api/v1/webhooksList Webhooks
Retrieve all webhooks for the company.
Response Example:
{
"webhooks": [
{
"webhook_id": "wh_123",
"url": "https://example.com/webhook",
"events": [
"agent.execute"
],
"status": "active"
}
]
}/api/v1/webhooksCreate Webhook
Create a new webhook.
Request Body Example:
{
"url": "https://example.com/webhook",
"events": [
"agent.execute"
]
}Response Example:
{
"webhook": {
"webhook_id": "wh_123",
"url": "https://example.com/webhook",
"events": [
"agent.execute"
],
"status": "active"
}
}System Endpoints
/api/v1/healthHealth Check
Check API health status.
Response Example:
{
"status": "ok",
"timestamp": "2025-01-15T10:00:00Z",
"database": {
"connected": true
},
"data": {
"responsive": true
}
}/api/v1/utils/industriesGet Industries
Retrieve list of supported industries.
Response Example:
{
"industries": [
"Technology",
"Healthcare",
"Finance"
]
}Rate Limits
Rate limit information is included in response headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
Error Handling
All errors follow a consistent format. Check the HTTP status code and error response body for details.
{
"error": true,
"message": "Human-readable error message",
"code": "ERROR_CODE",
"details": {
"field": "Additional error details"
}
}