Setting invoice to "paid" status the right way through API

is there anyone who can answer this please?