Usage of the ‘setessential’ console command is: setessential <1/0> – set a character (NPC) as immortal (1) or mortal (0). Note that the base ID and not the ref ID must be used. The ref ID is what appears when clicking on an object with the console open.
Skyrim SE (2020) | Gopher’s TOP 5 ‘Essential’ Mods