---
title: "Read an owned site's database"
description: "Runs SQL that only reads against the site's current database, on the edge or its VM: every statement must be one SQLite SELECT, VALUES or WITH ..."
canonical: "https://www.cool.computer/docs/api-reference/publishing/read-an-owned-sites-database"
---
# Read an owned site's database

> Runs SQL that only reads against the site's current database, on the edge or its VM: every statement must be one SQLite SELECT, VALUES or WITH ...

```http
POST https://api.cool.computer/api/computers/{id}/database/read
```

Runs SQL that only reads against the site's current database, on the edge or its VM: every statement must be one SQLite SELECT, VALUES or WITH ... SELECT, with any non-ASCII name quoted and only positional ? parameters. Any other statement, or a second statement inside one sql, is refused with 400 database_write_refused before it reaches the database. A response over 1 MiB is refused with 413 database_result_too_large: select fewer rows (LIMIT) or columns. Callers: the computer owner's account bearer or browser session.

## Authorization

- A Cool Computers API key, user access token, or claimed agent access token in the Authorization header. Follow https://www.cool.computer/auth.md for agent registration and https://www.cool.computer/authentication.md for direct user credentials.

## Parameters

- `id` (path, string, at least 1 characters, required): The computer's name, such as agent-atlas, or its id (cmp_…). Every caller may use either, the computer's own runtime token included.

## Request body

Required.

- `application/json` (object or object)
  - object
    - `sql` (string, at least 1 characters, required)
    - `params` (array of string or number or null): Positional SQLite parameters. Integers must be within ±(2^53−1); bind larger integers as strings.
  - object
    - `statements` (array of object, at least 1 items, required)
      - `sql` (string, at least 1 characters, required)
      - `params` (array of string or number or null): Positional SQLite parameters. Integers must be within ±(2^53−1); bind larger integers as strings.

## Responses

- `200`: One result per statement, in order.
  - `application/json` (object)
    - `results` (array of object, required)
      - `columns` (array of string, required): The result's column names in the statement's order, which the row objects do not keep. A name used twice appears once, and its row objects keep the later value. Empty when the statement returns no columns.
      - `results` (array of object, required): The rows, each an object keyed by column name.
      - `meta` (object, required)
        - `changes` (integer, required)
        - `last_row_id` (integer, required)
      - `success` (boolean, required)
- `400`: A machine-readable API error with a stable code and recovery instruction.
- `401`: Unauthorized.
- `403`: A machine-readable API error with a stable code and recovery instruction.
- `404`: A machine-readable API error with a stable code and recovery instruction.
- `409`: A machine-readable API error with a stable code and recovery instruction.
- `413`: A machine-readable API error with a stable code and recovery instruction.
- `422`: A machine-readable API error with a stable code and recovery instruction.
- `default`: A machine-readable API error with a stable code and recovery instruction.

An error is an `application/problem+json` document with a stable `code`; [API errors](/docs/api-reference/errors) says how to handle one.

## Example

```sh
curl -X POST "https://api.cool.computer/api/computers/$PARAM_ID/database/read" \
  -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" \
  --data '{"sql":"SELECT 1"}'
```
