Create and manage an API key

Learn how to use the developer dashboard to create and configure an API key to access ArcGIS resources.

Click to create a new key

An Application programming interface key (API key) is a permanent access token that defines the scope and permission for granting applications access to ArcGIS location services and content items.

In this tutorial you learn how to:

  • Create a new API key
  • Set location service and content item scopes
  • Set referrers
  • Use an API key in code
  • Monitor API key usage

Prerequisites

Steps

Create a new API key

To create a new key, you use the developer dashboard.

  1. Go to the API key page in your developer dashboard.

  2. On the left, click +New API Key.

    If you have an ArcGIS Developer account, a default key was created for you when you signed up.

    Click to create a new key
  3. Set a Title and Description for the key > Create API key.

Set location service scopes

When you create a new key, it is automatically configured to access some ArcGIS location services. You can add or remove services to customize the scope of the API key.

  1. Go to the API key page in your developer dashboard.

  2. Choose the API key that you want to edit. In the API key box, click Edit API key.

    ArcGIS Developer
  3. In the Overview, find the Location services box and click Set service scopes.

    Set scopes
  4. In the window, check or uncheck the service cards to set the scope of your key. The scopes available depend on the type of account you have.

    If you have an ArcGIS Developer account, you need to enable pay-as-you-go to add the scope for some services and service functionality such as Geocoding (stored), Optimized routing, and the GeoEnrichment service. Enable pay-as-you-go in the Billing section of the developer dashboard.

    ArcGIS Developer
  5. Click Apply to set the scopes.

Set content item scopes

If you have an ArcGIS Developer account, you can use API keys to access private content items. However, there are only a limited set of item types. You cannot access this feature with an ArcGIS Online account. To learn more about limitations and restrictions, go to ArcGIS data service scopes.

  1. Go to the API key page in your developer dashboard.

  2. Choose the API key that you want to edit. In the API key box, click Edit API key.

  3. In the Overview, find the Maps, layers, and data box. If you have an ArcGIS Developer account, you will be able to click Set content item scopes.

    ArcGIS Developer
  4. Select the items that you want the API key to access and the Add item(s).

    Content item scope

Set a referrer

An HTTP referrer is an HTTP header field used to identify the client requesting a server resource. This functions as a security measure, allowing applications to confirm their client's identity. If an API key does not have a referer, any request that uses the API key is valid. Learn more in API key referrers.

  1. Go to the API key page in your developer dashboard.

  2. Choose the API key that you want to edit. In the API key box, click Edit API key.

  3. In the Overview, find the Referrers box > Add Referrer.

    Add a referrer
  4. Enter the referrer address, such as http://localhost:8000 or https://*.your-app.com > Add Referrer Header.

Set the API key in an application

After you create and configure an API key, you can copy the key from the dashboard and use it in an application.

  1. Set the API key scopes to access the services and content items required by your application.

  2. Copy the key from your dashboard.

  3. Set the key in the application code. Learn more in How to use API keys in apps.

    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 Qt (C++)ArcGIS API for PythonArcGIS REST JSEsri LeafletMapLibre GL JSOpenLayers
    Use dark colors for code blocksCopy
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    esriConfig.apiKey = "YOUR_API_KEY";
    const map = new Map({
      basemap: "arcgis-navigation"
    });
    

Monitor API key usage

It is recommended that you regularly monitor your API key usage for irregularites and to frequently rotate API keys to prevent unauthorized access. The usage that is recorded depends on the services accessed by the API key.

  1. Go to the API key page in your developer dashboard.

  2. Choose an API key. In the API key box, click View usage.

    ArcGIS Developer
  3. In the dropdown, select a billing cycle or time interval to view the usage of the key. To view an example graph, go to Monitor usage.

Restrict API key deletion

You can enable delete protect to prevent the API key from being deleted.

  1. Go to the API key page in your developer dashboard.

  2. Choose the API key that you want to edit. In the API key box, click Edit API key.

  3. Click the Settings tab.

  4. Toggle the protection icon to enable deletion.

What's next?

Learn how to use additional tools, APIs, and location services in these tutorials:

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