To restrict API message size limit, allows you to specify a size limit for an entire message. When the request size exceeds the designated limit. You will get failed API response.

Configure the assertion as below:
- Specify size limit for
Select the target message to be controlled by the size limit: Request of type Message. - Maximum Size Limit
Enter the maximum message size that should be accepted by the Gateway in kilobytes (KB). The value must be a whole number or a context variable that resolves to the limit. - Exempt MIME attachments from the size limit
By default, the size limit applies to the entire message. To apply the limit to only the XML portion of the message and exempt any MIME attachments, select the check box.
Click on the Save button and you are done. Hit Try with Demo URL to check how assertion work.