microCMS

GET /api/v1/contents/{endpoint}/{content_id}

最終更新日:2023年11月08日

リスト型APIにおいて、idで指定したコンテンツのメタ情報を取得できるAPIです。

リクエストヘッダー

X-MICROCMS-API-KEY

GET APIリクエストの際に必要な認証キーです。
マネジメントAPIのデフォルト権限で「コンテンツの取得 (一覧・詳細)」を有効にして、リクエストヘッダーに含めて送信してください。

informationInformation

クライアントサイドから直接APIを呼び出すことでユーザーがキーを把握できてしまう場合、エンドポイントさえ分かればAPIを呼び出せてしまうことにご注意ください。
対処法としては、サーバサイドからAPIを呼び出す、またはJamstack構成にするなどしてキーを漏洩しないことが挙げられます。

レスポンス例

こちらがコンテンツ詳細のレスポンス例です。

{
    "id": "contentId",
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z",
     // 下書き中はnullが入る
    "publishedAt": "2019-08-24T14:15:22Z",
     // 下書き中はnullが入る
    "revisedAt": "2019-08-24T14:15:22Z",
    // 公開終了時は日時が入る(一度も公開終了していない場合はnullが入る)
    "closedAt": null,
    // DRAFT or PUBLISH or CLOSED or PUBLISH_AND_DRAFT
    "status": [
      "DRAFT"
    ],
    //カスタムステータス(未設定時はnullが入る)
    "customStatus": null,
    //コンテンツの公開時、公開終了時はnullが入る
    "draftKey": "draftKey",
    "createdBy": "string",
    "updatedBy": "string",
    // 予約が設定されていない場合nullが入る
    "reservationTime": {
      "publishTime": "2019-08-24T14:15:22Z", //公開開始予約設定がされていない場合nullが入る
      "stopTime": "2019-08-24T14:15:22Z" //公開停止予約設定がされていない場合nullが入る
    }
}


ステータスが「公開終了」のコンテンツの場合のレスポンス例です。closedAt に公開終了時刻が入ります。

{
  "id": "string",
  "createdAt": "2022-03-01T04:49:01.635Z",
  "updatedAt": "2022-03-01T05:05:54.711Z",
  "publishedAt": "2022-03-01T04:49:01.635Z",
  "revisedAt": "2022-03-01T04:49:01.635Z",
  "closedAt": "2022-03-01T05:05:54.711Z",
  "status": [
    "CLOSED"
  ],
   //カスタムステータス
   "customStatus": null,
  "draftKey": null,
  "createdBy": "681dcd71-b7b9-4149-b45b-5e96eb51fecf",
  "updatedBy": "681dcd71-b7b9-4149-b45b-5e96eb51fecf",
  "reservationTime": null
}


カスタムステータス

カスタムステータスが設定されたコンテンツでは以下のように customStatus がレスポンスに含まれます。

{
  "id": "string",
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z",
  "publishedAt": "2019-08-24T14:15:22Z",
  "revisedAt": "2019-08-24T14:15:22Z",
  "status": [
    "PUBLISH"
  ],
  // このcustomStatusが新たに追加されます。
  // customStatusが未対応のプランや設定されていない場合はnullになります。
  "customStatus": [
    {
      "key": "USER_DEFINED_CUSTOM_STATUS_KEY123",
      "description": "ユーザが定義したカスタムステータスです。",
      "name": "カスタムステータスのテスト",
      "behaviour": "PUBLISH",
      "color": "#a20063",
      "createdAt": "2019-08-24T14:15:22Z",
      "updatedAt": "2019-08-24T14:15:22Z"
    }
  ],
  "draftKey": "string",
  "createdBy": "string",
  "updatedBy": "string",
  "reservationTime": {
    "publishTime": "2019-08-24T14:15:22Z",
    "stopTime": "2019-08-24T14:15:22Z"
  }
}


カスタムステータスについて詳しくは、以下ドキュメントをご覧ください。

カスタムステータス
https://document.microcms.io/manual/custom-status