> ## Documentation Index
> Fetch the complete documentation index at: https://docs.konstantly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete User

> Delete user account

Permanently delete a user account.

<Warning>
  Users must be deactivated (blocked) before they can be deleted. Use the [Deactivate User](/api-reference/users/block-user) endpoint first.
</Warning>

## Request Headers

<ParamField header="X-API-KEY" type="string" required>
  API Key. Go to your Konstantly site > Settings > API and copy the value from there.
</ParamField>

## URL Parameters

<ParamField path="userId" type="string" required>
  User API ID
</ParamField>

## Response

On success, returns HTTP 200 status code.

### Error Responses

<ResponseField name="404" type="object">
  Not Found error response

  <Expandable title="Error object properties">
    <ResponseField name="status" type="integer" required>HTTP status code (404)</ResponseField>
    <ResponseField name="message" type="string" required>Error message</ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="422" type="object">
  Unprocessable Entity error response

  <Expandable title="Error object properties">
    <ResponseField name="status" type="integer" required>HTTP status code (422)</ResponseField>
    <ResponseField name="message" type="string" required>Error message</ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request DELETE \
  --url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890' \
  --header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
  ```

  ```python Python theme={null}
  import requests

  def delete_user(api_key: str, user_id: str) -> None:
  url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}"
  headers = {"X-API-KEY": api_key}

  response = requests.delete(url, headers=headers)

  if response.status_code == 404:
  raise ValueError(f"User {user_id} not found")
  elif response.status_code == 422:
  error_data = response.json()
  raise ValueError(error_data.get('message', 'Cannot process request'))

  response.raise_for_status()

  # Example usage
  try:
  delete_user("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
  print("User deleted successfully")
  except Exception as e:
  print(f"Failed to delete user: {str(e)}")
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  async function deleteUser(apiKey, userId) {
  try {
  await axios.delete(
  `https://YOURSITE.konstant.ly/openapi/v1/users/${userId}`,
  {
  headers: {
  'X-API-KEY': apiKey
  }
  }
  );
  } catch (error) {
  if (error.response?.status === 404) {
  throw new Error(`User ${userId} not found`);
  }
  if (error.response?.status === 422) {
  throw new Error(error.response.data.message || 'Cannot process request');
  }
  throw error;
  }
  }

  // Example usage
  deleteUser('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890')
  .then(() => console.log('User deleted successfully'))
  .catch(error => console.error('Failed to delete user:', error.message));
  ```
</RequestExample>

<ResponseExample>
  ```json 404 Error theme={null}
  {
      "status": 404,
      "message": "Not found"
  }
  ```

  ```json 422 Error theme={null}
  {
      "status": 422,
      "message": "You should block users before deleting them"
  }
  ```
</ResponseExample>
