"Give the Israelites the following laws:
If you buy a Hebrew slave, he shall serve you for six years. In the seventh year he is to be set free without having to pay anything. 1
References for Exodus 21:2
21.2-6 Lv 25.39-46.
If he was unmarried when he became your slave, he is not to take a wife with him when he leaves; but if he was married when he became your slave, he may take his wife with him.
If his master gave him a wife and she bore him sons or daughters, the woman and her children belong to the master, and the man is to leave by himself.
But if the slave declares that he loves his master, his wife, and his children and does not want to be set free,
then his master shall take him to the place of worship. There he is to make him stand against the door or the doorpost and put a hole through his ear. Then he will be his slave for life.
"If a man sells his daughter as a slave, she is not to be set free, as male slaves are.
If she is sold to someone who intends to make her his wife, but he doesn't like her, then she is to be sold back to her father; her master cannot sell her to foreigners, because he has treated her unfairly.
If a man buys a female slave to give to his son, he is to treat her like a daughter.
If a man takes a second wife, he must continue to give his first wife the same amount of food and clothing and the same rights that she had before.
If he does not fulfill these duties to her, he must set her free and not receive any payment.