API / anonymize or delete

'lo. We’re using hosted discourse with OAuth. We suddenly realized that when we process deletions, we’re neglecting to delete from our discourse instance.

I’d like to be able to anonymize an account, OR delete an account programmatically using the API – but I don’t see an easy way to do that, given that I don’t know what the discourse account ID is.

Am I missing something obvious? Any suggestions?




Do you know if email addresses match between your OAuth identity provider and Discourse? If they do, you could get the Discourse user based on their email address by making an authenticated API request to /admin/users/list/all.json?email=<users_email_address>. For example:

curl -X GET "http://localhost:3000/admin/users/list/all.json?email=bob@example.com" \
-H "Api-Key: $api_key" \
-H "Api-Username: system"

They should match, thank you – that was the call I was missing. Verifying.

I am also interested in using an api call to anonymize a user. What is the API endpoint you are using to anonymize a user?

The API endpoint for anonymizing:

HTTP Method: PUT
Endpoint: https://example-community.dev/admin/users/{id}/anonymize

you can use the call shown above to get the {id} value if you already know the email of the user you want to anonymize