Custom 413 Payload Error Handling in Apigee Edge

Custom 413 Payload Error Handling in Apigee Edge

I’m working on a scenario where the client sends requests with payloads exceeding 10 MB. The client has specifically requested a custom error response instead of Apigee’s default 413 Payload Too Large message.

We attempted to implement this by using a RaiseFault policy with a conditional check to return a custom JSON error payload. However, during testing, we observed that the API call is rejected immediately—before reaching the authorization or any flow logic. It appears that Apigee Edge is blocking the request at the entry point due to the payload size, and the flow doesn’t proceed far enough to trigger our custom logic.

Question:
Is it possible to configure Apigee Edge to return a custom response for 413 Payload Too Large errors?

Hello @NishVOIS

Have you explicitly verified through Apigee debug that the request does not reach your underlying proxying logic?

I am wondering if you have the Fault Rule out of scope, something as follows should work (this is for a Default Fault rule but can be conditionalized given use case, but would verify the above assumption):

<DefaultFaultRule name="DefaultFaultRule">
    <Step> 
	<Condition>(fault.name = "TooBigBody")</Condition>
	<Name>AM-MyCustomError</Name> 
    </Step>
    <AlwaysEnforce>true</AlwaysEnforce>
</DefaultFaultRule>

Thank for the help ,

Addition of condition in default rule worked.

Only thing is we have to always enforce true.