> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qwoty.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Product

> Update an existing product

## Authorization

<ParamField header="Authorization" type="string" required>
  Bearer token for authentication. Format: `Bearer qwoty_your_token`
</ParamField>

## Path Parameters

<ParamField path="id" type="string" required>
  UUID of the product to update
</ParamField>

## Request Body

<ParamField body="name" type="string">
  Product name
</ParamField>

<ParamField body="description" type="string">
  Product description
</ParamField>

<ParamField body="description_inherit_from_product" type="boolean">
  Whether to inherit description from parent product
</ParamField>

<ParamField body="primary_image_inherit_from_product" type="boolean">
  Whether to inherit primary image from parent product
</ParamField>

<ParamField body="reference" type="string">
  Internal reference
</ParamField>

<ParamField body="is_active" type="boolean">
  Active status
</ParamField>

<ParamField body="category_ids" type="array">
  Category UUIDs to link to the parent product. Replaces all existing category
  links.
</ParamField>

<ParamField body="inventory[sku]" type="string">
  Stock Keeping Unit
</ParamField>

<ParamField body="settings[unit_per_pack]" type="number">
  Number of units per pack
</ParamField>

<ParamField body="accounting[ledger_account]" type="string">
  Ledger account code
</ParamField>

<ParamField body="identifiers[crm]" type="string">
  External CRM ID
</ParamField>

<ParamField body="identifiers[erp]" type="string">
  External ERP ID
</ParamField>

<ParamField body="identifiers[accounting]" type="string">
  External accounting ID
</ParamField>

<ParamField body="shipping[weight]" type="number">
  Shipping weight
</ParamField>

<ParamField body="shipping[weight_unit]" type="string">
  Shipping weight unit (kg, lbs)
</ParamField>

<ParamField body="shipping[height]" type="number">
  Shipping height
</ParamField>

<ParamField body="shipping[length]" type="number">
  Shipping length
</ParamField>

<ParamField body="shipping[width]" type="number">
  Shipping width
</ParamField>

<ParamField body="shipping[length_unit]" type="string">
  Shipping length unit (cm, in, etc.)
</ParamField>

<ParamField body="shipping[country_of_origin]" type="string">
  Country of origin for shipping
</ParamField>

<ParamField body="shipping[harmonized_system_code]" type="string">
  HS code for customs
</ParamField>

<ParamField body="primary_image_id" type="string">
  UUID of the primary media to associate with this product. Set to `null` to
  remove the primary image.
</ParamField>

Fields such as `api_name` are creation-only: they may appear on the resource but cannot be sent in a PATCH body (the API returns `400` with a validation detail if they are).

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PATCH https://qwoty.app/api/products/550e8400-e29b-41d4-a716-446655440000 \
    -H "Authorization: Bearer qwoty_your_token" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Updated Product Name",
      "description": "Updated description",
      "is_active": false
    }'
  ```

  ```javascript JavaScript theme={null}
  const productId = '550e8400-e29b-41d4-a716-446655440000'

  const response = await fetch(`https://qwoty.app/api/products/${productId}`, {
    method: 'PATCH',
    headers: {
      Authorization: 'Bearer qwoty_your_token',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Updated Product Name',
      description: 'Updated description',
      is_active: false,
    }),
  })

  const data = await response.json()
  ```

  ```python Python theme={null}
  import requests

  product_id = '550e8400-e29b-41d4-a716-446655440000'

  response = requests.patch(
      f'https://qwoty.app/api/products/{product_id}',
      headers={
          'Authorization': 'Bearer qwoty_your_token',
          'Content-Type': 'application/json'
      },
      json={
          'name': 'Updated Product Name',
          'description': 'Updated description',
          'is_active': False
      }
  )

  data = response.json()
  ```
</CodeGroup>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  The updated product object with all fields, including the `prices` array
</ResponseField>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "success": true,
    "data": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "product_parent_id": "660e8400-e29b-41d4-a716-446655440001",
      "workspace_id": "880e8400-e29b-41d4-a716-446655440003",
      "name": "Updated Product Name",
      "api_name": "updated_product_name",
      "reference": "PROD-001",
      "description": "Updated description",
      "description_inherit_from_product": true,
      "primary_image_inherit_from_product": true,
      "is_active": false,
      "is_default": true,
      "catalogs": [
        {
          "id": "770e8400-e29b-41d4-a716-446655440002",
          "api_name": "catalog_main"
        }
      ],
      "categories": [],
      "settings": {
        "unit_per_pack": 1,
        "product_type": "physical",
        "language_code": null,
        "unit_of_measure": null,
        "recurrence_type": "one_off"
      },
      "shipping": {
        "weight": 2.8,
        "weight_unit": "kg",
        "length": 30,
        "width": 20,
        "height": 10,
        "length_unit": "cm",
        "country_of_origin": "FR",
        "harmonized_system_code": "8471.30"
      },
      "inventory": {
        "sku": "WID-PRE-001"
      },
      "identifiers": {
        "crm": "crm_123",
        "accounting": "acc_789",
        "erp": "erp_456"
      },
      "accounting": {
        "ledger_account": "4010"
      },
      "primary_image_id": null,
      "parent_primary_image_id": null,
      "options": [],
      "prices": [
        {
          "id": "ee0e8400-e29b-41d4-a716-446655440030",
          "pricebook_id": "ff0e8400-e29b-41d4-a716-446655440031",
          "pricebook_api_name": "standard",
          "pricing_model": "flat",
          "amount": 1990
        }
      ],
      "created_at": "2024-12-21T10:30:00Z",
      "updated_at": "2024-12-21T14:45:00Z"
    }
  }
  ```
</ResponseExample>

## Error Responses

<ResponseExample>
  ```json Not Found theme={null}
  {
    "success": false,
    "error": "Product not found"
  }
  ```

  ```json Validation Error theme={null}
  {
    "success": false,
    "error": "Validation error",
    "details": {
      "name": "Name must be at least 2 characters"
    }
  }
  ```

  ```json Validation Error (read-only field) theme={null}
  {
    "error": "Validation error",
    "details": ["Field 'reference' is read-only or unknown"]
  }
  ```

  ```json Unauthorized theme={null}
  {
    "success": false,
    "error": "Invalid API token"
  }
  ```
</ResponseExample>
