notion-dotnet / notion-sdk-net

A Notion SDK for .Net
MIT License
186 stars 46 forks source link

Block `colors` are now supported in the API #251

Closed KoditkarVedant closed 2 years ago

KoditkarVedant commented 2 years ago

Notion has added support for block colors in the Notion Public API. There is now a color keyword for the following block types: paragraph, heading_1, heading_2, heading_3, bulleted_list_item, numbered_list_item, to_do, toggle, callout, quote, and table_of_contents.

For these block types, the block color is returned in the block object, and you can use the update block, append block children, and create page endpoints to update the color of existing blocks and create new blocks with color.

The colors supported are default, gray, brown, orange, yellow, green, blue, purple, pink, red, gray_background, brown_background, orange_background, yellow_background, green_background, blue_background, purple_background, pink_background, and red_background.

Example block object

{
    "object": "block",
    "id": "79bc0ae2-b002-4ecd-92db-870354734aaf",
    "created_time": "2022-03-03T22:49:00.000Z",
    "last_edited_time": "2022-03-03T22:49:00.000Z",
    "created_by": {
        "object": "user",
        "id": "914ff1b3-45c7-48dc-b2c2-be37d21e7695"
    },
    "last_edited_by": {
        "object": "user",
        "id": "914ff1b3-45c7-48dc-b2c2-be37d21e7695"
    },
    "has_children": false,
    "archived": false,
    "type": "callout",
    "callout": {
        "rich_text": [
            {
                "type": "text",
                "text": {
                    "content": "This block has color!",
                    "link": null
                },
                "annotations": {
                    "bold": false,
                    "italic": false,
                    "strikethrough": false,
                    "underline": false,
                    "code": false,
                    "color": "default"
                },
                "plain_text": "This block has color!",
                "href": null
            }
        ],
        "icon": {
            "type": "emoji",
            "emoji": "💡"
        },
        "color": "green_background"
    }
}

Notion changelog: https://developers.notion.com/changelog/block-colors-are-now-supported-in-the-api