Instead of using one big switch statement, I would rather create a class like ResponseErrorHandler which would encapsulate the logic related to error codes.
This class could implement magic php methods __get or __call, so that in your exception handler you may bring it to life like:
(new ResponseErrorsHandler)->54321;
(new ResponseErrorsHandler)->12345;
or
(new ResponseErrorsHandler)->54321();
(new ResponseErrorsHandler)->12345();
Thanks to this magic methods, your class by default would catch all the current and future error codes from this external API.
In case a particular code like 54321 or 12345 is important to you, you could create public methods like processCode54321 or processCode12345 and react accordingly there.
Another idea would be to create a separate class for each error code returned from this outside API. Then you would instantiate the proper class in your exception handler, trying to map the error code to the proper class name - however in my opinion this sounds like an over-engineered solution.
If any other solution comes to my mind, I will share it promptly with you.
Good luck!