voidbase logo voidbase 0.1.0
FAQ Documentation
Introduction Going to production Web APIs reference ├ API Records ├ API Realtime ├ API Files ├ API Collections ├ API Settings ├ API Logs ├ API Backups ├ API Crons ├ API SQL └ API Health
Extend with
Go
Extend with
JavaScript
Go Overview Go Event hooks Go Routing Go Database Go Record operations Go Collection operations Go Migrations Go Jobs scheduling Go Sending emails Go Rendering templates Go Console commands Go Realtime messaging Go Filesystem Go Logging Go Testing Go Miscellaneous Go Record proxy
JS Overview JS Event hooks JS Routing JS Database JS Record operations JS Collection operations JS Migrations JS Jobs scheduling JS Sending emails JS Rendering templates JS Console commands JS Sending HTTP requests JS Realtime messaging JS Filesystem JS Logging JS Types reference
Web APIs reference - API SQL
API SQL

Executes a raw SQL query string (used primarily for the "SQL Console" UI in PocketBase v0.39+).

Only superusers can perform this action.

Be very careful when using this API!

It is intended for one-off analytic queries, the occasional VACUUM/PRAGMA optimize or debug purposes and NOT as the primary interface for interacting with your PocketBase data because, depending on the query, the execution could break your application and may not be reversible!

import PocketBase from 'pocketbase'; const pb = new PocketBase('http://127.0.0.1:8090'); ... await pb.collection('_superusers').authWithPassword('test@example.com', '1234567890'); await pb.sql.run('SELECT count(*) FROM users');
import 'package:pocketbase/pocketbase.dart'; final pb = PocketBase('http://127.0.0.1:8090'); ... await pb.collection('_superusers').authWithPassword('test@example.com', '1234567890'); await pb.sql.run('SELECT count(*) FROM users');
API details
POST
/api/sql
Requires Authorization:TOKEN
Body Parameters
ParamTypeDescription
Required query
StringThe SQL query to execute. Multiple inline SQL queries are supported but only the result of the last one is returned.
Responses
{ "execTime": 0, "affectedRows": 0, "columns": [ { "name": "count(*)", "type": "", "nullable": true } ], "rows": [ ["1"] ] }
{ "status": 400, "message": "Failed to execute query. Raw error: ...", "data": {} }
{ "status": 401, "message": "The request requires valid record authorization token.", "data": {} }
{ "status": 403, "message": "The authorized record is not allowed to perform this action.", "data": {} }

Prev: API Crons Next: API Health
FAQ Discussions Documentation
JavaScript SDK Dart SDK
voidbase
voidbase is an independent project, not affiliated with or endorsed by PocketBase. It runs PocketBase's API and admin panel and is built on Void's Cloudflare runtime; the two power most of what runs here and keep shipping the updates voidbase builds on.
© 2026 voidbase The Gopher artwork is from marcusolsson/gophers
Site design by Gani (PocketBase)