---
title: Managing schemas and types
description: >-
  Pull and compare microCMS API schemas, then generate TypeScript declarations
  or JSON Schema for applications, validation, forms, and AI tools.
sidebar:
  order: 4
noindex: false
---
mcms-cli can save the API schema used by a microCMS service. Keeping that definition in a build artifact or repository makes schema changes reviewable and gives other tools a reliable input.

## Pull an API schema

```bash
microcms schema pull \
  --out microcms-schema.json \
  --json
```

Limit the result to a specific endpoint when a task does not need the full service definition.

```bash
microcms schema pull \
  --endpoints blogs \
  --out blogs-schema.json \
  --json
```


## Create an API from a JSON file

Create an API from a JSON file that contains its schema. `microcms api create` uses the Management API. Use `--name`, `--endpoint`, and `--type` to fill in or override the file's basic API settings.

```bash
microcms api create \
  --file articles-api.json \
  --name articles \
  --endpoint articles \
  --type list \
  --dry-run \
  --json
```

The dry-run validates the API schema and custom-field structure. Review the result, then remove `--dry-run` to create the API. Add `--allow-additional-charge` only when you intend to allow additional charges.

See the [command reference](/en/command-reference) for the available options.


## Compare with a baseline

```bash
microcms schema diff \
  --baseline microcms-schema.json \
  --json
```

Add `--exit-code` in CI when a detected difference should fail the job. The JSON result still describes what changed.

## Generate TypeScript declarations

```bash
microcms types generate \
  --schema microcms-schema.json \
  --out microcms-types.d.ts \
  --json
```

`types sync` combines schema retrieval and type generation in one command.

```bash
microcms types sync \
  --out microcms-types.d.ts \
  --schema-out microcms-schema.json \
  --json
```

## Generate JSON Schema

```bash
microcms schema pull \
  --format json-schema \
  --include-extensions \
  --out schema.json \
  --json
```

The generated document uses JSON Schema draft-07. It can support payload validation, form generation, or a structured definition passed to an AI tool.

## Related pages

- [Safe content operations](/en/content-operations)
- [Command reference](/en/command-reference)
- [Using mcms-cli from AI and CI](/en/ai-and-ci)
