Admin API:エントリー
管理画面と同じように、エントリーを作る、変える、公開する、削除する操作と、版の履歴の操作です。共通の決まり(認証、エラーの形、日時)は Admin API のリファレンス にあります。
エントリーの値(data)の形は、フィールドの種類と値の形 と リッチテキストの形 にあります。
例の <ホスト名> はあなたの環境のホスト名、<アクセストークン> は hako_pat_ で始まるアクセストークンに置き換えます。<slug> などのほかの山かっこの値は、各操作のパラメーターの表にあるものに置き換えます。
| 操作 | メソッドとパス |
|---|---|
| エントリーの一覧 | GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries |
| エントリーを作る(下書き、または公開) | POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries |
| エントリーを取得する | GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id} |
| エントリーを削除する | DELETE /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id} |
| 下書きを保存する | PUT /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/draft |
| 下書きを捨てて、公開版に戻す | DELETE /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/draft |
| エントリーを公開する | POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/publish |
| 予約公開と予約公開終了を設定する | PUT /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/reservation |
| エントリーの版の一覧 | GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/revisions |
| エントリーの版を 1 つ、値ごと取得する | GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/revisions/{revision_id} |
| 公開を終了する | POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/unpublish |
エントリーの一覧
Section titled “エントリーの一覧”GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID | |
limit |
クエリ | 整数 | 0 以上 | ||
offset |
クエリ | 整数 | 0 以上 | ||
q |
クエリ | 文字列 | 全文検索 | ||
status |
クエリ | 文字列 | published draft closed reserved をカンマ区切りで(どれかに当てはまるもの) |
||
orders |
クエリ | 文字列 | updatedAt publishedAt createdAt。先頭に - で降順 |
返る値:
| 状態 | 本文 |
|---|---|
200 |
EntryList(application/json) |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries" \ -H "Authorization: Bearer <アクセストークン>"エントリーを作る(下書き、または公開)
Section titled “エントリーを作る(下書き、または公開)”POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID |
リクエストの本文(application/json):
| 名前 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|
data |
どの形でもよい | ○ | ||
id |
文字列か null | 省略すると自動で採番する | ||
publish |
真偽値 | true ならすぐ公開する。false(既定)なら下書きとして作る |
返る値:
| 状態 | 本文 |
|---|---|
201 |
Entry(application/json) |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl -X POST "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries" \ -H "Authorization: Bearer <アクセストークン>" \ -H "Content-Type: application/json" \ -d '{ "data": {}}'エントリーを取得する
Section titled “エントリーを取得する”GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID | |
id |
パス | 文字列 | ○ | ID |
返る値:
| 状態 | 本文 |
|---|---|
200 |
Entry(application/json) |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>" \ -H "Authorization: Bearer <アクセストークン>"エントリーを削除する
Section titled “エントリーを削除する”DELETE /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID | |
id |
パス | 文字列 | ○ | ID |
返る値:
| 状態 | 本文 |
|---|---|
204 |
なし |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl -X DELETE "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>" \ -H "Authorization: Bearer <アクセストークン>"下書きを保存する
Section titled “下書きを保存する”下書きを保存する。公開中なら公開版はそのままで、ステータスは「公開中(下書きあり)」になる。
PUT /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/draft- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID | |
id |
パス | 文字列 | ○ | ID |
リクエストの本文(application/json):
| 名前 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|
data |
どの形でもよい | ○ |
返る値:
| 状態 | 本文 |
|---|---|
200 |
Entry(application/json) |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl -X PUT "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>/draft" \ -H "Authorization: Bearer <アクセストークン>" \ -H "Content-Type: application/json" \ -d '{ "data": {}}'下書きを捨てて、公開版に戻す
Section titled “下書きを捨てて、公開版に戻す”DELETE /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/draft- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID | |
id |
パス | 文字列 | ○ | ID |
返る値:
| 状態 | 本文 |
|---|---|
200 |
Entry(application/json) |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl -X DELETE "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>/draft" \ -H "Authorization: Bearer <アクセストークン>"エントリーを公開する
Section titled “エントリーを公開する”POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/publish- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID | |
id |
パス | 文字列 | ○ | ID |
リクエストの本文(application/json。省略可):
PublishRequest か null。
返る値:
| 状態 | 本文 |
|---|---|
200 |
Entry(application/json) |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl -X POST "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>/publish" \ -H "Authorization: Bearer <アクセストークン>" \ -H "Content-Type: application/json" \ -d '{}'予約公開と予約公開終了を設定する
Section titled “予約公開と予約公開終了を設定する”予約公開と予約公開終了を設定する。キーを省略したものは変えず、null で取り消す。
PUT /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/reservation- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID | |
id |
パス | 文字列 | ○ | ID |
リクエストの本文(application/json):
| 名前 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|
closeAt |
文字列か null | 予約公開終了の日時(RFC 3339)。null で取り消す。省くと変えない | ||
publishAt |
文字列か null | 予約公開の日時(RFC 3339)。null で取り消す。省くと変えない |
返る値:
| 状態 | 本文 |
|---|---|
200 |
Entry(application/json) |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl -X PUT "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>/reservation" \ -H "Authorization: Bearer <アクセストークン>" \ -H "Content-Type: application/json" \ -d '{}'エントリーの版の一覧
Section titled “エントリーの版の一覧”版の一覧(値を含めない)。cursor は前のページの最後の版の番号。
GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/revisions- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID | |
id |
パス | 文字列 | ○ | ID | |
limit |
クエリ | 整数 | 0 以上 | ||
cursor |
クエリ | 文字列 |
返る値:
| 状態 | 本文 |
|---|---|
200 |
RevisionList(application/json) |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>/revisions" \ -H "Authorization: Bearer <アクセストークン>"エントリーの版を 1 つ、値ごと取得する
Section titled “エントリーの版を 1 つ、値ごと取得する”1 版を値ごと(比較と、編集画面への読み込みに使う)
GET /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/revisions/{revision_id}- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID | |
id |
パス | 文字列 | ○ | ID | |
revision_id |
パス | 文字列 | ○ | 版の ID |
返る値:
| 状態 | 本文 |
|---|---|
200 |
Revision(application/json) |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>/revisions/<revision_id>" \ -H "Authorization: Bearer <アクセストークン>"公開を終了する
Section titled “公開を終了する”公開を終了する。下書きは残る。
POST /admin/api/spaces/{slug}/content-types/{endpoint}/entries/{id}/unpublish- ログイン:要る(セッションかアクセストークン)
パラメーター:
| 名前 | 場所 | 型 | 必須 | 決まり | 説明 |
|---|---|---|---|---|---|
slug |
パス | 文字列 | ○ | スペースのスラッグ | |
endpoint |
パス | 文字列 | ○ | コンテンツタイプの ID | |
id |
パス | 文字列 | ○ | ID |
返る値:
| 状態 | 本文 |
|---|---|
200 |
Entry(application/json) |
うまくいかなかったときは、4xx か 5xx と、message を持つ JSON が返ります。状態ごとの意味は エラーの一覧 にあります。
例:
curl -X POST "https://<ホスト名>.hakocms.net/admin/api/spaces/<slug>/content-types/<endpoint>/entries/<id>/unpublish" \ -H "Authorization: Bearer <アクセストークン>"