API Overview

intermediate5 min read

API Overview

The AI for Database REST API lets applications and AI agents integrate natural-language querying, raw database results, dashboards, complete workflow automation, webhook subscriptions, usage, and API-key management. An agent can inspect sanitized connection metadata and schema, run raw SQL, create an encrypted outbound credential, build and revise a paused workflow draft, preview its query results without delivery, test one real action, inspect sanitized delivery attempts, and explicitly publish the workflow without using the browser UI.

Base URL

https://app.aifordatabase.com/api/v1

For self-hosted deployments, the base URL is your instance's address followed by /api/v1.

Live API Reference

An interactive, always-current API reference is served by the app itself:

If anything on this page ever disagrees with the OpenAPI spec, the spec wins. AI agents integrating with the API should fetch the OpenAPI spec directly.

Versioning

The API is versioned using URL path prefixes (/v1). We guarantee backward compatibility within a major version. Breaking changes will be released under a new version prefix with a migration guide.

Authentication

All API requests require authentication via a Bearer token in the Authorization header. API keys start with afd_:

bash
curl -H "Authorization: Bearer afd_your_api_key" \
  https://app.aifordatabase.com/api/v1/connections

Generate API keys in Settings > API Keys. Each key is scoped to specific permission areas (see Authentication) and has an optional expiration date.

Response Format

All responses are JSON with a consistent envelope — data and error are mutually exclusive:

json
{
  "data": { ... },
  "error": null,
  "meta": {
    "requestId": "8d6eb159-9896-4274-94c7-fab3f95ae1c6",
    "timestamp": "2026-01-15T10:30:00Z"
  }
}

Error responses:

json
{
  "data": null,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "name is required",
    "details": { ... }
  },
  "meta": {
    "requestId": "8d6eb159-9896-4274-94c7-fab3f95ae1c6",
    "timestamp": "2026-01-15T10:30:00Z"
  }
}

Rate Limits

Limits are applied per organization, per minute:

PlanGeneral requests/minChat requests/min
Free6020
Pro / Max300100
Enterprise1,000500

Exceeding a limit returns HTTP 429 with a RATE_LIMITED error code.

Pagination

List endpoints support page-based pagination:

bash
GET /api/v1/connections?page=1&pageSize=20

The response meta.pagination object contains total, page, pageSize, and totalPages.

Ready to try this on your own database?

Connect in minutes and ask your first question — no SQL required.

Start free

Free plan · No credit card required