---
type: api
title: Delete an API key for a user
description: Delete or invalidate an API key for a user.
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/cloud-enterprise/v4/operation/operation-delete-user-api-key
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/cloud-enterprise/v4/operation/operation-delete-user-api-key
products:
  - Elastic Cloud Enterprise
---

# Delete an API key for a user

Authentication: required

## Paths

- `DELETE` `/users/{user_id}/auth/keys/{api_key_id}`

#### Path parameters

- `user_id` (string) — required
  The user ID.
- `api_key_id` (string) — required
  The API Key ID.

## Description

Delete or invalidate an API key for a user.

## Responses

#### `200`

The API key is deleted.

`application/json`

Type: `object`

#### `404`

The {api_key_id} can't be found. (code: `api_keys.key_not_found`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

## Code examples

#### curl

```curl
curl -X DELETE "${API_URL}/users/${USER_ID}/auth/keys/${API_KEY_ID}" \
  -u "${USERNAME}:${PASSWORD}"
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{}
```

#### 404

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "errors": [
    {
      "code": "string",
      "message": "string",
      "fields": [
        "string"
      ]
    }
  ]
}
```

