Find the serial number of your Magic Keyboard, Magic Mouse, or Magic Trackpad - Apple Support
Change Apple Wireless Keyboard batteries - Apple Support
Amazon.com: Willhom Aluminium Battery Screw Cover Cap Lid Plug Replacement for Apple G6 Wireless Bluetooth Keyboard A1314 and Magic Trackpad A1339 : Electronics
Magic Keyboard with Touch ID and Numeric Keypad for Mac models with Apple silicon - US English - Black Keys - Apple
Replace Apple Wireless Keyboard (A1314) logic board assembly and stuck batteries - iFixit Repair Guide