Resting

From Player's Handbook, page 186.

Heroic though they might be, adventurers can't spend every hour of the day in the thick of exploration, social interaction, and combat. They need rest-time to sleep and eat, tend their wounds, refresh their minds and spirits for spellcasting, and brace themselves for further adventure.

Adventurers can take short rests in the midst of an adventuring day and a long rest to end the day. While the text here refers to adventurers, any creature can take a short or long rest.

Short Rest
A short rest is a period of downtime, at least 1 hour long, during which a character does nothing more strenuous than eating, drinking, reading, and tending to wounds.

A character can spend one or more hit dice at the end of a short rest, up to the character's maximum number of hit dice, which is equal to the character's level. For each hit die spent in this way, the player rolls the die and adds the character's Constitution modifier to it. The character regains hit points equal to the total. After applying your Constitution modifier to a hit die roll, you regain a minimum of 0 hit points. The player can decide to spend an additional hit die after each roll. A character regains some spent hit dice upon finishing a long rest, as explained below.

Long Rest
A long rest is a period of extended downtime, at least 8 hours long, during which a character sleeps for at least 6 hours and performs no more than 2 hours of light activity, such as reading, talking, eating, or standing watch. If the rest is interrupted by a period of strenuous activity — at least 1 hour of walking, fighting, casting spells, or similar adventuring activity, the characters must begin the rest again to gain any benefit from it.

At the end of a long rest, a character regains all lost hit points. The character also regains spent hit dice, up to a number of dice equal to half of the character's total number of them. You regain at least 1 hit die when you finish a long rest.

For example, if a character has eight hit dice, he or she can regain four spent hit dice upon finishing a long rest.

A character can't benefit from more than one long rest in a 24-hour period, and a character must have at least 1 hit point at the start of the rest to gain its benefits.