curl -sS -X POST 'https://matrix.example.com/_matrix/media/v3/upload?filename=photo.jpg' -H "Authorization: Bearer $ACCESS_TOKEN" -F 'file=@photo.jpg'

Category: Matrix & Synapse

curl -sS -X POST 'https://matrix.example.com/_matrix/media/v3/upload?filename=photo.jpg' -H "Authorization: Bearer $ACCESS_TOKEN" -F 'file=@photo.jpg'

Upload a file to the media repository

Uploads photo.jpg and returns an mxc:// URI like mxc://example.com/abcde12345, which is how Matrix references media everywhere. The filename query parameter is stored as the upload name. Embed the mxc URI in messages as the url field, or share it directly with the download endpoint. Uploads count against the media store, so monitor usage with the statistics API.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.