How To update "Contacts" in a Potential

How To update "Contacts" in a Potential

I created a potential  and map a contact to it, i try to replace the contact with the new one but it added with the current contact how to reset the attached contacts with the Potential through CRM api?