# Test TwiML Bins using Postman

[Postman](https://postman.com) is an application that you can use either as a standalone application or in your browser to make HTTP requests. You can, for example, [use Postman to explore our Twilio APIs](/docs/openapi/using-twilio-postman-collections), or in this case create an HTTP request to trigger your TwiML Bin.

In order to make a request to your TwiML Bin using Postman, you'll need:

1. Have your Account SID and Auth Token available
2. Your TwiML Bin Handler — it has the format of `https://handler.twilio.com/twiml/EHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`
3. Generate a valid `X-Twilio-Signature` to pass to your request.

## Getting started with our Postman collection

The best way to get started with triggering TwiML Bins from Postman is by using our Twilio Webhook Requests collection on postman.com/twilio.

Once you open the collection hover over the **Send** button, and you'll be promoted to **Create a fork**. Click the button to create a new fork (you might be prompted to sign-up or sign-in with Postman).

![Postman dialog: 'Requests can't be sent in public workspaces. Fork to send a request.' with 'Create a fork' button.](https://docs-resources.prod.twilio.com/4d90df6213d03bce58bd814514155aa5f16f84c21a8aecfa569d14b8fff025f0.png)

Afterwards, create the fork by giving it a label, and selecting the workspace in your account that you want the collection to be added to.

![Form to fork Twilio Webhook collection with fields for fork label and workspace selection.](https://docs-resources.prod.twilio.com/9d686a78db95f6bcbdd8c38ae05489f3573675907ece2ed5ed6bc05854857b74.png)

After creating a fork, you'll have to create a new Environment in your account by clicking **New** at the top left and choosing **Environment**. Once created, you want to give the environment a name, such as "Your Twilio Environment", by pressing the pencil icon next to **New Environment.** Next, you have to add two new **Variables**:

* `TWILIO_ACCOUNT_SID` with the Current Value of your Twilio Account SID
* `TWILIO_AUTH_TOKEN` with the Current Value of your Twilio Auth Token

![Postman dialog showing variables TWILIO\_ACCOUNT\_SID and TWILIO\_AUTH\_TOKEN with default types and initial values.](https://docs-resources.prod.twilio.com/0742d7ffa70a49b8e840d20b2335f3dc9b26e14c19b1add654c768385f6137e8.png)

Afterward, click **Save**, and select your new environment at the top right in the dropdown reading "No Environment".

![Dropdown showing options 'No Environment' and 'Your Twilio Environment'.](https://docs-resources.prod.twilio.com/ffd5a698523c7606438417235b0454ca2fb8e411ca45c1805f20d8886fe48872.png)

You are now ready to make your requests. Open the **TwiML Bin Request with Signature** request from the left navigation bar, replace the placeholder URL of `https://handler.twilio.com/twiml/EHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` with your own TwiML Bin URL, and click **Send**.

![Postman interface showing a TwiML Bin request with AccountSid parameter.](https://docs-resources.prod.twilio.com/e904bcf6ca00632249f92faf302a1fc837acbf07f281e4af3c179b4a913006f6.png)

## Already familiar with Postman?

If you are already familiar with Postman, you can use the following code in your *Pre-request Script* section in Postman:

```javascript
const authToken = pm.environment.get('TWILIO_AUTH_TOKEN');

function interpolate (value) {
    return value.replace(/{{([^}]+)}}/g, function (match, $1) {
        return pm.variables.get($1);
    });
}

function crypto(authToken, data) {
    let signature = CryptoJS.HmacSHA1(CryptoJS.enc.Utf8.parse(data), authToken);
    let base64 = CryptoJS.enc.Base64.stringify(signature);
    return base64;
}

function getSignature(authToken, url, params) {
    let data = Object.keys(params).sort().reduce((acc, key) => acc + key + interpolate(params[key]), interpolate(url));
    return crypto(authToken, data);
}

pm.environment.set('TWILIO_SIGNATURE', getSignature(authToken, request.url, request.data));
```

Afterwards, make sure to:

1. Create a [Postman environment](https://learning.postman.com/docs/sending-requests/managing-environments/#creating-environments) with the `TWILIO_ACCOUNT_SID` and `TWILIO_AUTH_TOKEN` variables defined.
2. Change the `Body` configuration to contain an `AccountSid` Key with the Value `{{TWILIO_ACCOUNT_SID}}`.
3. Change the `Headers` configuration to include a Key of `X-Twilio-Signature` with the Value `{{TWILIO_SIGNATURE}}`.

This will ensure that a valid `X-Twilio-Signature` is automatically generated and inserted into your request headers.
