POST
/
admin
/
products
/
imports
JS SDK
import Medusa from "@medusajs/js-sdk"

export const sdk = new Medusa({
  baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
  debug: import.meta.env.DEV,
  auth: {
    type: "session",
  },
})

sdk.admin.product.createImport({
  file // uploaded File instance
})
.then(({ transaction_id }) => {
  console.log(transaction_id)
})
{
"transaction_id": "<string>",
"summary": {
"toCreate": 123,
"toUpdate": 123
}
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

The details of the product's import file.

file_key
string
required

The name of the file as stored in the configured File Module Provider.

originalname
string
required

The file's original name.

extension
string
required

The file's extension.

Example:

"csv"

size
number
required

The file's size in bytes.

mime_type
string
required

The file's mime type.

Example:

"text/csv"

Response

OK

The import process's details.

transaction_id
string
required

The ID of the workflow execution's transaction. This is useful to confirm the import using the /admin/products/:transaction-id/import API route.

summary
object
required

The import's summary.