Sample - Slack Web API
POST/users.setPhoto

Set a user's profile photo

Updates a user's profile photo. Submit the image with optional crop coordinates and dimensions, using the authentication token included in the form.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

5 body fields

Form data containing the authentication token, image contents, and optional square crop settings.

tokenstringrequired
Authentication token. Requires scope: `users.profile:write`
crop_wstringoptional
Width/height of crop box (always square)
crop_xstringoptional
X coordinate of top-left corner of crop box
crop_ystringoptional
Y coordinate of top-left corner of crop box
imagestringoptional
File contents via `multipart/form-data`.

2 status codes
200Returns `ok` set to true and the updated profile photo URLs and avatar hash in `profile`.
okbooleanrequired
Allowed:true
profileobjectrequired
defaultTypical error response
callstackstringoptional
Note: PHP callstack is only visible in dev/qa
debug_stepstringoptional
possibly DEV/QA only
dimsstringoptional
possibly DEV/QA only
errorstringrequired
Allowed:bad_imagetoo_largetoo_many_framesnot_foundnot_authedinvalid_authaccount_inactivetoken_revokedno_permissionorg_login_requireduser_is_botinvalid_arg_name
okbooleanrequired
Allowed:false
time_identintegeroptional
possibly DEV/QA only

Error handling

token must be included in the form and must carry the users.profile:write scope. Supply image as file contents through multipart form data, and provide crop values as strings when you want to limit the uploaded image to a square region.