What constitutes apostasy in islam and carries the death sentence?

Apostasy is not a small issue in Islam. Over the years Islamic Jurisprudents developed a system to identify an Apostate. Let us go through the various conditions which render a person as an Apostate.

Regarding monotheism and polytheism
A public declaration or conduct that denies Islam, its beliefs, symbols or its principal actors such as statements as "I believe in gods other than Allah", or "God has a material form."

Worshiping an idol
Trinity: Saying that God is three in One; God the Father, God the Son, Holy Spirit, or Al lat, Al'Uzza and Manat (known as the daughters of Allah to the pre-Islamic Arabs). In Islam, God does not beget nor is He begotten (Al-Ikhas) and He alone has the right to be worshiped (Surah Al-Fatihah).

Regarding Beliefs
Saying the world has always existed from eternity, in such a way that it denies the existence of God as a creator
Saying that the world is everlasting and without end, in such a way that it could be interpreted as a denial of resurrection.
Believing in reincarnation into this world, in such a way that it could be interpreted as a denial of resurrection
Contradicting the positions that are upheld by a consensus (ijima) of Muslim scholars (Ulema), such as saying that prayers or fasting are not obligatory, or that the prohibition of adultery does not have to be followed. Not following these doctrines does not make one an apostate, but saying they need not be followed does.

Regarding prophethood of Muhammad
Rejecting Muhammad's claim to be a prophet, or denying the concept of prophethood.
Implying that one can become a prophet through spiritual exercise, since that would imply the possibility of a prophet after Muhammad.
Saying that there were prophets after Muhammad.
Cursing the prophet
Accusing the prophet of having a physical deficiency such as a limp or paralysisQuestioning the perfection of his knowledge or defaming the prophet's character, morals, virtues, or religion

Any clearly blasphemous action, such as burning the Quran out of contempt, and every manner of soiling it out of contempt or hatred. The same may also apply to the Hadiths books.

you can read in more detail this issue with references to islamic scriptures