# Mapbox key via environment variable, is that possible?

**URL:** <https://community.directus.com/t/mapbox-key-via-environment-variable-is-that-possible/429>\
**Category:** Help\
**Created:** [May 28, 2025, 8:00pm UTC](https://community.directus.com/t/mapbox-key-via-environment-variable-is-that-possible/429 "2025-05-28T20:00:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jogchum](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/jogchum/32/107_2.png) [@jogchum](https://community.directus.com/u/jogchum)\
**Post date:** [May 28, 2025, 8:00pm UTC](https://community.directus.com/t/mapbox-key-via-environment-variable-is-that-possible/429/1 "2025-05-28T20:00:19Z")

</div>

Hello there!

I was wondering, does anyone know whether it is possible to add the Mapbox key via an environment variable (via `MAPBOX_KEY` or something like that)? The docs kinda suggest it is possible but there is no reference (either in code and configuration docs) to found for it.

The hint I am seeing for this, is on this page: [Interfaces | Directus Docs](https://directus.io/docs/guides/data-model/interfaces#map)

> **Maps Provider**  
> By default, Directus will use [OpenStreetMap](https://www.openstreetmap.org/) to display your mapping data.[By entering a Mapbox API key](https://directus.io/docs/configuration/general#mapbox), you can enhance the platform’s mapping experience.

There is a text that has a link to the (old) docs website.

Thanks!

---

<div class="post-metadata">

**Author:** ![bryantgillespie](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/bryantgillespie/32/33_2.png) [@bryantgillespie](https://community.directus.com/u/bryantgillespie)\
**Post date:** [June 14, 2025, 1:31pm UTC](https://community.directus.com/t/mapbox-key-via-environment-variable-is-that-possible/429/2 "2025-06-14T13:31:40Z")

</div>

Yeah, you’re absolutely right - there’s currently no way to set the Mapbox key via environment variables.

The Mapbox API key needs to be configured through the **Project Settings** in the Directus admin interface, not through environment variables.

That broken documentation link is definitely confusing and misleading. The hint in the docs makes it sound like you can use env vars, but that’s not actually supported right now.

1. Go to **Settings \> Project Settings** in your Directus admin
2. Look for the **Mapbox Access Token** field
3. Enter your API key there

 ![ScreenShot 2025-06-14 at 09.28.40@2x](https://us1.discourse-cdn.com/flex002/uploads/directus/original/1X/c0789faf965bbb3abf7bf24c220c4ffba2dbc5b1.png)

If you need this to be configurable via environment variables for your deployment workflow, you might want to submit a feature request on the [Directus GitHub repository](https://github.com/directus/directus/issues).

Thanks for pointing out that broken link - we should definitely get that documentation updated to avoid confusion.

---

<div class="post-metadata">

**Author:** ![jogchum](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/jogchum/32/107_2.png) [@jogchum](https://community.directus.com/u/jogchum)\
**Post date:** [June 14, 2025, 7:02pm UTC](https://community.directus.com/t/mapbox-key-via-environment-variable-is-that-possible/429/3 "2025-06-14T19:02:13Z")

</div>

Thanks for this reply @bryantgillespie !

I was mainly just wondering about it. I don’t need to have it configured via env variables. So if someone does want that, feel free to create an issue like Bryant is mentioning 😎.

---

<div class="post-metadata">

**Author:** ![remihuigen](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/remihuigen/32/726_2.png) [@remihuigen](https://community.directus.com/u/remihuigen)\
**Post date:** [September 2, 2025, 4:54pm UTC](https://community.directus.com/t/mapbox-key-via-environment-variable-is-that-possible/429/4 "2025-09-02T16:54:19Z")

</div>

@jogchum should be fairly easy to achieve this with a lifecycle hook that updates `directus_settings` from a variable in `context.env`right?
