---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/AdminBatchJobsResource
---

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

# AdminBatchJobsResource

This class is used to send requests to [Admin Batch Job API Routes](https://docs.medusajs.com/api/admin#batch-jobs). All its method
are available in the JS Client under the `medusa.admin.batchJobs` property.

All methods in this class require [user authentication](AdminAuthResource.mdx#createsession).

A batch job is a task that is performed by the Medusa backend asynchronusly. For example, the Import Product feature is implemented using batch jobs.
The methods in this class allow admins to manage the batch jobs and their state.

Related Guide: [How to import products](https://docs.medusajs.com/modules/products/admin/import-products).

## Methods

### cancel

Mark a batch job as canceled. When a batch job is canceled, the processing of the batch job doesn’t automatically stop.

#### Example

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.cancel(batchJobId).then(({ batch_job }) => {
  console.log(batch_job.id)
})
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "batchJobId",
    "type": "`string`",
    "description": "The ID of the batch job.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "customHeaders",
    "type": "Record<`string`, `any`\\>",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "[`ResponsePromise`](../modules/internal.mdx#responsepromise)<[`AdminBatchJobRes`](../modules/internal.mdx#adminbatchjobres)\\>",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves to the batch job's details.",
    "expandable": false,
    "children": [
      {
        "name": "AdminBatchJobRes",
        "type": "`object`",
        "description": "The batch job's details.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "batch_job",
            "type": "[`BatchJob`](../internal/classes/internal.BatchJob.mdx)",
            "description": "Batch job details.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": [
              {
                "name": "canceled_at",
                "type": "`Date`",
                "description": "The date of the concellation.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "completed_at",
                "type": "`Date`",
                "description": "The date of the completion.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "confirmed_at",
                "type": "`Date`",
                "description": "The date when the confirmation has been done.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "context",
                "type": "Record<`string`, `unknown`\\>",
                "description": "The context of the batch job, the type of the batch job determines what the context should contain.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was created.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_by",
                "type": "``null`` \\| `string`",
                "description": "The unique identifier of the user that created the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_by_user",
                "type": "[`User`](../internal/classes/internal.User.mdx)",
                "description": "The details of the user that created the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "deleted_at",
                "type": "``null`` \\| `Date`",
                "description": "The date with timezone at which the resource was deleted.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "dry_run",
                "type": "`boolean`",
                "description": "Specify if the job must apply the modifications or not.",
                "optional": false,
                "defaultValue": "false",
                "expandable": false,
                "children": []
              },
              {
                "name": "failed_at",
                "type": "`Date`",
                "description": "The date when the job failed.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "id",
                "type": "`string`",
                "description": "The unique identifier for the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "pre_processed_at",
                "type": "`Date`",
                "description": "The date from which the job has been pre-processed.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "processing_at",
                "type": "`Date`",
                "description": "The date the job is processing at.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "result",
                "type": "{ `advancement_count?`: `number` ; `count?`: `number` ; `errors?`: (`string` \\| [`BatchJobResultError`](../internal/modules/internal.internal.mdx#batchjobresulterror))[] ; `file_key?`: `string` ; `file_size?`: `number` ; `progress?`: `number` ; `stat_descriptors?`: [`BatchJobResultStatDescriptor`](../internal/modules/internal.internal.mdx#batchjobresultstatdescriptor)[]  } & Record<`string`, `unknown`\\>",
                "description": "The result of the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "status",
                "type": "[`BatchJobStatus`](../internal/enums/internal.internal.BatchJobStatus.mdx)",
                "description": "The status of the batch job.",
                "optional": false,
                "defaultValue": "created",
                "expandable": false,
                "children": []
              },
              {
                "name": "type",
                "type": "`string`",
                "description": "The type of batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "updated_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was last updated.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              }
            ]
          }
        ]
      }
    ]
  }
]} />

___

### confirm

When a batch job is created, it's not executed automatically if `dry_run` is set to `true`. This method confirms that the batch job should be executed.

#### Example

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.confirm(batchJobId).then(({ batch_job }) => {
  console.log(batch_job.id)
})
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "batchJobId",
    "type": "`string`",
    "description": "The ID of the batch job.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "customHeaders",
    "type": "Record<`string`, `any`\\>",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "[`ResponsePromise`](../modules/internal.mdx#responsepromise)<[`AdminBatchJobRes`](../modules/internal.mdx#adminbatchjobres)\\>",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves to the batch job's details.",
    "expandable": false,
    "children": [
      {
        "name": "AdminBatchJobRes",
        "type": "`object`",
        "description": "The batch job's details.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "batch_job",
            "type": "[`BatchJob`](../internal/classes/internal.BatchJob.mdx)",
            "description": "Batch job details.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": [
              {
                "name": "canceled_at",
                "type": "`Date`",
                "description": "The date of the concellation.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "completed_at",
                "type": "`Date`",
                "description": "The date of the completion.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "confirmed_at",
                "type": "`Date`",
                "description": "The date when the confirmation has been done.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "context",
                "type": "Record<`string`, `unknown`\\>",
                "description": "The context of the batch job, the type of the batch job determines what the context should contain.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was created.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_by",
                "type": "``null`` \\| `string`",
                "description": "The unique identifier of the user that created the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_by_user",
                "type": "[`User`](../internal/classes/internal.User.mdx)",
                "description": "The details of the user that created the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "deleted_at",
                "type": "``null`` \\| `Date`",
                "description": "The date with timezone at which the resource was deleted.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "dry_run",
                "type": "`boolean`",
                "description": "Specify if the job must apply the modifications or not.",
                "optional": false,
                "defaultValue": "false",
                "expandable": false,
                "children": []
              },
              {
                "name": "failed_at",
                "type": "`Date`",
                "description": "The date when the job failed.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "id",
                "type": "`string`",
                "description": "The unique identifier for the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "pre_processed_at",
                "type": "`Date`",
                "description": "The date from which the job has been pre-processed.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "processing_at",
                "type": "`Date`",
                "description": "The date the job is processing at.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "result",
                "type": "{ `advancement_count?`: `number` ; `count?`: `number` ; `errors?`: (`string` \\| [`BatchJobResultError`](../internal/modules/internal.internal.mdx#batchjobresulterror))[] ; `file_key?`: `string` ; `file_size?`: `number` ; `progress?`: `number` ; `stat_descriptors?`: [`BatchJobResultStatDescriptor`](../internal/modules/internal.internal.mdx#batchjobresultstatdescriptor)[]  } & Record<`string`, `unknown`\\>",
                "description": "The result of the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "status",
                "type": "[`BatchJobStatus`](../internal/enums/internal.internal.BatchJobStatus.mdx)",
                "description": "The status of the batch job.",
                "optional": false,
                "defaultValue": "created",
                "expandable": false,
                "children": []
              },
              {
                "name": "type",
                "type": "`string`",
                "description": "The type of batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "updated_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was last updated.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              }
            ]
          }
        ]
      }
    ]
  }
]} />

___

### create

Create a Batch Job to be executed asynchronously in the Medusa backend. If `dry_run` is set to `true`, the batch job will not be executed until the it is confirmed,
which can be done using the [confirm](AdminBatchJobsResource.mdx#confirm) method.

#### Example

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.create({
  type: 'product-export',
  context: {},
  dry_run: false
}).then((({ batch_job }) => {
  console.log(batch_job.id);
})
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "payload",
    "type": "[`AdminPostBatchesReq`](../internal/classes/internal.AdminPostBatchesReq.mdx)",
    "description": "The data of the batch job to create.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "context",
        "type": "Record<`string`, `unknown`\\>",
        "description": "Additional infomration regarding the batch to be used for processing.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "dry_run",
        "type": "`boolean`",
        "description": "Set a batch job in dry_run mode, which would delay executing the batch job until it's confirmed.",
        "optional": false,
        "defaultValue": "false",
        "expandable": false,
        "children": []
      },
      {
        "name": "type",
        "type": "`string`",
        "description": "The type of batch job to start, which is defined by the `batchType` property of the associated batch job strategy.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  },
  {
    "name": "customHeaders",
    "type": "Record<`string`, `any`\\>",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "[`ResponsePromise`](../modules/internal.mdx#responsepromise)<[`AdminBatchJobRes`](../modules/internal.mdx#adminbatchjobres)\\>",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves to the batch job's details.",
    "expandable": false,
    "children": [
      {
        "name": "AdminBatchJobRes",
        "type": "`object`",
        "description": "The batch job's details.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "batch_job",
            "type": "[`BatchJob`](../internal/classes/internal.BatchJob.mdx)",
            "description": "Batch job details.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": [
              {
                "name": "canceled_at",
                "type": "`Date`",
                "description": "The date of the concellation.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "completed_at",
                "type": "`Date`",
                "description": "The date of the completion.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "confirmed_at",
                "type": "`Date`",
                "description": "The date when the confirmation has been done.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "context",
                "type": "Record<`string`, `unknown`\\>",
                "description": "The context of the batch job, the type of the batch job determines what the context should contain.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was created.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_by",
                "type": "``null`` \\| `string`",
                "description": "The unique identifier of the user that created the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_by_user",
                "type": "[`User`](../internal/classes/internal.User.mdx)",
                "description": "The details of the user that created the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "deleted_at",
                "type": "``null`` \\| `Date`",
                "description": "The date with timezone at which the resource was deleted.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "dry_run",
                "type": "`boolean`",
                "description": "Specify if the job must apply the modifications or not.",
                "optional": false,
                "defaultValue": "false",
                "expandable": false,
                "children": []
              },
              {
                "name": "failed_at",
                "type": "`Date`",
                "description": "The date when the job failed.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "id",
                "type": "`string`",
                "description": "The unique identifier for the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "pre_processed_at",
                "type": "`Date`",
                "description": "The date from which the job has been pre-processed.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "processing_at",
                "type": "`Date`",
                "description": "The date the job is processing at.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "result",
                "type": "{ `advancement_count?`: `number` ; `count?`: `number` ; `errors?`: (`string` \\| [`BatchJobResultError`](../internal/modules/internal.internal.mdx#batchjobresulterror))[] ; `file_key?`: `string` ; `file_size?`: `number` ; `progress?`: `number` ; `stat_descriptors?`: [`BatchJobResultStatDescriptor`](../internal/modules/internal.internal.mdx#batchjobresultstatdescriptor)[]  } & Record<`string`, `unknown`\\>",
                "description": "The result of the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "status",
                "type": "[`BatchJobStatus`](../internal/enums/internal.internal.BatchJobStatus.mdx)",
                "description": "The status of the batch job.",
                "optional": false,
                "defaultValue": "created",
                "expandable": false,
                "children": []
              },
              {
                "name": "type",
                "type": "`string`",
                "description": "The type of batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "updated_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was last updated.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              }
            ]
          }
        ]
      }
    ]
  }
]} />

___

### list

Retrieve a list of Batch Jobs. The batch jobs can be filtered by fields such as `type` or `confirmed_at`. The batch jobs can also be sorted or paginated.

#### Example

To list batch jobs:

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.list().then(({ batch_jobs, limit, offset, count }) => {
  console.log(batch_jobs.length)
})
```

To specify relations that should be retrieved within the batch jobs:

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs
  .list({
    expand: "created_by_user",
  })
  .then(({ batch_jobs, limit, offset, count }) => {
    console.log(batch_jobs.length)
  })
```

By default, only the first `10` records are retrieved. You can control pagination by specifying the `limit` and `offset` properties:

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs
  .list({
    expand: "created_by_user",
    limit,
    offset,
  })
  .then(({ batch_jobs, limit, offset, count }) => {
    console.log(batch_jobs.length)
  })
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "query",
    "type": "[`AdminGetBatchParams`](../internal/classes/internal.AdminGetBatchParams.mdx)",
    "description": "Filters and pagination configurations to apply on the retrieved batch jobs.",
    "optional": true,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "canceled_at",
        "type": "``null`` \\| [`DateComparisonOperator`](../internal/classes/internal.DateComparisonOperator.mdx)",
        "description": "Date filters to apply on the batch jobs' `canceled_at` date.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "completed_at",
        "type": "``null`` \\| [`DateComparisonOperator`](../internal/classes/internal.DateComparisonOperator.mdx)",
        "description": "Date filters to apply on the batch jobs' `completed_at` date.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "confirmed_at",
        "type": "``null`` \\| [`DateComparisonOperator`](../internal/classes/internal.DateComparisonOperator.mdx)",
        "description": "Date filters to apply on the batch jobs' `confirmed_at` date.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "created_at",
        "type": "[`DateComparisonOperator`](../internal/classes/internal.DateComparisonOperator.mdx)",
        "description": "Date filters to apply on the batch jobs' `created_at` date.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "gt",
            "type": "`Date`",
            "description": "The filtered date must be greater than this value.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "gte",
            "type": "`Date`",
            "description": "The filtered date must be greater than or equal to this value.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "lt",
            "type": "`Date`",
            "description": "The filtered date must be less than this value.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "lte",
            "type": "`Date`",
            "description": "The filtered date must be less than or equal to this value.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          }
        ]
      },
      {
        "name": "expand",
        "type": "`string`",
        "description": "Comma-separated relations that should be expanded in the returned data.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "failed_at",
        "type": "``null`` \\| [`DateComparisonOperator`](../internal/classes/internal.DateComparisonOperator.mdx)",
        "description": "Date filters to apply on the batch jobs' `failed_at` date.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "fields",
        "type": "`string`",
        "description": "Comma-separated fields that should be included in the returned data.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "id",
        "type": "`string` \\| `string`[]",
        "description": "IDs to filter batch jobs by.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "limit",
        "type": "`number`",
        "description": "Limit the number of items returned in the list.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "offset",
        "type": "`number`",
        "description": "The number of items to skip when retrieving a list.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "order",
        "type": "`string`",
        "description": "The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "pre_processed_at",
        "type": "``null`` \\| [`DateComparisonOperator`](../internal/classes/internal.DateComparisonOperator.mdx)",
        "description": "Date filters to apply on the batch jobs' `pre_processed_at` date.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "type",
        "type": "`string`[]",
        "description": "Types to filter batch jobs by.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "updated_at",
        "type": "[`DateComparisonOperator`](../internal/classes/internal.DateComparisonOperator.mdx)",
        "description": "Date filters to apply on the batch jobs' `updated_at` date.",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "gt",
            "type": "`Date`",
            "description": "The filtered date must be greater than this value.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "gte",
            "type": "`Date`",
            "description": "The filtered date must be greater than or equal to this value.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "lt",
            "type": "`Date`",
            "description": "The filtered date must be less than this value.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "lte",
            "type": "`Date`",
            "description": "The filtered date must be less than or equal to this value.",
            "optional": true,
            "defaultValue": "",
            "expandable": false,
            "children": []
          }
        ]
      }
    ]
  },
  {
    "name": "customHeaders",
    "type": "Record<`string`, `any`\\>",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "[`ResponsePromise`](../modules/internal.mdx#responsepromise)<[`AdminBatchJobListRes`](../modules/internal.mdx#adminbatchjoblistres)\\>",
    "optional": false,
    "defaultValue": "",
    "description": "The list of batch jobs with pagination fields.",
    "expandable": false,
    "children": [
      {
        "name": "AdminBatchJobListRes",
        "type": "[`PaginatedResponse`](../internal/interfaces/internal.PaginatedResponse.mdx) & { `batch_jobs`: [`BatchJob`](../internal/classes/internal.BatchJob.mdx)[]  }",
        "description": "",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "count",
            "type": "`number`",
            "description": "The total number of items available.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "limit",
            "type": "`number`",
            "description": "The maximum number of items that can be returned in the list.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "offset",
            "type": "`number`",
            "description": "The number of items skipped before the returned items in the list.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": []
          },
          {
            "name": "batch_jobs",
            "type": "[`BatchJob`](../internal/classes/internal.BatchJob.mdx)[]",
            "description": "An array of batch job details.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": [
              {
                "name": "canceled_at",
                "type": "`Date`",
                "description": "The date of the concellation.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "completed_at",
                "type": "`Date`",
                "description": "The date of the completion.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "confirmed_at",
                "type": "`Date`",
                "description": "The date when the confirmation has been done.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "context",
                "type": "Record<`string`, `unknown`\\>",
                "description": "The context of the batch job, the type of the batch job determines what the context should contain.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was created.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_by",
                "type": "``null`` \\| `string`",
                "description": "The unique identifier of the user that created the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_by_user",
                "type": "[`User`](../internal/classes/internal.User.mdx)",
                "description": "The details of the user that created the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "deleted_at",
                "type": "``null`` \\| `Date`",
                "description": "The date with timezone at which the resource was deleted.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "dry_run",
                "type": "`boolean`",
                "description": "Specify if the job must apply the modifications or not.",
                "optional": false,
                "defaultValue": "false",
                "expandable": false,
                "children": []
              },
              {
                "name": "failed_at",
                "type": "`Date`",
                "description": "The date when the job failed.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "id",
                "type": "`string`",
                "description": "The unique identifier for the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "pre_processed_at",
                "type": "`Date`",
                "description": "The date from which the job has been pre-processed.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "processing_at",
                "type": "`Date`",
                "description": "The date the job is processing at.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "result",
                "type": "{ `advancement_count?`: `number` ; `count?`: `number` ; `errors?`: (`string` \\| [`BatchJobResultError`](../internal/modules/internal.internal.mdx#batchjobresulterror))[] ; `file_key?`: `string` ; `file_size?`: `number` ; `progress?`: `number` ; `stat_descriptors?`: [`BatchJobResultStatDescriptor`](../internal/modules/internal.internal.mdx#batchjobresultstatdescriptor)[]  } & Record<`string`, `unknown`\\>",
                "description": "The result of the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "status",
                "type": "[`BatchJobStatus`](../internal/enums/internal.internal.BatchJobStatus.mdx)",
                "description": "The status of the batch job.",
                "optional": false,
                "defaultValue": "created",
                "expandable": false,
                "children": []
              },
              {
                "name": "type",
                "type": "`string`",
                "description": "The type of batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "updated_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was last updated.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              }
            ]
          }
        ]
      }
    ]
  }
]} />

___

### retrieve

Retrieve the details of a batch job.

#### Example

```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.batchJobs.retrieve(batchJobId).then(({ batch_job }) => {
  console.log(batch_job.id)
})
```

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "batchJobId",
    "type": "`string`",
    "description": "The ID of the batch job.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "customHeaders",
    "type": "Record<`string`, `any`\\>",
    "description": "Custom headers to attach to the request.",
    "optional": false,
    "defaultValue": "{}",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

<ParameterTypes parameters={[
  {
    "name": "ResponsePromise",
    "type": "[`ResponsePromise`](../modules/internal.mdx#responsepromise)<[`AdminBatchJobRes`](../modules/internal.mdx#adminbatchjobres)\\>",
    "optional": false,
    "defaultValue": "",
    "description": "Resolves to the batch job's details.",
    "expandable": false,
    "children": [
      {
        "name": "AdminBatchJobRes",
        "type": "`object`",
        "description": "The batch job's details.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": [
          {
            "name": "batch_job",
            "type": "[`BatchJob`](../internal/classes/internal.BatchJob.mdx)",
            "description": "Batch job details.",
            "optional": false,
            "defaultValue": "",
            "expandable": false,
            "children": [
              {
                "name": "canceled_at",
                "type": "`Date`",
                "description": "The date of the concellation.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "completed_at",
                "type": "`Date`",
                "description": "The date of the completion.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "confirmed_at",
                "type": "`Date`",
                "description": "The date when the confirmation has been done.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "context",
                "type": "Record<`string`, `unknown`\\>",
                "description": "The context of the batch job, the type of the batch job determines what the context should contain.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was created.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_by",
                "type": "``null`` \\| `string`",
                "description": "The unique identifier of the user that created the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "created_by_user",
                "type": "[`User`](../internal/classes/internal.User.mdx)",
                "description": "The details of the user that created the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": true,
                "children": []
              },
              {
                "name": "deleted_at",
                "type": "``null`` \\| `Date`",
                "description": "The date with timezone at which the resource was deleted.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "dry_run",
                "type": "`boolean`",
                "description": "Specify if the job must apply the modifications or not.",
                "optional": false,
                "defaultValue": "false",
                "expandable": false,
                "children": []
              },
              {
                "name": "failed_at",
                "type": "`Date`",
                "description": "The date when the job failed.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "id",
                "type": "`string`",
                "description": "The unique identifier for the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "pre_processed_at",
                "type": "`Date`",
                "description": "The date from which the job has been pre-processed.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "processing_at",
                "type": "`Date`",
                "description": "The date the job is processing at.",
                "optional": true,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "result",
                "type": "{ `advancement_count?`: `number` ; `count?`: `number` ; `errors?`: (`string` \\| [`BatchJobResultError`](../internal/modules/internal.internal.mdx#batchjobresulterror))[] ; `file_key?`: `string` ; `file_size?`: `number` ; `progress?`: `number` ; `stat_descriptors?`: [`BatchJobResultStatDescriptor`](../internal/modules/internal.internal.mdx#batchjobresultstatdescriptor)[]  } & Record<`string`, `unknown`\\>",
                "description": "The result of the batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "status",
                "type": "[`BatchJobStatus`](../internal/enums/internal.internal.BatchJobStatus.mdx)",
                "description": "The status of the batch job.",
                "optional": false,
                "defaultValue": "created",
                "expandable": false,
                "children": []
              },
              {
                "name": "type",
                "type": "`string`",
                "description": "The type of batch job.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              },
              {
                "name": "updated_at",
                "type": "`Date`",
                "description": "The date with timezone at which the resource was last updated.",
                "optional": false,
                "defaultValue": "",
                "expandable": false,
                "children": []
              }
            ]
          }
        ]
      }
    ]
  }
]} />
