Cancelar a assinatura de um usuário de todos os e-mails via chamada de API?

The site I maintain uses Discourse via SSO. When a user of my site unsubscribes from site generated emails, I would also like to unsubscribe the user from Discourse emails. It should be possible to determine what is required by looking at the API calls that are made when user email settings are changed via the UI, but I was wondering if there is an easier way?

Will it always be the case that they don’t want to see site emails and community emails?

If the possibility exists that they will want to opt out of one and not both why not simply link to a page where they can manage their email preferences for discourse?

Yes. Management has told me to unsubscribe users from discourse email when the user unsubs from site emails.

For anyone interested in a follow up:
My need was met by following the reverse engineering guide. 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

Implementei a mesma lógica, mas os valores não estão sendo refletidos nas preferências de e-mail do usuário no site.

Observe que o método de passar api_key e api_username via parâmetros de consulta está agora obsoleto; você deve usar os cabeçalhos Api-Key e Api-Username atualmente.