# Reset Password

The `resetPassword` mutation will reset the user's password through a code previously generated by the [`requestResetPassword`](https://docs.suggestic.com/graphql/query/mutations/user-profile/request-reset-password) mutation.

## Requirements

* Execute the [`requestResetPassword` ](https://docs.suggestic.com/graphql/query/mutations/user-profile/request-reset-password)mutation in order to get the code to be used to reset the password.

## Required Arguments

| Argument      | Type   | Description                                                                                                                                           |
| ------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `code`        | String | Code to be retrieved in the [`requestResetPassword` ](https://docs.suggestic.com/graphql/query/mutations/user-profile/request-reset-password)mutation |
| `newPassword` | String | The User’s new password                                                                                                                               |

## Available Fields

| Field     | Type    | Description                                                                                                                         |
| --------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `success` | Boolean | <p>True if the reset password has been updated successfully</p><p>False if the reset password has not been updated successfully</p> |
| `message` | String  | Description of the result                                                                                                           |

## Examples

The following example updates the password by using a giving reset code.

### Graphql Example

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

```graphql
mutation {
  resetPassword(code: "ZWE3MWQ0ZjktZDJkYS00NGMzLWE1NjQtNjE3NTUyNTJlY2I4OjVyNy00MzYyYzdkNGRmNGM1NzMwNTlmOA==", newPassword:"myStrongPassword") {
    success
    message
  }
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "resetPassword": {
      "success": true,
      "message": "Your password was successfully updated!"
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Curl example

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

```javascript
curl --location --request POST 'https://production.suggestic.com/graphql' \
--header 'Authorization: Token <API-Token>' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"mutation {\n    resetPassword(code: \"<reset-code-b64>\" newPassword: \"<new-password>\") {\n        success message\n    }\n}","variables":{}}'
```

{% endtab %}
{% endtabs %}
