The bed must have enough space. The room doesn't have to be any specific shape but the area of the room (including the walls, ceiling and floor) must equal at least 60 tiles but less than 750.
Enemies must not be able to spawn in the room; The room must have player-placed walls behind it. The background walls can not be a naturally-occurring wall. This includes dirt, mud and the background walls in Chasms and the Dungeon(Player-placed dirt walls will work.) Holes in the background wall must be no larger than 4 tiles wide or 4 high. (For example, a room that is 9 wide and 4 high split with a background wall down the center is usable as a bedroom).
Wood platforms can be used as the room's floor or ceiling.
A bed may be placed in a non-rectangular room, as long as the leftmost 3 blocks immediately above it are left clear. For instance, you may have a bed (2x4) surrounded by walls on the left, right and bottom sides, and the foot of the bed have one block on top of it, and as long as there is space for the player to spawn at the bed (3 high), the bed can be set as a spawn point. See the ASCII image below.
Must have a door as well.
tiens !