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

# Update Product

> Update any field of a product — codes, files, variants, course content, pricing, SEO.

# Update Product

<div className="flex items-center gap-2 mb-4">
  <span className="px-2 py-1 bg-yellow-100 text-yellow-800 rounded text-sm font-mono font-bold">PUT</span>
  <code>/products/{id}</code>
</div>

Updates a product you own. Accepts the **same full field set** as [Create Product](/merchant-api/products/create-product); all fields are optional except `slug`. Only the fields you send are changed — except where a field is a managed collection (see [Sync & replace semantics](#sync--replace-semantics)).

<Snippet file="rmz-plus-required.mdx" />

## Authentication

<Snippet file="auth-bearer-header.mdx" />

## Headers

| Header          | Value                   | Required    |
| --------------- | ----------------------- | ----------- |
| `Authorization` | `Bearer YOUR_API_TOKEN` | Yes         |
| `Accept`        | `application/json`      | Recommended |
| `Content-Type`  | `application/json`      | Yes         |

## Path Parameters

| Parameter | Type    | Required | Description                            |
| --------- | ------- | -------- | -------------------------------------- |
| `id`      | integer | Yes      | Product id (must belong to your store) |

## Body Parameters

All fields from [Create Product](/merchant-api/products/create-product) are accepted and **optional except `slug`**:

* **Core:** `name`, `slug`\* (must remain unique in your store), `type`, `description`, `marketing_title`, `activation_info`, `status`, `show_reviews`, `is_noticeable`
* **Pricing/inventory:** `price`, `cost_price`, `discount_price`, `discount_expiry`, `stock`, `min_qty`, `max_purchase_count`
* **Media:** `image.file.response.id` (omit to keep current), `product_files[]`, `extra_images[]`
* **Relations:** `categories[]`, `benefits[]`, `fields[]`
* **Per type:** `codes[]` (code), `subscriptionVariants[]` (+ `license_config` / subscription config), `course` (sections/modules)
* **Display/SEO:** `metadata.display.*`, `seo.*`

Refer to the [create reference](/merchant-api/products/create-product#body-parameters) for the exact shape of each object.

## Sync & replace semantics

| Field                             | Behavior on update                                                                                                                                                                                           |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `codes`                           | **Replaces** the live (unsold) code set. To add, send the existing codes plus new ones. Sold codes are preserved.                                                                                            |
| `subscriptionVariants`            | **Synced by `id`**: include `id` to update a variant, omit `id` to create, omit a variant entirely to delete it. A `subscription`/`license` must keep **at least one** variant (an empty array is rejected). |
| `subscriptionVariants[].features` | Synced by `id` within each variant.                                                                                                                                                                          |
| `course.sections` / `modules`     | Synced by `id`; omitted sections/modules are deleted.                                                                                                                                                        |
| `product_files` / `extra_images`  | Synced; ids omitted from the list are detached/removed from the product.                                                                                                                                     |
| `image`                           | Omit to keep the current image; provide a new media id to replace it.                                                                                                                                        |
| `benefits` / `categories`         | Replace the full set you send.                                                                                                                                                                               |

## Example Requests

<CodeGroup>
  ```bash Replace codes (cURL) theme={null}
  curl -X PUT "https://merchant-api.rmz.gg/shawarma/products/103" \
    -H "Authorization: Bearer YOUR_API_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Premium Key (v2)",
      "slug": "premium-key",
      "type": "code",
      "price": 59.99,
      "codes": [ { "code": "KEY-AAA-111" }, { "code": "KEY-CCC-333" } ]
    }'
  ```

  ```json Update subscription variants (body) theme={null}
  {
    "name": "Pro Plan",
    "slug": "pro-plan",
    "type": "subscription",
    "price": 19.99,
    "subscriptionVariants": [
      { "id": 5850, "duration": 30, "price": 24.99, "features": [] },
      { "duration": 365, "price": 199, "badge": "Yearly", "features": [{ "name": "2 months free" }] }
    ]
  }
  ```

  ```json Update discount + SEO + gallery (body) theme={null}
  {
    "name": "App License",
    "slug": "app-license",
    "type": "license",
    "discount_price": 79,
    "extra_images": [ { "file": { "response": { "id": 9101 } } } ],
    "seo": { "meta_title": "App License", "meta_description": "Buy a license" }
  }
  ```
</CodeGroup>

## Success Response

`200 OK`

```json theme={null}
{
  "message": "تم تحديث المنتج بنجاح",
  "data": {
    "id": 103,
    "name": "Premium Key (v2)",
    "slug": "premium-key",
    "type": "code",
    "price": 59.99,
    "codes": [ { "id": 5001, "code": "KEY-AAA-111" }, { "id": 5003, "code": "KEY-CCC-333" } ]
  },
  "api": "rmz.shawarma",
  "timestamp": 1699999999
}
```

## Error Responses

| Code  | Description                                                                                                                                 |
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `401` | Unauthorized — invalid or missing token                                                                                                     |
| `403` | Plan does not include the API feature, or `license` type requires a plan with license integration                                           |
| `404` | Product not found in your store, or a referenced media id is not yours                                                                      |
| `422` | Validation error (e.g. duplicate `slug`, empty `subscriptionVariants` for a subscription/license). The `data` object contains field errors. |
