# CreateNewProduct

<mark style="color:green;">`POST`</mark> `https://sandbox.pgecom.com/api/v1/product`

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer {{token}} |

#### Request Body

| Name                                          | Type   | Description                                   |
| --------------------------------------------- | ------ | --------------------------------------------- |
| shopId<mark style="color:red;">\*</mark>      | String | The id of the shop                            |
| name<mark style="color:red;">\*</mark>        | String | Name of the product                           |
| price<mark style="color:red;">\*</mark>       | Number | The current price of the product              |
| description<mark style="color:red;">\*</mark> | String | Product description                           |
| mainImageUrl                                  | String | The main image url                            |
| comparePrice                                  | Number | Discount price of the product                 |
| costPerItem                                   | Number | The amount of cost per item                   |
| inventory                                     | Number | Quantity of products in stock                 |
| productType                                   | String | Type of products (physical, digital, service) |
| status                                        | String | Product status (draft, active, archived)      |

{% tabs %}
{% tab title="200: OK Success" %}

```json
{
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "price": 50,
    "productType": "digital",
    "comparePrice": 0,
    "inventory": 20,
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": "",
    "id": "0ee6defd-2210-47f6-b624-07f79396ca2a",
    "slug": "hair",
    "isFeatured": false,
    "isContinueSellingOutStock": false,
    "published": false,
    "vendor": "facebook",
    "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal Server Error" %}

```json
{
    "message": "\"shopId\" is required",
    "status": 500
}
```

{% endtab %}

{% tab title="429: Too Many Requests Too many request" %}

```json
{
    "message": "Too many requests, please try again later.",
    "status": 429
}

```

{% endtab %}

{% tab title="401: Unauthorized Unauthorized" %}

```json
{
    "message": "Token needs to be provided",
    "status": 401
}
```

{% endtab %}

{% tab title="400: Bad Request Bad Request" %}

```json

{
    "message": "Shop with id 0a40d129-0728-b10-b32e-117abd6938c3 not found"
}
```

{% endtab %}
{% endtabs %}

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

```javascript
const axios = require('axios');
let data = {
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "id": "aa97f0b3-c13d-437d-8d06-d46f0f65a48b",
    "price": "50",
    "productType": "digital",
    "comparePrice": 0,
    "inventory": "20",
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": ""
}
let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://sandbox.pgecom.com/api/v1/merchant/product',
  headers: { },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import http.client

conn = http.client.HTTPSConnection("https://sandbox.pgecom.com")
payload = {
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "id": "aa97f0b3-c13d-437d-8d06-d46f0f65a48b",
    "price": "50",
    "productType": "digital",
    "comparePrice": 0,
    "inventory": "20",
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": ""
}
headers = {}
conn.request("POST", "/api/v1/merchant/product", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "net/http"

url = URI("https://sandbox.pgecom.com/api/v1/merchant/product")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request.body = {
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "id": "aa97f0b3-c13d-437d-8d06-d46f0f65a48b",
    "price": "50",
    "productType": "digital",
    "comparePrice": 0,
    "inventory": "20",
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": ""
}
response = http.request(request)
puts response.read_body

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://sandbox.pgecom.com/api/v1/merchant/product');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setBody({
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "id": "aa97f0b3-c13d-437d-8d06-d46f0f65a48b",
    "price": "50",
    "productType": "digital",
    "comparePrice": 0,
    "inventory": "20",
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": ""
})
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
```

{% endtab %}

{% tab title="Curl" %}

```
curl --location 'https://sandbox.pgecom.com/api/v1/merchant/product' \
--data '{
    "name": "Hair",
    "shopId": "0a40d129-0728-4b10-b32e-117abd6938c3",
    "description": "This is another fantastic product. I am looking forward to doing it here",
    "price": "50",
    "productType": "digital",
    "comparePrice": 0,
    "inventory": "20",
    "costPerItem": 0,
    "status": "draft",
    "mainImageUrl": ""
}'
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pgecom.com/api-endpoint/ecommerce/product/createnewproduct.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
