# Unsubscribing a user from all emails via an API call?

**URL:** https://meta.discourse.org/t/unsubscribing-a-user-from-all-emails-via-an-api-call/133319
**Category:** Support
**Created:** [13 november 2019 om 18:32 UTC](https://meta.discourse.org/t/unsubscribing-a-user-from-all-emails-via-an-api-call/133319 "2019-11-13T18:32:27Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![jezra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jezra/32/105986_2.png) [@jezra](https://meta.discourse.org/u/jezra)
#### Post date: [14 november 2019 om 18:20 UTC](https://meta.discourse.org/t/unsubscribing-a-user-from-all-emails-via-an-api-call/133319/4 "2019-11-14T18:20:12Z")

</div>

For anyone interested in a follow up:  
My need was met by following the [reverse engineering guide](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576). It was a fairly straight forward process to collect the contents of the PUT payload.

in Ruby, the payload I ended up with is:  
`payload = {mailing_list_mode: false, mailing_list_mode_frequency: 1, email_digests: false, email_in_reply_to: false, email_messages_level: 2, email_level: 2, email_previous_replies: 2 }`

the ‘mailing\_list\_mode\_frequency’ can probably be excluded since mailing\_list\_mode is false.  
The payload is then PUT to `https://DISCOURSEHOST/u/USERNAME.json?api_key=DISCOURSE_SYSTEM_API_KEY&api_username=system`

---

_[View the full topic](https://meta.discourse.org/t/unsubscribing-a-user-from-all-emails-via-an-api-call/133319)._
