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

# Toggle Email Forwarding

> Enable or disable email forwarding for your SlowNet alias, and set the forwarding address.

## Endpoint

```
POST https://theslow.net/api/email-forwarding/email-forwarding-toggle
```

## Overview

This endpoint allows you to enable or disable email forwarding for your SlowNet alias.
When enabling, it synchronizes with our email forwarding provider (ImprovMX), updates your SlowNet profile, and syncs with Brevo for contact management.

## 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                                                         |
| --------- | ------- | --------------- | ------------------------------------------------------------------- |
| `enabled` | boolean | ✅ yes           | Whether to enable (`true`) or disable (`false`) forwarding.         |
| `email`   | string  | ✅ when enabling | The email address to forward to. Required when `enabled` is `true`. |

## Request Examples

### cURL

```bash theme={null}
curl -X POST   'https://theslow.net/api/email-forwarding/email-forwarding-toggle'   -H 'X-API-KEY: YOUR_API_KEY'   -H 'Content-Type: application/json'   -d '{"enabled": true, "email": "you@example.com"}'
```

### Python

```python theme={null}
import requests

BASE_URL = "https://theslow.net/api"
API_KEY = "YOUR_API_KEY"

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

payload = {
    "enabled": True,
    "email": "you@example.com"
}

response = requests.post(
    f"{BASE_URL}/email-forwarding/email-forwarding-toggle",
    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 toggleForwarding(enabled, email) {
  try {
    const response = await fetch("/api/email-forwarding/email-forwarding-toggle", {
      method: "POST",
      headers: {
        "X-API-KEY": "YOUR_API_KEY",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({ enabled, email })
    });

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

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

// Example usage:
// toggleForwarding(true, "you@example.com");
```

## Responses

### 200 OK

Indicates the forwarding setting was successfully updated.

```json theme={null}
{
  "success": true
}
```

### 400 Bad Request

Invalid input, such as missing email when enabling.

```json theme={null}
{
  "error": "A valid email address is required to enable forwarding."
}
```

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

Occurs if the user does not have a profile yet.

```json theme={null}
{
  "error": "Your profile could not be found. Please set a SlowNet Name first."
}
```

### 500 Internal Server Error

A server-side error occurred.

```json theme={null}
{
  "error": "Failed to synchronize with the email forwarding service."
}
```

or

```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).
