# Update Product

- Sandbox: `PATCH https://sandbox.payme.io/api/products/{guid}`
- Production: `PATCH https://live.payme.io/api/products/{guid}`

## Credentials

- Header `Authorization: Bearer <token>`

The patch-product endpoint allows for partial updates to an existing product's details using `guid` as the identifier. Below is an example JSON payload for a PATCH request to update various fields of a product.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `guid` | path | string | yes |  |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | no | The name of the product. |
| `status` | integer | no | The status of the product. Options: 1 = `Available`, 0 = `Not Available` |
| `description` | string | no | The description of the product. |
| `store_configuration` | object | no | The item store configurations object. |
| `store_configuration.currency` | string | no | The currency of the item in the store. 3 Letter ISO |
| `store_configuration.is_vat_free` | boolean | no | The item VAT indicator. |
| `store_configuration.price_without_vat` | number | no | The price without VAT. |
| `store_configuration.price_include_vat` | number | no | The price including VAT. |
| `costs_details` | object | no | The item costs object. |
| `costs_details.currency` | string | no | The currency of the item in the store. 3 Letter ISO |
| `costs_details.is_vat_free` | boolean | no | The item VAT indicator. |
| `costs_details.price_without_vat` | number | no | The price without VAT. |
| `costs_details.price_include_vat` | number | no | The price including VAT. |

### Request example

```json
{
  "payme_client_key": "your_payme_client_key",
  "seller_payme_id": "seller123",
  "guid": "PRDCT001-123-123",
  "name": "Example Product",
  "status": 1,
  "category": 3,
  "description": "This is a description of the example product.",
  "item_sale_details": {
    "currency": "USD",
    "vat_free": false,
    "Price_without_vat": 99.99,
    "Price_include_vat": 117.99
  },
  "item_costs_details": {
    "currency": "USD",
    "vat_free": false,
    "Price_without_vat": 50,
    "Price_include_vat": 58.5
  }
}
```

## Code samples

### curl

```bash
curl -X PATCH 'https://sandbox.payme.io/api/products/<guid>' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_TOKEN>' \
  --data-raw '{
  "payme_client_key": "your_payme_client_key",
  "seller_payme_id": "seller123",
  "guid": "PRDCT001-123-123",
  "name": "Example Product",
  "status": 1,
  "category": 3,
  "description": "This is a description of the example product.",
  "item_sale_details": {
    "currency": "USD",
    "vat_free": false,
    "Price_without_vat": 99.99,
    "Price_include_vat": 117.99
  },
  "item_costs_details": {
    "currency": "USD",
    "vat_free": false,
    "Price_without_vat": 50,
    "Price_include_vat": 58.5
  }
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/products/<guid>", {
  method: "PATCH",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <YOUR_TOKEN>",
  },
  body: JSON.stringify({
    "payme_client_key": "your_payme_client_key",
    "seller_payme_id": "seller123",
    "guid": "PRDCT001-123-123",
    "name": "Example Product",
    "status": 1,
    "category": 3,
    "description": "This is a description of the example product.",
    "item_sale_details": {
      "currency": "USD",
      "vat_free": false,
      "Price_without_vat": 99.99,
      "Price_include_vat": 117.99
    },
    "item_costs_details": {
      "currency": "USD",
      "vat_free": false,
      "Price_without_vat": 50,
      "Price_include_vat": 58.5
    }
  }),
});

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

### Python

```python
import requests

response = requests.patch(
    "https://sandbox.payme.io/api/products/<guid>",
    headers={
        "Authorization": "Bearer <YOUR_TOKEN>",
    },
    json={
        "payme_client_key": "your_payme_client_key",
        "seller_payme_id": "seller123",
        "guid": "PRDCT001-123-123",
        "name": "Example Product",
        "status": 1,
        "category": 3,
        "description": "This is a description of the example product.",
        "item_sale_details": {
            "currency": "USD",
            "vat_free": False,
            "Price_without_vat": 99.99,
            "Price_include_vat": 117.99,
        },
        "item_costs_details": {
            "currency": "USD",
            "vat_free": False,
            "Price_without_vat": 50,
            "Price_include_vat": 58.5,
        },
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "payme_client_key": "your_payme_client_key",
  "seller_payme_id": "seller123",
  "guid": "PRDCT001-123-123",
  "name": "Example Product",
  "status": 1,
  "category": 3,
  "description": "This is a description of the example product.",
  "item_sale_details": {
    "currency": "USD",
    "vat_free": false,
    "Price_without_vat": 99.99,
    "Price_include_vat": 117.99
  },
  "item_costs_details": {
    "currency": "USD",
    "vat_free": false,
    "Price_without_vat": 50,
    "Price_include_vat": 58.5
  }
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/products/<guid>');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    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 — OK (success)

| Field | Type | Description |
| --- | --- | --- |
| `guid` | string |  |
| `created_at` | string |  |
| `updated_at` | string |  |

### 400 — Bad Request (error)

### 401 — Unauthorized (error)

### 500 — Internal Server Error (error)
