POST

Generate File Download Url


Generates one or more temporary URLs for downloading a specific file in the Media Manager.

To download different assets of the file, specify the assetKeys parameter which generates a download URL for each asset. If no assetKey is specified, it defaults to src, which generates one download URL in the original file's format and quality.

Call this endpoint to grant external clients access to a private media file. Specify the expirationInMinutes parameter to set the URL expiration time, and the expirationRedirectUrl parameter to add a redirect url when the URL expires.

To generate a permanent URL for downloading a compressed file that contains multiple files in the Media Manager, call the Generate Files Download URL endpoint. Since this is a permanent URL, it is less secure. Therefore, to download private files, call the Generate File Download URL endpoint for each private file that you want to generate a download URL for.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage Bookings Services and Settings
Manage Media Manager
Manage Portfolio
Manage Restaurants - all permissions
Learn more about app permissions.
Endpoint
POST
https://www.wixapis.com/site-media/v1/files/generate-file-download-url

Body Params
fileIdstringRequiredmaxLength 1000

File ID.

You can also specify the file's Wix media URL. For example, wix:image://v1/0abec0_b291a9349a0b4da59067f76287e386fb~mv2.jpg/leon.jpg#originWidth=3024&originHeight=4032. Learn more about the file ID parameter (SDK | REST).


downloadFileNamestringmaxLength 100

Temporary file name used to identify the file type. For example, a file named "myFile.jpeg" identifies as an "image/jpeg" file type.

Note: The name that appears in the Media Manager is taken from the filename parameter in the Generate File Upload Url call.


expirationInMinutesintegerminimum 1format int32

The time that it takes in minutes for the download URL to expire.
Default: 600.
Limit: 525600 (1 year).


expirationRedirectUrlstringformat WEB_URL

The redirect URL for when the temporary download URL with a token expires.
Default: A 403 Forbidden response page.


assetKeysArray <string>maxItems 100maxLength 100

Keys for downloading different assets (format and quality) of a file. Default: src, key representing the original file's format and quality.


contentDispositionstring

Whether the link downloads the file or opens the file in the browser.

  • ATTACHMENT: The link downloads the file.
  • INLINE: The link opens the file in the browser.

Default: ATTACHMENT

Response Object
downloadUrlsArray <DownloadUrl>maxItems 100

URL for downloading a specific file in the Media Manager.

Generate a URL for downloading a file
Request
cURL
curl -X POST \ 'https://www.wixapis.com/site-media/v1/files/generate-file-download-url' \ -H 'Authorization: <AUTH>' -H 'Content-Type: application/json' \ --data-binary '{ "fileId": "4acbb8_7596aeebcf5c41eca01c0d99667ac967.mp3", "downloadFileName": "Gorillaz - Feel Good Inc.mp3", "expirationInMinutes": "60", "expirationRedirectUrl":"www.mysite.com/store", "assetKeys": ["320kbs.mp3"] }'
Response
JSON
{ "downloadUrls": [ { "url": "https://download-files.wixmp.com/media/4acbb8_00668eb74c164439951039ca3a2ae54a~mv2_d_6031_4456_s_4_2.jpg?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJ1cm46YXBwOmU2NjYzMGU3MTRmMDQ5MGFhZWExZjE0OWIzYjY5ZTMyIiwic3ViIjoidXJuOmFwcDplNjY2MzBlNzE0ZjA0OTBhYWVhMWYxNDliM2I2OWUzMiIsImF1ZCI6WyJ1cm46c2VydmljZTpmaWxlLmRvd25sb2FkIl0sImlhdCI6MTY1MjY0OTY4MCwiZXhwIjoxNjUyNjQ5NzUwLCJqdGkiOiJlODk0MDEzOTJmYzUiLCJvYmoiOltbeyJwYXRoIjoiL21lZGlhLzJhY2JiOF8wMDY2OGViNzRjMTY0NDM5OTUxMDM5Y2EzYTJhZTU0YX5tdjJfZF82MDMxXzQ0NTZfc180XzIuanBnIn1dXSwicmVkIjoid3d3Lmdvb2dsZS5jb20iLCJhdHRhY2htZW50Ijp7ImZpbGVuYW1lIjoiZWxpcmFuLmpwZyJ9fQ.P9eCCRunJcjxdFyJVOqFwvuutpyjRekAuP67BFBs8Es", "assetKey": "320kbs.mp3" } ] }
Errors
400Invalid Argument

There is 1 error with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?