Reset avatar in sync SSO

A good approach to figure out what API call to make to perform an action is to perform the action through the Discourse user interface while watching your web inspector’s network tab to find details about the request that is being made. See How to reverse engineer the Discourse API for details about this approach.

User avatars can be updated to the system avatar by making an API PUT request to<discourse_username>/preferences/avatar/pick

Set type=system in the request’s form data. You’ll need to substitute your forum’s URL and the Discourse username that you want to update into the URL.

Here’s an example curl request from my local site. I’ve set $api_key to my All Users API Key:

curl -X PUT "http://localhost:3000/u/scossar/preferences/avatar/pick" \
-H "Api-Key: $api_key" \
-H "Api-Username: system" \
-H "Content-Type: multipart/form-data;" \
-F "type=system"

One thing to note is that this request will fail if you have enabled the sso overrides avatar site setting.

1 Like