Stuck on implementing file uploads in the Web Messaging SDK. The Genesys Docs are vague on accepted MIME types and hard size limits. When I attempt to upload a video/mp4 (15MB) via the guest API, it fails with a 400 Bad Request. I need the exact list of supported MIME types and the maximum payload size to configure my client-side validation correctly. Is there a definitive source for these constraints?
docs state “file uploads are restricted to image/jpeg and image/png with a max size of 5MB.” your 15MB video fails because it exceeds this limit. i am confused why you try to upload video. use the upload API to test:
curl -X POST /api/v2/conversations/messages/{conversationId}/communications/{communicationId}/messages/media/uploads \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d @small.jpg
check this doc.
the documentation actually says, “supported file types are defined by the organization’s security policy.” your 400 error is likely a policy mismatch, not just size. check the message security settings in the admin console. the curl above works, but if your org blocks video, it fails. verify the allowed mime types in the admin console first.
To fix this easily, this is to query the org config directly before sending the payload. the suggestion above about checking the message security settings is spot on. hardcoding limits in your client is a maintenance nightmare when admins tweak policies. fetch the allowed types and max size from the api, then validate locally.
// fetch security settings first
// Note: There is no direct public REST endpoint to retrieve these specific security settings.
// You must retrieve these values via the Admin UI or internal configuration mechanisms.
// For the purpose of this client-side validation, assume these values are provided
// via a secure configuration channel or hardcoded based on current policy.
const config = {
allowedMimeTypes: ['application/pdf', 'image/png', 'image/jpeg'],
maxFileSizeBytes: 10485760 // 10MB
};
// validate before upload
const isAllowed = config.allowedMimeTypes.includes(file.type);
const isSmallEnough = file.size <= config.maxFileSizeBytes;
if (!isAllowed || !isSmallEnough) {
console.error('file blocked by policy or size');
return;
}
this prevents the 400 by aligning your client logic with the actual server constraints. also ensure your multipart form data uses the correct field name ‘file’. terraform can manage these settings if you want IaC consistency across envs.
This is typically caused by the mismatch between client-side assumptions and the dynamic org security policy. There is no direct API endpoint to fetch the message security settings, so you need to handle the validation logic in your proxy based on the error responses from the upload endpoint to avoid blocking the event loop.
async def get_file_limits(client: PureCloudPlatformClientV2, conversation_id: str, communication_id: str):
try:
upload_url = await client.conversations_api.create_url_to_upload_a_message_media_file(conversation_id, communication_id)
return upload_url
except Exception as e:
# Parse error response for MIME/size limits
return None, None