A phylogenetic evaluation of sleep demonstrates that all
mammals, birds, and reptiles engage in sleep, and evidence
for sleep in amphibians, ﬁshes, and invertebrates is strong if
not certain.

So it seems that once you have a nervous system, you also have some rest periods. However, it may not be clear if the rest periods are dictated by the lifestyle (e.g. nocturnal foraging) or by a requirement to "recharge" the nervous system.