> ## Documentation Index
> Fetch the complete documentation index at: https://meilisearch-6b28dec2-mintlify-code-samples.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Keys

> The /keys route allows you to create, manage, and delete API keys.

export const RouteHighlighter = ({method, path}) => <div className={`routeHighlighter routeHighlighter--${method}`}>
    <div className="routeHighlighter__method">
      {method}
    </div>
    <div className="routeHighlighter__path">
      {path}
    </div>
  </div>;

The `/keys` route allows you to create, manage, and delete API keys. To use these endpoints, you must first [set the master key](/learn/security/basic_security). Once a master key is set, you can access these endpoints by supplying it in the header of the request, or using API keys that have access to the `keys.get`, `keys.create`, `keys.update`, or `keys.delete` actions.

<Warning>
  Accessing the `/keys` route without setting a master key will throw a [`missing_master_key`](/reference/errors/error_codes#missing_master_key) error.
</Warning>

## Key object

```json theme={null}
{
  "name": "Default Search API Key",
  "description": "Use it to search from the frontend code",
  "key": "0a6e572506c52ab0bd6195921575d23092b7f0c284ab4ac86d12346c33057f99",
  "uid": "74c9c733-3368-4738-bbe5-1d18a5fecb37",
  "actions": [
    "search"
  ],
  "indexes": [
    "*"
  ],
  "expiresAt": null,
  "createdAt": "2021-08-11T10:00:00Z",
  "updatedAt": "2021-08-11T10:00:00Z"
}
```

### `name`

**Type**: String<br />
**Default value**: `null`<br />
**Description**: A human-readable name for the key

### `description`

**Type**: String<br />
**Default value**: `null`<br />
**Description**: A description for the key. You can add any important information about the key here

### `uid`

**Type**: String<br />
**Default value**: N/A<br />
**Description**: A [uuid v4](https://www.sohamkamani.com/uuid-versions-explained) to identify the API key. If not specified, it is automatically generated by Meilisearch

### `key`

**Type**: String<br />
**Default value**: N/A<br />
**Description**: An alphanumeric key value generated by Meilisearch by hashing the `uid` and the master key on API key creation. Used for authorization when [making calls to a protected Meilisearch instance](/learn/security/basic_security#sending-secure-api-requests-to-meilisearch)

This value is also used as the `{key}` path variable to [update](#update-a-key), [delete](#delete-a-key), or [get](#get-one-key) a specific key.

If the master key changes, all `key` values are automatically changed.

<Note>
  Custom API keys are deterministic: `key` is a SHA256 hash of the `uid` and master key. To reuse custom API keys, launch the new instance with the same master key and recreate your API keys with the same `uid`.

  **You cannot reuse default API keys between instances.** Meilisearch automatically generates their `uid`s the first time you launch an instance.
</Note>

### `actions`

**Type**: Array<br />
**Default value**: N/A<br />
**Description**: An array of API actions permitted for the key, represented as strings. API actions are only possible on authorized [`indexes`](#indexes). `["*"]` for all actions.

You can use `*` as a wildcard to access all endpoints for the `documents`, `indexes`, `tasks`, `settings`, `stats`, `webhooks`, and `dumps` actions. For example, `documents.*` gives access to all document actions.

<Warning>
  For security reasons, we do not recommend creating keys that can perform all actions.
</Warning>

| Name                   | Description                                                                                                                                                                                                                                                                                                                  |
| :--------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`search`**           | Provides access to both [`POST`](/reference/api/search#search-in-an-index-with-post) and [`GET`](/reference/api/search#search-in-an-index-with-get) search endpoints                                                                                                                                                         |
| **`documents.add`**    | Provides access to the [add documents](/reference/api/documents#add-or-replace-documents) and [update documents](/reference/api/documents#add-or-update-documents) endpoints                                                                                                                                                 |
| **`documents.get`**    | Provides access to the [get one document](/reference/api/documents#get-one-document), [get documents with POST](/reference/api/documents#get-documents-with-post), and [get documents with GET](/reference/api/documents#get-documents-with-get) endpoints                                                                   |
| **`documents.delete`** | Provides access to the [delete one document](/reference/api/documents#delete-one-document), [delete all documents](/reference/api/documents#delete-all-documents), [batch delete](/reference/api/documents#delete-documents-by-batch), and [delete by filter](/reference/api/documents#delete-documents-by-filter) endpoints |
| **`indexes.create`**   | Provides access to the [create index](/reference/api/indexes#create-an-index) endpoint                                                                                                                                                                                                                                       |
| **`indexes.get`**      | Provides access to the [get one index](/reference/api/indexes#get-one-index) and [list all indexes](/reference/api/indexes#list-all-indexes) endpoints. **Non-authorized `indexes` will be omitted from the response**                                                                                                       |
| **`indexes.update`**   | Provides access to the [update index](/reference/api/indexes#update-an-index) endpoint                                                                                                                                                                                                                                       |
| **`indexes.delete`**   | Provides access to the [delete index](/reference/api/indexes#delete-an-index) endpoint                                                                                                                                                                                                                                       |
| **`indexes.swap`**     | Provides access to the swap indexes endpoint. **Non-authorized `indexes` will not be swapped**                                                                                                                                                                                                                               |
| **`tasks.get`**        | Provides access to the [get one task](/reference/api/tasks#get-one-task) and [get tasks](/reference/api/tasks#get-tasks) endpoints. **Tasks from non-authorized `indexes` will be omitted from the response**                                                                                                                |
| **`tasks.cancel`**     | Provides access to the [cancel tasks](/reference/api/tasks#cancel-tasks) endpoint. **Tasks from non-authorized `indexes` will not be canceled**                                                                                                                                                                              |
| **`tasks.delete`**     | Provides access to the [delete tasks](/reference/api/tasks#delete-tasks) endpoint. **Tasks from non-authorized `indexes` will not be deleted**                                                                                                                                                                               |
| **`settings.get`**     | Provides access to the [get settings](/reference/api/settings#get-settings) endpoint and equivalents for all subroutes                                                                                                                                                                                                       |
| **`settings.update`**  | Provides access to the [update settings](/reference/api/settings#update-settings) and [reset settings](/reference/api/settings#reset-settings) endpoints and equivalents for all subroutes                                                                                                                                   |
| **`stats.get`**        | Provides access to the [get stats of an index](/reference/api/stats#get-stats-of-an-index) endpoint and the [get stats of all indexes](/reference/api/stats#get-stats-of-all-indexes) endpoint. For the latter, **non-authorized `indexes` are omitted from the response**                                                   |
| **`dumps.create`**     | Provides access to the [create dump](/reference/api/dump#create-a-dump) endpoint. **Not restricted by `indexes`**                                                                                                                                                                                                            |
| **`snapshots.create`** | Provides access to the [create snapshot](/reference/api/snapshots#create-a-snapshot) endpoint. **Not restricted by `indexes`**                                                                                                                                                                                               |
| **`version`**          | Provides access to the [get Meilisearch version](/reference/api/version#get-version-of-meilisearch) endpoint                                                                                                                                                                                                                 |
| **`keys.get`**         | Provides access to the [get all keys](#get-all-keys) endpoint                                                                                                                                                                                                                                                                |
| **`keys.create`**      | Provides access to the [create key](#create-a-key) endpoint                                                                                                                                                                                                                                                                  |
| **`keys.update`**      | Provides access to the [update key](#update-a-key) endpoint                                                                                                                                                                                                                                                                  |
| **`keys.delete`**      | Provides access to the [delete key](#delete-a-key) endpoint                                                                                                                                                                                                                                                                  |
| **`network.get`**      | Provides access to the [get the network object](/reference/api/network#get-the-network-object) endpoint                                                                                                                                                                                                                      |
| **`network.update`**   | Provides access to the [update the network object](/reference/api/network#update-the-network-object) endpoint                                                                                                                                                                                                                |
| **`chatCompletions`**  | Provides access to the [chat completions endpoints](/reference/api/chats). Requires experimental feature to be enabled                                                                                                                                                                                                       |
| **`webhooks.get`**     | Provides access to the [get webhooks](/reference/api/webhooks#get-all-webhooks) endpoints                                                                                                                                                                                                                                    |
| **`webhooks.create`**  | Provides access to the [create webhooks](/reference/api/webhooks#create-a-webhook) endpoint                                                                                                                                                                                                                                  |
| **`webhooks.update`**  | Provides access to the [update webhooks](/reference/api/webhooks#update-a-webhook) endpoint                                                                                                                                                                                                                                  |
| **`webhooks.delete`**  | Provides access to the [delete webhooks](/reference/api/webhooks#delete-a-webhook) endpoint                                                                                                                                                                                                                                  |

### `indexes`

**Type**: Array<br />
**Default value**: N/A<br />
**Description**: An array of indexes the key is authorized to act on. Use`["*"]` for all indexes. Only the key's [permitted actions](#actions) can be used on these indexes.

You can also use the `*` character as a wildcard by adding it at the end of a string. This allows an API key access to all index names starting with that string. For example, using `"indexes": ["movie*"]` will give the API key access to the `movies` and `movie_ratings` indexes.

### `expiresAt`

**Type**: String<br />
**Default value**: N/A<br />
**Description**: Date and time when the key will expire, represented in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. `null` if the key never expires

<Note>
  Once a key is past its `expiresAt` date, using it for API authorization will return an error.
</Note>

### `createdAt`

**Type**: String<br />
**Default value**: `null`<br />
**Description**: Date and time when the key was created, represented in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format

### `updatedAt`

**Type**: String<br />
**Default value**: `null`<br />
**Description**: Date and time when the key was last updated, represented in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format

## Get all keys

<RouteHighlighter method="GET" path="/keys" />

Returns the 20 most recently created keys in a `results` array. **Expired keys are included in the response**, but deleted keys are not.

### Query parameters

Results can be paginated using the `offset` and `limit` query parameters.

| Query Parameter | Default Value | Description              |
| :-------------- | :------------ | :----------------------- |
| **`offset`**    | `0`           | Number of keys to skip   |
| **`limit`**     | `20`          | Number of keys to return |

### Response

| Name          | Type    | Description                            |
| :------------ | :------ | :------------------------------------- |
| **`results`** | Array   | An array of [key objects](#key-object) |
| **`offset`**  | Integer | Number of keys skipped                 |
| **`limit`**   | Integer | Number of keys returned                |
| **`total`**   | Integer | Total number of API keys               |

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X GET 'MEILISEARCH_URL/keys?limit=3' \
    -H 'Authorization: Bearer MASTER_KEY'
  ```

  ```javascript JS theme={null}
  client.getKeys({ limit: 3 })
  ```

  ```python Python theme={null}
  client.get_keys({'limit': 3})
  ```

  ```php PHP theme={null}
  $client->getKeys((new KeysQuery())->setLimit(3));
  ```

  ```java Java theme={null}
  KeysQuery query = new KeysQuery().setLimit(3);
  client.getKeys(query);
  ```

  ```ruby Ruby theme={null}
  client.keys(limit: 3)
  ```

  ```go Go theme={null}
  client.GetKeys(&meilisearch.KeysQuery{
    Limit: 3
  });
  ```

  ```csharp C# theme={null}
  ResourceResults<Key> keyResult = await client.GetKeysAsync(new KeysQuery { Limit = 3 });
  ```

  ```rust Rust theme={null}
  let mut query = KeysQuery::new()
    .with_limit(3)
    .execute(&client)
    .await
    .unwrap();
  ```

  ```swift Swift theme={null}
  client.getKeys(params: KeysQuery(limit: 3)) { result in
      switch result {
      case .success(let keys):
          print(keys)
      case .failure(let error):
          print(error)
      }
  }
  ```

  ```dart Dart theme={null}
  await client.getKeys(params: KeysQuery(limit: 3));
  ```
</CodeGroup>

#### Response: `200 Ok`

```json theme={null}
{
  "results": [
    {
      "name": null,
      "description": "Manage documents: Products/Reviews API key",
      "key": "d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4",
      "uid": "6062abda-a5aa-4414-ac91-ecd7944c0f8d",
      "actions": [
        "documents.add",
        "documents.delete"
      ],
      "indexes": [
        "prod*",
        "reviews"
      ],
      "expiresAt": "2021-12-31T23:59:59Z",
      "createdAt": "2021-10-12T00:00:00Z",
      "updatedAt": "2021-10-13T15:00:00Z"
    },
    {
      "name": "Default Search API Key",
      "description": "Use it to search from the frontend code",
      "key": "0a6e572506c52ab0bd6195921575d23092b7f0c284ab4ac86d12346c33057f99",
      "uid": "74c9c733-3368-4738-bbe5-1d18a5fecb37",
      "actions": [
        "search"
      ],
      "indexes": [
        "*"
      ],
      "expiresAt": null,
      "createdAt": "2021-08-11T10:00:00Z",
      "updatedAt": "2021-08-11T10:00:00Z"
    },
    {
      "name": "Default Admin API Key",
      "description": "Use it for anything that is not a search operation. Caution! Do not expose it on a public frontend",
      "key": "380689dd379232519a54d15935750cc7625620a2ea2fc06907cb40ba5b421b6f",
      "uid": "20f7e4c4-612c-4dd1-b783-7934cc038213",
      "actions": [
        "*"
      ],
      "indexes": [
        "*"
      ],
      "expiresAt": null,
      "createdAt": "2021-08-11T10:00:00Z",
      "updatedAt": "2021-08-11T10:00:00Z"
    }
  ],
  "offset": 0,
  "limit": 3,
  "total": 7
}
```

<Note>
  API keys are displayed in descending order based on their `createdAt` date. This means that the most recently created keys appear first.
</Note>

## Get one key

<RouteHighlighter method="GET" path="/keys/{key_or_uid}" />

Get information on the specified key. Attempting to use this endpoint with a non-existent or deleted key will result in [an error](/reference/errors/error_codes#api_key_not_found).

### Path parameters

A valid API `key` or `uid` is required.

| Name         | Type   | Description                                  |
| :----------- | :----- | :------------------------------------------- |
| **`key`** \* | String | [`key`](#key) value of the requested API key |
| **`uid`** \* | String | [`uid`](#uid) of the requested API key       |

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X GET 'MEILISEARCH_URL/keys/6062abda-a5aa-4414-ac91-ecd7944c0f8d' \
    -H 'Authorization: Bearer MASTER_KEY'
  ```

  ```javascript JS theme={null}
  client.getKey('6062abda-a5aa-4414-ac91-ecd7944c0f8d')
  ```

  ```python Python theme={null}
  client.get_key('6062abda-a5aa-4414-ac91-ecd7944c0f8d')
  ```

  ```php PHP theme={null}
  $client->getKey('6062abda-a5aa-4414-ac91-ecd7944c0f8d');
  ```

  ```java Java theme={null}
  client.getKey("6062abda-a5aa-4414-ac91-ecd7944c0f8d");
  ```

  ```ruby Ruby theme={null}
  client.key('6062abda-a5aa-4414-ac91-ecd7944c0f8d')
  ```

  ```go Go theme={null}
  client.GetKey("6062abda-a5aa-4414-ac91-ecd7944c0f8d")
  ```

  ```csharp C# theme={null}
  Key key = await client.GetKeyAsync("d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4");
  ```

  ```rust Rust theme={null}
  let key = client
    .get_key("6062abda-a5aa-4414-ac91-ecd7944c0f8d")
    .await
    .unwrap();
  ```

  ```swift Swift theme={null}
  client.getKey(keyOrUid: "6062abda-a5aa-4414-ac91-ecd7944c0f8d") { result in
      switch result {
      case .success(let key):
          print(key)
      case .failure(let error):
          print(error)
      }
  }
  ```

  ```dart Dart theme={null}
  await client.getKey('6062abda-a5aa-4414-ac91-ecd7944c0f8d');
  ```
</CodeGroup>

#### Response: `200 Ok`

```json theme={null}
{
  "name": null,
  "description": "Add documents: Products API key",
  "key": "d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4",
  "uid": "6062abda-a5aa-4414-ac91-ecd7944c0f8d",
  "actions": [
    "documents.add"
  ],
  "indexes": [
    "products"
  ],
  "expiresAt": "2021-11-13T00:00:00Z",
  "createdAt": "2021-11-12T10:00:00Z",
  "updatedAt": "2021-11-12T10:00:00Z"
}
```

For an explanation of these fields, see the [key object](#key-object).

## Create a key

<RouteHighlighter method="POST" path="/keys" />

Create an API key with the provided description, permissions, and expiration date.

### Body

| Name                              | Type   | Default value | Description                                                                                                                                     |
| :-------------------------------- | :----- | :------------ | :---------------------------------------------------------------------------------------------------------------------------------------------- |
| **[`actions`](#actions)** \*      | Array  | N/A           | A list of API actions permitted for the key. `["*"]` for all actions                                                                            |
| **[`indexes`](#indexes)** \*      | Array  | N/A           | An array of indexes the key is authorized to act on. `["*"]` for all indexes                                                                    |
| **[`expiresAt`](#expiresat)** \*  | String | N/A           | Date and time when the key will expire, represented in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. `null` if the key never expires |
| **[`name`](#name)**               | String | `null`        | A human-readable name for the key                                                                                                               |
| **[`uid`](#uid)**                 | String | N/A           | A [uuid v4](https://www.sohamkamani.com/uuid-versions-explained) to identify the API key. If not specified, it is generated by Meilisearch      |
| **[`description`](#description)** | String | `null`        | An optional description for the key                                                                                                             |

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X POST 'MEILISEARCH_URL/keys' \
    -H 'Authorization: Bearer MASTER_KEY' \
    -H 'Content-Type: application/json' \
    --data-binary '{
      "description": "Add documents: Products API key",
      "actions": ["documents.add"],
      "indexes": ["products"],
      "expiresAt": "2042-04-02T00:42:42Z"
    }'
  ```

  ```javascript JS theme={null}
  client.createKey({
    description: 'Add documents: Products API key',
    actions: ['documents.add'],
    indexes: ['products'],
    expiresAt: '2021-11-13T00:00:00Z'
  })
  ```

  ```python Python theme={null}
  client.create_key(options={
    'description': 'Add documents: Products API key',
    'actions': ['documents.add'],
    'indexes': ['products'],
    'expiresAt': '2042-04-02T00:42:42Z'
  })
  ```

  ```php PHP theme={null}
  $client->createKey([
    'description' => 'Add documents: Products API key',
    'actions' => ['documents.add'],
    'indexes' => ['products'],
    'expiresAt' => '2042-04-02T00:42:42Z',
  ]);
  ```

  ```java Java theme={null}
  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
  Date dateParsed = format.parse("2042-04-02T00:42:42Z");

  Key keyInfo = new Key();

  keyInfo.setDescription("Add documents: Products API key");
  keyInfo.setActions(new String[] {"documents.add"});
  keyInfo.setIndexes(new String[] {"products"});
  keyInfo.setExpiresAt(dateParsed);

  client.createKey(keyInfo);
  ```

  ```ruby Ruby theme={null}
  client.create_key(
    description: 'Add documents: Products API key',
    actions: ['documents.add'],
    indexes: ['products'],
    expires_at: '2042-04-02T00:42:42Z'
  )
  ```

  ```go Go theme={null}
  client.CreateKey(&meilisearch.Key{
    Description: "Add documents: Products API key",
    Actions: []string{"documents.add"},
    Indexes: []string{"products"},
    ExpiresAt: time.Date(2042, time.April, 02, 0, 42, 42, 0, time.UTC),
  })
  ```

  ```csharp C# theme={null}
  Key keyOptions = new Key
  {
      Description = "Add documents: Products API key",
      Actions = new KeyAction[] { KeyAction.DocumentsAdd },
      Indexes = new string[] { "products" },
      ExpiresAt = DateTime.Parse("2042-04-02T00:42:42Z")
  };
  Key createdKey = await this.client.CreateKeyAsync(keyOptions);
  ```

  ```rust Rust theme={null}
  let mut key_options = KeyBuilder::new();
  key_options
    .with_name("Add documents: Products API key")
    .with_action(Action::DocumentsAdd)
    .with_expires_at(time::macros::datetime!(2042 - 04 - 02 00:42:42 UTC))
    .with_index("products");
  let new_key = client
    .create_key(key_options)
    .await
    .unwrap();
  ```

  ```swift Swift theme={null}
  let keyParams = KeyParams(
    description: "Add documents: Products API key",
    actions: ["documents.add"],
    indexes: ["products"],
    expiresAt: "2042-04-02T00:42:42Z"
  )
  client.createKey(keyParams) { result in
      switch result {
      case .success(let key):
          print(key)
      case .failure(let error):
          print(error)
      }
  }
  ```

  ```dart Dart theme={null}
  await client.createKey(
      description: 'Add documents: Products API key',
      actions: ['documents.add'],
      indexes: ['products'],
      expiresAt: DateTime(2042, 04, 02));
  ```
</CodeGroup>

#### Response: `201 Created`

```json theme={null}
{
  "name": null,
  "description": "Manage documents: Products/Reviews API key",
  "key": "d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4",
  "uid": "6062abda-a5aa-4414-ac91-ecd7944c0f8d",
  "actions": [
    "documents.add"
  ],
  "indexes": [
    "products"
  ],
  "expiresAt": "2021-11-13T00:00:00Z",
  "createdAt": "2021-11-12T10:00:00Z",
  "updatedAt": "2021-11-12T10:00:00Z"
}
```

## Update a key

<RouteHighlighter method="PATCH" path="/keys/{key_or_uid}" />

Update the `name` and `description` of an API key.

Updates to keys are **partial**. This means you should provide only the fields you intend to update, as any fields not present in the payload will remain unchanged.

### Path parameters

A valid API `key` or `uid` is required.

| Name         | Type   | Description                                  |
| :----------- | :----- | :------------------------------------------- |
| **`key`** \* | String | [`key`](#key) value of the requested API key |
| **`uid`** \* | String | [`uid`](#uid) of the requested API key       |

### Body

| Name                              | Type   | Default value | Description                         |
| :-------------------------------- | :----- | :------------ | :---------------------------------- |
| **[`name`](#name)**               | String | `null`        | A human-readable name for the key   |
| **[`description`](#description)** | String | `null`        | An optional description for the key |

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X PATCH 'MEILISEARCH_URL/keys/6062abda-a5aa-4414-ac91-ecd7944c0f8d' \
    -H 'Authorization: Bearer MASTER_KEY' \
    -H 'Content-Type: application/json' \
    --data-binary '{
      "name": "Products/Reviews API key",
      "description": "Manage documents: Products/Reviews API key"
    }'
  ```

  ```javascript JS theme={null}
  client.updateKey('6062abda-a5aa-4414-ac91-ecd7944c0f8d', {
      name: 'Products/Reviews API key',
      description: 'Manage documents: Products/Reviews API key',
  })
  ```

  ```python Python theme={null}
  client.update_key(key_or_uid='6062abda-a5aa-4414-ac91-ecd7944c0f8d',
    options={
      'name': 'Products/Reviews API key',
      'description': 'Manage documents: Products/Reviews API key'
  })
  ```

  ```php PHP theme={null}
  $client->updateKey('6062abda-a5aa-4414-ac91-ecd7944c0f8d',
    [
      'name' => 'Products/Reviews API key',
      'description' => 'Manage documents: Products/Reviews API key'
    ]);
  ```

  ```java Java theme={null}
  KeyUpdate keyChanges = new KeyUpdate();
  keyChanges.setName("Products/Reviews API key");
  keyChanges.setDescription("Manage documents: Products/Reviews API key");

  client.updateKey("6062abda-a5aa-4414-ac91-ecd7944c0f8d", keyChanges);
  ```

  ```ruby Ruby theme={null}
  client.update_key(
    '6062abda-a5aa-4414-ac91-ecd7944c0f8d',
    {
      description: 'Manage documents: Products/Reviews API key',
      name: 'Products/Reviews API key'
    }
  )
  ```

  ```go Go theme={null}
  client.UpdateKey("6062abda-a5aa-4414-ac91-ecd7944c0f8d", &meilisearch.Key{
    Description: "Manage documents: Products/Reviews API key",
    Actions: []string{"documents.add", "document.delete"},
    Indexes: []string{"products", "reviews"},
    ExpiresAt: time.Date(2042, time.April, 02, 0, 42, 42, 0, time.UTC),
  })
  ```

  ```csharp C# theme={null}
  await client.UpdateKeyAsync(
    "6062abda-a5aa-4414-ac91-ecd7944c0f8d",
    description: "Manage documents: Products/Reviews API key",
    name: "Products/Reviews API key"
  )
  ```

  ```rust Rust theme={null}
  let mut key = client
    .get_key("6062abda-a5aa-4414-ac91-ecd7944c0f8d")
    .await
    .unwrap();
  key
      .with_description("Manage documents: Products/Reviews API key".to_string())
      .with_name("Products/Reviews API key".to_string())
      .update(&client)
      .await
      .unwrap();
  ```

  ```swift Swift theme={null}
  let keyParams = KeyUpdateParams(
    description: "Manage documents: Products/Reviews API key",
    name: "Products/Reviews API key"
  )

  client.updateKey(keyOrUid: "6062abda-a5aa-4414-ac91-ecd7944c0f8d", keyParams: keyParams) { result in
    switch result {
    case .success(let key):
        print(key)
    case .failure(let error):
        print(error)
    }
  }
  ```

  ```dart Dart theme={null}
  await client.updateKey(
    '6062abda-a5aa-4414-ac91-ecd7944c0f8d',
    description: 'Manage documents: Products/Reviews API key',
    name: 'Products/Reviews API key',
  );
  ```
</CodeGroup>

#### Response: `200 Ok`

```json theme={null}
{
  "name": "Products/Reviews API key",
  "description": "Manage documents: Products/Reviews API key",
  "key": "d0552b41536279a0ad88bd595327b96f01176a60c2243e906c52ac02375f9bc4",
  "uid": "6062abda-a5aa-4414-ac91-ecd7944c0f8d",
  "actions": [
    "documents.add",
    "documents.delete"
  ],
  "indexes": [
    "products",
    "reviews"
  ],
  "expiresAt": "2021-12-31T23:59:59Z",
  "createdAt": "2021-10-12T00:00:00Z",
  "updatedAt": "2021-10-13T15:00:00Z"
}
```

## Delete a key

<RouteHighlighter method="DELETE" path="/keys/{key_or_uid}" />

Delete the specified API key.

### Path parameters

A valid API `key` or `uid` is required.

| Name         | Type   | Description                                  |
| :----------- | :----- | :------------------------------------------- |
| **`key`** \* | String | [`key`](#key) value of the requested API key |
| **`uid`** \* | String | [`uid`](#uid) of the requested API key       |

### Example

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X DELETE 'MEILISEARCH_URL/keys/6062abda-a5aa-4414-ac91-ecd7944c0f8d' \
    -H 'Authorization: Bearer MASTER_KEY'
  ```

  ```javascript JS theme={null}
  client.deleteKey('6062abda-a5aa-4414-ac91-ecd7944c0f8d')
  ```

  ```python Python theme={null}
  client.delete_key('6062abda-a5aa-4414-ac91-ecd7944c0f8d')
  ```

  ```php PHP theme={null}
  $client->deleteKey('6062abda-a5aa-4414-ac91-ecd7944c0f8d');
  ```

  ```java Java theme={null}
  client.deleteKey("6062abda-a5aa-4414-ac91-ecd7944c0f8d")
  ```

  ```ruby Ruby theme={null}
  client.delete_key('6062abda-a5aa-4414-ac91-ecd7944c0f8d')
  ```

  ```go Go theme={null}
  client.DeleteKey("6062abda-a5aa-4414-ac91-ecd7944c0f8d")
  ```

  ```csharp C# theme={null}
  client.DeleteKeyAsync("6062abda-a5aa-4414-ac91-ecd7944c0f8d")
  ```

  ```rust Rust theme={null}
  let key = client
    .get_key("6062abda-a5aa-4414-ac91-ecd7944c0f8d")
    .await
    .unwrap();
  client
    .delete_key(&key)
    .await?;
  ```

  ```swift Swift theme={null}
  client.deleteKey(keyOrUid: "6062abda-a5aa-4414-ac91-ecd7944c0f8d") { result in
      switch result {
      case .success:
          print("success")
      case .failure(let error):
          print(error)
      }
  }
  ```

  ```dart Dart theme={null}
  await client.deleteKey('6062abda-a5aa-4414-ac91-ecd7944c0f8d');
  ```
</CodeGroup>

#### Response: `204 No Content`
