サービスにAPIを作成するAPIです。
項目 | 制約 |
|---|---|
API名 | サービス内で識別できる名前を指定します。 |
エンドポイント | サービス内で一意の値を指定します。既存のAPIと同じ値は使用できません。 |
フィールド数 |
|
allowAdditionalCharge=true を指定してください。リクエストとレスポンスには、APIスキーマ取得時と共通の形式を使用します。そのため、取得したAPIスキーマをもとに、別のサービスや環境へAPIを作成できます。
APIスキーマ取得のマネジメントAPIについては「GET /api/v1/apis/{endpoint}」をご確認ください。
X-MICROCMS-API-KEYが判別できると、第三者による不正なコンテンツの操作が可能となります。お取り扱いには十分ご注意ください。詳細は「APIキー(APIの認証と権限管理)」をご覧ください。
送信するデータの形式を指定します。
microCMSではJSON形式のデータのみ扱っているため、application/json と指定してください。
API数が契約プランの上限に達している場合に、追加料金によるAPI作成を許可するかを指定します。Teamプラン、Businessプラン、Enterpriseプランで利用できます。
値 | 説明 |
|---|---|
| 追加料金による作成を許可しません。パラメータ省略時の既定値です。 |
| 追加料金によるAPI作成を許可します。Teamプラン、Businessプラン、Enterpriseプランで利用できます。 |
プロパティ | 型 | 指定要否 | 説明 |
|---|---|---|---|
| string | 必須 | API名です。1〜300文字で指定します。 |
| string | 必須 | APIのエンドポイントです。3〜32文字の半角英小文字、数字、ハイフン( |
| string | 必須 | APIの形式です。 |
| array | 必須 | 詳細は、下記のapiFieldsをご覧ください。 |
| array | 任意 | カスタムフィールドの定義です。 |
未知のプロパティや、各フィールド種別で利用できないプロパティを指定した場合は、400 Bad Request が返却されます。
apiFields には、APIに作成するフィールドを配列で指定します。
以降のセクションでは、各フィールドのJSONに指定可能なプロパティや制約を、フィールド種別ごとに説明します。
すべてのフィールドのJSONは、共通プロパティを持ちます。
{
"fieldId": "title",
"name": "タイトル",
"kind": "text",
"description": "説明文",
"required": true
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| フィールドID | string | 必須 |
|
| 表示名 | string | 必須 | 1〜100文字 |
| フィールド種別 | enum | 必須 | 指定できる値と対応するフィールドは下記の「kindプロパティに指定できる値と対応するフィールド」を参照 |
| 説明文 | string | null | 任意 |
|
| 必須設定 | boolean | 任意 | - |
kindの値 | フィールド | ドキュメント |
|---|---|---|
| テキストフィールド | |
| テキストエリア | |
| リッチエディタ | |
| 画像 | |
| 複数画像 | |
| ファイル | |
| 日時 | |
| 数字 | |
| 真偽値 | |
| セレクトフィールド | |
| コンテンツ参照 | |
| 複数コンテンツ参照 | |
| 拡張フィールド | |
| カスタム | |
| 繰り返し |
{
"fieldId": "title",
"name": "タイトル",
"kind": "text",
"description": "記事のタイトルです",
"required": true,
"isUnique": false,
"patternMatchValidation": {
"regexp": { "pattern": "^[A-Za-z0-9]+$", "flags": "gi" }
},
"textSizeLimitValidation": {
"textSize": { "min": 1, "max": 50 }
},
"initialValue": "初期値のテキスト"
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 重複を許可しない(ユニーク) | boolean | 任意 |
|
| 特定のパターンのみ入力を許可する | object | null | 任意 | - |
| パターン | string | 任意 |
|
| Flags | string | null | 任意 |
|
| 文字数を制限する | object | null | 任意 | 制限を設定する場合は、 |
| 最小 | number | null | 任意 |
|
| 最大 | number | null | 任意 |
|
| 初期値 | string | null | 任意 |
|
{
"fieldId": "body",
"name": "本文",
"kind": "textArea",
"description": "記事の本文です",
"required": true,
"patternMatchValidation": {
"regexp": { "pattern": "^[A-Za-z0-9]+$", "flags": "gi" }
},
"textSizeLimitValidation": {
"textSize": { "min": 0, "max": 1000 }
},
"initialValue": "初期値の本文"
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 特定のパターンのみ入力を許可する | object | null | 任意 | - |
| パターン | string | 任意 |
|
| Flags | string | null | 任意 |
|
| 文字数を制限する | object | null | 任意 | 制限を設定する場合は、 |
| 最小 | number | null | 任意 |
|
| 最大 | number | null | 任意 |
|
| 初期値 | string | null | 任意 |
|
{
"fieldId": "editor",
"name": "リッチエディタ",
"kind": "richEditorV2",
"description": "記事の本文です",
"required": true,
"richEditorV2Options": ["paragraph", "bold", "link", "image", "color", "size"],
"richEditorV2ColorList": [{ "id": "f7Kp_2mQx9", "value": "rgb(255, 0, 0)" }],
"richEditorV2HideColorPicker": false,
"richEditorV2FontSizeList": [{ "id": "a9X-3vLmQ2", "name": "Large", "value": "120" }],
"customClassList": [{ "id": "N4cR_8zTp1", "name": "注釈", "value": "note" }]
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| ツールバーの編集 | enum[] | 任意 |
|
| 色のプリセット | object[] | 任意 | 最大20件 |
| 内部識別子 | string | 任意 |
|
| 色 | string | 条件付き必須 |
|
| 色のプリセットのみを表示し、カラーピッカーを非表示にする | boolean | 任意 | true にする場合は richEditorV2ColorList が1件以上必要 |
| 文字サイズのプリセット | object[] | 任意 | 最大20件 |
| 内部識別子 | string | 任意 |
|
| 表示名 | string | 条件付き必須 |
|
| サイズ(%) | string | 条件付き必須 |
|
| カスタムclass | object[] | 任意 | - |
| 内部識別子 | string | 任意 |
|
| 表示名 | string | 条件付き必須 |
|
| class名 | string | 条件付き必須 |
|
値 | 装飾/機能 |
|---|---|
| 見出し1 |
| 見出し2 |
| 見出し3 |
| 見出し4 |
| 見出し5 |
| 段落 |
| 太字 |
| 斜体 |
| 下線 |
| 取り消し線 |
| インラインコード |
| 引用 |
| コードブロック |
| 箇条書き |
| 番号付きリスト |
| リンク |
| 画像 |
| ファイル |
| 表 |
| 区切り線 |
| 埋め込み(OEmbed) |
| 文字揃え |
| カスタムクラス |
| 文字色 |
| 文字サイズ |
undo、redo、clean は常に有効な固定項目であるため、richEditorV2Options には指定できません。指定した場合は 400 Bad Request が返されます。また、GETおよび作成成功時のレスポンスにも含まれません。
{
"fieldId": "thumbnail",
"name": "サムネイル",
"kind": "media",
"description": "記事のサムネイル画像です",
"required": true,
"imageSizeValidation": { "imageSize": { "width": 600, "height": 400 } },
"initialValue": "https://images.microcms-assets.io/assets/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/image.jpg"
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 画像のサイズ制限 | object | null | 任意 | 制限を設定する場合は、 |
| width | number | null | 任意 | 1以上の整数 |
| height | number | null | 任意 | 1以上の整数 |
| 初期値 | string | null | 任意 |
|
{
"fieldId": "gallery",
"name": "ギャラリー",
"kind": "mediaList",
"description": "記事内で使用するギャラリーの画像を複数選択",
"required": false,
"mediaListLayout": "GRID_3",
"imageSizeValidation": { "imageSize": { "width": 400, "height": 600 } },
"initialValue": [
"https://images.microcms-assets.io/assets/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/image-01.jpg",
"https://images.microcms-assets.io/assets/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy/image-02.jpg"
]
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| レイアウト | enum | 任意 |
|
| 画像のサイズ制限 | object | null | 任意 | 制限を設定する場合は、 |
| width | number | null | 任意 | 1以上の整数 |
| height | number | null | 任意 | 1以上の整数 |
| 初期値 | string[] | 任意 |
|
値 | レイアウト |
|---|---|
| 横並び(スクロール) |
| 横並び(2カラム) |
| 横並び(3カラム) |
| 横並び(4カラム) |
ファイルフィールドは、Teamプラン、Businessプラン、Enterpriseプランで利用できます。Hobbyプランでは利用できません。
プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 初期値 | string | null | 任意 |
|
{
"fieldId": "eventDate",
"name": "開催日時",
"kind": "date",
"description": "コンテンツの日付です",
"required": false,
"dateFormat": true,
"initialValue": "2026-07-03T09:00:00.000Z"
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 日付指定のみ | boolean | 任意 |
|
| 初期値 | string | null | 任意 |
|
{
"fieldId": "price",
"name": "価格",
"kind": "number",
"description": "商品の価格です",
"required": false,
"numberSizeLimitValidation": { "numberSize": { "min": 100, "max": 10000 } },
"initialValue": 10000
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 数値を制限する | object | null | 任意 | 制限を設定する場合は、 |
| 最小 | number | null | 任意 |
|
| 最大 | number | null | 任意 |
|
| 初期値 | number | null | 任意 |
|
{
"fieldId": "isActive",
"name": "有効",
"kind": "boolean",
"description": "真偽値です",
"required": false,
"initialValue":true
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 初期値 | boolean | 任意 | - |
{
"fieldId": "category",
"name": "カテゴリ",
"kind": "select",
"description": "記事のカテゴリです",
"required": true,
"selectItems": [
{ "id": "0HGv33ahx5", "value": "ニュース" },
{ "id": "9zB0S7w-HU", "value": "ブログ" }
],
"multipleSelect": false,
"initialValue": ["9zB0S7w-HU"]
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 選択肢 | object[] | 必須 | 空配列を指定可能 |
| 内部識別子 | string | 任意 |
|
| 選択肢の値 | string | 条件付き必須 |
|
| 複数選択 | boolean | 必須 |
|
| 初期値 | string[] | 任意 |
|
{
"fieldId": "category",
"name": "カテゴリ",
"kind": "relation",
"description": "記事に紐づくカテゴリです",
"required": false,
"referencedApiEndpoint": "categories",
"listViewFieldId": "title"
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 参照先API | string | 必須 |
|
| 一覧画面に表示する項目 | string | 任意 |
|
{
"fieldId": "relatedArticles",
"name": "関連記事",
"kind": "relationList",
"description": "記事に紐づく関連記事です",
"required": false,
"relationListCountLimitValidation": {
"relationListCount": { "min": 1, "max": 4 }
},
"referencedApiEndpoint": "articles",
"listViewFieldId": "title"
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 複数コンテンツ参照の数を制限する | object | null | 任意 | 制限を設定する場合は、 |
| 最小 | number | null | 任意 |
|
| 最大 | number | null | 任意 |
|
| 参照先API | string | 必須 |
|
| 一覧画面に表示する項目 | string | 任意 |
|
{
"fieldId": "embed",
"name": "埋め込み",
"kind": "iframe",
"description": "外部ツールと連携する拡張フィールドです",
"required": false,
"iframeUrl": "https://example.com/embed"
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 拡張フィールド URL | string | 必須 | http または https スキームを持ち、ホストを含むURL形式の文字列 |
customFieldsで定義したデータを紐付けます。
{
"fieldId": "authorProfile",
"name": "著者プロフィール",
"kind": "custom",
"description": "著者プロフィールを入力するカスタムフィールドです",
"required": false,
"customFieldId": "profile",
"listViewFieldId": "name"
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 対象のカスタムフィールド | string | 必須 | 「customFields」内にある対象データの |
| 一覧画面に表示する項目 | string | 任意 |
|
customFieldsで定義したデータを複数選択して紐付けます。
{
"fieldId": "items",
"name": "セクション",
"kind": "repeater",
"description": "見出しや本文などのブロックを繰り返し入力できます",
"required": false,
"customFieldIds": [
"headingBlock",
"bodyBlock"
],
"repeaterCountLimitValidation": {
"repeatCount": { "min": 1, "max": 10 }
}
}プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| 対象のカスタムフィールド | string[] | 必須 |
|
| 繰り返しフィールドの数を制限する | object | null | 任意 | 制限を設定する場合は、 |
| 最小 | number | 任意 |
|
| 最大 | number | 任意 |
|
initialValue の型がフィールド種別と一致しない場合は、対象のフィールドとプロパティを示す 400 Bad Request が返却されます。initialValue 自体を省略してください。null を指定できるかどうかはプロパティによって異なります。initialValue もその条件を満たす必要があります。文字数、正規表現、数値範囲などの条件を満たさない場合は、400 Bad Request が返却されます。プロパティ | 設定項目 | 型 | 指定要否 | 仕様/制約 |
|---|---|---|---|---|
| カスタムフィールドID | string | 必須 |
|
| 表示名 | string | 必須 | 1〜300文字で指定 |
| フィールド定義 | object[] | 必須 | 1件以上指定。各フィールドの設定内容は apiFields と同じ |
| カスタムフィールド内のレイアウト | string[][] | 必須 | 各フィールドの表示位置。詳細は「レイアウトの指定方法」を参照 |
1列配置
すべてのフィールドを縦一列に並べる場合、配列を1つだけ内包します。
"fieldOrderByColumn": [
["field01", "field02", "field03"]
]1つ目の配列が左列、2つ目の配列が右列に対応します。
"fieldOrderByColumn": [
["field01", "field02"], // 左側に表示
["field03"] // 右側に表示
]fields に含まれるすべての fieldId を重複や不足なく指定してください。customFields は最大99件まで指定できます。kind が custom の場合は customFieldId、repeater の場合は customFieldIds に、同じリクエストの customFields[].fieldId を指定します。customFieldId または customFieldIds に、customFields で定義されていないフィールドIDを指定した場合は、400 Bad Request が返却されます。customFields[].fields には、1件以上のフィールドを指定します。空配列は指定できません。custom を指定することはできません。customFields[].fields[] 内のテキストフィールドでは、isUnique: trueを指定できません。false またはキー省略のみ指定可能です。以下は、リスト形式のAPIを作成する例です。
curl -X POST "https://[サービスID].microcms-management.io/api/v1/apis" \
-H "X-MICROCMS-API-KEY: [APIキー]" \
-H "Content-Type: application/json" \
-d '{
"name": "ブログ",
"endpoint": "blog",
"type": "list",
"apiFields": [
{
"fieldId": "title",
"name": "タイトル",
"kind": "text",
"required": true,
"initialValue": "無題"
},
{
"fieldId": "price",
"name": "価格",
"kind": "number",
"initialValue": 1000
},
{
"fieldId": "published",
"name": "公開",
"kind": "boolean",
"initialValue": true
},
{
"fieldId": "thumbnail",
"name": "サムネイル",
"kind": "media",
"initialValue": "https://images.microcms-assets.io/assets/xxxx/yyyy/sample.png"
}
]
}'curl -X POST "https://[サービスID].microcms-management.io/api/v1/apis" \
-H "X-MICROCMS-API-KEY: [APIキー]" \
-H "Content-Type: application/json" \
-d '{
"name": "製品紹介",
"endpoint": "products",
"type": "list",
"apiFields": [
{
"fieldId": "productName",
"name": "製品名",
"kind": "text",
"required": true,
"isUnique": true
},
{
"fieldId": "seo",
"name": "SEO設定",
"kind": "custom",
"customFieldId": "seoSettings"
},
{
"fieldId": "faq",
"name": "よくある質問",
"kind": "repeater",
"customFieldIds": ["faqItem"],
"repeaterCountLimitValidation": {
"repeatCount": {
"min": 1,
"max": 20
}
}
}
],
"customFields": [
{
"fieldId": "seoSettings",
"name": "SEO設定",
"fields": [
{
"fieldId": "metaTitle",
"name": "メタタイトル",
"kind": "text",
"required": true
},
{
"fieldId": "metaDescription",
"name": "説明",
"kind": "textArea"
}
],
"fieldOrderByColumn": [
["metaTitle"],
["metaDescription"]
]
},
{
"fieldId": "faqItem",
"name": "FAQ項目",
"fields": [
{
"fieldId": "question",
"name": "質問",
"kind": "text",
"required": true
},
{
"fieldId": "answer",
"name": "回答",
"kind": "richEditorV2",
"richEditorV2Options": ["bold", "link", "listBullet"]
}
],
"fieldOrderByColumn": [
["question"],
["answer"]
]
}
]
}'正常にAPIを作成できた場合は、201 Created が返却されます。
レスポンスボディは、作成したAPIのスキーマです。APIスキーマ取得時と同じ形式で返却されます。apiFields および customFields[].fields の各要素には、フィールド種別に対応するすべてのプロパティが含まれます。リクエスト時に省略したプロパティも、既定値または null で返却されます。
{
"name": "ブログ",
"endpoint": "blog",
"type": "list",
"apiFields": [
{
"fieldId": "title",
"name": "タイトル",
"kind": "text",
"description": null,
"required": true,
"textSizeLimitValidation": null,
"patternMatchValidation": null,
"isUnique": false,
"initialValue": "無題"
},
{
"fieldId": "price",
"name": "価格",
"kind": "number",
"description": null,
"required": false,
"numberSizeLimitValidation": null,
"initialValue": 1000
},
{
"fieldId": "published",
"name": "公開",
"kind": "boolean",
"description": null,
"required": false,
"initialValue": true
},
{
"fieldId": "thumbnail",
"name": "サムネイル",
"kind": "media",
"description": null,
"required": false,
"imageSizeValidation": null,
"initialValue": "https://images.microcms-assets.io/assets/xxxx/yyyy/sample.png"
}
],
"customFields": []
}ステータスコード | 説明 |
|---|---|
| APIの作成に成功しました。 |
| リクエストボディが不正です。必須項目の不足、型の不一致、未知のプロパティ、フィールド種別に対応しないプロパティなどが含まれます。 |
| 契約プランのAPI数上限に達しています。追加料金による作成を許可する場合は、 |
| APIキーに「APIの作成」権限がない、または契約プランで利用できないフィールド種別が含まれています。 |
| 同じエンドポイントのAPIがすでに存在します。 |
たとえば、text フィールドの initialValue に数値を指定した場合は、次のようなレスポンスが返却されます。
{ "message": "field \"title\": \"initialValue\" must be of type string" }