# Dynamic Variables for API calls

**URL:** <https://community.weweb.io/t/dynamic-variables-for-api-calls/1418>\
**Category:** Ask us anything\
**Created:** [November 12, 2022, 5:15am UTC](https://community.weweb.io/t/dynamic-variables-for-api-calls/1418 "2022-11-12T05:15:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![felixtanhm](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/felixtanhm/32/1544_2.png) [@felixtanhm](https://community.weweb.io/u/felixtanhm)\
**Post date:** [November 12, 2022, 5:15am UTC](https://community.weweb.io/t/dynamic-variables-for-api-calls/1418/1 "2022-11-12T05:15:19Z")

</div>

Are we able to set dynamic variables for API calls based on the environment?

For instance, an API call to Xano should have the Headers of X-Data-Source test while when in production, it should have the Headers of X-Data-Source live.

Otherwise, each time we publish to live, we’d have to update these values individually?

---

<div class="post-metadata">

**Author:** ![peteletkemansst](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@peteletkemansst](https://community.weweb.io/u/peteletkemansst)\
**Post date:** [November 12, 2022, 6:25pm UTC](https://community.weweb.io/t/dynamic-variables-for-api-calls/1418/2 "2022-11-12T18:25:26Z")

</div>

If your only concern is x-data-source then you can use the Xano plugin

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/1/13081190209b3f409c8f33d1199339b7c05503eb.png)  
That said there are other instances where changing value based on the environment would be handy/helpful.

That said what I have done is put a variable in x-data-source as shown below.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/4/49db3e9c5148608dbf71fa68164a6fe5842de933.png)

What you could do with some work is connect the Headers to a collection that can be dynamic.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/1/1341097148a6bccebc329bc736c91c8945acbb7b.png)

I too would like an option of a deployment feature script, but I don’t think that is available yet, however, you can request it here [https://feedback.weweb.io/](https://feedback.weweb.io/)

---

<div class="post-metadata">

**Author:** ![felixtanhm](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/felixtanhm/32/1544_2.png) [@felixtanhm](https://community.weweb.io/u/felixtanhm)\
**Post date:** [November 13, 2022, 6:13am UTC](https://community.weweb.io/t/dynamic-variables-for-api-calls/1418/3 "2022-11-13T06:13:32Z")

</div>

Thanks Pete.

I didn’t use the Xano plug-in as it doesn’t allow me to add other Headers into my API call (such as Authorization). Using the Xano plug-in ties me in to using the Xano Auth plug-in.

Ironically, the Xano Auth plug-in only accounts for Live authentication, so you can’t auth into your test Xano environment.

Thus, using the Xano plug-in places you in a catch-22 situation 🙂

Good idea on using the collections though! I’ll use that instead. Will also submit the feature request.

---

<div class="post-metadata">

**Author:** ![felixtanhm](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/felixtanhm/32/1544_2.png) [@felixtanhm](https://community.weweb.io/u/felixtanhm)\
**Post date:** [November 13, 2022, 6:57am UTC](https://community.weweb.io/t/dynamic-variables-for-api-calls/1418/4 "2022-11-13T06:57:41Z")

</div>

For anyone in future who chances upon this thread, here’s how I handled it in the end. Opted for variables instead of collections. The intention is to change these variables prior to deployment to live.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/e/e81d41135ab52d93235afaa5f84e83e201a9cd65.png)
