# Start a workflow from Standard Webhooks events

> Run a workflow when a service that follows the Standard Webhooks specification sends an event, with a Webhook block set to Standard Webhooks.

To run a workflow when a service that follows the Standard Webhooks specification sends an event, add a **Webhook** block whose **Source** is **Standard Webhooks** and give its URL to that service. The block expects one event per request. Each event starts its own run.

Standard Webhooks is a published specification for how a service signs and labels the events it sends. A service that follows it sends three request headers with every event: `webhook-id`, `webhook-timestamp`, and `webhook-signature`. Use this source when the sending service's documentation says it follows the specification and OutWin has no source named after the service. GitLab and Resend have their own sources.

You need an account with the sending service in which you can add a webhook endpoint and see its signing secret, and edit access to the workflow's project. The steps on the sender's side happen in that service, and its labels differ from one service to the next.

## Add the Webhook block and generate its URL

1. In a draft workflow, add a **Webhook** block. The block palette also lists **Standard Webhooks webhook** in the **Start** group, which adds the block with its source already set.
2. Under **Source**, choose **Standard Webhooks**. 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.

## Add the endpoint in the sending service

1. In the sending service, open its webhook settings and add an endpoint.
2. Paste the URL you copied as the address the endpoint sends to.
3. Choose the events the endpoint sends, and save.

The service must deliver each event as a `POST` request. The block does not take other methods from this source.

## Save the Signing secret

A sender that follows the specification signs each request it posts. The **Signing secret** lets OutWin check that signature.

1. In the sending service, open the endpoint you added and find its signing secret. It usually starts with `whsec_`.
2. Copy the whole secret.
3. In OutWin, paste it into **Signing secret** in the block's settings and select **Save**.

After you save, the settings show only the last four characters of the secret, with **Replace** and **Remove**. Under **Set up**, the second line changes to "The signing secret is saved: deliveries are verified."

The sender issues the secret for one endpoint, so OutWin saves it on the block's URL. It is not saved on a connection. A second Webhook block has its own URL and needs its own endpoint and secret.

OutWin checks the specification's symmetric signature, the one made with a secret that both sides hold. A `webhook-signature` header can carry several signatures, which senders use while a secret is being replaced, and the request passes if any one of them matches. A sender that signs with a private key and publishes a public key is not covered by this source. Neither is a sender that uses other header names, such as `svix-signature`.

With a secret saved, OutWin also checks the time in the `webhook-timestamp` header. A request signed more than five minutes before or after the moment it arrives is listed as **Refused**.

Without a saved secret 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

This source covers many services, so the block has no list of event types to tick. Under **Events that start a run**, type an event type exactly as the sender names it into the box that shows "Another event type" and select **Add**. The type then appears in the list, ticked. With none added, every event the sender posts starts a run.

The block reads an event's type from the `type` field of the body, which is where the specification puts it. 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**. [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 the sending service, cause one of the events the endpoint sends, or use the service's own way to send a test event if it has one.
2. In OutWin, look under **Recent deliveries** in the block's settings.

**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 from "Waiting for the first event…" to, for example, "Received invoice.paid. Dropped." for an event whose `type` is `invoice.paid`.

With a secret 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 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 the sender posted it. The specification asks for the fields `type`, `timestamp`, and `data`. A sender can name its fields differently. |
| `{{input.body.data}}` | One field of the event. Read any other field the same way. |
| `{{input.event.type}}` | The event's type. It is the body's `type` field, and is empty when the sender's body has none. |
| `{{input.event.id}}` | The event's id. It is the request's `webhook-id` header, which stays the same when the sender sends the event again. |
| `{{input.event.time}}` | The event's time as an ISO 8601 date and time. It is the body's `timestamp` field, and is empty when the sender's body has none. |
| `{{input.headers["webhook-id"]}}` | One request header. Header names are lowercase. |
| `{{input.delivery.verified}}` | `true` only when the signature was checked and passed. |

A block further along reads the same values through the Webhook block's name, as in `{{steps["Standard Webhooks"].body.data}}` for a block named `Standard Webhooks`. [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. You can still replace the secret there.

| 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** | A request with the same `webhook-id` already ran in the last 72 hours. The line reads "This event was already received and run, so it did not run again." |

Runs start in the order events arrive. That is not always the order things happened, so do not build a workflow that relies on one event arriving before another.

Receiving an event costs no credits, and neither does an event that is filtered out or a duplicate. 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. | Check that the endpoint in the sending service is active, that it sends the event you caused, and that its address is the block's current URL. **Rotate token** on a published workflow changes the URL, and the old one stops working. |
| **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 "invoice.paid" are not chosen on this trigger.` | The event's type is not ticked under **Events that start a run**. | Add and tick the type, or clear every tick so that all events start a run. The settings are read-only on a published workflow. |
| **Filtered out** with "The event has no type, and this trigger runs only for chosen types." | At least one type is ticked, and the sender's body has no `type` field. | Clear every tick so that all events start a run, and narrow with a row under **Only when** on the field the sender does use. |
| **Refused** with "The signature did not match. Check that the secret saved here is the one the sender shows for this URL." | The saved secret is not the one the sender holds for this endpoint. This can happen when the secret was copied from another endpoint, or when the endpoint's secret was replaced in the sending service after it was copied. | Copy the endpoint's secret again and select **Replace**. You do not republish the workflow. |
| **Refused** with "The saved secret could not be used as this sender's key. Save it again exactly as the sender shows it." | The saved text is not a secret in the specification's form: `whsec_` followed by letters, digits, and the characters of base64. This can happen when something else was copied with it. | Copy the whole secret again and select **Replace**. |
| **Refused** with "The request carried no signature." | A secret is saved in OutWin, and the request had no `webhook-signature` header with a symmetric signature. A request sent by hand to try the URL has none, and neither does a sender that does not follow the specification. | Cause the event in the sending service so that it sends the request. If its requests never carry the header, this source does not fit the sender. |
| **Refused** with "The request's timestamp is too far from now, so it may be a replay of an old delivery." | The request was signed more than five minutes before or after it arrived, for example because a saved copy of an earlier request was sent again. | Cause a new event in the sending service. |

A delivery listed as **Refused** is answered with status `401` and starts nothing. OutWin keeps none of its data. For every other outcome in the table, the sender receives a success response and OutWin does not run the event later.
