How to pay an invoice by credit memo via API?

Hi Community,

Could you share the API request of how to pay the invoice by credit memo?