API Reference

Complete API reference for DevSync.AI Dashboard API endpoints.

Base URL

All API endpoints are relative to the base URL:

text
http://localhost:3000/api  # Development
https://your-domain.com/api # Production

Authentication

All API endpoints require authentication. Two methods are supported:

Session Authentication (Web)

Uses Supabase session cookies automatically handled by the browser. No additional headers required when accessing from the web dashboard.

API Key Authentication (CLI)

Pass JWT token in the Authorization header:

http
Authorization: Bearer <your-jwt-token>

Endpoints

Projects

GET /api/projects

Get all projects for the authenticated user.

http
GET /api/projects
Authorization: Bearer <token>

Scan Reports

POST /api/scans

Create a new scan report.

http
POST /api/scans
Content-Type: application/json
Authorization: Bearer <token>

{
  "project_id": "uuid",
  "status": "completed",
  "mismatches": [...]
}

GET /api/scans

Get scan reports for a project.

http
GET /api/scans?project_id=<uuid>
Authorization: Bearer <token>

Migrations

POST /api/migrations

Generate a migration from a scan report.

http
POST /api/migrations
Content-Type: application/json
Authorization: Bearer <token>

{
  "scan_report_id": "uuid"
}

GET /api/migrations

Get migrations for a project or scan report.

http
GET /api/migrations?scan_report_id=<uuid>
Authorization: Bearer <token>

POST /api/migrations/[id]/execute

Execute a migration (dry-run or actual execution).

http
POST /api/migrations/<id>/execute
Content-Type: application/json
Authorization: Bearer <token>

{
  "dry_run": false
}

AI Features

POST /api/ai/explain

Generate AI explanation for a migration.

http
POST /api/ai/explain
Content-Type: application/json
Authorization: Bearer <token>

{
  "migration_id": "uuid"
}

POST /api/ai/query

Ask AI a question about a schema.

http
POST /api/ai/query
Content-Type: application/json
Authorization: Bearer <token>

{
  "question": "What's the risk of this migration?",
  "context": {...}
}

Error Responses

All endpoints return errors in this format:

json
{
  "error": "Error message",
  "message": "User-friendly message",
  "details": {}
}

Common Error Codes

  • 401: Unauthorized - Invalid or missing authentication
  • 403: Forbidden - Insufficient permissions
  • 404: Not Found - Resource doesn't exist
  • 422: Unprocessable Entity - Validation error
  • 500: Internal Server Error - Server error