---
displayed_sidebar: productReference
badge:
  variant: orange
  text: Beta
slug: /references/product/softDelete
sidebar_label: softDelete
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# softDelete - Product Module Reference

This documentation provides a reference to the softDelete method. This belongs to the Product Module.

This method is used to delete products. Unlike the [delete](product.IProductModuleService.delete.mdx) method, this method won't completely remove the product. It can still be accessed or retrieved using methods like [retrieve](product.IProductModuleService.retrieve.mdx) if you pass the `withDeleted` property to the `config` object parameter.

The soft-deleted products can be restored using the [restore](product.IProductModuleService.restore.mdx) method.

## Example

```ts
import {
  initialize as initializeProductModule,
} from "@medusajs/product"

async function deleteProducts (ids: string[]) {
  const productModule = await initializeProductModule()

  const cascadedEntities = await productModule.softDelete(ids)

  // do something with the returned cascaded entity IDs or return them
}
```

## Type Parameters

<ParameterTypes parameters={[
  {
    "name": "TReturnableLinkableKeys",
    "type": "`string`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

## Parameters

<ParameterTypes parameters={[
  {
    "name": "productIds",
    "type": "`string`[]",
    "description": "The IDs of the products to soft-delete.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "config",
    "type": "[SoftDeleteReturn](../../product/interfaces/product.SoftDeleteReturn.mdx)&#60;TReturnableLinkableKeys&#62;",
    "description": "Configurations determining which relations to soft delete along with the each of the products. You can pass to its `returnLinkableKeys`\nproperty any of the product's relation attribute names, such as `variant_id`.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "returnLinkableKeys",
        "type": "`TReturnableLinkableKeys`[]",
        "description": "An array of strings, each being the ID attribute names of the entity's relations.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  },
  {
    "name": "sharedContext",
    "type": "[Context](../../product/interfaces/product.Context.mdx)",
    "description": "A context used to share resources, such as transaction manager, between the application and the module.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "enableNestedTransactions",
        "type": "`boolean`",
        "description": "A boolean value indicating whether nested transactions are enabled.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "isolationLevel",
        "type": "`string`",
        "description": "A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "manager",
        "type": "`TManager`",
        "description": "An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "transactionId",
        "type": "`string`",
        "description": "A string indicating the ID of the current transaction.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "transactionManager",
        "type": "`TManager`",
        "description": "An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  }
]} />

## Returns

<ParameterTypes parameters={[
  {
    "name": "Promise",
    "type": "Promise&#60;void \\| Record&#60;string, string[]&#62;&#62;",
    "optional": false,
    "defaultValue": "",
    "description": "An object that includes the IDs of related records that were also soft deleted, such as the ID of associated product variants. The object's keys are the ID attribute names of the product entity's relations, such as `variant_id`, and its value is an array of strings, each being the ID of a record associated with the product through this relation, such as the IDs of associated product variants.\n\nIf there are no related records, the promise resolved to `void`.",
    "expandable": false,
    "children": [
      {
        "name": "void \\| Record&#60;string, string[]&#62;",
        "type": "`void` \\| `Record<string, string[]>`",
        "optional": true,
        "defaultValue": "",
        "description": "",
        "expandable": false,
        "children": []
      }
    ]
  }
]} />
