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

# Update Display Name

> Update the display name of the currently authenticated user.

## Endpoint

```
POST https://theslow.net/api/account/update-display-name
```

## Overview

This endpoint allows an authenticated user to update their `display_name`.
When a display name is updated:

* It is sanitized to enforce lowercase, hyphenated format, and safe characters.
* Any existing email forwarding is **disabled** and the forwarding address is cleared.
* If the user previously had email forwarding, their old ImprovMX alias is removed.

An analytics event is also logged for auditing and tracking purposes.

## Authentication

This endpoint requires an API key. You can retrieve an API key from your [dashboard](https://theslow.net/dashboard). Include it in the `X-API-KEY` header:

```
X-API-KEY: YOUR_API_KEY_HERE
```

For more details, see the [Authentication Guide](https://docs.theslow.net/authentication).

## Request Body

| Field          | Type   | Required | Description                                                                               |
| -------------- | ------ | -------- | ----------------------------------------------------------------------------------------- |
| `display_name` | string | ✅ yes    | The new desired display name. Must be at least 3 characters and pass sanitization checks. |

## Rules & Validation

* The `display_name` will be:
  * Converted to lowercase.
  * Spaces replaced with hyphens.
  * Non-alphanumeric characters (except hyphens) removed.
* Must be at least **3 characters long** after sanitization.
* Must be **unique** across all profiles and not in the reserved names list.

If the input fails these checks, you’ll receive detailed error messages.

## Request Examples

### cURL

```bash theme={null}
curl -X POST   'https://theslow.net/api/account/update-display-name'   -H 'X-API-KEY: YOUR_API_KEY'   -H 'Content-Type: application/json'   -d '{"display_name": "new-username"}'
```

### Python

```python theme={null}
import requests

BASE_URL = "https://theslow.net/api"
API_KEY = "YOUR_API_KEY"
payload = {"display_name": "new-username"}

headers = {
    "X-API-KEY": API_KEY,
    "Content-Type": "application/json"
}

response = requests.post(
    f"{BASE_URL}/account/update-display-name",
    headers=headers,
    json=payload
)

if response.ok:
    print("✅ Success:", response.json())
else:
    print("❌ Error:", response.status_code, response.json())
```

### JavaScript (Fetch)

```js theme={null}
async function updateDisplayName(newName) {
  try {
    const response = await fetch("/api/account/update-display-name", {
      method: "POST",
      headers: {
        "X-API-KEY": "YOUR_API_KEY",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({ display_name: newName })
    });

    if (!response.ok) {
      const errorData = await response.json();
      console.error("Failed to update:", errorData.error);
      return;
    }

    const data = await response.json();
    console.log("Name updated:", data.message);
  } catch (err) {
    console.error("Unexpected error:", err);
  }
}

// Example usage:
// updateDisplayName("new-username");
```

## Responses

### 200 OK

Successfully updated the display name.

```json theme={null}
{
  "success": true,
  "message": ""Name updated. Due to this, email forwarding has been disabled. You can enable it via the API or through the dashboard.""
}
```

### 400 Bad Request

Invalid or missing input.

```json theme={null}
{
  "error": "A display name is required."
}
```

```json theme={null}
{
  "error": "SlowNet Name must be at least 3 characters long."
}
```

```json theme={null}
{
  "error": "The name "bad name!" is not valid. Try "bad-name" instead."
}
```

### 401 Unauthorized

Occurs if authentication fails (e.g., missing or invalid API key).

```json theme={null}
{
  "error": "Unauthorized: You must be logged in or provide a valid API Key."
}
```

### 404 Not Found

Profile could not be found (possible stale session).

```json theme={null}
{
  "error": "Could not find your profile to update."
}
```

### 409 Conflict

The requested display name is reserved or already taken.

```json theme={null}
{
  "error": "This SlowNet name is not available."
}
```

```json theme={null}
{
  "error": "This SlowNet name is already taken."
}
```

### 500 Internal Server Error

A server-side error occurred.

```json theme={null}
{
  "error": "An internal server error occurred."
}
```

## Need Further Assistance?

If you have any questions or encounter issues, please don't hesitate to reach out to our [support team](https://theslow.net/dashboard#support).
