---
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/4493/api/doc/cloud-enterprise/operation/operation-delete-user-api-key
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/cloud-enterprise/operation/operation-delete-user-api-key
products:
  - Elastic Cloud Enterprise
---

# Delete an API key for a user

## 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.

## Authentication

- Basic: `Authorization: Basic <credentials>`
- Api key: `Authorization: <value>`

## 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}"
```

