さらに新しいブロックとしてコラムリストとコラムがサポートされた。コラムがどういうものがわからなかったので、サンプルで提供されていた JSON をこのページに追加してみた。このところ、取得しか実行していなかったので、たまには追加の実行例としても有用かと思う。スクリプトはこんな感じ。

#!/bin/sh

curl -X PATCH '<https://api.notion.com/v1/blocks/bea89c89792a481f86fe9520708c252e/children>' \\
  -H 'Authorization: Bearer '"$NOTION_API_KEY"'' \\
  -H "Content-Type: application/json" \\
  -H "Notion-Version: 2021-08-16" \\
  --data '{
	"children": [
    {
      "object": "block",
      "type": "column_list",
      "column_list": {
        "children": [
          {
            "object": "block",
            "type": "column",
            "column": {
              "children": [
                {
                  "object": "block",
                  "type": "paragraph",
                  "paragraph": {
                    "text": [
                      {
                        "type": "text",
                        "text": {
                          "content": "some text here"
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          {
            "object": "block",
            "type": "column",
            "column": {
              "children": [
                {
                  "object": "block",
                  "type": "paragraph",
                  "paragraph": {
                    "text": [
                      {
                        "type": "text",
                        "text": {
                          "content": "some text here"
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    }
  ]
}'

返却された JSON はこんな感じ。has_children が true になっているので、必要であれば子ブロックを取得する API を利用すればよい。

{
    "object": "list",
    "results": [
        {
            "object": "block",
            "id": "da3146ad-e5fb-45fe-8b7c-2b63f34be0fd",
            "created_time": "2021-11-11T02:30:00.000Z",
            "last_edited_time": "2021-11-11T02:30:00.000Z",
            "has_children": true,
            "archived": false,
            "type": "column_list",
            "column_list": {}
        }
    ],
    "next_cursor": null,
    "has_more": false
}

作成されたコラムリストはこれ。なるほどブロックを横に並べたものをコラムと呼ぶらしい。

some text here

some text here


Notion API Changelog まとめ