I think that as follows from your error, the command was sent via user channel but should be sent via device channel according to Apple Documentation https://developer.apple.com/documentation/devicemanagement/lock_a_device
Topic:
Developer Tools & Services
SubTopic:
General
Tags: