db_batch
Run multiple SQL statements as a single atomic transaction. Every statement commits together, or none do — a single failure rolls the entire batch back. Suited to any logical operation that spans more than one write (account deletion across multiple tables, moving money between rows, denormalized counters). Max 1000 statements per call.
Each statement returns its own { rows, count, changes, last_row_id } in results[i] matching the order you passed in.
Example (account deletion):
{
"project_id": "my-saas",
"statements": [
{ "sql": "UPDATE accounts SET status = 'deleted' WHERE id = ?", "params": ["u_abc"] },
{ "sql": "DELETE FROM sessions WHERE user_id = ?", "params": ["u_abc"] },
{ "sql": "DELETE FROM posts WHERE author_id = ?", "params": ["u_abc"] }
]
}Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project_id": "<project_id>",
"statements": "<statements>"
},
"name": "db_batch"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| draft | No | Alias for the preview target flag. | |
| target | No | Database target. Preview requires preview_session_id (or draft_id). | |
| preview | No | Explicit preview target flag. Cannot be combined with a production target. | |
| draft_id | No | Alias for preview_session_id. | |
| preview_id | No | Optional expected preview candidate release id. | |
| production | No | Explicit production target flag. Cannot be combined with a preview target. | |
| project_id | Yes | Project ID (UUID), subdomain, or slug — resolved server-side, no UUID lookup needed. 'default' also works when the account has exactly one project; multi-project accounts must name one (the error lists them). | |
| statements | Yes | Array of { sql, params? } objects. Accepts a native JSON array; a JSON-stringified array is also accepted. Each runs atomically; any error rolls every statement back. Max 1000. | |
| preview_session_id | No | Identifier for an active preview session's isolated database. | |
| candidate_release_id | No | Alias for preview_id. |