Maymun bin Abi Shabib narrates from Sayyiduna Ali (may Allah be pleased with him): The Messenger of Allah (peace and blessings be upon him) gave me two slave boys who were brothers as a gift. I sold one of them. The Prophet (peace and blessings be upon him) said: "What happened to the slave boys?" I said: I have sold one of them. He (peace and blessings be upon him) said: "Take him back."
This is how al-Hajjaj narrated it, and al-Hajjaj is not used as proof; the hadith of Abu Khalid al-Dalani from al-Hakam is more likely to be the preserved one, because of its many corroborating reports, and Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السير / 18320