# Create a Wholesale Product

This API handles creating a wholesale product.&#x20;

{% tabs %}
{% tab title="Request" %}

| Method | Endpoint                        |
| ------ | ------------------------------- |
| POST   | /wp-json/wholesale/v1/products/ |

| Body Parameters        | Required | Type  | Description               |
| ---------------------- | -------- | ----- | ------------------------- |
| wholesale\_price       | yes      | array | The wholesale price.      |
| wholesale\_sale\_price | no       | array | The wholesale sale price. |
| {% endtab %}           |          |       |                           |

{% tab title="Request Example" %}

#### Postman

Creating wholesale simple product

```
POST: /wp-json/wholesale/v1/products/

JSON Body:
{
  "name" : "Premium Quality",
  "type" : "simple",
  "regular_price" : "21.99",
  "wholesale_price" : { 
    "wholesale_customer" : "12"
  }
  // With sale price.
  "wholesale_sale_price" : { 
    "wholesale_customer" : "10"
  }
}
```

Creating a wholesale variable product

```php
POST: /wp-json/wholesale/v1/products/

JSON Body:
{
  "name" : "Ship Your Idea",
  "type" : "variable",
  "attributes" : [
    {
      "name" : "Size",
      "position" : 0,
      "visible" : true,
      "variation" : true,
      "options" : [
        "S",
        "M"
      ]
    }
  ]
}
```

{% endtab %}

{% tab title="Response Example" %}

#### Status: 200 OK

Create a wholesale product.

```
POST: /wp-json/wholesale/v1/products/

JSON Body:
{
  "name" : "Premium Quality",
  "type" : "simple",
  "regular_price" : "21.99",
  "wholesale_price" : { 
    "wholesale_customer" : "12"
  }
  // With sale price.
  "wholesale_sale_price" : { 
    "wholesale_customer" : "10"
  }
}

Response:
{
    "id": 4294,
    "name": "Premium Quality",
    "slug": "premium-quality",
    "permalink": "https://example.com/product/premium-quality/",
    "date_created": "2021-03-15T03:49:57",
    "date_created_gmt": "2021-03-15T03:49:57",
    "date_modified": "2021-03-15T03:49:57",
    "date_modified_gmt": "2021-03-15T03:49:57",
    "type": "simple",
    "status": "publish",
    "featured": false,
    "catalog_visibility": "visible",
    "description": "",
    "short_description": "",
    "sku": "",
    "price": "21.99",
    "regular_price": "21.99",
    "sale_price": "",
    "date_on_sale_from": null,
    "date_on_sale_from_gmt": null,
    "date_on_sale_to": null,
    "date_on_sale_to_gmt": null,
    "on_sale": false,
    "purchasable": true,
    "total_sales": 0,
    "virtual": false,
    "downloadable": false,
    "downloads": [],
    "download_limit": -1,
    "download_expiry": -1,
    "external_url": "",
    "button_text": "",
    "tax_status": "taxable",
    "tax_class": "",
    "manage_stock": false,
    "stock_quantity": null,
    "backorders": "no",
    "backorders_allowed": false,
    "backordered": false,
    "sold_individually": false,
    "weight": "",
    "dimensions": {
        "length": "",
        "width": "",
        "height": ""
    },
    "shipping_required": true,
    "shipping_taxable": true,
    "shipping_class": "",
    "shipping_class_id": 0,
    "reviews_allowed": true,
    "average_rating": "0",
    "rating_count": 0,
    "upsell_ids": [],
    "cross_sell_ids": [],
    "parent_id": 0,
    "purchase_note": "",
    "tags": [],
    "images": [],
    "attributes": [],
    "default_attributes": [],
    "variations": [],
    "grouped_products": [],
    "menu_order": 0,
    "price_html": "<span class=\"woocommerce-Price-amount amount\"><bdi><span class=\"woocommerce-Price-currencySymbol\">&#36;</span>21.99</bdi></span>",
    "related_ids": [
        4291,
        4292
    ],
    "stock_status": "instock",
    "wholesale_data": {
        "wholesale_price": {
            "wholesale_customer": "12"
        },
        // With wholesale sale price.
        "wholesale_sale_price": {
            "wholesale_customer": "10"
        },
    }
}
```

####

#### Status: 400 Bad Request

Invalid Wholesale Role key and Wholesale Price.

```
POST: /wp-json/wholesale/v1/products/

JSON Body:
{
  "name" : "Premium Quality",
  "type" : "simple",
  "regular_price" : "21.99",
  "wholesale_price" : { 
    "invalid_role_key" : "invalid_wholesale_price"
  }
}

Response:
{
    "code": "wholesale_rest_product_cannot_update",
    "message": "Unable to update. Invalid wholesale price.",
    "data": {
        "status": 400,
        "invalid_roles": [
            "invalid_role_key"
        ],
        "invalid_wholesale_price": {
            "invalid_role_key": "invalid_wholesale_price"
        }
    }
}
```

{% endtab %}
{% endtabs %}

**Note:**

* Since v1.16, it is now allowed to create both non-wholesale and wholesale products. Meaning providing wholesale\_price is optional.
