to topics, which are just keys that devices can subscribe to
You’ll note that there is no way to send to all devices explicitly. You can build such functionality with each of these though.
For sending to a topic you have a syntax error in your command. Topics are identified by starting with /topics/. Since you don’t have that in your code, the server interprets allDevices as a device id. Since it is an invalid format for a device registration token, it raises an error.
From the documentation on sending messages to topics:
"message": "This is a Firebase Cloud Messaging Topic Message!",