# Products

### POST /products

Create a new product. \
The json with the product should be valid with the following [json-schema](http://json-schema.org/)

#### **Request content format**

```
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "A representation of a product",
    "type": "object",
    "required": ["sku", "name"],
    "properties": {
        "sku": {"type":"string"},
        "base_sku": {"type":"string"},
        "name": {"type":"string", "minLength": 1},
        "base_name": {"type": "string"},
        "brand": {"type":"string"},
        "description": {"type":"string"},
        "url": {"type":"string"},
        "image_url": {"type":"string"},
        "thumbnail_url": {"type":"string"},
        "price": {"type":"number"},
        "offer_price": {"type":"number"},        
        "stock": {"type":"number"},
        "available": {"type":"boolean"},
        "release_date": {"type":"string"},
        "category": {
            "type": "array",
            "items": {
                "oneOf": [
                    {
                        "type": "string",
                        "minLength" : 1,
                        "maxLength" : 100
                    },
                    {
                        "type": "object",
                        "required": ["id", "name" ],
                        "properties": {
                            "id": {
                                "type" : "string",
                                "minLength" : 1,
                                "maxLength" : 64
                            },
                            "name": {
                                "type" : "string",
                                "minLength" : 1,
                                "maxLength" : 100
                            },
                            "url": { "type": "string" },
                            "image_url": { "type": "string" }
                        }
                    }
                ]
            }
        },
        "specifications": {
            "type": "array",
            "items": {
                "type": "object",
                "required": ["name", "value"],
                "properties": {
                    "name": { "type": "string" },
                    "value": { "type": "string" }
                }
            }
        },
        "metadata": {
            "type": "object"
        },
        "with_extension_warranty": { "type": "boolean" },
        "custom_attributes": { "type": "object" }
    }
}
```

**Example**

This is a valid purchase according to the previous [json-schema](http://json-schema.org/):

```
{
    "sku": "6786896868",
    "base_sku": "6786896",
    "brand": "BGH Positive",
    "name": "Notebook",
    "base_name": "BGH Notebook",
    "description": "Notebook BGH 14\"",
    "url": "http://www.example.com/notebook-bgh-6786896868",
    "image_url": "http://www.example.com/notebook-bgh-6786896868.png",
    "thumbnail_url": "http://www.example.com/thumbnail_notebook-bgh-6786896868.png",
    "price": 12200,
    "offer_price": 12000,
    "stock": 20,
    "available": true,
    "release_date": "2020-04-16T00:00:00-03:00",
    "category": [
        {
            "id": "a",
            "name": "Todos los productos",
            "url": "http://www.example.com/categorias/a",
            "image_url": "http://www.example.com/categorias/a.jpg"
        },
        {
            "id": "a-b",
            "name": "Hogar",
            "url": "http://www.example.com/categorias/a/b",
            "image_url": "http://www.example.com/categorias/b.png"
        },
        {
            "id": "a-b-c",
            "name": "Notebook",
            "url": "http://www.example.com/categorias/a/b/c",
            "image_url": "http://www.example.com/categorias/c.jpg"
        }
    ],
    "specifications": [
        {"name": "Disco rígido", "value": "1TB"}
    ],
    "metadata": {
        "internal_id": 123456789,
        "uploaded_by": {
            "id": 1,
            "name": "john doe",
            "email": "dataentry@myecommerce.com"
        }
    },
    "custom_attributes": { 
        "weight": 2,
        "release_date": "2019-05-22T14:35:22-03:00"
    }
}
```

This is a curl example:

```
curl -X POST \
  https://api.woowup.com/apiv3/products \
  -H 'accept: application/json' \
  -H 'authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
  -H 'cache-control: no-cache' \
  -d '{
    "sku": "6786896868",
    "base_sku": "6786896",
    "brand": "BGH Positive",
    "name": "Notebook",
    "base_name": "BGH Notebook",
    "description": "Notebook BGH 14\"",
    "url": "http://www.example.com/notebook-bgh-6786896868",
    "image_url": "http://www.example.com/notebook-bgh-6786896868.png",
    "thumbnail_url": "http://www.example.com/thumbnail_notebook-bgh-6786896868.png",
    "price": 12200,
    "offer_price": 12000,
    "stock": 20,
    "available": true,
    "release_date": "2020-04-16 03:00:00",
    "category": [
        {
            "id": "a",
            "name": "Todos los productos",
            "url": "http://www.example.com/categorias/a",
            "image_url": "http://www.example.com/categorias/a.jpg"
        },
        {
            "id": "a-b",
            "name": "Hogar",
            "url": "http://www.example.com/categorias/a/b",
            "image_url": "http://www.example.com/categorias/b.png"
        },
        {
            "id": "a-b-c",
            "name": "Notebook",
            "url": "http://www.example.com/categorias/a/b/c",
            "image_url": "http://www.example.com/categorias/c.jpg"
        }
    ],
    "specifications": [
        {"name": "Disco rígido", "value": "1TB"}
    ],
    "metadata": {
        "internal_id": 123456789,
        "uploaded_by": {
            "id": 1,
            "name": "john doe",
            "email": "dataentry@myecommerce.com"
        }
    },
    "custom_attributes": { 
        "weight": 2,
        "release_date": "2019-05-22T14:35:22-03:00"
    }
}'
```

**Errors**

| HttpCode | HttpCode Name     | Code                | Description                                       |
| -------- | ----------------- | ------------------- | ------------------------------------------------- |
| 201      | ok                | ok                  | Request successful                                |
| 400      | bad request       | bad\_request        | Invalid parameters, view message for more details |
| 429      | too many requests | too\_many\_requests | API's requests-per-second limit exceeded          |
| 500      | internal error    | internal\_error     | Unexpected error                                  |

### POST /products/bulk

Create multiple products in one request. This endpoint is equal to `/products` but accept an array of products.

This is an example with 2 products in one request:

```
curl -X POST \
  https://api.woowup.com/apiv3/products/bulk \
  -H 'accept: application/json' \
  -H 'authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
  -H 'cache-control: no-cache' \
  -d '[{
    "sku": "6786896868",
    "brand": "BGH Positive",
    "name": "Notebook",
    "base_name": "BGH Notebook",
    "description": "Notebook BGH 14\"",
    "url": "http://www.example.com/notebook-bgh-6786896868",
    "image_url": "http://www.example.com/notebook-bgh-6786896868.png",
    "thumbnail_url": "http://www.example.com/thumbnail_notebook-bgh-6786896868.png",
    "price": 12200,
    "offer_price": 12000,
    "stock": 20,
    "available": true,
    "category": [
        {
            "id": "a",
            "name": "Todos los productos",
            "url": "http://www.example.com/categorias/a",
            "image_url": "http://www.example.com/categorias/a.jpg"
        },
        {
            "id": "a-b",
            "name": "Hogar",
            "url": "http://www.example.com/categorias/a/b",
            "image_url": "http://www.example.com/categorias/b.png"
        },
        {
            "id": "a-b-c",
            "name": "Notebook",
            "url": "http://www.example.com/categorias/a/b/c",
            "image_url": "http://www.example.com/categorias/c.jpg"
        }
    ],
    "specifications": [
        {"name": "Disco rígido", "value": "1TB"}
    ],
    "metadata": {
        "internal_id": 123456789,
        "uploaded_by": {
            "id": 1,
            "name": "john doe",
            "email": "dataentry@myecommerce.com"
        }
    },
    "custom_attributes": { 
        "weight": 2,
        "release_date": "2019-05-22T14:35:22-03:00"
    }
}, {
    "sku": "44558987",
    "brand": "Asus",
    "name": "Notebook",
    "base_name": "Asus Notebook",
    "description": "Notebook ASUS 15\"",
    "url": "http://www.example.com/notebook-asus-44558987",
    "image_url": "http://www.example.com/notebook-asus-44558987.png",
    "thumbnail_url": "http://www.example.com/thumbnail_notebook-asus-44558987.png",
    "price": 14000,
    "offer_price": 13900,
    "stock": 15,
    "available": true,
    "category": [
        {
            "id": "a",
            "name": "Todos los productos",
            "url": "http://www.example.com/categorias/a",
            "image_url": "http://www.example.com/categorias/a.jpg"
        },
        {
            "id": "a-b",
            "name": "Hogar",
            "url": "http://www.example.com/categorias/a/b",
            "image_url": "http://www.example.com/categorias/b.png"
        },
        {
            "id": "a-b-c",
            "name": "Notebook",
            "url": "http://www.example.com/categorias/a/b/c",
            "image_url": "http://www.example.com/categorias/c.jpg"
        }
    ],
    "specifications": [
        {"name": "Disco rígido", "value": "720GB"}
    ]
}]'
```

**Errors**

| HttpCode | HttpCode Name     | Code                | Description                                       |
| -------- | ----------------- | ------------------- | ------------------------------------------------- |
| 201      | ok                | ok                  | Request successful                                |
| 400      | bad request       | bad\_request        | Invalid parameters, view message for more details |
| 429      | too many requests | too\_many\_requests | API's requests-per-second limit exceeded          |
| 500      | internal error    | internal\_error     | Unexpected error                                  |

### PUT /products/{id}

Update product's information. The {id} parameter is required and can be: the product's code encoded or the product's id.

This is an example to update the stock and the availability of the product according to the json schema on the POST section:

```
curl -X PUT \
  https://api.woowup.com/apiv3/products/Njc4Njg5Njg2OA== \
  -H 'accept: application/json' \
  -H 'authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
  -H 'cache-control: no-cache' \
  -d '{
    "sku": "6786896868",
    "base_sku": "6786896",
    "brand": "BGH Positive",
    "name": "Notebook",
    "base_name": "BGH Notebook",
    "description": "Notebook BGH 14\"",
    "url": "http://www.example.com/notebook-bgh-6786896868",
    "image_url": "http://www.example.com/notebook-bgh-6786896868.png",
    "thumbnail_url": "http://www.example.com/thumbnail_notebook-bgh-6786896868.png",
    "price": 12200,
    "offer_price": 12000,
    "stock": 20,
    "available": true,
    "release_date": "2020-04-16T00:00:00-03:00",
    "category": [
        {
            "id": "a",
            "name": "Todos los productos",
            "url": "http://www.example.com/categorias/a",
            "image_url": "http://www.example.com/categorias/a.jpg"
        },
        {
            "id": "a-b",
            "name": "Hogar",
            "url": "http://www.example.com/categorias/a/b",
            "image_url": "http://www.example.com/categorias/b.png"
        },
        {
            "id": "a-b-c",
            "name": "Notebook",
            "url": "http://www.example.com/categorias/a/b/c",
            "image_url": "http://www.example.com/categorias/c.jpg"
        }
    ],
    "specifications": [
        {"name": "Disco rígido", "value": "1TB"}
    ],
    "metadata": {
        "internal_id": 987654321,
        "uploaded_by": {
            "id": 2,
            "name": "joanne doe",
            "email": "dataentry2@myecommerce.com"
        }
    },
    "custom_attributes": { 
        "weight": 15,
        "release_date": "2019-04-26"
    }
}'
```

**Errors**

| HttpCode | HttpCode Name     | Code                | Description                                       |
| -------- | ----------------- | ------------------- | ------------------------------------------------- |
| 200      | ok                | ok                  | Request successful                                |
| 400      | bad request       | bad\_request        | Invalid parameters, view message for more details |
| 404      | not found         | not\_found          | Product not found                                 |
| 429      | too many requests | too\_many\_requests | API's requests-per-second limit exceeded          |
| 500      | internal error    | internal\_error     | Unexpected error                                  |

### GET /products/{id}/exist

Test if a product exist by id/sku. The {id} parameter is required and can be: the product's code encoded or the product's id.

| Parameter | Type | Required | Description               |
| --------- | ---- | -------- | ------------------------- |
| id        | uri  | Yes      | Product ID or encoded sku |

**Example**

```
curl -X GET \
    -H "Accept: application/json" \
    -H "Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -H "Cache-Control: no-cache" \
    "https://api.woowup.com/apiv3/products/12345/exist"
```

**Response**

```
{
    "payload": {
        "exist": true
    },
    "message":"ok",
    "code":"ok",
    "time":"100ms"
}
```

**Errors**

| HttpCode | HttpCode Name     | Code                | Description                              |
| -------- | ----------------- | ------------------- | ---------------------------------------- |
| 200      | ok                | ok                  | Request successful                       |
| 429      | too many requests | too\_many\_requests | API's requests-per-second limit exceeded |
| 500      | internal error    | internal\_error     | Unexpected error                         |
