AMI SIP Responses and Reason Codes

Hi all,

I’m using the AMI to originate outbound SIP calls. What I need is a way to capture the SIP responses and reason codes sent back from the operator (e.g., “500 Internal Server Error”, “Reason: Q.850;cause=111”, etc.) when a call fails or is rejected.
Is there a way to get this information from AMI events ?

Asterisk 20.14.1

If you are able to get it in the dialplan, you can generate a hint there.