How to redirect to third party URL from the REST API Response Magento 2?

You can redirect to a third-party URL from the response of the rest API operation in Magento with some simple code snippets.

We can redirect to a third-party URL with a PHP method header(“Location: URL”) in the REST API but this is the not standard way to redirect using the header method in Magento.