---
type: api
title: Delete users
description: Delete users from the native realm.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/operation/operation-security-delete-user
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/operation/operation-security-delete-user
products:
  - Elasticsearch
---

# Delete users

## Paths

- `DELETE` `/_security/user/{username}`

#### Path parameters

- `username` (string) — required
  An identifier for the user.

## Description

Delete users from the native realm.

## Required authorization

- Cluster privileges: `manage_security`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Query string parameters

- `refresh` (enum) — optional
  If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.
  Values: `true`, `false`, `wait_for`

## Response

`application/json`

- `found` (boolean)
  If the user is successfully deleted, the request returns `{"found": true}`.
Otherwise, `found` is set to `false`.
## Code examples

#### Console

```console
DELETE /_security/user/jacknich
```

#### JavaScript

```javascript
const response = await client.security.deleteUser({
  username: "jacknich",
});
```

#### Python

```python
resp = client.security.delete_user(
    username="jacknich",
)
```

#### curl

```curl
curl -X DELETE "$ELASTICSEARCH_URL/_security/user/jacknich" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.security().deleteUser(d -> d
    .username("jacknich")
);
```

#### C#

```c#
var response = await client.Security.DeleteUserAsync(username: "jacknich");
```

#### PHP

```php
$resp = $client->security()->deleteUser([
    "username" => "jacknich",
]);
```

#### Ruby

```ruby
response = client.security.delete_user(
  username: "jacknich"
)
```

## Response examples

#### Security delete user response example1

A successful response from `DELETE /_security/user/jacknich`.

```json
{
  "found" : true
}
```

