> For the complete documentation index, see [llms.txt](https://docs.keepup.store/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.keepup.store/docs/api/products/edit-product.md).

# Edit Product

## Endpoint

<mark style="color:purple;">**PUT**</mark> `https://api.keepup.store/v2.0/products/edit/{product_id}`

## Headers

`Authorization: Bearer API_KEY`

## Body Parameters

|                                                                             |             |                                                                                        |
| --------------------------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------- |
| <p><strong>product\_name</strong></p><p>string</p>                          | yes         | Name of the product. Example: "Widget A"                                               |
| <p><strong>description</strong></p><p><em>string</em></p>                   | optional    | Detailed description of the product. Uses sanitized content.                           |
| <p><strong>cost\_price</strong></p><p><em>float</em></p>                    | optional    | Cost price of the product. Must be a valid monetary amount. Example: 15.75             |
| <p><strong>selling\_price</strong></p><p><em>float</em></p>                 | yes         | Selling price of the product. Must be a valid monetary amount. Example: 20.00          |
| <p><strong>previous\_price</strong></p><p><em>float</em></p>                | optional    | Previous selling price, if any. Must be a valid monetary amount. Example: 18.00        |
| <p><strong>quantity</strong></p><p><em>integer</em></p>                     | conditional | Available quantity of the product. Required if `stock_limit` is 'limited'. Example: 50 |
| <p><strong>restock\_level</strong></p><p><em>integer</em></p>               | optional    | Level at which the product should be restocked. Example: 10                            |
| <p><strong>show\_on\_storefront</strong></p><p><em>string</em></p>          | optional    | Whether to show the product on the storefront. Accepts 'yes' or 'no'. Default is 'no'. |
| <p><strong>featured\_product</strong></p><p><em>string</em></p>             | optional    | Whether the product is featured. Accepts 'yes' or 'no'. Default is 'no'.               |
| <p><strong>category</strong></p><p><em>string</em></p>                      | optional    | Category of the product. Example: "Electronics"                                        |
| <p><strong>tags</strong></p><p><em>JSON</em></p>                            | optional    | Tags associated with the product, in JSON format. Example: `["Electronics", "Gadget"]` |
| <p><strong>variants</strong></p><p><em>JSON</em></p>                        | optional    | Variants of the product, in JSON format. Example: `[{"color": "red", "size": "M"}]`    |
| <p><strong>SKU</strong></p><p><em>string</em></p>                           | optional    | Stock Keeping Unit, unique identifier for each product variant. Example: "SKU12345"    |
| <p><strong>barcode</strong></p><p><em>string</em></p>                       | optional    | Barcode of the product. Example: "0123456789012"                                       |
| <p><strong>product\_location</strong></p><p><em>string</em></p>             | optional    | Storage location of the product within the business. Example: "Aisle 3, Shelf 5"       |
| <p><strong>expirations</strong></p><p><em>JSON</em></p>                     | optional    | List of expiration details in JSON format. Includes batch numbers and dates.           |
| <p><strong>removed\_images</strong></p><p><em>array</em></p>                | optional    |                                                                                        |
| <p><strong>primary\_product\_image\_index</strong></p><p><em>array</em></p> | optional    |                                                                                        |

## Sample Requests

{% tabs %}
{% tab title="Node.js" %}
{% code overflow="wrap" fullWidth="true" %}

```javascript
const axios = require('axios');

const productData = {
  product_name: 'Product A',
  description: 'High-quality gadget',
  cost_price: 15.75,
  selling_price: 20.00,
  quantity: 50,
  restock_level: 10,
  show_on_storefront: 'yes',
  featured_product: 'no',
  category: 'Electronics',
  tags: ["Electronics", "Gadget"],
  variants: [{ color: "red", size: "M" }],
  SKU: 'SKU12345',
  barcode: '0123456789012',
  product_location: 'Aisle 3, Shelf 5',
  expirations: [{
    batch_number: "batch123",
    expiration_date: "2024-12-31",
    alert_date: "2024-12-01"
  }],
  removed_images: [],
  primary_product_image_index: 0
};

const config = {
  method: 'post',
  url: 'https://api.keepup.store/v2.0/products/edit/{product_id}',
  headers: {
    'Authorization': 'Bearer API_KEY',  // Replace YOUR_ACCESS_TOKEN with your actual access token
    'Content-Type': 'application/json'
  },
  data: JSON.stringify(productData)
};

axios(config)
.then(function (response) {
  console.log('Product updated successfully:', response.data);
})
.catch(function (error) {
  console.error('Failed to updated product:', error);
});

```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}

```php
<?php
$curl = curl_init();

$filePath = '/path/to/file.jpg';
$cfile = new CURLFile($filePath, 'image/jpeg', 'file.jpg');

$postData = array(
    'product_name' => 'Product A',
    'description' => 'High-quality gadget',
    'cost_price' => '15.75',
    'selling_price' => '20.00',
    'quantity' => '50',
    'restock_level' => '10',
    'stock_limit' => 'limited',
    'show_on_storefront' => 'yes',
    'featured_product' => 'no',
    'category' => 'Electronics',
    'tags' => json_encode(["Electronics", "Gadget"]),
    'variants' => json_encode([{"color": "red", "size": "M"}]),
    'SKU' => 'SKU12345',
    'barcode' => '0123456789012',
    'product_location' => 'Aisle 3, Shelf 5',
    'expirations' => json_encode([{ "batch_number": "batch123", "expiration_date": "2024-12-31", "alert_date": "2024-12-01" }]),
    'removed_images' => [],
    'primary_product_image_index': 0
);

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.keepup.store/v2.0/products/edit/{product_id}',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => $postData,
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer API_KEY' // Replace 'API_KEY' with your actual API key
  ),
));

$response = curl_exec($curl);

if ($response === false) {
    echo 'Curl error: ' . curl_error($curl);
}

curl_close($curl);
echo $response;

?>

```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder

m = MultipartEncoder(
    fields={
        'product_name': 'Product A',
        'description': 'High-quality gadget',
        'cost_price': '15.75',
        'selling_price': '20.00',
        'quantity': '50',
        'restock_level': '10',
        'stock_limit': 'limited',
        'show_on_storefront': 'yes',
        'featured_product': 'no',
        'category': 'Electronics',
        'tags': json.dumps(["Electronics", "Gadget"]),
        'variants': json.dumps([{"color": "red", "size": "M"}]),
        'SKU': 'SKU12345',
        'barcode': '0123456789012',
        'product_location': 'Aisle 3, Shelf 5',
        'expirations': json.dumps([{"batch_number": "batch123", "expiration_date": "2024-12-31", "alert_date": "2024-12-01"}]),
        'primary_product_image_index': '0',
        'removed_image': [],
        'primary_product_image_index': 0
    }
)

response = requests.post('https://api.keepup.store/v2.0/products/edit/{product_id}', 
                         data=m, 
                         headers={'Authorization': 'Bearer API_KEY', 'Content-Type': m.content_type})  # Replace YOUR_ACCESS_TOKEN with your actual access token

print(response.text)

```

{% endtab %}
{% endtabs %}

## Sample Response

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

```json
{
    "status": 200,
    "message": "product updated",
    "data": {
        "product_id": 19845
    }
}
```

{% endtab %}

{% tab title="Error" %}

```json
{
    "status": 401,
    "error": "Authentication invalid"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.keepup.store/docs/api/products/edit-product.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
