Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

5.1 KB
Raw Blame
---
title: "Batch Create Offers"
api: "POST /vendor/offers/batch"
description: "Create up to 100 offers in a single request."
---

Creates multiple offers at once; the whole batch is validated and processed together.

## Query parameters

<ParamField query="fields" type="string">
  Comma-separated fields to include in the returned offers. Prefix with `+`/`-` to add to or remove from the defaults.
</ParamField>

## Body parameters

<ParamField body="offers" type="object[]" required>
  Between 1 and 100 offers to create.
  <Expandable title="properties">
    <ParamField body="sku" type="string" required>The seller's SKU for the listing.</ParamField>
    <ParamField body="variant_id" type="string" required>ID of the product variant being listed.</ParamField>
    <ParamField body="shipping_profile_id" type="string" required>ID of the shipping profile used to fulfill the offer.</ParamField>
    <ParamField body="prices" type="object[]" required>
      At least one price.
      <Expandable title="properties">
        <ParamField body="amount" type="number" required>Price amount.</ParamField>
        <ParamField body="currency_code" type="string" required>Currency code, e.g. `usd`.</ParamField>
        <ParamField body="min_quantity" type="number">Minimum quantity for the price to apply; positive integer.</ParamField>
        <ParamField body="max_quantity" type="number">Maximum quantity for the price to apply; positive integer.</ParamField>
        <ParamField body="rules" type="object">Price rules as attribute-to-value pairs.</ParamField>
      </Expandable>
    </ParamField>
    <ParamField body="inventory_items" type="object[]" required>
      At least one inventory item.
      <Expandable title="properties">
        <ParamField body="title" type="string">Title for the created inventory item.</ParamField>
        <ParamField body="sku" type="string">SKU for the created inventory item.</ParamField>
        <ParamField body="required_quantity" type="number" default="1">Units consumed per sale; positive integer.</ParamField>
        <ParamField body="stock_levels" type="object[]">
          <Expandable title="properties">
            <ParamField body="location_id" type="string" required>Stock location ID.</ParamField>
            <ParamField body="stocked_quantity" type="number" required>Stocked quantity at the location; non-negative integer.</ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
    <ParamField body="ean" type="string">EAN barcode.</ParamField>
    <ParamField body="upc" type="string">UPC barcode.</ParamField>
    <ParamField body="manage_inventory" type="boolean" default="true">Whether stock is tracked for the offer. Set to `false` to sell without inventory checks.</ParamField>
    <ParamField body="allow_backorder" type="boolean" default="false">Whether the offer can be purchased when it is out of stock.</ParamField>
    <ParamField body="metadata" type="object">Custom key-value pairs.</ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="offers" type="object[]">
  <Expandable title="properties">
    <ResponseField name="id" type="string">The offer's ID.</ResponseField>
    <ResponseField name="variant_id" type="string">ID of the listed product variant.</ResponseField>
    <ResponseField name="sku" type="string">The seller's SKU for the listing.</ResponseField>
    <ResponseField name="manage_inventory" type="boolean">Whether stock is tracked for the offer.</ResponseField>
    <ResponseField name="allow_backorder" type="boolean">Whether the offer can be purchased when it is out of stock.</ResponseField>
    <ResponseField name="prices" type="object[]">The offer's prices.</ResponseField>
    <ResponseField name="inventory_items" type="object[]">Linked inventory items.</ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
```bash cURL
curl -X POST 'http://localhost:9000/vendor/offers/batch' \
  -H 'Authorization: Bearer <token>' \
  -H 'x-seller-id: <seller_id>' \
  -H 'Content-Type: application/json' \
  -d '{
    "offers": [
      {
        "sku": "ACME-SHIRT-S",
        "variant_id": "variant_01HABC",
        "shipping_profile_id": "sp_01HXYZ",
        "prices": [{ "amount": 2500, "currency_code": "usd" }],
        "inventory_items": [{ "required_quantity": 1 }]
      },
      {
        "sku": "ACME-SHIRT-M",
        "variant_id": "variant_01HXYZ",
        "shipping_profile_id": "sp_01HXYZ",
        "prices": [{ "amount": 2500, "currency_code": "usd" }],
        "inventory_items": [{ "required_quantity": 1 }]
      }
    ]
  }'
```

```ts JS Client
const { offers } = await client.vendor.offers.batch.mutate({
  offers: [
    {
      sku: "ACME-SHIRT-M",
      variant_id: "variant_01HXYZ",
      shipping_profile_id: "sp_01HXYZ",
      prices: [{ amount: 2500, currency_code: "usd" }],
      inventory_items: [{ required_quantity: 1 }],
    },
  ],
})
```
</RequestExample>

<ResponseExample>
```json 201
{
  "offers": [
    {
      "id": "offer_01HABC",
      "variant_id": "variant_01HABC",
      "sku": "ACME-SHIRT-S"
    },
    {
      "id": "offer_01HXYZ",
      "variant_id": "variant_01HXYZ",
      "sku": "ACME-SHIRT-M"
    }
  ]
}
```
</ResponseExample>