Skip to content

API keys (legacy) are permanent access tokens created with before June 2024. They can no longer be created or managed, and have been replaced by API key credentials. All developers should replace their existing API keys (legacy) with new API keys from API key credentials.

This tutorial shows how to migrate your application from an API key (legacy) to API key credentials with ArcGIS Online, and preserve the same privileges and item access.

Prerequisites

  1. You need an ArcGIS Online account with the correct user type and role. Please review the Product and account requirements before proceeding.

  2. You need to know the privileges to assign to your API key. The privileges assigned to a key allow your application to access specific ArcGIS services and resources.

Steps

Sign in to your portal

You use your portal to create and manage items, including API key credentials.

  1. Sign in to your portal with your ArcGIS Online account.

Check the scopes of your API key (legacy)

API keys (legacy) can only be scoped to access location services. These capabilities and more are available through API key credentials. Use your portal to check the service scopes of your API key (legacy) to create a new set of credentials with equivalent capabilities.

  1. Go to Content > My content.
  2. Click on the API key (legacy) item you want to replace. The item should have the label API key (legacy). You will then be redirected to the item page of your API key (legacy) item.
    An item of type "API Key (Legacy)" listed as an entry in the My content window.
  3. Under Credentials, click Manage.
  4. In API key (legacy), scroll down to the Location services section.
  5. Write down the selected scopes under Required service and Available services. These scopes will be replicated in your API key credentials using privileges.

Create API key credentials

  1. In your portal, click Content > My content > New item.
    New item button

  2. Click Developer credentials > API key credentials and click Next.

    API key credentials

Select application type

You can configure your API key credentials in this menu to align their capabilities with the type of application you are building. This menu determines the privileges that will be available for selection in the next steps.

  1. In the Where will you use these credentials? menu, select Public application.

    Selecting a key environment
  2. Click Next.

Select items (optional)

If your application will require access to specific private items, you will need to configure your developer credentials to access them. The Item access menu allows you to browse your portal's content and grant your API key access to specific items.

  1. If your token does not require item access, select No item access. Then, click Next.

  2. Otherwise, select Grant access to specific items.

  3. Select the items you want to grant access to. You can select up to 100 items in this menu.

    Item access menu
  4. Click Next.

Select privileges

You can configure the settings of API key credentials to configure the privileges of generated API keys. For an API key to work in your application, it needs to have the correct privileges to access the content and services your app is using. Select the privileges your app requires in this menu.

  1. In the Create developer credentials > Privileges window, select the privileges required by your application.

    Privilege selection window (ArcGIS Online)
  2. Click Next.

Set the expiration date and referrers

API key credentials generate long-lived access tokens called API keys. API keys are valid for up to one year, and their expiration date is set when they are generated. You can also set referrers on an API key, which restrict the key to only be usable from authorized domains.

  1. In the Create developer credentials window, click on the Expiration date field. Set the expiration date of the access token to one month from today's date.

    Expiration date selector
  2. Set the Referrers field to the web domains you would like to restrict the access token to. This is highly recommended for security purposes. To learn more about referrers, go to API key credentials.

    Referrer selector
  3. Click Next.

Save the item

After configuring the properties of your API key credentials, save the credentials as a new item.

  1. In the Create developer credentials window, set the following properties:

    • Title: My API key credentials
    • Folder: Developer credentials (Create a new folder)
    • Tags: Add tags related to the privileges of the credentials.
    • Description: Describe the application that these developer credentials will be used in.
    API key credential details

    Click Next.

  2. In the Summary window, review the properties, privileges, and item access you have set.

    Personal privileges summary screen
  3. Click Next.

Copy the API key

  1. In the Create developer credentials > Generate API key window, select Generate the API key and go to item details page. I am ready to copy and save the key.

    Generate the key
  2. Click Next.

  3. Copy the API key from the window that appears and paste it into your application.

    Window titled "Generate API key" with a header that says "Copy your key". An API key is displayed with an option to copy text. This is the only time the API key will be visible.

Delete the API key (legacy)

Once you replace your API key (legacy) in your application with your new API key, you can safely delete the API key (legacy) item.

  1. Go to Content > My content.
  2. Click on the API key (legacy) item you want to delete. You will then be redirected to the item page of your API key (legacy) item.
  3. Click on the Settings tab.
  4. In General, click Delete Item > Delete.

What's next?

Learn how to use your API key to access secure ArcGIS resources in the following guides:

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