# Trigger collection runs using webhooks A webhook provides a way to automatically send data from one application to another. Using a webhook, you can trigger a [collection run](/docs/collections/running-collections/intro-to-collection-runs/) at a specific time or when an event occurs. When the webhook is triggered, Postman runs the collection using a [monitor](/docs/monitoring-your-api/intro-monitors/). You can also send a custom payload to the webhook, and Postman can access the data when the collection runs. Sending a custom payload means the collection can run without an [environment](/docs/sending-requests/variables/managing-environments/), and instead rely on the data sent to the webhook. ## Create a webhook With a collection webhook, data is sent to the webhook URL using a POST request when certain events are triggered. You must configure the application that sends the data and the trigger events. Webhooks for a collection must be created using the [Postman API](/docs/developer/postman-api/intro-api/). Learn how to use the Postman API to [create a webhook](https://www.postman.com/postman/postman-public-workspace/request/z961fuf/create-a-webhook). To access the data sent to the webhook, use the [`pm.globals.get` method](/docs/tests-and-scripts/write-scripts/postman-sandbox-reference/pm-variables/#pmglobals) with the `previousRequest` global variable. Using [scripts](/docs/tests-and-scripts/write-scripts/intro-to-scripts/), you can parse that data and use it during the collection run in any way possible. ## Access the request body in scripts When you trigger the webhook, the `previousRequest` global [variable](/docs/sending-requests/variables/variables/) is temporarily created, and its value is the request body of the webhook as a JSON string. Use the `pm.globals.get('previousRequest')` method to get the request body of the webhook, then parse it using `JSON.parse()`. The data sent to the webhook is available in the `data` parameter inside the parsed object, as shown in the following example code: ```js var previousRequest = JSON.parse(pm.globals.get('previousRequest')); var webhookRequestData = previousRequest.data; // webhookRequestData contains the data sent to your webhook. console.log(JSON.stringify(webhookRequestData)); ``` The request body sent to the webhook must use JSON format. When you [create a webhook](#create-a-webhook) using the Postman API, a monitor is created for the webhook. You must trigger the webhook in a separate request to run the example code using the monitor. Then you can [view the monitor run details](/docs/monitoring-your-api/viewing-monitor-results/#console-log) that were logged to Console. To learn more about monitor results, go to [View monitor results](/docs/monitoring-your-api/viewing-monitor-results/). ## Send output to another API Use the data that's sent to the collection webhook to define logic and trigger another API. For example, you might set up a webhook for your GitHub repository. Based on the updates happening in your repository, you can use the webhook to run custom build pipelines or perform CI tests.