# Trigger "set random password and send via email" via API

**URL:** <https://forums.rocket.chat/t/trigger-set-random-password-and-send-via-email-via-api/15868>\
**Category:** Community Support\
**Created:** [January 30, 2023, 1:59pm UTC](https://forums.rocket.chat/t/trigger-set-random-password-and-send-via-email-via-api/15868 "2023-01-30T13:59:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nluetic](https://avatars.discourse-cdn.com/v4/letter/n/7bcc69/32.png) [@nluetic](https://forums.rocket.chat/u/nluetic)\
**Post date:** [January 30, 2023, 1:59pm UTC](https://forums.rocket.chat/t/trigger-set-random-password-and-send-via-email-via-api/15868/1 "2023-01-30T13:59:49Z")

</div>

### Description

I have a set of known users (emails, names) that I would like to programmatically add to `rocketchat` and then give them the opportunity to set their passwords. The registration page is therefore turned off. Also I do not need two-factor-authentication.

What I achieved so far using the API is

- importing the users  
this requires an initial password and I disabled “welcome email” as I have to send another email anyway
- sending an email using `users.forgotPassword`.

However, as the users never used `rocketchat`previously I would rather send the equivalent of “set random password and send via email” in the admin interface. I was not able to identify the correct api endpoint for this. Is it available?

Everything would be much simpler, if the `createUser` endpoint would allow to chose which mail to send (welcome email, random password, …). Currently it is only possible to send a welcome email or to not do so.

I actually expect this to be quite a common use case. So maybe there is better way altogether to achieve what I want?

### Server Setup Information

- Version of Rocket.Chat Server: 5.4.2
- Operating System: Debian (bookworm/sid)
- Deployment Method: docker-compose
- Number of Running Instances: 1
- DB Replicaset Oplog: default from docker-compose.yml
- NodeJS Version: 4.19.3 (as per the rocketchat image)
- MongoDB Version: 5.0.0
- Proxy: nginx
- Firewalls involved:

### Any additional Information

see above: no two-factor-auth, no registration page

---

<div class="post-metadata">

**Author:** ![JadenSmip](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/jadensmip/32/4442_2.png) [@JadenSmip](https://forums.rocket.chat/u/JadenSmip)\
**Post date:** [February 24, 2023, 5:06am UTC](https://forums.rocket.chat/t/trigger-set-random-password-and-send-via-email-via-api/15868/2 "2023-02-24T05:06:22Z")

</div>

great, thank you very much for this information
