Web Messaging SDK file upload 413 Error despite small file size

We’re hitting a 413 Request Entity Too Large when customers try to upload images via the Android Web Messaging SDK. The payload is just 2MB and the MIME type is image/jpeg, which should be fine. Here’s the snippet:

kotlin
val file = File("/storage/emulated/0/Pictures/test.jpg")
messagingSession.uploadFile(file, "image/jpeg")

The error occurs immediately on the network call. Is there a hard limit I’m missing?

Check your organization’s file attachment settings in Admin. The 413 error usually means the request is hitting a server-side limit before it even processes the file content. The default max file size is often set quite low, sometimes just 500KB or 1MB for web messaging channels.

Go to Admin > Settings > Messaging. Look for the “File attachments” section. You need to increase the “Maximum file size” value. Set it to something like 5242880 bytes (5MB) to give your 2MB images some headroom.

Here is the curl command to check and update this via API if you prefer not to use the UI. First, get the current messaging settings:

curl -X GET "https://api.mypurecloud.com/api/v2/messaging/settings" \
 -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Find the fileAttachmentSettings object in the response. Note the maxFileSize value. Then update it:

curl -X PATCH "https://api.mypurecloud.com/api/v2/messaging/settings" \
 -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{
 "fileAttachmentSettings": {
 "maxFileSize": 5242880,
 "allowedMimeTypes": ["image/jpeg", "image/png", "application/pdf"]
 }
 }'

Make sure image/jpeg is in the allowedMimeTypes list too. If the MIME type is blocked, you get a 415, but sometimes the gateway throws a generic 413 if the header parsing fails early. It’s a small config change but it solves the immediate blockage. The Android SDK code you posted looks standard, so the issue is definitely on the backend configuration side. Restart your session after updating the settings to ensure the new limits are pulled down.

nailed it. The server-side limit is definitely the culprit here. I’ve seen this exact 413 error pop up when the org default is set too low for media files. You need to bump that max file size in Admin. It’s under Settings > Messaging > File attachments. Set it to at least 5MB (5242880 bytes) to cover your 2MB images with some headroom. Don’t forget to check the channel-specific limits too. Sometimes the global setting is fine, but the specific Web Messaging channel has a separate, stricter cap. Here’s how to verify the current limit via API if you want to double-check before changing the UI:

curl -X GET "https://api.mypurecloud.com/api/v2/organizations/settings/messaging.file.maxSize" \
 -H "Authorization: Bearer <your_token>" \
 -H "Content-Type: application/json"

If the value returned is less than 2097152, that’s your problem. Update it and test again. The SDK itself doesn’t enforce this, so the config is the only thing blocking the upload.