Create an API key

Learn how to create an API key using API key credentials.

API key credentials
The developer credentials creation interface in a portal

An API key is a long-lived access token that authorizes your application to access secure services, content, and functionality in ArcGIS. API keys are generated using API key credentials, a type of item you create and manage in your portal. API key credentials contain settings that allow you to generate API keys and manage properties such as their privileges and expiration date.

This tutorial shows you how to use your portal to create API key credentials to do the following:

  • Generate long-lived API keys and save them in your application.

  • Configure properties of API key credentials, such as expiration date and referrer URLs.

  • Configure privileges to allow your API keys to access ArcGIS services, content, and functionality.

Prerequisites

  1. You need an ArcGIS Location Platform or ArcGIS Online account to create an API key to access location services. Your account must have a user type of Creator or higher and the correct permissions to generate API keys. To learn more, go to Security and authentication > Product and account requirements.

  2. You need to know the services and content that you want to access in your application.

Steps

Create an API key credential

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 your portal, click Content > My content > New item.

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

  3. 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.

  4. Set the Referrers field to the web domains you would like to restrict the access token to.

  5. Click Next.

Select location services privileges

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. If you are following another ArcGIS tutorial, please refer to it to see the list of required privileges.

  1. In the Create developer credentials > Privileges window, browse the available privileges.

  2. Select the privileges required by your application and click Next.

Grant item access

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 API key does not require item access, click Skip.

  2. Otherwise, in the Grant item access window, click Browse items.

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

  4. Click Add items.

Copy the API key

After configuring the properties of your API key credentials, you can 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.

    Click Next.

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

  3. 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.

  4. Click Next.

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

    This is the only time you will be able to access the value of your API key. You will not be able to view it again. To get a new key, you need to regenerate one using the API key credentials item page.

Now you have an API key that allows your application to access ArcGIS services and content.

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