# Product Update

## Product Update

<mark style="color:green;">`POST`</mark> `https://api.cakes.com/v1/update_product`

This endpoint allows you to update/edit product details.

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
{    "name": "Cake's name",    "recipe": "Cake's recipe name",    "cake": "Binary cake"}
```

{% endtab %}

{% tab title="404 Could not find a cake matching this query." %}

```
{    "message": "Ain't no cake like that."}
```

{% endtab %}
{% endtabs %}

### Request

```javascript
{
	"product_id": 3221,
    "title":"demo product",
    "title_ar":"منتج تجريبي",
    "category":251,
    "weight":1,
    "brand_id":5,
    "description":"demo product description",
    "description_ar":"منتج تجريبي منتج تجريبي",
    "sub_category":154,
    "sale_price":10,
    "prices":{
    	"1": 10,
    	"10": 20
    },
    "purchase_price":7,
    "shipping_cost":1,
    "purchase_limit":5,
    "barcode":"123456789",
    "sort_order":10,
    "tag":"tag1,tag2",
    "unit":1,
    "catering":0,
    "featured":1,
    "preparation_time":0,
    "preparation_type":1,
    "pdt_special_price_discount":1,
    "pdt_discount":2,
    "all_branches":1,
    "celebrity":{
    	"0":1,
    	"1":2
    },
    "product_option":{
    	"0":{
    		"title":"Demo production option title en",
    		"title_ar":"Demo production option title ar",
    		"related":0,
    		"with_stock":0,
    		"type":"multi_select",
    		"required":1,
    		"more_extras":1,
    		"option_values":{
    			"0":173,
    			"1":174
    		}
    	}
    }
}
```

### Examples

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

```python
import http.client

conn = http.client.HTTPSConnection("sandbox.mnasati.com")

payload = "{\"product_id\":3221,\"title\":\"demo product\",\"title_ar\":\"منتج تجريبي\",\"category\":251,\"weight\":1,\"brand_id\":5,\"description\":\"demo product description\",\"description_ar\":\"منتج تجريبي منتج تجريبي\",\"sub_category\":154,\"sale_price\":10,\"prices\":{\"1\":10,\"10\":20},\"purchase_price\":7,\"shipping_cost\":1,\"purchase_limit\":5,\"barcode\":\"123456789\",\"sort_order\":10,\"tag\":\"tag1,tag2\",\"unit\":1,\"catering\":0,\"featured\":1,\"preparation_time\":0,\"preparation_type\":1,\"pdt_special_price_discount\":1,\"pdt_discount\":2,\"all_branches\":1,\"celebrity\":{\"0\":1,\"1\":2},\"product_option\":{\"0\":{\"title\":\"Demo production option title en\",\"title_ar\":\"Demo production option title ar\",\"related\":0,\"with_stock\":0,\"type\":\"multi_select\",\"required\":1,\"more_extras\":1,\"option_values\":{\"0\":173,\"1\":174}}}}"

headers = {
    'Content-Type': "",
    'Authorization-Jwt': ""
    }

conn.request("POST", "/v1/update_product", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://sandbox.mnasati.com/v1/update_product",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"product_id\":3221,\"title\":\"demo product\",\"title_ar\":\"منتج تجريبي\",\"category\":251,\"weight\":1,\"brand_id\":5,\"description\":\"demo product description\",\"description_ar\":\"منتج تجريبي منتج تجريبي\",\"sub_category\":154,\"sale_price\":10,\"prices\":{\"1\":10,\"10\":20},\"purchase_price\":7,\"shipping_cost\":1,\"purchase_limit\":5,\"barcode\":\"123456789\",\"sort_order\":10,\"tag\":\"tag1,tag2\",\"unit\":1,\"catering\":0,\"featured\":1,\"preparation_time\":0,\"preparation_type\":1,\"pdt_special_price_discount\":1,\"pdt_discount\":2,\"all_branches\":1,\"celebrity\":{\"0\":1,\"1\":2},\"product_option\":{\"0\":{\"title\":\"Demo production option title en\",\"title_ar\":\"Demo production option title ar\",\"related\":0,\"with_stock\":0,\"type\":\"multi_select\",\"required\":1,\"more_extras\":1,\"option_values\":{\"0\":173,\"1\":174}}}}",
  CURLOPT_HTTPHEADER => [
    "Authorization-Jwt: ",
    "Content-Type: "
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

{% endtab %}

{% tab title="Java" %}

```java
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"product_id\":3221,\"title\":\"demo product\",\"title_ar\":\"منتج تجريبي\",\"category\":251,\"weight\":1,\"brand_id\":5,\"description\":\"demo product description\",\"description_ar\":\"منتج تجريبي منتج تجريبي\",\"sub_category\":154,\"sale_price\":10,\"prices\":{\"1\":10,\"10\":20},\"purchase_price\":7,\"shipping_cost\":1,\"purchase_limit\":5,\"barcode\":\"123456789\",\"sort_order\":10,\"tag\":\"tag1,tag2\",\"unit\":1,\"catering\":0,\"featured\":1,\"preparation_time\":0,\"preparation_type\":1,\"pdt_special_price_discount\":1,\"pdt_discount\":2,\"all_branches\":1,\"celebrity\":{\"0\":1,\"1\":2},\"product_option\":{\"0\":{\"title\":\"Demo production option title en\",\"title_ar\":\"Demo production option title ar\",\"related\":0,\"with_stock\":0,\"type\":\"multi_select\",\"required\":1,\"more_extras\":1,\"option_values\":{\"0\":173,\"1\":174}}}}");
Request request = new Request.Builder()
  .url("https://sandbox.mnasati.com/v1/update_product")
  .post(body)
  .addHeader("Content-Type", "")
  .addHeader("Authorization-Jwt", "")
  .build();

Response response = client.newCall(request).execute();
```

{% endtab %}

{% tab title="C#" %}

```csharp
var client = new HttpClient();
var request = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new Uri("https://sandbox.mnasati.com/v1/update_product"),
    Headers =
    {
        { "Content-Type", "" },
        { "Authorization-Jwt", "" },
    },
    Content = new StringContent("{\"product_id\":3221,\"title\":\"demo product\",\"title_ar\":\"منتج تجريبي\",\"category\":251,\"weight\":1,\"brand_id\":5,\"description\":\"demo product description\",\"description_ar\":\"منتج تجريبي منتج تجريبي\",\"sub_category\":154,\"sale_price\":10,\"prices\":{\"1\":10,\"10\":20},\"purchase_price\":7,\"shipping_cost\":1,\"purchase_limit\":5,\"barcode\":\"123456789\",\"sort_order\":10,\"tag\":\"tag1,tag2\",\"unit\":1,\"catering\":0,\"featured\":1,\"preparation_time\":0,\"preparation_type\":1,\"pdt_special_price_discount\":1,\"pdt_discount\":2,\"all_branches\":1,\"celebrity\":{\"0\":1,\"1\":2},\"product_option\":{\"0\":{\"title\":\"Demo production option title en\",\"title_ar\":\"Demo production option title ar\",\"related\":0,\"with_stock\":0,\"type\":\"multi_select\",\"required\":1,\"more_extras\":1,\"option_values\":{\"0\":173,\"1\":174}}}}")
    {
        Headers =
        {
            ContentType = new MediaTypeHeaderValue("application/json")
        }
    }
};
using (var response = await client.SendAsync(request))
{
    response.EnsureSuccessStatusCode();
    var body = await response.Content.ReadAsStringAsync();
    Console.WriteLine(body);
}
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://sandbox.mnasati.com/v1/update_product")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["Content-Type"] = ''
request["Authorization-Jwt"] = ''
request.body = "{\"product_id\":3221,\"title\":\"demo product\",\"title_ar\":\"منتج تجريبي\",\"category\":251,\"weight\":1,\"brand_id\":5,\"description\":\"demo product description\",\"description_ar\":\"منتج تجريبي منتج تجريبي\",\"sub_category\":154,\"sale_price\":10,\"prices\":{\"1\":10,\"10\":20},\"purchase_price\":7,\"shipping_cost\":1,\"purchase_limit\":5,\"barcode\":\"123456789\",\"sort_order\":10,\"tag\":\"tag1,tag2\",\"unit\":1,\"catering\":0,\"featured\":1,\"preparation_time\":0,\"preparation_type\":1,\"pdt_special_price_discount\":1,\"pdt_discount\":2,\"all_branches\":1,\"celebrity\":{\"0\":1,\"1\":2},\"product_option\":{\"0\":{\"title\":\"Demo production option title en\",\"title_ar\":\"Demo production option title ar\",\"related\":0,\"with_stock\":0,\"type\":\"multi_select\",\"required\":1,\"more_extras\":1,\"option_values\":{\"0\":173,\"1\":174}}}}"

response = http.request(request)
puts response.read_body
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://sandbox.mnasati.com/v1/update_product"

	payload := strings.NewReader("{\"product_id\":3221,\"title\":\"demo product\",\"title_ar\":\"منتج تجريبي\",\"category\":251,\"weight\":1,\"brand_id\":5,\"description\":\"demo product description\",\"description_ar\":\"منتج تجريبي منتج تجريبي\",\"sub_category\":154,\"sale_price\":10,\"prices\":{\"1\":10,\"10\":20},\"purchase_price\":7,\"shipping_cost\":1,\"purchase_limit\":5,\"barcode\":\"123456789\",\"sort_order\":10,\"tag\":\"tag1,tag2\",\"unit\":1,\"catering\":0,\"featured\":1,\"preparation_time\":0,\"preparation_type\":1,\"pdt_special_price_discount\":1,\"pdt_discount\":2,\"all_branches\":1,\"celebrity\":{\"0\":1,\"1\":2},\"product_option\":{\"0\":{\"title\":\"Demo production option title en\",\"title_ar\":\"Demo production option title ar\",\"related\":0,\"with_stock\":0,\"type\":\"multi_select\",\"required\":1,\"more_extras\":1,\"option_values\":{\"0\":173,\"1\":174}}}}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "")
	req.Header.Add("Authorization-Jwt", "")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

{% endtab %}

{% tab title="Swift" %}

```swift
import Foundation

let headers = [
  "Content-Type": "",
  "Authorization-Jwt": ""
]
let parameters = [
  "product_id": 3221,
  "title": "demo product",
  "title_ar": "منتج تجريبي",
  "category": 251,
  "weight": 1,
  "brand_id": 5,
  "description": "demo product description",
  "description_ar": "منتج تجريبي منتج تجريبي",
  "sub_category": 154,
  "sale_price": 10,
  "prices": [
    "1": 10,
    "10": 20
  ],
  "purchase_price": 7,
  "shipping_cost": 1,
  "purchase_limit": 5,
  "barcode": "123456789",
  "sort_order": 10,
  "tag": "tag1,tag2",
  "unit": 1,
  "catering": 0,
  "featured": 1,
  "preparation_time": 0,
  "preparation_type": 1,
  "pdt_special_price_discount": 1,
  "pdt_discount": 2,
  "all_branches": 1,
  "celebrity": [
    "0": 1,
    "1": 2
  ],
  "product_option": ["0": [
      "title": "Demo production option title en",
      "title_ar": "Demo production option title ar",
      "related": 0,
      "with_stock": 0,
      "type": "multi_select",
      "required": 1,
      "more_extras": 1,
      "option_values": [
        "0": 173,
        "1": 174
      ]
    ]]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox.mnasati.com/v1/update_product")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

{% endtab %}

{% tab title="jQuery" %}

```javascript
const settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://sandbox.mnasati.com/v1/update_product",
  "method": "POST",
  "headers": {
    "Content-Type": "",
    "Authorization-Jwt": ""
  },
  "processData": false,
  "data": "{\"product_id\":3221,\"title\":\"demo product\",\"title_ar\":\"منتج تجريبي\",\"category\":251,\"weight\":1,\"brand_id\":5,\"description\":\"demo product description\",\"description_ar\":\"منتج تجريبي منتج تجريبي\",\"sub_category\":154,\"sale_price\":10,\"prices\":{\"1\":10,\"10\":20},\"purchase_price\":7,\"shipping_cost\":1,\"purchase_limit\":5,\"barcode\":\"123456789\",\"sort_order\":10,\"tag\":\"tag1,tag2\",\"unit\":1,\"catering\":0,\"featured\":1,\"preparation_time\":0,\"preparation_type\":1,\"pdt_special_price_discount\":1,\"pdt_discount\":2,\"all_branches\":1,\"celebrity\":{\"0\":1,\"1\":2},\"product_option\":{\"0\":{\"title\":\"Demo production option title en\",\"title_ar\":\"Demo production option title ar\",\"related\":0,\"with_stock\":0,\"type\":\"multi_select\",\"required\":1,\"more_extras\":1,\"option_values\":{\"0\":173,\"1\":174}}}}"
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

{% 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.mnasati.com/api-methods/product-list/product-update.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.
