How to get LuaRef for use in nvim_buf_call (over Msgpack RPC)?

This Q pertains to usage of the API over Msgpack RPC (i.e. outside Lua).

The API function nvim_buf_call takes a LuaRef, which seems to be a new type in Neovim 0.5.0. I don’t see an API function that returns one of these. As far as I can tell they are meant to be treated opaquely. How do I obtain one?

One thing I can imagine (and maybe this is how it works but I’m really not sure as I haven’t worked with Lua before), is that you get a LuaRef by calling nvim_exec_lua and having the executed code return a reference to a Lua function, which I’m guessing is something you can do in Lua. And then you would treat the msgpack value that you get back as a response opaquely, and that would be your LuaRef. Is that how it works?