When a Cybertronian dies, their spirit goes to the AllSpark where they stay there for eternity. At first, it seemed as if there was a physical AllSpark object through which the afterlife was accessed, kept within the Well of All Sparks, but later, it was explained the "physical" Allspark was actually nothing of the sort: it was ethereal energy, which was placed within a container built by Alpha Trion so that it could be launched into space and put beyond Megatron's reach. The language used to describe the energy was vague, but spoke of how it was "extracted from the ether" and was made up of "a multitude of sparks," suggesting that the energy might have actually been that of the Allspark realm itself, drawn into the material world.
When Optimus Prime was injured from the destruction of the old Autobot base, he was close to joining Alpha Trion in the AllSpark. Smokescreen revived Optimus by placing the Forge of Solus Prime on his hand. This prevented Optimus from joining the AllSpark and resurrected him in a new body.
Megatron was prevented by Unicron from entering the AllSpark. Unicron told Megatron that Unicron's blood was inside Megatron's body which prevented Megatron from joining the AllSpark. Unicron used Megatron's body as a vessel to attack Cybertron and nearly destroying the Core of Cybertron. Optimus trapped Unicron's anti-spark inside the vessel which once stored the AllSpark inside. In the end, Optimus Prime sacrificed himself to restore Cybertron's life.