Skip to content

Mapbox Access Token

How to Create a Mapbox Access Token

Official Mapbox Pages

Steps to Create a Mapbox Access Token

  1. Sign in to your Mapbox account.
  2. Open your Access Tokens page in the Mapbox account dashboard.
  3. You will already see a default public token available in your account.
  4. To create a new token, click Create a token.
  5. Enter a name for the token so you can identify where it will be used.
  6. Select the required scopes for the token.
    • For most frontend map applications, a public token is used.
    • Public tokens usually start with pk.
    • Secret tokens usually start with sk and should only be used on the server side.
  7. Save or create the token.
  8. Copy the token and store it securely.

Token Types

  • Public token (pk)
    Use this in websites, browser apps, and mobile apps.
  • Secret token (sk)
    Use this only in backend or server-side applications.
  • Temporary token (tk)
    Can be created programmatically for short-lived access through the Tokens API.

Important Recommendations

  • Create separate tokens for different environments such as:
    • local development
    • testing
    • production
  • Only enable the minimum scopes required.
  • Never expose a secret token in frontend code.
  • If a token is exposed publicly and you suspect misuse, rotate it by creating a new one and deleting the old one.

Example for Mapbox GL JS

<script src="https://api.mapbox.com/mapbox-gl-js/v3.15.0/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v3.15.0/mapbox-gl.css" rel="stylesheet" />

<script>
  mapboxgl.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
  const map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v12',
    center: [77.2090, 28.6139],
    zoom: 10
  });
</script>

Notes

  • Every request to Mapbox APIs requires an access token.
  • Your account includes a default public token by default.
  • For advanced automation, you can create and manage tokens using the Tokens API.