Skip to main content
POST
Change a database directly

Authorizations

Authorization
string
header
required

API key in the format: Bearer {api_token}

Headers

Idempotency-Key
string

Makes this write safe to retry: a repeat with the same key replays the first response instead of creating a second resource. Scoped to the account, remembered for 24 hours; reusing a key with a different payload is an error.

Maximum string length: 255

Path Parameters

id
string
required

The resource ID (e.g., "prod_abc123") or slug (e.g., "my-product")

Body

application/json
name
string
required

Unique migration name, e.g. 0003_add_ratings. Used as the idempotency key in the ledger.

sql
string
required

The migration SQL. Multiple statements may be separated by ;. Runs in one batch with the ledger insert, so a failed migration is never recorded as applied.

allow_destructive
boolean
default:false

Set to true to permit data-destroying statements (DROP/TRUNCATE/unqualified DELETE|UPDATE) against tables that hold rows. Defaults to false.

environment
enum<string>
default:production

Which database to change. development is the one you build against — created on first use, and where every structural change belongs. production is the live site's, and accepts data changes only. Defaults to production.

Available options:
development,
production

Response

Migration result

object
string
name
string
applied
boolean
already_applied
boolean
destructive
boolean
bookmark
string | null
destructive_statements
object[]

The statements that were classified as destructive, each with the table it targets and that table's row_count.

risks
object[]

Statements that keep every row but can still fail against existing data or break the currently live version of the site (column renames, NOT NULL without DEFAULT, UNIQUE indexes). Reported, never blocked.

checksum
string | null

SHA-256 of the migration SQL, recorded in the ledger to detect later edits to the file.