# Getting APIKEY undefined on serverless functions via process.env (Loca

**URL:** <https://community.hubspot.com/t/getting-apikey-undefined-on-serverless-functions-via-process-env-loca/44692>\
**Category:** APIs & Integrations\
**Tags:** oauth\
**Created:** [October 1, 2021, 2:46pm UTC](https://community.hubspot.com/t/getting-apikey-undefined-on-serverless-functions-via-process-env-loca/44692 "2021-10-01T14:46:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RobertMarinho](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/robertmarinho/32/86506_2.png) [@RobertMarinho](https://community.hubspot.com/u/RobertMarinho)\
**Post date:** [October 1, 2021, 2:46pm UTC](https://community.hubspot.com/t/getting-apikey-undefined-on-serverless-functions-via-process-env-loca/44692/1 "2021-10-01T14:46:49Z")

</div>

Hello all,

I´m not able to get theprocess.env.APIKEY on serverless functions locally.

I´ve added the APIKEY through hs secrets add command:

![RobertMarinho_1-1633097838909.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/2/32c6c2054569b2ccd9388035153fe0554b831fc1.png)

After running the local server secrets env are all set:

 ![RobertMarinho_2-1633098579812.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/d/d500ecceb2465022cd734c1395393f82b722f3ac.png)

On the code I´m loggin the APIKEY and the API response to some request:

![RobertMarinho_4-1633099334848.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/9/79ee3f632a6c446813b3dc6b0e880dcad9dbaa89.png)

Since APIKEY is undefined the hapikey is not present in the query params.

That´s the result I get:

![RobertMarinho_3-1633098872219.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/c/cccf26ddf352099ae37da45f8b557d7d8a05ff05.png)

Anyone also having this issue?

Thanks,

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [October 4, 2021, 2:43pm UTC](https://community.hubspot.com/t/getting-apikey-undefined-on-serverless-functions-via-process-env-loca/44692/2 "2021-10-04T14:43:28Z")

</div>

@RobertMarinho ,

Are you still having issues with this?

---

<div class="post-metadata">

**Author:** ![RobertMarinho](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/robertmarinho/32/86506_2.png) [@RobertMarinho](https://community.hubspot.com/u/RobertMarinho)\
**Post date:** [October 4, 2021, 3:34pm UTC](https://community.hubspot.com/t/getting-apikey-undefined-on-serverless-functions-via-process-env-loca/44692/3 "2021-10-04T15:34:05Z")

</div>

@dennisedson

I´m not having issues with this anymore.

I´m wondering If It was just a problem on my end.

I´ve updated @hubspot/cli from 3.0.8 to 3.0.9. and It started working again.

Thanks,

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [October 4, 2021, 3:39pm UTC](https://community.hubspot.com/t/getting-apikey-undefined-on-serverless-functions-via-process-env-loca/44692/4 "2021-10-04T15:39:35Z")

</div>

@RobertMarinho ever watch the IT crowd? 🤣

[https://youtu.be/nn2FB1P\_Mn8?t=11](https://youtu.be/nn2FB1P_Mn8?t=11)

---

<div class="post-metadata">

**Author:** ![AChong6](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/achong6/32/29572_2.png) [@AChong6](https://community.hubspot.com/u/AChong6)\
**Post date:** [July 28, 2022, 3:28pm UTC](https://community.hubspot.com/t/getting-apikey-undefined-on-serverless-functions-via-process-env-loca/44692/5 "2022-07-28T15:28:16Z")

</div>

For others, be sure to CAPITALIZE your environment variable names and you can also find the secret in the context parameter of exports.main, if process.env is not working for you.

---

<div class="post-metadata">

**Author:** ![RobertMarinho](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/robertmarinho/32/86506_2.png) [@RobertMarinho](https://community.hubspot.com/u/RobertMarinho)\
**Post date:** [October 4, 2021, 3:43pm UTC](https://community.hubspot.com/t/getting-apikey-undefined-on-serverless-functions-via-process-env-loca/44692/6 "2021-10-04T15:43:53Z")

</div>

lol 😂 Never watched It. That was funny.

Thanks for sharing!
