> For the complete documentation index, see [llms.txt](https://api.epixelsoftware.help/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.epixelsoftware.help/user-password.md).

# User Password

## Change password

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/profile/change-password/`

This API endpoint is for changing user password

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| apikey<mark style="color:red;">\*</mark>        | string | apikey              |
| Authorization<mark style="color:red;">\*</mark> | string | Bearer access-token |

#### Request Body

| Name                                                | Type   | Description      |
| --------------------------------------------------- | ------ | ---------------- |
| old\_password<mark style="color:red;">\*</mark>     | string | old password     |
| new\_password<mark style="color:red;">\*</mark>     | string | new password     |
| confirm\_password<mark style="color:red;">\*</mark> | string | confirm password |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/profile/change-password/',
  'headers': {
    'apikey': '<apikey>',
    'Authorization': 'Bearer <access-token>',
  },
  formData: {
    'old_password': '<old_password>',
    'new_password': '<new_password>',
    'confirm_password': '<confirm_password>',
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/profile/change-password/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('old_password' => '<old_password>','new_password' => '<new_password>','confirm_password' => '<confirm_password>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>",
    "Authorization: Bearer <access-token>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type           | Field             | Description                                                                                                                                                                                                                                                                                                                                           |
| ----------- | -------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 401         | Authentication Error |                   | Your old password was entered incorrectly. Please enter it again.                                                                                                                                                                                                                                                                                     |
| 400         | Validation Error     | confirm\_password | The two password fields didn't match.                                                                                                                                                                                                                                                                                                                 |
| 400         | Validation Error     | password          | <p>Your password can't be too similar to your other personal information.</p><p>Your password must contain at least 8 characters.</p><p>Your password can't be a commonly used password.</p><p>Your password can't be entirely numeric.</p><p>Your password must contain at least one capital letter, small letter, number and special character.</p> |

## Forgot password request

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/forgot-password/`

This API endpoint is to reset the user password. Users can request with the registered email or username. Users will get a link with token and user key in an email. This token, user key, and a new password can send to the forget password submit API endpoint to change the current password or directly use the link to change the password.

#### Headers

| Name                                     | Type   | Description |
| ---------------------------------------- | ------ | ----------- |
| apikey<mark style="color:red;">\*</mark> | string | apikey      |

#### Request Body

| Name                                    | Type   | Description       |
| --------------------------------------- | ------ | ----------------- |
| email<mark style="color:red;">\*</mark> | string | email or username |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
ar request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/forgot-password/',
  'headers': {
    'apikey': '<apikey>',
  },
  formData: {
    'email': '<email or username>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/forgot-password/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('email' => '<email or username>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

#### Error Responses

| Status Code | Error Type           | Description                                                                                        |
| ----------- | -------------------- | -------------------------------------------------------------------------------------------------- |
| 40**1**     | Authentication Error | There is multiple users are registered with the specified E-Mail address.Please enter the username |
| 401         | Authentication Error | This username or email does not exist in the system.                                               |

## Forgot password submit

<mark style="color:green;">`POST`</mark> `‎https://<domain>/<api prefix>/<version>/user/forgot-password-submit/‎‎`

This endpoint is to reset the user password. User will get a link with token and user key in an email after success response from forgot password request API endpoint. Once use the link to change the password else send the token, user key, and a new password to this API endpoint to change the current user password.

#### Headers

| Name                                     | Type   | Description |
| ---------------------------------------- | ------ | ----------- |
| apikey<mark style="color:red;">\*</mark> | string | apikey      |

#### Request Body

| Name                                            | Type   | Description        |
| ----------------------------------------------- | ------ | ------------------ |
| user<mark style="color:red;">\*</mark>          | string | user key from link |
| token<mark style="color:red;">\*</mark>         | string | token from link    |
| new\_password<mark style="color:red;">\*</mark> | string | new password       |

{% tabs %}
{% tab title="200 " %}

```markup
HTTP/1.1 200 OK
Content-Type: application/json

Body:
{
    "status_code": 200,
    "errors": {},
    "data": {}
}
```

{% endtab %}
{% endtabs %}

#### Sample code

**Node**

```javascript
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://<domain>/<api prefix>/<version>/user/forgot-password-submit/',
  'headers': {
    'apikey': '<apikey>'
  },
  formData: {
    'token': '<token_from_link>',
    'new_password': '<new_password>',
    'user': '<user_key_from_link>'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
```

**PHP**

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://<domain>/<api prefix>/<version>/user/forgot-password-submit/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => array('user' => '<user_key_from_link>','token' => '<token>','new_password' => '<new_password>'),
  CURLOPT_HTTPHEADER => array(
    "apikey: <apikey>"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;	
```

#### Error Responses

| Status Code | Error Type       | Field    | Description                                                                                                                                                                                                                                                                                                                                           |
| ----------- | ---------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400         | Validation Error | token    | The token is invalid. Enter the correct token that send to your email.                                                                                                                                                                                                                                                                                |
| 400         | Validation Error | password | <p>Your password can't be too similar to your other personal information.</p><p>Your password must contain at least 8 characters.</p><p>Your password can't be a commonly used password.</p><p>Your password can't be entirely numeric.</p><p>Your password must contain at least one capital letter, small letter, number and special character.</p> |
| 400         | Validation Error | user     | This field is required.                                                                                                                                                                                                                                                                                                                               |
