Skip to content

Learn how to create and manage an API key with ArcGIS Online 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 privileges to allow your API keys to access ArcGIS services, content, and functionality.

  • Set the expiration date and referrer URLs of an API key.

  • Manage API keys using the item page of your API key credentials.

This tutorial focuses on creating an API key for a public application with access to location services.

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.

Create an API key credential

  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 item privileges (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 service 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.

    Copy the key

What's next?

Learn how to manage your API key credentials to generate additional keys, edit credential settings, and implement key rotation in the following tutorials:

Manage API key credentials

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


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.