# Webhook

The **Webhook connector** allows workflows to create [webhooks](https://en.wikipedia.org/wiki/Webhook), which can receive data from external applications or services through HTTP requests. When an external service sends a request to the webhook URL, the workflow is triggered and processes the incoming data.

Webhooks are commonly used to integrate external systems with iMBrace workflows. They allow services to send event data directly to a workflow without requiring a dedicated integration.

Workflows triggered by webhooks can also return a response, making it possible to build workflows that behave like API endpoints.

### Testing Webhooks

While building or testing a workflow, you can use the Test Webhook URL. Using the test webhook allows you to view incoming request data directly in the workflow editor, which helps with debugging and development.

Send a request to the Test Webhook URL to simulate an incoming webhook request. The request data will appear in the workflow editor, allowing you to inspect and debug the incoming payload.

### Production Webhooks <a href="#production-workflows" id="production-workflows"></a>

Once the workflow is ready for production use, switch to the Production Webhook URL. Once the workflow is ready for production use, external services can send requests to the Live Webhook URL, which automatically triggers the workflow.

When working with a Production webhook, ensure that you have saved and activated the workflow. Data flowing through the webhook isn't visible in the editor UI with the production webhook.

### Webhook URLs <a href="#webhook-urls" id="webhook-urls"></a>

The Webhook connector provides two types of URLs for interacting with the workflow.

1. Live URL: The Live URL is the primary webhook endpoint used to trigger the workflow from external applications. When an HTTP request is sent to this URL, the workflow is executed and the incoming request data becomes available to subsequent connectors in the workflow.

<figure><img src="https://3400071099-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FypCKq44Psaly6khgrY7x%2Fuploads%2F958gwkmbgbdsADUTbTrT%2Fimage.png?alt=media&#x26;token=8f2a1c0e-2d62-44b5-82e8-0fbef271f83a" alt=""><figcaption></figcaption></figure>

2. Test URL: The Test URL allows you to send sample data to the webhook without triggering the full workflow execution. To generate a test request, append `/test` to the Live URL. This is useful for validating request payloads and testing webhook configurations during development.

<figure><img src="https://3400071099-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FypCKq44Psaly6khgrY7x%2Fuploads%2FoDkVNuLTWHBMTtV4M8Up%2Fimage.png?alt=media&#x26;token=635405a8-83f5-4e66-95b0-99f4dd7efd3f" alt=""><figcaption></figcaption></figure>

### Configuration Fields <a href="#http-method" id="http-method"></a>

1. HTTP Method: The Webhook connector supports standard [HTTP Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods).
2. Path: Defines the endpoint path for the webhook URL. By default, the system generates a unique path to prevent conflicts with other webhooks. You can also manually define the path if you want consistent API endpoints. The **Path** field can take the following formats:

* `/:variable`
* `/path/:variable`
* `/:variable/path`
* `/:variable1/path/:variable2`
* `/:variable1/:variable2`

These allow dynamic parameters to be passed through the URL.

#### Response Behavior:  <a href="#respond" id="respond"></a>

The webhook response behavior can be configured depending on how the workflow should return data.

* **Immediately**: the Webhook connector returns the response code and the message **Workflow got started**.
* **When Last Connector Finishes**: the Webhook connector returns the response code and the data output from the last connector executed in the workflow.
* **Using 'Respond to Webhook' Connector** : the Webhook connector responds as defined in the [Respond to Webhook](https://imbrace.gitbook.io/imbrace-no-code-workflow/workflow/respond-to-webhook) connector.

#### Response Code

Customize the [HTTP response code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) that the Webhook connector returns upon successful execution.

#### Response Data <a href="#response-data" id="response-data"></a>

Choose what data to include in the response body.

### Connector Options <a href="#node-options" id="node-options"></a>

Select **Add Option** to view more configuration options. The available options depend on your connector parameters. Refer to the table for option availability.

* **Binary Data**: enabling this setting allows the Webhook connector to receive binary data, such as an image or audio file.
* **Ignore Bots**: ignore requests from bots like link previewers and web crawlers.
* **No Response Body**: enable this to prevent iMBrace sending a body with the response.
* **Raw Body**: specify that the Webhook connector will receive data in a raw format, such as JSON or XML.
* **Response Content-Type**: choose the format for the webhook body.
* **Response Data**: send custom data with the response.
* **Response Headers**: send additional headers in the Webhook response. Refer to [MDN Web Docs | Response header](https://developer.mozilla.org/en-US/docs/Glossary/Response_header) to learn more about response headers.
* **Property Name:** allows returning a specific JSON property instead of the entire response data.

| Option                | Required  Connector Configuration                                                          |
| --------------------- | ------------------------------------------------------------------------------------------ |
| Binary data           | <p>Either:<br>HTTP Method > POST<br>HTTP Method > PATCH<br>HTTP Method > PUT</p>           |
| Ignore Bots           | Any                                                                                        |
| No Response Body      | Respond > Immediately                                                                      |
| Raw Body              | Any                                                                                        |
| Response Content-Type | <p>Both:<br>Respond > When Last Connector Finishes<br>Response Data > First Entry JSON</p> |
| Response Data         | Respond > Immediately                                                                      |
| Response Headers      | Any                                                                                        |
| Property Name         | <p>Both:<br>Respond > When Last Connector Finishes<br>Response Data > First Entry JSON</p> |

### Triggering a Webhook Using the HTTP Request Connector <a href="#use-the-http-request-node-to-trigger-the-webhook-node" id="use-the-http-request-node-to-trigger-the-webhook-node"></a>

You can trigger a webhook from another workflow using the [HTTP Request](https://imbrace.gitbook.io/imbrace-no-code-workflow/workflow/http-s-request) **connector**.

1. Create a new workflow.
2. Add the **HTTP Request connector** to the workflow.
3. Select the appropriate request method.
4. Copy the webhook URL from the Webhook connector.
5. Paste the URL into the **URL field** in the HTTP Request connector.
6. Execute the HTTP Request connector to send the request.
