# Api key woking locally but not after deployment

**URL:** <https://answers.netlify.com/t/api-key-woking-locally-but-not-after-deployment/119798>\
**Category:** Support\
**Tags:** environment-vars, deployment\
**Created:** [June 5, 2024, 12:02am UTC](https://answers.netlify.com/t/api-key-woking-locally-but-not-after-deployment/119798 "2024-06-05T00:02:47Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![dig](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/dig/32/56744_2.png) [@dig](https://answers.netlify.com/u/dig)\
**Post date:** [June 5, 2024, 9:42pm UTC](https://answers.netlify.com/t/api-key-woking-locally-but-not-after-deployment/119798/4 "2024-06-05T21:42:09Z")

</div>

Read this support guide

> [@\[Support Guide\] Using environment variables on Netlify correctly](https://answers.netlify.com/t/support-guide-using-environment-variables-on-netlify-correctly/267):
>
> Last reviewed: May 2024 The preferred way to use environment variables in Netlify is to set them in our environment - be that in the Environment Variables settings UI (on the site’s “Build & Deploy settings” page), or [via netlify.toml](https://docs.netlify.com/configure-builds/file-based-configuration/). You’ll want to choose the right pattern to meet your needs. Setting variables in our UI may be considered a bit more secure, since only people with access to the Netlify admin UI for your site can see them, rather than “anyone who can clone your repo!”. These v…

Based on the information you’ve provided I can offer no further advice.

---

_[View the full topic](https://answers.netlify.com/t/api-key-woking-locally-but-not-after-deployment/119798)._
