|
1 | 1 | ---
|
2 |
| -title: Managing API keys |
| 2 | +title: How to Manage API keys |
3 | 3 | ---
|
4 | 4 |
|
| 5 | +This guide shows you how to create, manage, and secure API keys for your [Subgraphs](/subgraphs/developing/subgraphs/). |
| 6 | + |
5 | 7 | ## Overview
|
6 | 8 |
|
7 |
| -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. |
| 9 | +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. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +- A [Subgraph Studio](https://thegraph.com/studio/) account |
| 14 | + |
| 15 | +## Create a New API Key |
| 16 | + |
| 17 | +1. Navigate to [Subgraph Studio](https://thegraph.com/studio/) |
| 18 | +2. Click the **API Keys** tab in the navigation menu |
| 19 | +3. Click the **Create API Key** button |
| 20 | + |
| 21 | +A new window will popup: |
| 22 | + |
| 23 | +4. Enter a name for your API key |
| 24 | +5. Optional: You can enable a period spending limit |
| 25 | +6. Click **Create API Key** |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +## Manage API Keys |
| 30 | + |
| 31 | +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. |
| 32 | + |
| 33 | +### How to Set Spending Limits |
| 34 | + |
| 35 | +1. Find your API key in the API keys table |
| 36 | +2. Click the "three dots" menu next to the key |
| 37 | +3. Select "Manage spending limit" |
| 38 | +4. Enter your desired monthly limit in USD |
| 39 | +5. Click **Save** |
| 40 | + |
| 41 | +> 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). |
| 42 | +
|
| 43 | +### How to Rename an API Key |
| 44 | + |
| 45 | +1. Click the "three dots" menu next to the key |
| 46 | +2. Select "Rename API key" |
| 47 | +3. Enter the new name |
| 48 | +4. Click **Save** |
| 49 | + |
| 50 | +### How to Regenerate an API Key |
| 51 | + |
| 52 | +1. Click the "three dots" menu next to the key |
| 53 | +2. Select "Regenerate API key" |
| 54 | +3. Confirm the action in the popup dialog |
| 55 | + |
| 56 | +> Warning: Regenerating an API key will invalidate the previous key immediately. Update your applications with the new key to prevent service interruption. |
| 57 | +
|
| 58 | +## API Key Details |
8 | 59 |
|
9 |
| -### Create and Manage API Keys |
| 60 | +### Monitoring Usage |
10 | 61 |
|
11 |
| -Go to [Subgraph Studio](https://thegraph.com/studio/) and click the **API Keys** tab to create and manage your API keys for specific Subgraphs. |
| 62 | +1. Click on your API key to view the Details page |
| 63 | +2. Check the **Overview** section for: |
| 64 | + - Total number of queries |
| 65 | + - GRT spent |
| 66 | + - Current usage statistics |
12 | 67 |
|
13 |
| -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. |
| 68 | +### Restricting Domain Access |
14 | 69 |
|
15 |
| -You can click the "three dots" menu to the right of a given API key to: |
| 70 | +1. Click on your API key to open the Details page |
| 71 | +2. Navigate to the **Security** section |
| 72 | +3. Click "Add Domain" |
| 73 | +4. Enter the authorized domain name |
| 74 | +5. Click **Save** |
16 | 75 |
|
17 |
| -- Rename API key |
18 |
| -- Regenerate API key |
19 |
| -- Delete API key |
20 |
| -- 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). |
| 76 | +### Limiting Subgraph Access |
21 | 77 |
|
22 |
| -### API Key Details |
| 78 | +1. In the API key Details page |
| 79 | +2. Navigate to the **Security** section |
| 80 | +3. Click "Assign Subgraphs" |
| 81 | +4. Select the Subgraphs you want to authorize |
| 82 | +5. Click **Save** |
23 | 83 |
|
24 |
| -You can click on an individual API key to view the Details page: |
| 84 | +## Additional Resources |
25 | 85 |
|
26 |
| -1. Under the **Overview** section, you can: |
27 |
| - - Edit your key name |
28 |
| - - Regenerate API keys |
29 |
| - - View the current usage of the API key with stats: |
30 |
| - - Number of queries |
31 |
| - - Amount of GRT spent |
32 |
| -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: |
33 |
| - - View and manage the domain names authorized to use your API key |
34 |
| - - Assign Subgraphs that can be queried with your API key |
| 86 | +[Deploying Using Subgraph Studio](/subgraphs/developing/deploying/using-subgraph-studio/) |
0 commit comments