How to upload files through the API?

As far as I can see, this is the only response:
Error: Request failed with status code 422

And I don’t see anything in the logs.