---
title: "Read the schema of an app's database"
method: GET
path: "/apps/{id}/schema"
tags: ["Apps"]
---

# Read the schema of an app's database

`GET /apps/{id}/schema`

## Request

- Base URL: `https://api.hypamoon.com/api/v1`
- URL: `https://api.hypamoon.com/api/v1/apps/{id}/schema`
- Auth: one of:
  - HTTP bearer
  - OAuth 2 (authorization code, authorization URL `https://app.hypamoon.com/oauth/authorize`, token URL `https://api.hypamoon.com/oauth/token`, scopes: `sites:read`)

Read-only. The tables of the app's own database (env.DB) with their columns, indexes, number of rows and whether they are per-user (set_table_owner_column), the views, the applied migrations and a name for the next one. Use it to see where a build stands before you change the tables.

## Path parameters

- `id` string, uuid, required

## Response `200`

The schema.

- object
  - `app_id` string, required
  - `database` true, required
  - `tables` object[], required
    - `name` string, required
    - `columns` object[], required
      - `name` string, required
      - `type` string, required
      - `not_null` boolean, required
      - `primary_key` boolean, required
      - `default` string, nullable, required
    - `indexes` object[], required
      - `name` string, required
      - `unique` boolean, required
      - `sql` string, nullable, required
    - `rows` integer, nullable, required: The number of rows, or null when the database has too many tables to count.
    - `per_user` object, nullable, required: Set with set_table_owner_column: the code reads it with env.DB.mine(table).
      - `column` string, required
      - `admin_role` string, nullable, required
    - `sql` string, nullable, required
  - `views` object[], required
    - `name` string, required
    - `sql` string, nullable, required
  - `migrations` object[], required: Applied migrations, oldest first.
    - `name` string, required
    - `applied_at` string, required
    - `statements` integer, required
  - `next_migration_name` string, required: A name that sorts after the last applied migration, like 0003_next.sql; replace next with what it does.
  - `database_bytes` integer, required

## Other responses

- `401`: Unauthorized: unauthorized, missing_api_key, invalid_api_key, api_key_revoked, project_deleted.
- `403`: Forbidden: project_not_enabled, key_mode_mismatch, missing_scope, verification_required.
- `404`: Not Found: not_found.
- `409`: Conflict: conflict.
- `429`: Too Many Requests: rate_limited.
- `500`: Internal Server Error: internal_error.
- `503`: Service Unavailable: service_unavailable.

---

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