# Authentication

The TiDB Cloud API uses [HTTP Digest Authentication](https://en.wikipedia.org/wiki/Digest_access_authentication). It protects your private key from being sent over the network. For more details about HTTP Digest Authentication, refer to the [IETF RFC](https://datatracker.ietf.org/doc/html/rfc7616).

## API key overview

- The API key contains a public key and a private key, which act as the username and password required in the HTTP Digest Authentication. The private key only displays upon the key creation.
- The API key belongs to your organization and acts as the `Owner` role. You can check [permissions of owner](https://docs.pingcap.com/tidbcloud/manage-user-access#configure-member-roles).
- You must provide the correct API key in every request. Otherwise, the TiDB Cloud responds with a `401` error.

## API key management

### Create an API key

Only the **owner** of an organization can create an API key.

To create an API key in an organization, perform the following steps:

1. Click <svg width="16" height="16" viewBox="0 -2 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13 11H17.8C18.9201 11 19.4802 11 19.908 11.218C20.2843 11.4097 20.5903 11.7157 20.782 12.092C21 12.5198 21 13.0799 21 14.2V21M13 21V6.2C13 5.0799 13 4.51984 12.782 4.09202C12.5903 3.71569 12.2843 3.40973 11.908 3.21799C11.4802 3 10.9201 3 9.8 3H6.2C5.0799 3 4.51984 3 4.09202 3.21799C3.71569 3.40973 3.40973 3.71569 3.21799 4.09202C3 4.51984 3 5.0799 3 6.2V21M22 21H2M6.5 7H9.5M6.5 11H9.5M6.5 15H9.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> **Organization** in the lower-left corner of the TiDB Cloud console.
2. Click **Organization Settings**. The organization settings page is displayed.
3. Click the **API Keys** tab and then click **Create API Key**.
4. Enter a description for your API key. The role of the API key is always `Owner` currently.
5. Click **Next**. Copy and save the public key and the private key.
6. Make sure that you have copied and saved the private key in a secure location. The private key only displays upon the creation. After leaving this page, you will not be able to get the full private key again.
7. Click **Done**.

### View details of an API key

To view details of an API key, perform the following steps:

1. Click <svg width="16" height="16" viewBox="0 -2 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13 11H17.8C18.9201 11 19.4802 11 19.908 11.218C20.2843 11.4097 20.5903 11.7157 20.782 12.092C21 12.5198 21 13.0799 21 14.2V21M13 21V6.2C13 5.0799 13 4.51984 12.782 4.09202C12.5903 3.71569 12.2843 3.40973 11.908 3.21799C11.4802 3 10.9201 3 9.8 3H6.2C5.0799 3 4.51984 3 4.09202 3.21799C3.71569 3.40973 3.40973 3.71569 3.21799 4.09202C3 4.51984 3 5.0799 3 6.2V21M22 21H2M6.5 7H9.5M6.5 11H9.5M6.5 15H9.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> **Organization** in the upper-right corner of the TiDB Cloud console.
2. Click **Organization Settings**. The organization settings page is displayed.
3. Click the **API Keys** tab.
4. You can view the details of the API keys in the menu.

### Edit an API key

Only the **owner** of an organization can modify an API key.

To edit an API key in an organization, perform the following steps:

1. Click <svg width="16" height="16" viewBox="0 -2 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13 11H17.8C18.9201 11 19.4802 11 19.908 11.218C20.2843 11.4097 20.5903 11.7157 20.782 12.092C21 12.5198 21 13.0799 21 14.2V21M13 21V6.2C13 5.0799 13 4.51984 12.782 4.09202C12.5903 3.71569 12.2843 3.40973 11.908 3.21799C11.4802 3 10.9201 3 9.8 3H6.2C5.0799 3 4.51984 3 4.09202 3.21799C3.71569 3.40973 3.40973 3.71569 3.21799 4.09202C3 4.51984 3 5.0799 3 6.2V21M22 21H2M6.5 7H9.5M6.5 11H9.5M6.5 15H9.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> **Organization** in the upper-right corner of the TiDB Cloud console.
2. Click **Organization Settings**. The organization settings page is displayed.
3. Click the **API Keys** tab.
4. Click **Edit** in the API key row that you want to change.
4. You can update the API key description.
5. Click **Done**.

### Delete an API key

Only the **owner** of an organization can delete an API key.

To delete an API key in an organization, perform the following steps:

1. Click <svg width="16" height="16" viewBox="0 -2 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13 11H17.8C18.9201 11 19.4802 11 19.908 11.218C20.2843 11.4097 20.5903 11.7157 20.782 12.092C21 12.5198 21 13.0799 21 14.2V21M13 21V6.2C13 5.0799 13 4.51984 12.782 4.09202C12.5903 3.71569 12.2843 3.40973 11.908 3.21799C11.4802 3 10.9201 3 9.8 3H6.2C5.0799 3 4.51984 3 4.09202 3.21799C3.71569 3.40973 3.40973 3.71569 3.21799 4.09202C3 4.51984 3 5.0799 3 6.2V21M22 21H2M6.5 7H9.5M6.5 11H9.5M6.5 15H9.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg> **Organization** in the upper-right corner of the TiDB Cloud console.
2. Click **Organization Settings**. The organization settings page is displayed.
3. Click the **API Keys** tab.
4. Click **Delete** in the API key row that you want to delete.
5. Click **I understand the consequences, delete this API Key.**
