---
title: "Run SQL (retiring for the service key; use POST /projects/v1/{project_id}/sql)"
method: POST
path: "/projects/v1/admin/{project_id}/sql"
tags: ["Admin"]
deprecated: true
---

# Run SQL (retiring for the service key; use POST /projects/v1/{project_id}/sql)

`POST /projects/v1/admin/{project_id}/sql`

## Request

- Base URL: `https://api.run402.com`
- URL: `https://api.run402.com/projects/v1/admin/{project_id}/sql`
- Auth: HTTP bearer

> **Deprecated.**

Retiring for service-key callers: use POST /projects/v1/{project_id}/sql, which takes the same key and body and returns the same shape. Service-key calls here are counted; once the route warns, responses carry Deprecation, Sunset, and Link (rel=successor-version) headers and a ROUTE_RETIRING warning, and once retired they answer 410 ROUTE_RETIRED with a use_successor next action. Platform-admin-key calls (staff diagnostics) keep this route: they run inside a PostgreSQL read-only transaction, and any write is refused with 403 ADMIN_SQL_READ_ONLY.

## Path parameters

- `project_id` string, required: Run402 project ID. Public IDs are not UUIDs.

## Request body

- object
  - `sql` string, required: SQL statement(s) to execute

## Response `200`

SQL executed

- object
  - `status` string
  - `schema` string
  - `rows` object[]
  - `row_count` integer: Rows returned or affected by the last statement: the statement whose rows and fields are returned.
  - `statements` object[]: One entry per statement, in order. For a multi-statement batch, each statement's own command and count; their sum is the batch total.
    - `command` unknown, required
    - `row_count` integer, required
  - `warnings` object[]: Warnings that never change the result: ROUTE_RETIRING (the caller used a route being retired; next_actions names the successor or the upgrade), SCHEMA_CHANGE_OUTSIDE_MIGRATION (DDL on a project with a live release, which the release no longer describes; next_actions: create_migration), MULTI_STATEMENT_TEXT_BODY (several statements in one text body; use the batch route).
    - `code` 'ROUTE_RETIRING' | 'SCHEMA_CHANGE_OUTSIDE_MIGRATION' | 'MULTI_STATEMENT_TEXT_BODY', required
    - `severity` string
    - `message` string, required
    - `next_actions` object[], required
  - `fields` object[]: Result column descriptors of the last statement.
    - `name` string
    - `type` string

## Other responses

- `401`: Missing or invalid authentication. Run402-originated JSON bodies use the canonical ErrorEnvelope.
- `403`: Project is past_due/frozen/dormant — control-plane gated
- `410`: ROUTE_RETIRED: the route is retired for this caller (or a brownout window is open); next_actions names the successor.

---

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