# createPriceListsWorkflow - Medusa Core Workflows Reference

This documentation provides a reference to the `createPriceListsWorkflow`. It belongs to the `@medusajs/medusa/core-flows` package.

This workflow creates one or more price lists. It's used by the
[Create Price List Admin API Route](https://docs.medusajs.com/api/admin#price-lists_postpricelists).

You can use this workflow within your customizations or your own custom workflows, allowing you to
create price lists in your custom flows.

[Source code](https://github.com/medusajs/medusa/blob/f04adb17d322dd6a5e17eca2498df9d05c75f6f0/packages/core/core-flows/src/price-list/workflows/create-price-lists.ts#L52)

## Examples

### API Route

```ts title="src/api/workflow/route.ts"
import type {
  MedusaRequest,
  MedusaResponse,
} from "@medusajs/framework/http"
import { createPriceListsWorkflow } from "@medusajs/medusa/core-flows"

export async function POST(
  req: MedusaRequest,
  res: MedusaResponse
) {
  const { result } = await createPriceListsWorkflow(req.scope)
    .run({
      input: {
        price_lists_data: [{
          title: "Price List 1",
          description: "Price List 1 Description",
        }]
      }
    })

  res.send(result)
}
```

### Subscriber

```ts title="src/subscribers/order-placed.ts"
import {
  type SubscriberConfig,
  type SubscriberArgs,
} from "@medusajs/framework"
import { createPriceListsWorkflow } from "@medusajs/medusa/core-flows"

export default async function handleOrderPlaced({
  event: { data },
  container,
}: SubscriberArgs < { id: string } > ) {
  const { result } = await createPriceListsWorkflow(container)
    .run({
      input: {
        price_lists_data: [{
          title: "Price List 1",
          description: "Price List 1 Description",
        }]
      }
    })

  console.log(result)
}

export const config: SubscriberConfig = {
  event: "order.placed",
}
```

### Scheduled Job

```ts title="src/jobs/message-daily.ts"
import { MedusaContainer } from "@medusajs/framework/types"
import { createPriceListsWorkflow } from "@medusajs/medusa/core-flows"

export default async function myCustomJob(
  container: MedusaContainer
) {
  const { result } = await createPriceListsWorkflow(container)
    .run({
      input: {
        price_lists_data: [{
          title: "Price List 1",
          description: "Price List 1 Description",
        }]
      }
    })

  console.log(result)
}

export const config = {
  name: "run-once-a-day",
  schedule: "0 0 * * *",
}
```

### Another Workflow

```ts title="src/workflows/my-workflow.ts"
import { createWorkflow } from "@medusajs/framework/workflows-sdk"
import { createPriceListsWorkflow } from "@medusajs/medusa/core-flows"

const myWorkflow = createWorkflow(
  "my-workflow",
  () => {
    const result = createPriceListsWorkflow
      .runAsStep({
        input: {
          price_lists_data: [{
            title: "Price List 1",
            description: "Price List 1 Description",
          }]
        }
      })
  }
)
```

## Steps

- [validateVariantPriceLinksStep](../../../Steps_Price_List/functions/core_flows.Price_List.Steps_Price_List.validateVariantPriceLinksStep/page.mdx): This step validates that the specified variants have prices.
  If not valid, the step throws an error.
- [createPriceListsStep](../../../Steps_Price_List/functions/core_flows.Price_List.Steps_Price_List.createPriceListsStep/page.mdx): This step creates a price list.

## Input

- CreatePriceListsWorkflowInput: (\[CreatePriceListsWorkflowInput]\(../../../../types/core\_flows.CreatePriceListsWorkflowInput/page.mdx)) The data to create price lists.

  - price\_lists\_data: (\[CreatePriceListWorkflowInputDTO]\(../../../../../types/interfaces/types.CreatePriceListWorkflowInputDTO/page.mdx)\[]) The price lists to create.

    - title: (\`string\`) The title of the price list.

    - description: (\`string\`) The description of the price list.

    - starts\_at: (\`null\` \\| \`string\`) The start date and time of the price list.

    - ends\_at: (\`null\` \\| \`string\`) The end date and time of the price list.

    - status: (\[PriceListStatus]\(../../../../../pricing/types/pricing.PriceListStatus/page.mdx)) The status of the price list.

    - rules: (\`Record\<string, string\[]>\`) The rules associated with the price list.

    - prices: (\[CreatePriceListPriceWorkflowDTO]\(../../../../../types/interfaces/types.CreatePriceListPriceWorkflowDTO/page.mdx)\[]) The prices associated with the price list.

      - amount: (\`number\`) The amount for the price.

      - currency\_code: (\`string\`) The currency code for the price.

      - variant\_id: (\`string\`) The ID of the variant that this price applies to.

      - max\_quantity: (\`null\` \\| \`number\`) The maximum quantity of the variant allowed in the cart for this price to be applied.

      - min\_quantity: (\`null\` \\| \`number\`) The minimum quantity of the variant required in the cart for this price to be applied.

      - rules: (\`Record\<string, string>\`) Additional rules for the price list.

## Output

- PriceListDTO\[]: (\[PriceListDTO]\(../../../../../pricing/interfaces/pricing.PriceListDTO/page.mdx)\[])

  - id: (\`string\`) The price list's ID.

  - title: (\`string\`) The price list's title.

  - description: (\`string\`) The price list's description.

  - starts\_at: (\`null\` \\| \`string\`) The price list is enabled starting from this date.

  - status: (\[PriceListStatus]\(../../../../../pricing/types/pricing.PriceListStatus/page.mdx)) The price list's status.

  - type: (\[PriceListType]\(../../../../../pricing/types/pricing.PriceListType/page.mdx)) The price list's type.

  - ends\_at: (\`null\` \\| \`string\`) The price list expires after this date.

  - rules\_count: (\`number\`) The number of rules associated with this price list.

  - prices: (\[PriceDTO]\(../../../../../pricing/interfaces/pricing.PriceDTO/page.mdx)\[]) The associated price list money amounts.

    - id: (\`string\`) The ID of a price.

    - created\_at: (\`Date\`) When the price was created.

    - updated\_at: (\`Date\`) When the price was updated.

    - deleted\_at: (\`null\` \\| \`Date\`) When the price was deleted.

    - title: (\`string\`) The title of the price.

    - currency\_code: (\`string\`) The currency code of this price.

    - amount: (\[BigNumberValue]\(../../../../../pricing/types/pricing.BigNumberValue/page.mdx)) The price of this price.

      - numeric: (\`number\`)

      - raw: (\[BigNumberRawValue]\(../../../../../pricing/types/pricing.BigNumberRawValue/page.mdx))

      - bigNumber: (\`BigNumber\`)

    - min\_quantity: (\[BigNumberValue]\(../../../../../pricing/types/pricing.BigNumberValue/page.mdx)) The minimum quantity required to be purchased for this price to be applied.

      - numeric: (\`number\`)

      - raw: (\[BigNumberRawValue]\(../../../../../pricing/types/pricing.BigNumberRawValue/page.mdx))

      - bigNumber: (\`BigNumber\`)

    - max\_quantity: (\[BigNumberValue]\(../../../../../pricing/types/pricing.BigNumberValue/page.mdx)) The maximum quantity required to be purchased for this price to be applied.

      - numeric: (\`number\`)

      - raw: (\[BigNumberRawValue]\(../../../../../pricing/types/pricing.BigNumberRawValue/page.mdx))

      - bigNumber: (\`BigNumber\`)

    - price\_set: (\[PriceSetDTO]\(../../../../../pricing/interfaces/pricing.PriceSetDTO/page.mdx)) The price set associated with the price.

      - id: (\`string\`) The ID of the price set.

      - prices: (\[MoneyAmountDTO]\(../../../../../pricing/interfaces/pricing.MoneyAmountDTO/page.mdx)\[]) The prices that belong to this price set.

      - calculated\_price: (\[CalculatedPriceSet]\(../../../../../pricing/interfaces/pricing.CalculatedPriceSet/page.mdx)) The calculated price based on the context.

    - price\_list: (\[PriceListDTO]\(../../../../../pricing/interfaces/pricing.PriceListDTO/page.mdx)) The price list associated with the price.

      - id: (\`string\`) The price list's ID.

      - title: (\`string\`) The price list's title.

      - description: (\`string\`) The price list's description.

      - starts\_at: (\`null\` \\| \`string\`) The price list is enabled starting from this date.

      - status: (\[PriceListStatus]\(../../../../../pricing/types/pricing.PriceListStatus/page.mdx)) The price list's status.

      - type: (\[PriceListType]\(../../../../../pricing/types/pricing.PriceListType/page.mdx)) The price list's type.

      - ends\_at: (\`null\` \\| \`string\`) The price list expires after this date.

      - rules\_count: (\`number\`) The number of rules associated with this price list.

      - prices: (\[PriceDTO]\(../../../../../pricing/interfaces/pricing.PriceDTO/page.mdx)\[]) The associated price list money amounts.

      - money\_amounts: (\[MoneyAmountDTO]\(../../../../../pricing/interfaces/pricing.MoneyAmountDTO/page.mdx)\[]) The associated money amounts.

      - price\_list\_rules: (\[PriceListRuleDTO]\(../../../../../pricing/interfaces/pricing.PriceListRuleDTO/page.mdx)\[]) The price list's rules.

    - price\_set\_id: (\`string\`) The ID of the associated price set.

    - price\_rules: (\[PriceRuleDTO]\(../../../../../pricing/interfaces/pricing.PriceRuleDTO/page.mdx)\[]) The price rules associated with the price.

      - id: (\`string\`) The ID of the price rule.

      - price\_set\_id: (\`string\`) The ID of the associated price set.

      - price\_set: (\[PriceSetDTO]\(../../../../../pricing/interfaces/pricing.PriceSetDTO/page.mdx)) The associated price set.

      - attribute: (\`string\`) The attribute of the price rule

      - value: (\`string\`) The value of the price rule.

      - priority: (\`number\`) The priority of the price rule in comparison to other applicable price rules.

      - price\_id: (\`string\`) The ID of the associated price.

      - price\_list\_id: (\`string\`) The ID of the associated price list.

      - created\_at: (\`Date\`) When the price\\\_rule was created.

      - updated\_at: (\`Date\`) When the price\\\_rule was updated.

      - deleted\_at: (\`null\` \\| \`Date\`) When the price\\\_rule was deleted.

  - money\_amounts: (\[MoneyAmountDTO]\(../../../../../pricing/interfaces/pricing.MoneyAmountDTO/page.mdx)\[]) The associated money amounts.

    - id: (\`string\`) The ID of the money amount.

    - created\_at: (\`Date\`) When the money\\\_amount was created.

    - updated\_at: (\`Date\`) When the money\\\_amount was updated.

    - deleted\_at: (\`null\` \\| \`Date\`) When the money\\\_amount was deleted.

    - currency\_code: (\`string\`) The currency code of this money amount.

    - amount: (\[BigNumberValue]\(../../../../../pricing/types/pricing.BigNumberValue/page.mdx)) The price of this money amount.

      - numeric: (\`number\`)

      - raw: (\[BigNumberRawValue]\(../../../../../pricing/types/pricing.BigNumberRawValue/page.mdx))

      - bigNumber: (\`BigNumber\`)

    - min\_quantity: (\[BigNumberValue]\(../../../../../pricing/types/pricing.BigNumberValue/page.mdx)) The minimum quantity required to be purchased for this price to be applied.

      - numeric: (\`number\`)

      - raw: (\[BigNumberRawValue]\(../../../../../pricing/types/pricing.BigNumberRawValue/page.mdx))

      - bigNumber: (\`BigNumber\`)

    - max\_quantity: (\[BigNumberValue]\(../../../../../pricing/types/pricing.BigNumberValue/page.mdx)) The maximum quantity required to be purchased for this price to be applied.

      - numeric: (\`number\`)

      - raw: (\[BigNumberRawValue]\(../../../../../pricing/types/pricing.BigNumberRawValue/page.mdx))

      - bigNumber: (\`BigNumber\`)

    - rules\_count: (\`number\`) The number of rules that apply to this price

    - price\_rules: (\[PriceRuleDTO]\(../../../../../pricing/interfaces/pricing.PriceRuleDTO/page.mdx)\[]) The price rules that apply to this price

      - id: (\`string\`) The ID of the price rule.

      - price\_set\_id: (\`string\`) The ID of the associated price set.

      - price\_set: (\[PriceSetDTO]\(../../../../../pricing/interfaces/pricing.PriceSetDTO/page.mdx)) The associated price set.

      - attribute: (\`string\`) The attribute of the price rule

      - value: (\`string\`) The value of the price rule.

      - priority: (\`number\`) The priority of the price rule in comparison to other applicable price rules.

      - price\_id: (\`string\`) The ID of the associated price.

      - price\_list\_id: (\`string\`) The ID of the associated price list.

      - created\_at: (\`Date\`) When the price\\\_rule was created.

      - updated\_at: (\`Date\`) When the price\\\_rule was updated.

      - deleted\_at: (\`null\` \\| \`Date\`) When the price\\\_rule was deleted.

  - price\_list\_rules: (\[PriceListRuleDTO]\(../../../../../pricing/interfaces/pricing.PriceListRuleDTO/page.mdx)\[]) The price list's rules.

    - id: (\`string\`) The price list rule's ID.

    - attribute: (\`string\`) The attribute of the rule.

    - value: (\`string\` \\| \`string\`\[]) The value of the rule.

    - price\_list: (\[PriceListDTO]\(../../../../../pricing/interfaces/pricing.PriceListDTO/page.mdx)) The associated price list.

      - id: (\`string\`) The price list's ID.

      - title: (\`string\`) The price list's title.

      - description: (\`string\`) The price list's description.

      - starts\_at: (\`null\` \\| \`string\`) The price list is enabled starting from this date.

      - status: (\[PriceListStatus]\(../../../../../pricing/types/pricing.PriceListStatus/page.mdx)) The price list's status.

      - type: (\[PriceListType]\(../../../../../pricing/types/pricing.PriceListType/page.mdx)) The price list's type.

      - ends\_at: (\`null\` \\| \`string\`) The price list expires after this date.

      - rules\_count: (\`number\`) The number of rules associated with this price list.

      - prices: (\[PriceDTO]\(../../../../../pricing/interfaces/pricing.PriceDTO/page.mdx)\[]) The associated price list money amounts.

      - money\_amounts: (\[MoneyAmountDTO]\(../../../../../pricing/interfaces/pricing.MoneyAmountDTO/page.mdx)\[]) The associated money amounts.

      - price\_list\_rules: (\[PriceListRuleDTO]\(../../../../../pricing/interfaces/pricing.PriceListRuleDTO/page.mdx)\[]) The price list's rules.


---

The best way to deploy Medusa is through Medusa Cloud where you get autoscaling production infrastructure fine tuned for Medusa. Create an account by signing up at cloud.medusajs.com/signup.
