POST

Import File


Imports a file to the Media Manager using an external url.

Returns information about the imported file. Specify the parentFolderId and filePath parameters to specify which folder you want the file to be imported to. If no folder is specified, the file is imported to the media-root folder.

Notes:

  • The media property isn't returned in the files response object.
  • When you import a file, it's not immediately available, meaning you can't manage or use the file straight away. Learn more about knowing when a file is ready (SDK | REST).

To import a file, you need to do one of the following:

  • Specify its MIME type in the mimeType field of the request. For example, mimeType: 'image/jpeg'.
  • Specify its extension in either the displayName or url field of the request. For example, displayName: 'Example Image.jpeg or url: https://www.example.com/image.jpeg.
  • Ensure the server hosting the file supports HEAD requests. In these cases the Wix servers can retrieve the MIME type from the hosting server.

Note: If you want to validate the media type, specify the file's expected media type in the optional mediaType field of the request. For example, mediaType: 'IMAGE'.

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/import

Body Params
urlstringRequiredformat WEB_URL

Publicly accessible external file URL.


mediaTypestring

Media type of the file to import. excluding: OTHER media type


displayNamestringmaxLength 200

File name that appears in the Media Manager.


parentFolderIdstringmaxLength 100

ID of the file's parent folder.
This folder is the path root for the filePath.
Default: media-root.


privateboolean

Whether the file will be public or private. Learn more about private files (SDK | REST).


labelsArray <string>maxItems 500maxLength 200

Labels assigned to media files that describe and categorize them. Provided by the Wix user, or generated by Google Vision API for images.


mimeTypestringmaxLength 100

File mime type.


externalInfoExternalInfo

Information sent to the File Ready and File Failed events. See Importing Files (SDK | REST) to learn more.


urlParamsstruct

Optional parameters that should be sent with the external URL.


urlHeadersstruct

Optional headers that should be sent with the external URL.


filePathstringmaxLength 100

Path to the folder where the file will be stored. For example, /videos/2024/december.
If parentFolderId is defined, the parent folder is used as the path root. Otherwise, the root is media-root. The folders in the path will be created if they don't already exist.

Response Object
fileFile

Information about the imported file.

Import a file using an external URL
Request
cURL
curl -X POST \ 'https://www.wixapis.com/site-media/v1/files/import' \ -H 'Authorization: <AUTH>' \ -H 'Content-Type: application/json' \ --data-binary '{ "mimeType": "image/jpeg", "displayName": "T-shirt", "parentFolderId":"25284aa06584441ea94338fdcfbaba12", "private": false, "url": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_light_color_272x92dp.png" }'
Response
JSON
{ "file": { "id": "4acbb8_f968336b3fea4cbebc056d5c41f9944d~mv2.png", "displayName": "T-shirt.png", "url": "https://static.wixstatic.com/media/4acbb8_f968336b3fea3cbebc056d5c41f9944d~mv2.png", "parentFolderId": "25284aa06584441ea94338fdcfbaba12", "hash": "", "sizeInBytes": "7108", "private": false, "mediaType": "IMAGE", "media": null, "operationStatus": "PENDING", "sourceUrl": "https://www.google.com/images/branding/googlelogo/2x/googlelogo_light_color_272x92dp.png", "thumbnailUrl": "https://static.wixstatic.com/media/4acbb8_f968336b3f4a4cbebc056d5c41f9944d~mv2.png", "labels": [], "createdDate": "2022-08-31T18:20:37Z", "updatedDate": "2022-08-31T18:20:37Z", "state": "OK" } }
Errors
400Invalid Argument

There is 1 error with this status code.

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

Event TriggersThis method triggers the following events:
Did this help?