Hi sp9001,
It is the same as creating a payment via actions/UI.
You can either just insert a ReceivePayment record and set IsAutoApply = true or if you want to assign a specific invoice, insert ReceivePayment with IsAutoApply=false and ReceivePaymentAppliedtoTxn that references the specific transaction.
Today our API actions are all table-specific calls but in the future, we might have higher endpoints maybe something like AcceptPayment, where you can just pass it an invoice recordID and it creates all the related receivepayment records. I will create a feature request for our development team to have it on their product roadmap.
As of now, I think you will have to manually call the post on the ReceivePaymentAppliedtoTxn table to connect it with the invoice explicitly.
Regards,
Inder