# Start a workflow from Notion events

> Run a workflow when Notion reports a created or changed page, a data source change, or a comment, with a Webhook block set to Notion.

To run a workflow when Notion reports a created or changed page, a data source change, or a comment, add a **Webhook** block whose **Source** is **Notion** and create a webhook subscription in Notion that sends to its URL. Notion posts one event per request. Each event starts its own run.

You need a Notion connection whose settings you can open, and edit access to the workflow's project. A connection is Notion's name for the app that reads your Notion pages. It is not a connection in OutWin, and you add nothing under **Connections** for this guide. The Notion steps happen in Notion's connection settings.

## Add the Webhook block and generate its URL

1. In a draft workflow, add a **Webhook** block. The block palette also lists **Notion webhook** in the **Start** group, which adds the block with its source already set.
2. Under **Source**, choose **Notion**. The line under the setting reads "Verifies the signature · one run per event · skips duplicates".
3. Under **Webhook URL**, select **Generate URL**, then copy the URL.

The badge beside the URL reads "Runs start after publish". The URL contains a token, and anyone who has the URL can send requests to it. Keep it out of shared documents.

## Select Connect, then create the subscription in Notion

Notion makes a verification token for each subscription and posts it to the block's URL once, when the subscription is created. The block saves a token that arrives this way only while it is waiting for one, so start the wait before you create the subscription.

1. In the block's settings, under **Verification token**, select **Connect**. The line then starts "Waiting for Notion until", followed by a time 15 minutes ahead.
2. Before that time, open your connection's settings in Notion, open the **Webhooks** tab, and select **+ Create a subscription**.
3. Paste the URL you copied as the webhook URL, and choose the event types Notion sends.
4. Select **Create subscription**.

Notion then posts the token. The block saves it, and **Recent deliveries** lists the request as **Handshake** with "Notion sent its verification token, and it is saved. Copy it from the block's settings and paste it into Notion to finish." The settings show only the last four characters of the token, with **Replace** and **Remove**. Under **Set up**, the second line changes to "The verification token is saved: deliveries are verified."

The first token that arrives ends the wait. **Stop waiting** ends it sooner. A token that arrives when the block is not waiting is not saved. **Recent deliveries** then lists a **Handshake** with "Notion sent a verification token, but this trigger was not waiting for one, so it was not saved. Press Connect in the block's settings, then send the token from Notion again."

The Webhook block offers these Notion event types: `page.created`, `page.content_updated`, `page.properties_updated`, `page.moved`, `page.deleted`, `page.undeleted`, `page.locked`, `page.unlocked`, `data_source.created`, `data_source.content_updated`, `data_source.schema_updated`, `data_source.deleted`, `database.created`, `database.deleted`, `comment.created`, `comment.updated`, and `comment.deleted`.

## Paste the token into Notion

The subscription sends no events until you give Notion the token it posted. The block shows the token for 15 minutes after it arrives, for this step only.

1. In the block's settings, select **Show the verification token**. The line beside the button reads "Paste it into Notion to finish." and gives the time until which the token can be shown.
2. Select **Copy**. **Hide** hides the token again.
3. In Notion, on the **Webhooks** tab, select **Verify** on the subscription, paste the token, and select **Verify subscription**.

After the 15 minutes the token is not shown again, in OutWin or to any role. If you did not paste it in time, select **Replace**, then **Connect**, and select **Resend token** where Notion asks for the token. Notion posts the token again, and the block shows it for another 15 minutes.

Notion signs each event with the token, and the saved token lets OutWin check that signature. Notion issues the token for one subscription, so OutWin saves it on the block's URL. A second Webhook block has its own URL and needs its own subscription.

Without a saved token, for example after you select **Remove**, the block still starts runs, and nothing is verified: anyone who has the URL can start the workflow. Publishing then shows a warning that ends "has no signing secret saved, so its deliveries are not verified: anyone who has this URL can start this workflow". The warning does not block publishing.

## Choose which events start a run

Under **Events that start a run**, tick the event types that start a run. With none ticked, every event Notion sends starts a run. To start runs for a type that is not listed, type it into the box under the list and select **Add**.

An event whose type is not ticked is listed as **Filtered out** and starts no run. To narrow further by a field of the event, add a row under **Only when**. For example, a row with the field `body.entity.id` starts runs for one page only. [Webhook settings](https://outwin.ai/docs/reference/triggers-approvals-and-waits/#webhook-settings) lists the comparisons.

## Send a test and check what arrived

1. In Notion, do something that causes one of the subscribed events, such as adding a page in a place the connection has access to.
2. In OutWin, look under **Recent deliveries** in the block's settings.

Notion sends an event only for a page or data source that the connection has access to. A page created inside a private page that the connection cannot read causes no event.

**Recent deliveries** lists every event that reached the URL, including while the workflow is a draft. On a draft each event is listed as **Dropped** with "The workflow is not published, so nothing ran." It starts no run and is not run later. The last line under **Set up** changes to, for example, "Received page.created. Dropped."

With a token saved, an event listed as **Dropped** on a draft has passed the signature check. A delivery that fails the check is listed as **Refused**.

If you have edit access, select an event to see what the block passed on. The list is kept for seven days, and the data of the newest 20 events is kept.

## Read the event in the next block

Each run receives one Notion event. An HTTP request block or a database block directly after the Webhook block reads it with these expressions. An AI block such as **Think** receives the whole value as its input.

| Expression | What it holds |
| --- | --- |
| `{{input.body}}` | The event as Notion sent it, with fields such as `id`, `timestamp`, `type`, `entity`, `workspace_id`, `subscription_id`, `attempt_number`, and `data`. |
| `{{input.body.entity.id}}` | One field of the event: the id of the page, data source, or comment the event is about. Read any other field the same way. |
| `{{input.event.type}}` | The event's type, such as `page.created`. It is the event's `type` field. |
| `{{input.event.id}}` | The event's id. It is the event's `id` field. |
| `{{input.event.time}}` | The event's time as an ISO 8601 date and time. It is the event's `timestamp` field. |
| `{{input.delivery.verified}}` | `true` only when the signature was checked and passed. |

An event says what changed and where. It does not hold the page's content. If the workflow needs the page, read it from Notion's API with an [HTTP request](https://outwin.ai/docs/reference/blocks/http-request/) block and `{{input.body.entity.id}}`.

A block further along reads the same values through the Webhook block's name, as in `{{steps["Notion"].body.entity.id}}` for a block named `Notion`. [Data and context](https://outwin.ai/docs/reference/data-and-context/) describes what each block passes on.

## Publish and check the runs

[Publish the workflow](https://outwin.ai/docs/run/publish-and-start/). From then on, each event that passes the filter starts a run. On a published workflow the block's settings are read-only, and **Recent deliveries** is in the block's inspector. The token is there too, with **Replace**, **Connect**, and **Show the verification token**.

| Outcome | What happened |
| --- | --- |
| **Ran** | The event started a run. |
| **Waiting** | 10 runs of the workflow are already active. The event starts a run when one of them ends. An event that waits longer than an hour is listed as **Dropped**. |
| **Duplicate** | An event with the same `id` already ran in the last 72 hours. The line reads "This event was already received and run, so it did not run again." |
| **Handshake** | Notion's request that carried the verification token. It starts no run. |

Runs start in the order events arrive. That is not always the order things happened, so do not build a workflow that relies on `page.created` arriving before `page.content_updated`.

Receiving an event costs no credits, and neither does an event that is filtered out, a duplicate, or a handshake. A run that starts uses credits for the blocks that run in it.

## If nothing runs

Open **Recent deliveries** and read the outcome and the sentence beside the newest event.

| What you see | Cause | Fix |
| --- | --- | --- |
| "Nothing has arrived yet." | No request has reached the URL, not even the token. | Check that the subscription's URL in Notion is the block's current URL. **Rotate token** on a published workflow changes the URL, and the old one stops working. |
| **Handshake** with "Notion sent a verification token, but this trigger was not waiting for one, so it was not saved." | The subscription was created, or the token was sent again, before **Connect** was selected or after the 15 minutes ended. | Select **Connect**, then select **Resend token** in Notion. |
| **Handshake** with "Notion sent its verification token, and it is saved." and nothing else | The token has not been pasted into Notion yet, or no subscribed event has happened since in a place the connection has access to. | Finish the steps under "Paste the token into Notion". Then cause an event on a page the connection can read. |
| **Dropped** with "The workflow is not published, so nothing ran." | The workflow is a draft. | Publish the workflow. Events that arrived before then are not run later. |
| **Dropped** with "The workflow is paused, so nothing ran." | The workflow is paused. | Resume the workflow. Events that arrived while it was paused are not run later. |
| **Filtered out** with `Events of type "comment.created" are not chosen on this trigger.` | The event's type is not ticked under **Events that start a run**. | Tick the type, or clear every tick so that all events start a run. The settings are read-only on a published workflow. |
| **Refused** with "The signature did not match. Check that the secret saved here is the one the sender shows for this URL." | The saved token is not the one of the subscription that sent the event. This can happen when an earlier subscription in Notion still sends to the URL after the token was replaced. | Delete the subscriptions for this URL in Notion. Then select **Replace** and **Connect**, and create one subscription again. You do not republish the workflow. |
| **Refused** with "The request carried no signature." | A token is saved in OutWin, and the request did not carry Notion's signature. A request sent by hand to try the URL has none. | Cause the event in Notion so that Notion sends the request. |

A delivery listed as **Refused** is answered with status `401` and starts nothing. OutWin keeps none of its data. Notion sends a failed delivery again, up to eight attempts in all. For every other outcome in the table, Notion receives a success response and OutWin does not run the event later.
