# Notion

Run Notion REST API operations from a workflow.

## Auth and Access

- Select a `notion` connection.
- API key auth uses a Notion internal integration token.
- OAuth auth uses the stored Notion access token when available.
- The connection can only access pages, blocks, and data sources shared with that integration/user.
- IDs must be exact Notion IDs. URLs and names are not resolved.

## Inputs

- `input` - Triggers the node. Interpolatable fields can read from `{{ input.* }}`.

## Configuration

- `connection` - required Notion connection ID.
- `operation` - tagged operation object with `op`.
- `retry` - whether each Notion request is sent again after a failure that passes: a rate limit, a busy server, a dropped connection. Off by default; see [Retries](http_get.md#retries). `search`, `content_search`, `retrieve_page`, `delete_block`, `list_block_children` and `query_data_source` are sent again freely; `create_page`, `update_page_properties`, `delete_page`, `append_block_children` and `update_block` are writes, sent again only when Notion refused them before acting: the connection never opened, or Notion answered 425 or 429.

## Operations

### `search`

Searches shared pages and data sources by title/name using Notion REST `/v1/search`.

- `query` - optional search text. Blank is omitted.
- `object_filter` - `all`, `page`, or `data_source`. `all` omits the Notion filter.
- `limit` - max total results, default `50`, max `1000`.
- `start_cursor` - optional initial cursor. Blank is omitted.

### `content_search`

Searches text inside shared pages by enumerating pages and scanning block text. Use this for content questions such as “What is our leave policy?”.

- `query` - required text to find in page content.
- `limit` - max matching pages to return, default `50`, max `1000`.
- `max_pages` - max shared pages to inspect, default `25`, max `1000`.
- `max_blocks_per_page` - max blocks to inspect per page, default `200`, max `1000`.

### `retrieve_page`

Retrieves one page.

- `page_id` - required exact page ID.

### `create_page`

Creates a page.

- `parent_kind` - `page`, `data_source`, or `workspace`.
- `parent_id` - required for `page` and `data_source`; omitted for `workspace`.
- `title` - used only when `properties` is empty.
- `markdown` - optional top-level Markdown content. Blank is omitted.
- `properties` - optional Notion page properties object. If non-empty, sent as-is.

Properties example:

```json
{
  "Name": { "title": [{ "text": { "content": "Incident follow-up" } }] },
  "Status": { "status": { "name": "Open" } },
  "Priority": { "select": { "name": "High" } }
}
```

### `update_page_properties`

Updates page properties.

- `page_id` - required exact page ID.
- `properties` - required non-empty Notion properties object.

### `delete_page`

Moves a page to trash.

- `page_id` - required exact page ID.
- Sends `in_trash: true` to Notion.

### `append_block_children`

Appends child blocks.

- `block_id` - required exact block ID.
- `children` - required non-empty Notion block children array.

Children example:

```json
[
  {
    "object": "block",
    "type": "paragraph",
    "paragraph": {
      "rich_text": [{ "type": "text", "text": { "content": "Follow up required." } }]
    }
  }
]
```

### `update_block`

Updates a block.

- `block_id` - required exact block ID.
- `block` - required non-empty Notion block update object.

Block update example:

```json
{
  "type": "paragraph",
  "paragraph": {
    "rich_text": [{ "type": "text", "text": { "content": "Updated text." } }]
  }
}
```

### `delete_block`

Deletes a block.

- `block_id` - required exact block ID.

### `list_block_children`

Lists child blocks.

- `block_id` - required exact block ID.
- `limit` - max total results, default `50`, max `1000`.
- `start_cursor` - optional initial cursor. Blank is omitted.

### `query_data_source`

Queries a shared data source.

- `data_source_id` - required exact data source ID.
- `filter` - optional Notion filter object. `null` omits it.
- `sorts` - optional Notion sorts array. `null` omits it.
- `limit` - max total results, default `50`, max `1000`.
- `start_cursor` - optional initial cursor. Blank is omitted.

Filter example:

```json
{
  "property": "Status",
  "status": { "equals": "Open" }
}
```

Sorts example:

```json
[
  { "property": "Priority", "direction": "ascending" },
  { "timestamp": "created_time", "direction": "descending" }
]
```

## Pagination

- `search`, `list_block_children`, and `query_data_source` auto-page until `limit` results are collected or Notion returns `has_more: false`.
- Requests use Notion page sizes up to `100`.
- Output preserves the final Notion list object and replaces `results` with the merged results.

## Outputs

- `output` - raw Notion JSON response.
- List operations return a Notion list object with merged `results`.
- Non-list operations return the raw Notion page/block/mutation response.
