# 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 foreign key column names the table and column it points at in `references`, and on the older database a column of an enum type names that type in `udtName`, which is what `list_enum_options` takes. 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).

## 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. |
| `schema` | string | No | The schema the collection lives in, exactly as `list_collections` reports it. Leave it out to use the site database's own default, which is right unless `list_collections` showed something else. A site on the newer database always uses its default. |
| `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.