Sample - Box Platform API
POST/users/{user_id}/avatar

Add or update a user avatar

Adds or updates a user's avatar from an uploaded image file. Send the image in the pic multipart form field; use a JPG or PNG file no larger than 1MB and no larger than 1024 × 1024 pixels. A 200 response indicates an existing avatar was updated, while a 201 response indicates a new avatar was created.

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

1 parameter · 1 body field
user_idstringrequired
The unique identifier of the user whose avatar to add or update.

Multipart form data containing the avatar image to upload.

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

6 status codes
200Returns a `pic_urls` object containing URLs for the existing user avatars that were updated.
pic_urlsobjectoptional
Represents an object with user avatar URLs.
201Returns a `pic_urls` object containing URLs for the user avatars uploaded with the request.
pic_urlsobjectoptional
Represents an object with user avatar URLs.
400Returned when `pic` is missing or empty, the image exceeds 1MB or 1024 × 1024 pixels, or the file extension is not `.jpg` or `.png`.
typestringoptional
The value will always be `error`.
Allowed:error
statusintegeroptional
The HTTP status of the response.
codestringoptional
A Box-specific error code.
Allowed:createdacceptedno_contentredirectnot_modifiedbad_requestunauthorizedforbiddennot_foundmethod_not_allowedconflictprecondition_failed
messagestringoptional
A short message describing the error.
context_infoobjectoptional
A free-form object that contains additional context about the error. The possible fields are defined on a per-endpoint basis. `message` is only one example.
help_urlstringoptional
A URL that links to more information about why this error occurred.
request_idstringoptional
A unique identifier for this response, which can be used when contacting Box support.
403Returned when the user lacks permission to upload an avatar or is not activated.
typestringoptional
The value will always be `error`.
Allowed:error
statusintegeroptional
The HTTP status of the response.
codestringoptional
A Box-specific error code.
Allowed:createdacceptedno_contentredirectnot_modifiedbad_requestunauthorizedforbiddennot_foundmethod_not_allowedconflictprecondition_failed
messagestringoptional
A short message describing the error.
context_infoobjectoptional
A free-form object that contains additional context about the error. The possible fields are defined on a per-endpoint basis. `message` is only one example.
help_urlstringoptional
A URL that links to more information about why this error occurred.
request_idstringoptional
A unique identifier for this response, which can be used when contacting Box support.
404Returned when the specified user does not exist or cannot be found.
typestringoptional
The value will always be `error`.
Allowed:error
statusintegeroptional
The HTTP status of the response.
codestringoptional
A Box-specific error code.
Allowed:createdacceptedno_contentredirectnot_modifiedbad_requestunauthorizedforbiddennot_foundmethod_not_allowedconflictprecondition_failed
messagestringoptional
A short message describing the error.
context_infoobjectoptional
A free-form object that contains additional context about the error. The possible fields are defined on a per-endpoint basis. `message` is only one example.
help_urlstringoptional
A URL that links to more information about why this error occurred.
request_idstringoptional
A unique identifier for this response, which can be used when contacting Box support.
defaultReturned when an unexpected client error occurs; the response contains a generic error object with an error code, message, request identifier, and optional context.
typestringoptional
The value will always be `error`.
Allowed:error
statusintegeroptional
The HTTP status of the response.
codestringoptional
A Box-specific error code.
Allowed:createdacceptedno_contentredirectnot_modifiedbad_requestunauthorizedforbiddennot_foundmethod_not_allowedconflictprecondition_failed
messagestringoptional
A short message describing the error.
context_infoobjectoptional
A free-form object that contains additional context about the error. The possible fields are defined on a per-endpoint basis. `message` is only one example.
help_urlstringoptional
A URL that links to more information about why this error occurred.
request_idstringoptional
A unique identifier for this response, which can be used when contacting Box support.

Error handling

A 400 is returned when pic is missing or empty, exceeds 1MB or 1024 × 1024 pixels, or uses an extension other than .jpg or .png. A 403 is returned when the authenticated user lacks permission to upload an avatar or the user is not activated. A 404 is returned when the specified user_id does not exist.