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.0 KB
Raw Blame
---
title: "Batch Create Offers"
api: "POST /admin/offers/batch"
description: "Create up to 100 offers for a seller in one request."
---

Creates multiple offers on behalf of a seller. The authenticated admin user is recorded as the creator.

## Body parameters

<ParamField body="seller_id" type="string" required>ID of the seller the offers belong to.</ParamField>
<ParamField body="offers" type="object[]" required>
  The offers to create, between 1 and 100.
  <Expandable title="properties">
    <ParamField body="sku" type="string" required>The offer's SKU.</ParamField>
    <ParamField body="variant_id" type="string" required>ID of the product variant to offer.</ParamField>
    <ParamField body="shipping_profile_id" type="string" required>ID of the seller's shipping profile.</ParamField>
    <ParamField body="prices" type="object[]" required>
      Offer prices, at least one.
      <Expandable title="properties">
        <ParamField body="amount" type="number" required>The price amount.</ParamField>
        <ParamField body="currency_code" type="string" required>The price currency.</ParamField>
        <ParamField body="min_quantity" type="number">Minimum quantity the price applies to.</ParamField>
        <ParamField body="max_quantity" type="number">Maximum quantity the price applies to.</ParamField>
        <ParamField body="rules" type="object">Price rules as attribute-value pairs.</ParamField>
      </Expandable>
    </ParamField>
    <ParamField body="inventory_items" type="object[]" required>
      Inventory items backing the offer, at least one.
      <Expandable title="properties">
        <ParamField body="title" type="string">The inventory item's title.</ParamField>
        <ParamField body="sku" type="string">The inventory item's SKU.</ParamField>
        <ParamField body="required_quantity" type="number" default="1">Quantity required per unit sold.</ParamField>
        <ParamField body="stock_levels" type="object[]">
          Initial stock levels.
          <Expandable title="properties">
            <ParamField body="location_id" type="string" required>The stock location's ID.</ParamField>
            <ParamField body="stocked_quantity" type="number" required>Quantity in stock at the location.</ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
    <ParamField body="ean" type="string">The offer's EAN.</ParamField>
    <ParamField body="upc" type="string">The offer's UPC.</ParamField>
    <ParamField body="metadata" type="object">Custom key-value data.</ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="offers" type="object[]">
  <Expandable title="properties">
    <ResponseField name="id" type="string">The offer's ID.</ResponseField>
    <ResponseField name="seller_id" type="string">ID of the seller who owns the offer.</ResponseField>
    <ResponseField name="variant_id" type="string">ID of the offered product variant.</ResponseField>
    <ResponseField name="shipping_profile_id" type="string">ID of the offer's shipping profile.</ResponseField>
    <ResponseField name="sku" type="string">The offer's SKU.</ResponseField>
    <ResponseField name="prices" type="object[]">The offer's prices.</ResponseField>
    <ResponseField name="inventory_items" type="object[]">The offer's linked inventory items.</ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
```bash cURL
curl -X POST 'http://localhost:9000/admin/offers/batch' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "seller_id": "sel_01HXYZ",
    "offers": [
      {
        "sku": "SHIRT-M-BLUE",
        "variant_id": "variant_01HXYZ",
        "shipping_profile_id": "sp_01HXYZ",
        "prices": [{ "amount": 2500, "currency_code": "usd" }],
        "inventory_items": [
          {
            "sku": "SHIRT-M-BLUE",
            "required_quantity": 1,
            "stock_levels": [{ "location_id": "sloc_01HXYZ", "stocked_quantity": 100 }]
          }
        ]
      }
    ]
  }'
```

```ts JS Client
const { offers } = await client.admin.offers.batch.mutate({
  seller_id: "sel_01HXYZ",
  offers: [
    {
      sku: "SHIRT-M-BLUE",
      variant_id: "variant_01HXYZ",
      shipping_profile_id: "sp_01HXYZ",
      prices: [{ amount: 2500, currency_code: "usd" }],
      inventory_items: [
        {
          sku: "SHIRT-M-BLUE",
          required_quantity: 1,
          stock_levels: [{ location_id: "sloc_01HXYZ", stocked_quantity: 100 }],
        },
      ],
    },
  ],
})
```
</RequestExample>

<ResponseExample>
```json 201
{
  "offers": [
    {
      "id": "offer_01HXYZ8Q2M4N6P8R0T2V4W6X8Y",
      "seller_id": "sel_01HXYZ",
      "variant_id": "variant_01HXYZ",
      "shipping_profile_id": "sp_01HXYZ",
      "sku": "SHIRT-M-BLUE",
      "prices": [
        { "id": "price_01HXYZ", "amount": 2500, "currency_code": "usd" }
      ],
      "inventory_items": [
        { "id": "iitem_01HXYZ", "inventory_item_id": "iitem_01HXYZ", "required_quantity": 1, "sku": "SHIRT-M-BLUE" }
      ]
    }
  ]
}
```
</ResponseExample>