---
title: "Apply Schema Migration"
method: POST
path: "/admin/migrations/apply"
tags: ["Admin"]
---

# Apply Schema Migration

`POST /admin/migrations/apply`

## Request

- Base URL: `https://api.kolens.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.kolens.ai/admin/migrations/apply`
- Auth: none declared

Apply one migration file end-to-end. Idempotent: a second call with
the same filename returns ``already_applied=true`` and does no work.

Returns ``error`` (non-null) if the SQL execution failed — the
response wire is still 200 so the UI can show the message inline.
The whole file rolls back on any error; the tracking row is only
inserted after every statement succeeds.

## Headers

- `x-admin-user` string, nullable
- `x-admin-secret` string, nullable

## Request body

- ApplyMigrationRequest
  - `filename` string, required: Migration filename, e.g. 006_translate_kol_fields.sql
  - `target` string: Which database: 'app' (Neon, DATABASE_URL) or 'supabase'.

## Response `200`

Successful Response

- object

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/kolens/apis/kolens-api.md) · [All operations](https://skmtc.dev/kolens/apis/kolens-api/llms.txt) · [OpenAPI document](https://skmtc.dev/kolens/apis/kolens-api/revisions/5d6865ab0a24?raw)
