Skip to content

Updating Manage API Keys #954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added website/public/img/create-api-key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 73 additions & 21 deletions website/src/pages/en/subgraphs/querying/managing-api-keys.mdx
Original file line number Diff line number Diff line change
@@ -1,34 +1,86 @@
---
title: Managing API keys
title: How to Manage API keys
---

This guide shows you how to create, manage, and secure API keys for your [Subgraphs](/subgraphs/developing/subgraphs/).

## Overview

API keys are needed to query Subgraphs. They ensure that the connections between application services are valid and authorized, including authenticating the end user and the device using the application.
API keys are required to query Subgraphs. They authenticate users and devices, authorize access to specific endpoints, enforce rate limits, and enable usage tracking across The Graph.

## Prerequisites

- A [Subgraph Studio](https://thegraph.com/studio/) account

## Create a New API Key

1. Navigate to [Subgraph Studio](https://thegraph.com/studio/)
2. Click the **API Keys** tab in the navigation menu
3. Click the **Create API Key** button

A new window will pop up:

4. Enter a name for your API key
5. Optional: You can enable a period spending limit
6. Click **Create API Key**

![Create API Key Window](/img/create-api-key.png)

## Manage API Keys

The “API keys” table lists existing API keys and allows you to manage or delete them. For each key, you can see its status, the cost for the current period, the spending limit for the current period, and the total number of queries.

### How to Set Spending Limits

1. Find your API key in the API keys table
2. Click the "three dots" icon next to the key
3. Select "Manage spending limit"
4. Enter your desired monthly limit in USD
5. Click **Save**

> Manage spending limit: this is an optional monthly spending limit for a given API key, in USD. This limit is per billing period (calendar month).

### How to Rename an API Key

1. Click the "three dots" icon next to the key
2. Select "Rename API key"
3. Enter the new name
4. Click **Save**

### How to Regenerate an API Key

1. Click the "three dots" icon next to the key
2. Select "Regenerate API key"
3. Confirm the action in the pop up dialog

> Warning: Regenerating an API key will invalidate the previous key immediately. Update your applications with the new key to prevent service interruption.

## API Key Details

### Create and Manage API Keys
### Monitoring Usage

Go to [Subgraph Studio](https://thegraph.com/studio/) and click the **API Keys** tab to create and manage your API keys for specific Subgraphs.
1. Click on your API key to view the Details page
2. Check the **Overview** section for:
- Total number of queries
- GRT spent
- Current usage statistics

The "API keys" table lists existing API keys and allows you to manage or delete them. For each key, you can see its status, the cost for the current period, the spending limit for the current period, and the total number of queries.
### Restricting Domain Access

You can click the "three dots" menu to the right of a given API key to:
1. Click on your API key to open the Details page
2. Navigate to the **Security** section
3. Click "Add Domain"
4. Enter the authorized domain name
5. Click **Save**

- Rename API key
- Regenerate API key
- Delete API key
- Manage spending limit: this is an optional monthly spending limit for a given API key, in USD. This limit is per billing period (calendar month).
### Limiting Subgraph Access

### API Key Details
1. In the API key Details page
2. Navigate to the **Security** section
3. Click "Assign Subgraphs"
4. Select the Subgraphs you want to authorize
5. Click **Save**

You can click on an individual API key to view the Details page:
## Additional Resources

1. Under the **Overview** section, you can:
- Edit your key name
- Regenerate API keys
- View the current usage of the API key with stats:
- Number of queries
- Amount of GRT spent
2. Under the **Security** section, you can opt into security settings depending on the level of control you’d like to have. Specifically, you can:
- View and manage the domain names authorized to use your API key
- Assign Subgraphs that can be queried with your API key
[Deploying Using Subgraph Studio](/subgraphs/developing/deploying/using-subgraph-studio/)