# Create New Product

- Sandbox: `POST https://sandbox.payme.io/api/products`
- Production: `POST https://live.payme.io/api/products`

## Credentials

- Header `Authorization: Bearer <token>`

This endpoint is an essential part of the product management system. 

The endpoint allows clients to add new products to the system by sending the necessary information in the request.

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

Post the necessary fields for the API to create a new user.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `product_remote_id` | string | no | The extneral product identifier. |
| `name` | string | yes | The name of the product. |
| `status` | integer | yes | The status of the product. Options: 1 = `Available`, 0 = `Not Available` |
| `description` | string | yes | The product description. Maximum Length = 75 Characters. |
| `store_prices` | object | no | The item store configuration. |
| `store_prices.currency` | string | no | 3 Letter ISO. |
| `store_prices.is_vat_free` | boolean | no | The VAT indicator. |
| `store_prices.price_without_vat` | number | no | Price without VAT. |
| `store_prices.price_include_vat` | number | no | Price with VAT. |
| `costs` | object | no | The item costs object. |
| `costs.currency` | string | no | 3 Letter ISO. |
| `costs.is_vat_free` | boolean | no | The VAT indicator. |
| `costs.price_without_vat` | number | no | The price without VAT. |
| `costs.price_include_vat` | number | no | The price including VAT. |

### Request example

```json
{
  "payme_client_key": "your_payme_client_key",
  "seller_payme_id": "seller789",
  "product_code": "PROD003",
  "name": "Detailed Costs Product",
  "status": 0,
  "category": 2,
  "description": "This product includes detailed cost information.",
  "item_sale_details": {
    "currency": "GBP",
    "vat_free": false,
    "Price_without_vat": 150,
    "Price_include_vat": 180
  },
  "item_costs_details": {
    "currency": "GBP",
    "vat_free": false,
    "Price_without_vat": 70,
    "Price_include_vat": 84
  }
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/products' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_TOKEN>' \
  --data-raw '{
  "payme_client_key": "your_payme_client_key",
  "seller_payme_id": "seller789",
  "product_code": "PROD003",
  "name": "Detailed Costs Product",
  "status": 0,
  "category": 2,
  "description": "This product includes detailed cost information.",
  "item_sale_details": {
    "currency": "GBP",
    "vat_free": false,
    "Price_without_vat": 150,
    "Price_include_vat": 180
  },
  "item_costs_details": {
    "currency": "GBP",
    "vat_free": false,
    "Price_without_vat": 70,
    "Price_include_vat": 84
  }
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/products", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <YOUR_TOKEN>",
  },
  body: JSON.stringify({
    "payme_client_key": "your_payme_client_key",
    "seller_payme_id": "seller789",
    "product_code": "PROD003",
    "name": "Detailed Costs Product",
    "status": 0,
    "category": 2,
    "description": "This product includes detailed cost information.",
    "item_sale_details": {
      "currency": "GBP",
      "vat_free": false,
      "Price_without_vat": 150,
      "Price_include_vat": 180
    },
    "item_costs_details": {
      "currency": "GBP",
      "vat_free": false,
      "Price_without_vat": 70,
      "Price_include_vat": 84
    }
  }),
});

console.log(await response.text());
```

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/products",
    headers={
        "Authorization": "Bearer <YOUR_TOKEN>",
    },
    json={
        "payme_client_key": "your_payme_client_key",
        "seller_payme_id": "seller789",
        "product_code": "PROD003",
        "name": "Detailed Costs Product",
        "status": 0,
        "category": 2,
        "description": "This product includes detailed cost information.",
        "item_sale_details": {
            "currency": "GBP",
            "vat_free": False,
            "Price_without_vat": 150,
            "Price_include_vat": 180,
        },
        "item_costs_details": {
            "currency": "GBP",
            "vat_free": False,
            "Price_without_vat": 70,
            "Price_include_vat": 84,
        },
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "payme_client_key": "your_payme_client_key",
  "seller_payme_id": "seller789",
  "product_code": "PROD003",
  "name": "Detailed Costs Product",
  "status": 0,
  "category": 2,
  "description": "This product includes detailed cost information.",
  "item_sale_details": {
    "currency": "GBP",
    "vat_free": false,
    "Price_without_vat": 150,
    "Price_include_vat": 180
  },
  "item_costs_details": {
    "currency": "GBP",
    "vat_free": false,
    "Price_without_vat": 70,
    "Price_include_vat": 84
  }
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/products');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'Authorization: Bearer <YOUR_TOKEN>',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
```

## Responses

### 200 — Product created successfully. (success)

| Field | Type | Description |
| --- | --- | --- |
| `created_at` | string | The timestamp of the creation. |
| `guid` | integer | The unique PayMe product identifier. |

```json
{
  "status_code": 0,
  "message": "OK",
  "Created_date": "2024-05-16T00:00:00Z",
  "Payme_product_id": 1234567890
}
```

### 400 — Bad Request (error)

| Field | Type | Description |
| --- | --- | --- |
| `message` | string | The error text message. |
| `status_error_code` | integer | The error code. |

```json
{
  "status_code": 1,
  "message": "Bad Request",
  "status_error_code": 400
}
```

### 401 — Unauthorized (error)

| Field | Type | Description |
| --- | --- | --- |
| `message` | string | The error text message. |
| `status_error_code` | integer | The error code. |

```json
{
  "status_code": 1,
  "message": "Unauthorized request",
  "status_error_code": 401
}
```

### 500 — Internal Server Error (error)

| Field | Type | Description |
| --- | --- | --- |
| `message` | string | The error text message. |
| `status_error_code` | integer |  |

```json
{
  "status_code": 1,
  "message": "Internal Server Error",
  "status_error_code": 500
}
```
