_NET_NUMBER_OF_DESKTOPS
The root window property holding the number of virtual desktops, set by the window manager, with an open request channel for anyone who wants more.
In 1999 the question of how many desktops there were had as many answers as there were window managers: CDE had four, FVWM as many as you liked, kwm its own count, and GNOME's panel read _WIN_WORKSPACE_COUNT. EWMH made the count a CARDINAL on the root window, owned and kept current by the window manager. A pager or settings dialog that wants a different number sends a ClientMessage with the new value, and the manager decides whether to comply. If it does and the number shrinks, windows on the removed desktops are moved to the last one left and _NET_CURRENT_DESKTOP is clamped if it fell off the end; if the number grows, empty desktops are appended. Indices always run from zero to n minus one, no gaps.
That last rule is what chafes for window managers with ideas of their own. i3 lets workspaces be called 1, 5 and "mail" and spring into existence on demand, so it reports them as a densely packed count and leaves the names in _NET_DESKTOP_NAMES to carry the truth. GNOME 3 introduced dynamic workspaces in 2011, with an empty one always waiting at the end, so the number changes by itself as you work. FVWM, whose desks are effectively unlimited, gained the EwmhNumberOfDesktops command to choose which figure to advertise. wmctrl -d lists them and wmctrl -n 6 asks for six; what happens next depends on who is listening.