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

# Post Change Password

> Learn about Post Change Password Actions, which run after a Database connection user resets or changes their password. They can be used to notify another system that the user's password has changed.

The `post-change-password` trigger runs after a Database connection user resets or changes their password. Use this trigger to email the user after a password change or to notify another system that the user's password has changed, so that other sessions not managed by Auth0 can be revoked. Multiple Actions can be bound to this trigger, and the Actions will run in order.

<Frame>
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/docs-staging/docs/images/cdy7uua7fh8z/3i65TvmTpHkyDTqKvXAkMi/3adb8f0bd195cec4dd0a82cb87b270b9/post-change-password-flow.png" alt="Diagram showing the Actions Post Change Password Flow." />
</Frame>

Actions in this flow are non-blocking (asynchronous): the Auth0 pipeline continues to run without waiting for the Action to finish, so the Action's outcome does not affect the Auth0 transaction.

## References

* [Event object](/docs/customize/actions/reference/post-change-password/post-change-password-event-object): Provides contextual information about the user and the connection on which the password was changed.
* [API object](/docs/customize/actions/reference/post-change-password/post-change-password-api-object): Provides methods for changing the behavior of the flow.

## Common use cases

### Invalidate the user's session in another system

A post-change-password Action can be used to invalidate the user's session in another system:

```javascript lines theme={null}
const axios = require("axios");

/**
 * @param {Event} event - Details about user whose password was changed.
 */
exports.onExecutePostChangePassword = async (event) => {
  axios.post("https://my-api.exampleco.com/revoke-session", { params: { email: event.user.email }});
};
```

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  To use an `npm` library like `axios`, you must add the library to the Action as a dependency. To learn more, read the "Add a dependency" section in [Write Your First Action](/docs/customize/actions/write-your-first-action).
</Callout>

### Send an email after the user changes their password

A post-change-password Action can be used to notify the user by email that their password was changed:

```javascript lines expandable theme={null}
const axios = require("axios");

/**
 * @param {Event} event - Details about user whose password was changed.
 */
exports.onExecutePostChangePassword = async (event) => {
  try {
    // https://sendgrid.api-docs.io/v3.0/mail-send
    axios.post('https://api.sendgrid.com/v3/mail/send',
      {
        personalizations: [{
          to: [{ email: event.user.email }]
        }],
        from: { email: 'admin@exampleco.com' },
        subject: 'Your password was changed',
        content: [{
          type: 'text/plain',
          value: 'The password for your ' + event.connection.name + ' account ' + event.user.email + ' was recently changed.'
        }]
      },
      {
        headers: {
          'Authorization': 'Bearer ' + event.secrets.SENDGRID_API_KEY
        },
      }
    );
  } catch (err) {
    console.log(`Error sending email to ${event.user.email}:`, err.message)
  }
};
```

<Callout icon="file-lines" color="#0EA5E9" iconType="regular">
  For this Action to execute properly, the Action must contain a secret named `SENDGRID_API_KEY` and must have a dependency on the `axios` `npm` package.
</Callout>
