API Reference

Database API

Manage CDC mappings, versions, promotions, and database subscriptions.

The Database API manages domain mappings (table-to-topic configurations), mapping versions, environment promotion, and database subscriptions.

Mappings

List Mappings

GET /api/database/mappings

Returns all mappings scoped to the current application and environment.

Get Mapping

GET /api/database/mappings/:id

Create Mapping

POST /api/database/mappings

Request Body:

{
  "table": "sessions",
  "topic": "session.status",
  "events": ["insert", "update"],
  "triggerColumns": ["status", "ended_at"],
  "payload": {
    "sessionId": "$row.id",
    "status": "$row.status",
    "endedAt": "$row.ended_at"
  },
  "when": {
    "or": [
      { "changed": "status" },
      { "changed": "ended_at" }
    ]
  },
  "environment": "development"
}

Update Mapping

PATCH /api/database/mappings/:id

Delete Mapping

DELETE /api/database/mappings/:id

Get Mappings by Topic

GET /api/database/mappings/topic/:topic

Environment Status

GET /api/database/mappings/status

Returns the promotion status of all mappings across environments. Used by the Environment Grid UI.

Response:

[
  {
    "id": "map_123",
    "table": "sessions",
    "topic": "session.status",
    "environments": {
      "development": { "version": 3, "active": true },
      "staging": { "version": 2, "active": true },
      "production": { "version": 1, "active": true }
    }
  }
]

Versions

List Versions

GET /api/database/mappings/:id/versions

Create Version Snapshot

POST /api/database/mappings/:id/versions

Request Body:

{
  "environment": "development"
}

Promote Mapping

POST /api/database/mappings/:id/promote

Copies the source environment's latest version into the next environment (dev → staging, staging → prod).

Request Body:

{
  "environment": "staging"
}

Subscriptions

List Subscriptions

GET /api/database/subscriptions

Create Subscription

POST /api/database/subscriptions

Request Body:

{
  "mappingId": "map_123"
}

Activate / Deactivate

POST /api/database/subscriptions/:id/activate
POST /api/database/subscriptions/:id/deactivate

Delivery Logs

GET /api/database/subscriptions/logs?event=database.update