---
displayed_sidebar: entitiesSidebar
slug: /references/entities/classes/BatchJob
---

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

# BatchJob

A Batch Job indicates an asynchronus task stored in the Medusa backend. Its status determines whether it has been executed or not.

## Properties

<ParameterTypes parameters={[
  {
    "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](entities.User.mdx)",
    "description": "The details of the user that created the batch job.",
    "optional": false,
    "defaultValue": "",
    "expandable": true,
    "children": [
      {
        "name": "api_token",
        "type": "`string`",
        "description": "An API token associated with the user.",
        "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": "deleted_at",
        "type": "`null` \\| `Date`",
        "description": "The date with timezone at which the resource was deleted.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "email",
        "type": "`string`",
        "description": "The email of the User",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "first_name",
        "type": "`string`",
        "description": "The first name of the User",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "id",
        "type": "`string`",
        "description": "The user's ID",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "last_name",
        "type": "`string`",
        "description": "The last name of the User",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "metadata",
        "type": "`Record<string, unknown>`",
        "description": "An optional key-value map with additional details",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "password_hash",
        "type": "`string`",
        "description": "",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "role",
        "type": "[UserRoles](../enums/entities.UserRoles.mdx)",
        "description": "The user's role. These roles don't provide any different privileges.",
        "optional": false,
        "defaultValue": "member",
        "expandable": false,
        "children": []
      },
      {
        "name": "updated_at",
        "type": "`Date`",
        "description": "The date with timezone at which the resource was updated.",
        "optional": false,
        "defaultValue": "",
        "expandable": false,
        "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": "`object` & `Record<string, unknown>`",
    "description": "The result of the batch job.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": [
      {
        "name": "advancement_count",
        "type": "`number`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "count",
        "type": "`number`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "errors",
        "type": "(`string` \\| [BatchJobResultError](../../medusa/types/medusa.BatchJobResultError.mdx))[]",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "file_key",
        "type": "`string`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "file_size",
        "type": "`number`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "progress",
        "type": "`number`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "stat_descriptors",
        "type": "[BatchJobResultStatDescriptor](../../medusa/types/medusa.BatchJobResultStatDescriptor.mdx)[]",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      }
    ]
  },
  {
    "name": "status",
    "type": "[BatchJobStatus](../../medusa/enums/medusa.BatchJobStatus.mdx)",
    "description": "The status of the batch job.",
    "optional": false,
    "defaultValue": "created",
    "expandable": false,
    "children": [
      {
        "name": "CANCELED",
        "type": "`\"canceled\"`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "COMPLETED",
        "type": "`\"completed\"`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "CONFIRMED",
        "type": "`\"confirmed\"`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "CREATED",
        "type": "`\"created\"`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "FAILED",
        "type": "`\"failed\"`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "PRE_PROCESSED",
        "type": "`\"pre_processed\"`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "expandable": false,
        "children": []
      },
      {
        "name": "PROCESSING",
        "type": "`\"processing\"`",
        "description": "",
        "optional": true,
        "defaultValue": "",
        "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": []
  }
]} expandUrl="https://docs.medusajs.com/development/entities/repositories#retrieving-a-list-of-records"/>
