How to use an API key

This topic outlines the high-level steps of how to create and use .

The API key workflow
The typical API key workflow

1. Create API key credentials

requires a set of .

The steps to create API key credentials with an are:

  1. Sign in to your .

  2. Click Content > My content > New item and select Developer credentials.

  3. In the Credential types menu, select API key credentials.

  4. Set the credential to determine the operations your will be authorized to perform.

  5. Set the credential item access privileges to determine the your will be authorized to access.

  6. Review your selections and, when you are ready, click Generate token. Save the as you will not be able to view it again.

2. Copy the API key

The created in the previous step can contain up to two . These long-lived are only visible once when they are created and are not stored anywhere in ArcGIS. Copy the API key to use it in your client application.

You can get the API key access token in two ways:

Get the access token immediately:

  1. When you first create API key credentials, click Generate token to create an API key. Copy the resulting string.

Get the access token after the is created:

  1. Go to the of your and click Credentials > Manage.

  2. Under API keys, click Regenerate API key to generate a new . This will invalidate the existing key.

  3. Alternatively, click Generate a secondary API key to generate a second API key without invalidating the first. The two keys share identical , and each has a unique expiration date.

3. Use the API key

The last step is to use the API key to make requests to . To use the access token, embed it directly into your application.

ArcGIS REST APIs

This example shows how to access the directly by setting the token parameter to an . To run this request, replace <YOUR_ACCESS_TOKEN> with an API key that has to access the geocoding service.

cURLcURLHTTP
1
2
3
4
curl https://geocode-api.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates \
-d "f=pjson" \
-d "address=1600 Pennsylvania Ave NW, DC" \
-d "token=<YOUR_ACCESS_TOKEN>"

ArcGIS APIs

If you use with an , the API key value is typically set once when the application is initialized and is applied every time a service request is made.

The examples below show how to use an API key to access the .

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for .NETArcGIS Maps SDK for KotlinArcGIS Maps SDK for SwiftArcGIS Maps SDK for JavaArcGIS Maps SDK for QtArcGIS API for PythonEsri LeafletMapLibre GL JSOpenLayers
Expand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
      esriConfig.apiKey= "YOUR_ACCESS_TOKEN";
      const map = new Map({
        basemap: "arcgis/topographic" // Basemap layer
      });

      const view = new MapView({
        map: map,
        center: [-118.805, 34.027],
        zoom: 13, // scale: 72223.819286
        container: "viewDiv",
        constraints: {
          snapToZoom: false
        }
      });

Open source APIs

If you are using an open source or third-party API, you can set the access using a class or property (if they are available), otherwise, you need to add a token parameter to each service request and include your access token.

The examples below show how to use an access token to access the .

Esri LeafletEsri LeafletMapLibre GL JSOpenLayersCesiumJS
1
2
3
4
5
6
7
8
9
const apiKey = "YOUR_ACCESS_TOKEN";
const map = L.map('map', {
  center: [34.027, -118.805]
});
map.setView([34.027, -118.805], 13); // latitude, longitude, zoom level, scale: 72223.819286
const basemapEnum = "arcgis/topographic"
L.esri.Vector.vectorBasemapLayer(basemapEnum, {
  token: accessToken
}).addTo(map)

Tutorials

Create an API key

Create and configure API key credentials to get a long-lived API key access token.


Manage API key credentials

Manage previously created API key credentials to regenerate, edit privileges, and edit item access of API keys.


Migrate API keys (legacy) to API key credentials

Migrate from an API key (legacy) created before June 2024 to an API key from API key credentials.


Rotate API keys

Rotate API keys in a deployed application to refresh their expiration dates.


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.

You can no longer sign into this site. Go to your ArcGIS portal or the ArcGIS Location Platform dashboard to perform management tasks.

Your ArcGIS portal

Create, manage, and access API keys and OAuth 2.0 developer credentials, hosted layers, and data services.

Your ArcGIS Location Platform dashboard

Manage billing, monitor service usage, and access additional resources.

Learn more about these changes in the What's new in Esri Developers June 2024 blog post.

Close