---
title: "Get a diagram's schema"
method: GET
path: "/diagrams/{uuid}/schema"
tags: ["Diagrams"]
---

# Get a diagram's schema

`GET /diagrams/{uuid}/schema`

## Request

- Base URL: `https://api.drawsql.app/v1`
- URL: `https://api.drawsql.app/v1/diagrams/{uuid}/schema`
- Auth: HTTP bearer

A diagram's schema in the curated, "schema-pure" profile: `driver`,
`schema_version`, `tables` (each carrying its `columns` and `indexes`
nested inline, in schema order), and `relationships`. Layout, groups, and
sticky notes are omitted. For the verbatim, re-importable document use
`/schema-full` (this response is a strict subset of it: same nesting,
same field names).

Two representations. `application/json` is the default. Send
`Accept: text/markdown` (or `?format=ai`) for the AI Schema Format — a
compact Markdown rendering built for pasting into an LLM, with
`?level=simple` for column names only and `?level=detailed` (the
default) for types and constraints.

Supports ETag conditional requests. The ETag is a hash of this payload,
so a canvas-only edit (moving a table, recoloring) still returns
`304 Not Modified`; each representation carries its own ETag.
Rate limit: 30 requests/minute per token (serialization is heavier here).

## Path parameters

- `uuid` string, uuid, required

## Query parameters

- `format` 'json' | 'ai'
- `level` 'simple' | 'detailed'

## Headers

- `If-None-Match` string

## Response `200`

The schema.

- object
  - `data` Schema, required: A diagram's schema in the curated "schema-pure" profile. Denormalized: each table carries its `columns` and `indexes` inline. A strict subset of `SchemaFull` (same field names, no renames).
    - `driver` string, nullable, required: Database dialect.
    - `schema_version` number, required: The document-format version carried in the payload (distinct from the `/v1` API version).
    - `tables` Table[], required: Tables, sorted by name for diff stability.
      - `uuid` string, uuid, required
      - `name` string, nullable, required
      - `comment` string, nullable, required
      - `columns` Column[], required: Columns in schema (DDL) order; array position is semantic.
        - `uuid` string, uuid, required
        - `name` string, nullable, required
        - `driver_data_type_name` string, required: The column's data type name within the schema's driver (e.g. "varchar", "int").
        - `driver_data_type_params` unknown[], nullable, required: Type parameters, e.g. length or precision.
          - unknown
        - `default` union, required: Native number when the column's default is numeric, otherwise a string.
          - string
          - number
        - `default_type` string: Present only when the default is typed (e.g. "number", "expression").
        - `is_nullable` boolean, required
        - `is_primary_key` boolean, required
        - `is_unique_key` boolean, required
        - `is_index` boolean, required
        - `is_auto_increment` boolean, required
        - `is_unsigned` boolean, required
        - `enum_values` string[]: Present only for enum columns.
        - `set_values` string[]: Present only for MySQL SET columns.
        - `array_suffix` string: PostgreSQL array suffix, e.g. '[]' or '[5]'. Present only for array columns.
        - `identity_params` object: SQL Server identity parameters { seed, increment }. Present only for identity columns.
        - `comment` string, nullable, required
      - `indexes` Index[], required
        - `uuid` string, uuid, required
        - `name` string, nullable, required
        - `type` string, required: Index type.
        - `columns` IndexColumnRef[], required: The columns covered by this index, in order.
          - `uuid` string, uuid, required
          - `name` string, nullable, required
    - `relationships` Relationship[], required
      - `uuid` string, uuid, required
      - `source_table_uuid` string, uuid, required
      - `source_column_uuid` string, uuid, required
      - `target_table_uuid` string, uuid, required
      - `target_column_uuid` string, uuid, required
      - `type` string, required: Cardinality of the relationship.
      - `name` string: Present only when the relationship is named.

## Other responses

- `304`: The schema is unchanged since the supplied `If-None-Match`.
- `401`: Missing, malformed, expired, or revoked token (code `unauthenticated`), or a valid token whose team no longer exists or whose user is no longer a member of that team (code `invalid_token`).
- `403`: The token's team is not on a paid plan (code `plan_required`), or the token is not allowed to perform this action (code `forbidden`).
- `404`: No such diagram, or it is not visible to this token.
- `406`: The `Accept` header admits neither JSON nor Markdown.
- `409`: The diagram is still importing, so it has no schema yet. Poll `GET /diagrams/{uuid}` until `status` is `ready`.
- `422`: An unsupported `format` or `level` was requested.
- `429`: Too many requests.

---

[API](https://skmtc.dev/drawsql/apis/drawsql-api.md) - [All operations](https://skmtc.dev/drawsql/apis/drawsql-api/llms.txt) - [OpenAPI document](https://skmtc.dev/drawsql/apis/drawsql-api/revisions/8b333e0bae67?raw)
