---
title: コマンドリファレンス
description: >-
  mcms-cliで利用できる主要コマンドを、認証、設定、コンテンツ、メディア、APIスキーマ、型生成、ドキュメント参照の目的別に一覧化します。各コマンドの役割と代表的な実行例に加え、JSON出力、プロファイル選択、タイムアウト、再試行など、共通オプションも確認できます。
sidebar:
  order: 6
noindex: false
---
## APIとコンテンツ

```bash
microcms api list --json
microcms api info <endpoint> --json
microcms api schema inspect <endpoint> --json

microcms content list <endpoint> --all --json
microcms content get <endpoint> <id> --json
microcms content create <endpoint> --file payload.json --dry-run --json
microcms content update <endpoint> <id> --file payload.json --dry-run --json
microcms content delete <endpoint> <id> --dry-run --json
microcms validate <endpoint> --file payload.json --json
```


### APIを作成する（v0.8.0以降）

`microcms api create`は、Management APIを使ってJSONファイルからAPIを作成します。`--name`、`--endpoint`、`--type`でファイルの基本設定を補完または上書きできます。

まずdry-runを実行し、作成するAPIの内容を確認します。

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

dry-runではAPIスキーマとカスタムフィールドの構造を検証します。出力、終了コード、JSONの`.ok`を確認してから、`--dry-run`を外して作成します。

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

API作成で追加料金を許可する場合だけ、`--allow-additional-charge`を明示します。

v0.8.0で加わった変更点は[リリースノート](/changelog/v0-8-0)にまとめています。


## エクスポートとインポート

```bash
microcms content export <endpoint> \
  --out backup/contents.json \
  --json

microcms content export --all \
  --out backup/ \
  --json

microcms content import <endpoint> \
  --file backup/contents.json \
  --dry-run \
  --strict-warnings \
  --json
```

## file-based運用

```bash
microcms content pull <endpoint> \
  --all \
  --out managed-content \
  --format managed-json \
  --json

microcms content verify <endpoint> \
  --dir managed-content \
  --only-changed \
  --json

microcms content push <endpoint> \
  --dir managed-content \
  --json
```

`content push`は、既定ではverifyだけを行います。remoteへ書き込む場合は`--execute`が必要です。managed-json v1はlist APIが対象で、削除は明示的なtombstoneを使います。

## メディア

```bash
microcms media list --limit 20 --image-only --json
microcms media upload ./image.png --dry-run --json
microcms media delete --url <media-url> --dry-run --json
```

## スキーマと型

```bash
microcms schema pull --out schema.json --json
microcms schema diff --baseline schema.json --json
microcms types sync --out microcms-types.d.ts --json
```

## 認証と設定

```bash
microcms auth status --json
microcms auth profile list --json
microcms config doctor --json
microcms completion install zsh --json
```

## 主なグローバルオプション

- `--json`: 機械判定用JSON
- `--profile <name>`: 接続プロファイルを選択
- `--service-domain <domain>`: service domainを明示
- `--api-key-stdin`: APIキーを標準入力から渡す
- `--timeout <ms>`: タイムアウトを指定
- `--retry <count>`: retry-safeなリクエストの再試行回数
- `--verbose`: 詳細情報を含める
- `--no-color`: 色付き出力を無効化

## 関連ページ

- [コンテンツを安全に操作する](/content-operations)
- [スキーマと型を管理する](/schema-and-types)
- [FAQ・トラブルシューティング](/faq)
