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

# Update email

Use this endpoint to update a user's email address within your project. The user is identified by their current email and updated with a new email address.

```method: POST theme={null}
https://api.taag.cc/v1/users/update/email
```

## Authorization

All you need is to include your **secret key** as a value of **authorization** in the header and hit the endpoint above.

```bash theme={null}
Authorization: taag_sk_mode_xxxxxxxxx
```

<ParamField path="Authorization" type="string" required> Use the secret key that matches the mode you are in TEST or LIVE </ParamField>

## Request Body

Provide both the current email address and the new email address for the user.

```bash theme={null}
{
  "oldEmail": "user@example.com",
  "newEmail": "newemail@example.com"
}
```

<ParamField body="oldEmail" type="string" required>
  The current email address of the user you want to update
</ParamField>

<ParamField body="newEmail" type="string" required>
  The new email address to assign to the user. Must be a valid email format and not already in use by another user in this project.
</ParamField>

<Note>
  * The new email must be different from the old email
  * The new email cannot already be in use by another user in the same project and mode
  * Users are scoped to both project and mode (TEST or LIVE)
</Note>

## Response

If the email is updated successfully, you will receive a confirmation with the update details.

```bash theme={null}
{
  "success": true,
  "message": "User email updated successfully",
  "data": {
    "oldEmail": "user@example.com",
    "newEmail": "newemail@example.com",
    "mode": "TEST",
    "updatedAt": "2025-12-12T14:30:00.000Z"
  }
}
```

## Error Responses

<AccordionGroup>
  <Accordion title="400 Bad Request - Missing Fields">
    Returned when either oldEmail or newEmail is missing.

    ```bash theme={null}
    { 
        "success": false, 
        "error": "Missing required fields", 
        "description": "oldEmail and newEmail are required" 
    } 
    ```
  </Accordion>

  <Accordion title="400 Bad Request - Invalid Old Email">
    Returned when the old email format is invalid.

    ```bash theme={null}
    { 
        "success": false, 
        "error": "Invalid old email format", 
        "description": "Please provide a valid old email address" 
    } 
    ```
  </Accordion>

  <Accordion title="400 Bad Request - Invalid New Email">
    Returned when the new email format is invalid.

    ```bash theme={null}
    { 
        "success": false, 
        "error": "Invalid new email format", 
        "description": "Please provide a valid new email address" 
    } 
    ```
  </Accordion>

  <Accordion title="400 Bad Request - Identical Emails">
    Returned when the old and new email addresses are the same.

    ```bash theme={null}
    { 
        "success": false, 
        "error": "Emails are identical", 
        "description": "The new email must be different from the old email" 
    } 
    ```
  </Accordion>

  <Accordion title="404 Not Found">
    Returned when no user exists with the provided old email address.

    ```bash theme={null}
    { 
        "success": false, 
        "error": "User not found", 
        "description": "No user found with email user@example.com in this project" 
    } 
    ```
  </Accordion>

  <Accordion title="409 Conflict">
    Returned when the new email is already in use by another user.

    ```bash theme={null}
    { 
        "success": false, 
        "error": "Email already in use", 
        "description": "Email newemail@example.com is already used by another user in this project" 
    } 
    ```
  </Accordion>

  <Accordion title="500 Internal Server Error">
    Returned when an unexpected error occurs.

    ```bash theme={null}
    { 
        "success": false, 
        "error": "Internal Server Error", 
        "description": "An unexpected error occurred while updating the user email. Please try again or contact support if the issue persists." 
    } 
    ```
  </Accordion>
</AccordionGroup>
