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

# Reset Admin Password (Self-Hosted)

> Change the password for the currently authenticated admin user on a self-hosted Databrain instance. Self-hosted only.

Change the password for the admin user identified by the current authentication token. Requires the current password and the new password. The new password should meet the same complexity rules as sign-up (see [Create Admin Account](/developer-docs/helpers/api-reference/create-admin-account)).

<Warning>
  **Self-Hosted Only:** This endpoint is available only on **self-hosted** Databrain instances.
</Warning>

<Warning>
  **Authentication Requirement:** This endpoint requires an authenticated admin user. Use the Bearer token from [Create Admin JWT](/developer-docs/helpers/api-reference/create-admin-jwt).
</Warning>

## Authentication

Use a valid admin JWT in the `Authorization` header. Obtain one via [Create Admin JWT](/developer-docs/helpers/api-reference/create-admin-jwt).

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for the admin whose password is being changed.

  ```
  Authorization: Bearer <access_token>
  ```
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be `application/json` when sending a JSON body.

  ```
  Content-Type: application/json
  ```
</ParamField>

## Request Body

<ParamField body="currentPassword" type="string" required>
  The admin's current password.
</ParamField>

<ParamField body="password" type="string" required>
  The new password. Should meet the same requirements as sign-up: minimum 8 characters, at least one uppercase, one lowercase, one digit, one special character, no spaces.
</ParamField>

## Response

On success, the API returns **200** with a JSON object:

<ResponseField name="data" type="object">
  Wrapper object for the response payload.
</ResponseField>

<ResponseField name="data.success" type="boolean">
  `true` when the password was changed successfully.
</ResponseField>

On error, the API returns a JSON object with `error.code` and `error.message` and an appropriate HTTP status (400 or 500).

## Examples

<Panel>
  <RequestExample>
    ```bash cURL theme={"dark"}
    curl --request POST \
      --url https://api.usedatabrain.com/api/v2/service-token/reset-password \
      --header 'Authorization: Bearer YOUR_ADMIN_ACCESS_TOKEN' \
      --header 'Content-Type: application/json' \
      --data '{"currentPassword":"OldP@ss1","password":"NewSecureP@ss2"}'
    ```

    ```javascript Node.js icon="fa-brands fa-node-js" theme={"dark"}
    const response = await fetch('https://api.usedatabrain.com/api/v2/service-token/reset-password', {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_ADMIN_ACCESS_TOKEN',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        currentPassword: 'OldP@ss1',
        password: 'NewSecureP@ss2'
      })
    });
    const data = await response.json();
    if (data.error) throw new Error(data.error.message);
    console.log('Password reset:', data.data.success);
    ```

    ```python Python icon="fa-brands fa-python" theme={"dark"}
    import requests

    url = "https://api.usedatabrain.com/api/v2/service-token/reset-password"
    headers = {
        "Authorization": "Bearer YOUR_ADMIN_ACCESS_TOKEN",
        "Content-Type": "application/json"
    }
    payload = {
        "currentPassword": "OldP@ss1",
        "password": "NewSecureP@ss2"
    }

    response = requests.post(url, headers=headers, json=payload)
    data = response.json()
    if data.get("error"):
        raise Exception(data["error"].get("message", "Request failed"))
    print("Password reset:", data["data"]["success"])
    ```
  </RequestExample>

  <ResponseExample>
    ```json Success (200) theme={"dark"}
    {
      "data": {
        "success": true
      }
    }
    ```

    ```json Error (400) theme={"dark"}
    {
      "error": {
        "code": "RESET_PASSWORD_ERROR",
        "message": "The current password is not correct!"
      }
    }
    ```

    ```json Error (500) theme={"dark"}
    {
      "error": {
        "code": "SELFHOSTED_APP_ERROR",
        "message": "This feature is only available for self-hosted instances"
      }
    }
    ```
  </ResponseExample>
</Panel>

## HTTP Status Code Summary

| Status Code | Description                                                                  |
| ----------- | ---------------------------------------------------------------------------- |
| `200`       | **OK** – Password changed successfully; `data.success` is `true`             |
| `400`       | **Bad Request** – Wrong current password or validation error on new password |
| `500`       | **Internal Server Error** – Server error or self-hosted-only error           |

## Possible Errors

| Code                    | Message                                                                          | HTTP Status |
| ----------------------- | -------------------------------------------------------------------------------- | ----------- |
| `RESET_PASSWORD_ERROR`  | Error message from password change (e.g. "The current password is not correct!") | 400         |
| `SELFHOSTED_APP_ERROR`  | This feature is only available for self-hosted instances                         | 500         |
| `INTERNAL_SERVER_ERROR` | Internal server error or GraphQL error message                                   | 500         |

## Related

* [Create Admin JWT](/developer-docs/helpers/api-reference/create-admin-jwt) – Sign in to get an access token
* [Create Admin Account](/developer-docs/helpers/api-reference/create-admin-account) – Create the first admin account
