Add or update user avatar

post
https://api.box.com/2.0
/users/:user_id/avatar

Adds or updates a user avatar.

Request

Bearer [ACCESS_TOKEN]
multipart/form-data

Path Parameters

stringin pathrequired
12345

The ID of the user.

Request Body

string / binaryin bodyrequired

The image file to be uploaded to Box. Accepted file extensions are .jpg or .png. The maximum file size is 1MB.

Response

application/jsonUser avatar
  • ok: Returns the pic_urls object with URLs to existing user avatars that were updated.
application/jsonUser avatar
  • created: Returns the pic_urls object with URLS to user avatars uploaded to Box with the request.
application/jsonClient error
  • bad_request: Returns an error when:
    • An image is not included in the request
    • The uploaded file is empty
    • The image size exceeds 1024 * 1024 pixels or 1MB
    • The file extension is other than .jpg or .png.
application/jsonClient error
  • forbidden: Returns an error if the user does not have permissions necessary to upload an avatar or is not activated.
application/jsonClient error
  • not_found: Returns an error if the user does not exist or cannot be found.
post
Add or update user avatar
You can now try out some of our APIs live, right here in the documentation.
Log in

Request Example

cURL
curl -i -X POST -L "https://api.box.net/2.0/users/12345/avatar" \
     -H "Authorization: Bearer <ACCESS_TOKEN>" \
     --form 'pic=@"path/to/file/file.jpeg"'
.NET
using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
{
    BoxUploadAvatarResponse response = await client.UsersManager.AddOrUpdateUserAvatarAsync(userId, fileStream);
}
Java
String userID = "33333";
BoxUser user = new BoxUser(api, userID);
AvatarUploadResponse response = user.uploadAvatar(new File("path_to_avatar_file"));

Response Example

{
  "pic_urls": {
    "large": "https://app.box.com/index.php?rm=pic_storage_auth&pic=euks pac3kv01!lipGQlQQOtCTCoB6zCOArUjVWLFJtLr5tn6aOZMCybhRx0NNuFQbVI36nw jtEk5YjUUz1KVdVuvU2yDhu_ftK_bvxeKP1Ffrx9vKGVvJ-UJc1z32p6n2CmFzzpc gSoX4pnPhFgydAL-u9jDspXUGElr-htDG_HPMiE9DZjqDueOxXHy8xe22wbaPAheC ao1emv8r_fmufaUgSndeMYmyZj-KqOYsLBrBNgdeiK5tZmPOQggAEUmyQPkrd8W92TQ6sSlIp0r",
    "preview": "https://app.box.com/index.php?rm=pic_storage_auth&pic=euks! pac3kv01!8UcNPweOOAWj2DtHk_dCQB4wJpzyPkl7mT5nHj5ZdjY92ejYCBBZc95--403b29CW k-8hSo_uBjh5h9QG42Ihu-cOZ-816sej1kof3SOm5gjn7qjMAx89cHjUaNK-6XasRqSNboenjZ 04laZuV9vSH12BZGAYycIZvvQ5R66Go8xG5GTMARf2nBU84c4H_SL5iws-HeBS4oQJWOJh6FBl sSJDSTI74LGXqeZb3EY_As34VFC95F10uozoTOSubZmPYylPlaKXoKWk2f9wYQso1ZTN7sh-Gc 9Kp43zMLhArIWhok0Im6FlRAuWOQ03KYgL-k4L5EZp4Gw6B7uqVRwcBbsTwMIorWq1g",
    "small": "https://app.box.com/index.php?rm=pic_storage_auth&pic=euks! pac3kv01!7B6R5cZLmurEV_xB-KkycPk8Oi7oENUX2O_qUtIuO4342CG IldyCto9hqiQP7uxqYU5V2w63Ft4ln4UVVLDtDZu903OqzkflY2O-Lq00 ubA29xU-RJ6b_KzJEWRYgUhX1zEl3dzWo12g8eWRE2rStf123DF7AYahNqM 1BmLmviL_nODc7SDQHedTXPAjxURUAra5BvtLe7B05AizbNXdPlCNp-LNh _S-eZ_RjDXcGO-MkRWd_3BOMHnvjf450t5BfKoJ15WhEfiMlfXH1tmouHXrsC 66cT6-pzF9E40Iir_zThqSlrFxzP_xcmXzHapr_k-0E2qr2TXp4iC396TSlEw"
  }
}