# Test TwiML Bins using twilio-cli

> \[!NOTE]
>
> The Webhook Plugin is still in an experimental stage and is part of [Twilio Labs](https://www.twilio.com/en-us/labs). If you find any issues, please [open an issue on our GitHub repository](https://github.com/twilio-labs/plugin-webhook/issues).

With the [Twilio Labs Webhook Plugin](https://github.com/twilio-labs/plugin-webhook) you can simulate webhook events. These will not result in actual HTTP requests made from Twilio but instead are HTTP requests made from your machine that pass mock data that has a similar shape to the data Twilio would pass in a request.

## Setup

If you don't have [twilio-cli](/docs/twilio-cli) installed yet, make sure to install it first and log in using `twilio login`.

After setting up twilio-cli you'll need to install the Webhook Plugin:

```bash
twilio plugins:install @twilio-labs/plugin-webhook
```

## Usage

Once you have the Webhook Plugin installed, you can use the `twilio webhook:invoke` command to simulate a webhook event to the URL that you pass:

```bash
twilio webhook:invoke <your-twiml-bin-url>
```

An example with a TwiML Bin would look like this:

```bash
twilio webhook:invoke https://handler.twilio.com/twiml/EHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

Because TwiML Bins validate the [`X-Twilio-Signature`](/docs/usage/webhooks/webhooks-security#validating-signatures-from-twilio) header of a request, you'll have to either have the valid Auth Token for your account stored as an environment variable with the name `TWILIO_AUTH_TOKEN`, or pass in the Auth Token using the `--auth-token` argument. This Auth Token has to match the Account SID of your CLI profile & TwiML Bin. Otherwise, you can change the Account SID by using the `--account-sid` flag.

Once you execute your command, you'll see the TwiML response from your TwiML Bin. For example:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Message>Ahoy</Message>
</Response>
```

If you also want to check the HTTP response headers, you can use the `-i` flag.

## Simulating different events

By default, the `twilio webhook:invoke` command will simulate an SMS event. You can change the type by using the `--type` flag.

For example the following will simulate a phone call request instead:

```bash
twilio webhook:invoke <your-url> --type=voice
```

If you want to modify some of the mock values that are being passed, for example to change the body of an incoming message you can use the `-d` flag:

```bash
twilio webhook:invoke <your-url> --type=sms -d Body="Ahoy there!"
```

If you want to learn more about the options you can pass into the Webhook Plugin, you can run `twilio webhook:invoke --help` or [visit the GitHub repository](https://github.com/twilio-labs/plugin-webhook).
