# get_collection_schema

Source: https://modulify.ai/docs/api/database/get-collection-schema

Reads the columns of one table in a site database, with their types, nullability, primary key and CMS field type.

- Title: Read a collection schema
- Scope: `data:read`
- Access: Read only
- Endpoint: `POST /v1/get_collection_schema`

Each column carries its `uiType`, the CMS field type registered for it, such as `image`, `richtext` or `code`, or null. A language column with no type of its own reports its base field's type when that type is `color`, `richtext`, `code`, `file`, `image`, `date` or `datetime`. A `code` value is raw HTML, CSS or JavaScript that the site runs exactly as written. A `richtext` value is HTML, and an [embed](https://modulify.ai/docs/data/cms#embeds) inside it is an empty `<div data-embed="…">` whose attribute holds the embed's code with `&`, `<`, `>` and `"` escaped.

A foreign key column names the table and column it points at in `references`. Read this before writing a row with `create_row` or `update_row`, so the right columns are supplied. See [Column types](https://modulify.ai/docs/data/column-types).

A collection that does not exist in the site's database is refused with a `404` and the message "That collection was not found in your database!".

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/get_collection_schema`, sending the inputs below as a JSON object. The token needs the `data:read` scope.

It only reads and changes nothing, so retrying it is safe.

```bash
curl -X POST https://api.modulify.ai/v1/get_collection_schema \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId":"PROJECT_ID","name":"NAME"}'
```

Over MCP, the same method is the [get_collection_schema tool](https://modulify.ai/docs/mcp/database/get-collection-schema).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | string | Yes | The site id. |
| `name` | string | Yes | The table name, from `list_collections`. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.