Uploads API Routes

Use these API routes to upload files to your MedusaGo application using the installed file module provider.

You can upload public files, such as product images, or private files, such as CSV files used to import products.

POST /admin/uploads#

Upload Files

Upload files to the configured File Module Provider.

Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.

Request body (application/json)

(body)object | object[]
The files to upload.

Request examples

Responses

200 OK

filesobject[]
The list of uploaded files.

400, 401, 404, 409, 422, 500: an error response is returned.


POST /admin/uploads/presigned-urls#

Get Presigned Upload URL

Get a presigned URL for uploading a file to the configured File Module Provider. The presigned URL can be used to upload files directly to the third-party provider. This only works if your configured provider supports presigned URLs, such as the S3 provider.

Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.

Request body (application/json)

originalnamestring
The file's original name.
sizenumber
The file's size in bytes.
mime_typestring
The file's mime type.
Example: text/csv
access"public" | "private"Optional
The access level of the file. If private, the file will not be publicly accessible. The default value depends on the configured File Module Provider.

Request examples

Responses

200 OK

urlstring
The file's pre-signed upload URL.
filenamestring
The file's filename.
originalnamestring
The file's orignal name.
mime_typestring
The file's mime type.
Example: text/csv
extensionstring
The file's extension.
Example: csv
sizenumber
The file's size in bytes.

400, 401, 404, 409, 422, 500: an error response is returned.


GET /admin/uploads/{id}#

Get a File

Retrieve an uploaded file by its ID. You can expand the file's relations or select the fields that should be returned.

Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.

Path parameters

idstring
The upload's ID.

Query parameters

fieldsstringOptional
Comma-separated fields that should be included in the returned data. if a field is prefixed with + it will be added to the default fields, using - will remove it from the default fields. without prefix it will replace the entire default fields.

Request examples

Responses

200 OK

fileobject
A file's details.

400, 401, 404, 409, 422, 500: an error response is returned.


DELETE /admin/uploads/{id}#

Delete a File

Delete a file. Uses the installed file module provider to delete the file.

Authentication: secret API key (HTTP Basic authorization), cookie session, JWT bearer token.

Path parameters

idstring
The file's ID.

Request examples

Responses

200 OK

idstring
The file's ID.
objectstring
The name of the deleted object.

Default: "file"

deletedboolean
Whether the file was deleted.

400, 401, 404, 409, 422, 500: an error response is returned.

Found a problem with this page?Report Issue
Edited Nov 14·Edit this page