---
title: "ESCAPE HATCH (advanced): run ONE read-only SELECT against this org's data, RLS-isolated (cannot see other orgs, cannot write)"
method: POST
path: "/api/v1/run_readonly_sql"
tags: ["General"]
---

# ESCAPE HATCH (advanced): run ONE read-only SELECT against this org's data, RLS-isolated (cannot see other orgs, cannot write)

`POST /api/v1/run_readonly_sql`

## Request

- Base URL: `https://api.pymaia.com`
- URL: `https://api.pymaia.com/api/v1/run_readonly_sql`
- Auth: HTTP bearer

ESCAPE HATCH (advanced): run ONE read-only SELECT against this org's data, RLS-isolated (cannot see other orgs, cannot write). Use ONLY when query_data does not cover the question; returns the rows as-is. Tables: store_orders (+ store_connections via store_connection_id; no org_id), meta_ad_creatives (Meta metrics per ad per day), meta_ad_creatives_con_anuncio (same rows + ad copy, URLs, media), ad_accounts. Return explicit columns. Only standard functions (aggregates, window, text, dates, json); no comments, `$`, or schema-qualified calls.

## Request body

- object
  - `sql` string, required

## Response `200`

Tool executed successfully

- object
  - `ok` boolean
  - `result` unknown
  - `duration_ms` number

## Other responses

- `400`: Invalid params or handler error
- `401`: Missing or invalid Bearer token
- `403`: Missing required scope(s) (`denied_scope`), or the tool's module is disabled for the organization (`module_disabled`, with `why`, `fix` and `module`)
- `404`: Tool not found, internal-only, or excluded for OAuth connectors
- `429`: Rate limit exceeded

---

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