# How to call an API before executing another API call

**URL:** <https://community.postman.com/t/how-to-call-an-api-before-executing-another-api-call/6897>\
**Category:** Help Hub\
**Created:** [July 31, 2019, 6:58pm UTC](https://community.postman.com/t/how-to-call-an-api-before-executing-another-api-call/6897 "2019-07-31T18:58:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vineeth0696](https://avatars.discourse-cdn.com/v4/letter/v/aeb1de/32.png) [@Vineeth0696](https://community.postman.com/u/Vineeth0696)\
**Post date:** [July 31, 2019, 6:58pm UTC](https://community.postman.com/t/how-to-call-an-api-before-executing-another-api-call/6897/1 "2019-07-31T18:58:40Z")

</div>

I need to execute an API for that i need to pass Authorization token every time. so how can i write pre-requisite script which does the token API call and then it sets as environment variable. So that i can use token where ever i need in the APi.

Note:- Token API call is a POST method.

---

<div class="post-metadata">

**Author:** ![singhsivcan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/singhsivcan/32/1595_2.png) [@singhsivcan](https://community.postman.com/u/singhsivcan)\
**Post date:** [July 31, 2019, 8:09pm UTC](https://community.postman.com/t/how-to-call-an-api-before-executing-another-api-call/6897/2 "2019-07-31T20:09:14Z")

</div>

Hello @Vineeth0696, welcome to the community! 👋

You can use [`pm.sendRequest`](https://learning.getpostman.com/docs/postman/scripts/postman_sandbox_api_reference/#pmsendrequest) feature in the pre-request script.  
So you make the call using pm.sendRequest and then store the value in the environment variable.

Then the main request will be executed and it’ll take up the token value from the environment
