Backwrite API examples for schemas and branches
These examples describe requests made by the repository MCP client. Check the published OpenAPI contract and your deployment for available routes and authorization.
Inspect a branch schema
Use a project ID and branch ID you are authorized to access. The example below prints the schema; it does not run a write operation.
curl --fail-with-body --silent --show-error \
"https://api.backwrite.dev/v1/projects/${BACKWRITE_PROJECT_ID}/branches/${BACKWRITE_BRANCH_ID}/schema" \
-H "apikey: ${BACKWRITE_SERVICE_KEY}" \
-H "Authorization: Bearer ${BACKWRITE_SERVICE_KEY}"Request shapes
The MCP client uses GET /v1/projects/{project_id}/branches to list branches. It uses GET /v1/projects/{project_id}/branches/{branch_id}/schema to inspect a branch. Project-default schema requests omit /branches/{branch_id}.
SQL request body
The MCP client sends POST /v1/projects/{project_id}/branches/{branch_id}/query with a JSON body containing sql and view. This illustrative request selects a constant. It is not evidence of a live API call.
{
"sql": "SELECT 1 AS connection_check",
"view": "raw"
}Handle errors explicitly
Check the HTTP status and returned error before using response data. A denied request, missing branch, or connection failure is not an empty successful result. Avoid logging tokens or complete connection strings.