What if you bought a new iPhone so when you transferred your contacts your previous contacts via the old iCloud account, then you sign out of the old iCloud account into a new one. The contacts then disappeared, so how do you now retrieve the contacts?
You may retrieve them by doing the following.
Open any web browser, and go to icloud.com on your computer.
Log in with your iCloud account (Your Apple ID and password).
Click on Contacts. Click the gear shaped Settings button on the bottom left, and click Select All.
Click the gear button again, and click Export vCard… to download contacts from iCloud.
Then, you reupload by signing in with the other Apple ID following these steps.
In iCloud Contacts, click the Action pop-up menu in the sidebar, then choose Import vCard.
Select a vCard to import.