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

# Update a product

> Partially update a product and sync nested prices, contributors, collections, and collateral.

Updates an existing product. Send only the fields you want to change — omitted
core fields stay as they are. Pass `null` on nullable foreign keys (for example
`license_id`) to clear them.

There is no `PATCH` route for a single product; use `PUT` with a partial body.

## Nested sync behaviour

When a nested key is **present** in the body:

| Key                      | Behaviour                                                               |
| ------------------------ | ----------------------------------------------------------------------- |
| `product_prices`         | Entries with `id` update; without `id` create. `[]` deletes all prices. |
| `packing_configurations` | Same merge-by-id pattern as prices. `[]` deletes all.                   |
| `product_collections`    | Syncs to the supplied set — extras are removed.                         |
| `contributors`           | Syncs to the supplied set — extras are removed.                         |
| `collateral`             | Rows with `id` update; without `id` create; omitted ids are deleted.    |
| `custom_fields`          | Replaces/syncs custom field values.                                     |

You can send **only** nested arrays with no core product fields.

## Headers

<ParamField header="x-api-key" type="string" required>
  Organisation API key.
</ParamField>

<ParamField header="Accept-Version" type="string" default="1.0">
  API version. Use `1.0`.
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be `application/json`.
</ParamField>

## Path parameters

<ParamField path="id" type="string" required>
  Product UUID.
</ParamField>

## Body

All create fields are optional on update (partial schema). Common fields:

<ParamField body="title" type="string">
  Product title.
</ParamField>

<ParamField body="publishing_status_id" type="string">
  Publishing status UUID, or `null` to clear.
</ParamField>

<ParamField body="license_id" type="string">
  Organisation license UUID, or `null` to clear. Must belong to the authenticated
  organisation.
</ParamField>

<ParamField body="page_count" type="integer">
  Positive page count.
</ParamField>

<ParamField body="format_id" type="string">
  Format UUID.
</ParamField>

<ParamField body="product_prices" type="object[]">
  Price sync array. Include `id` to update an existing price.
</ParamField>

<ParamField body="collateral" type="object[]">
  Collateral sync array. Include `id` to update; omit an existing id to delete
  that row.
</ParamField>

## Response

Returns **200** with the enriched product in `data`.

<ResponseField name="success" type="boolean" required>
  `true` when the update succeeds.
</ResponseField>

<ResponseField name="data" type="object" required>
  Updated product.
</ResponseField>

## Errors

| Status | When                                                                           |
| ------ | ------------------------------------------------------------------------------ |
| `400`  | Validation failed, invalid `license_id`, or series not in attached collections |
| `401`  | Missing or invalid API key                                                     |
| `500`  | Database or unexpected server error                                            |

<RequestExample>
  ```bash theme={null}
  curl -X PUT "https://vzguoukmiwxvqdnabfma.supabase.co/functions/v1/api/products/123e4567-e89b-12d3-a456-426614174000" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "Accept-Version: 1.0" \
    -H "Content-Type: application/json" \
    -d '{
      "publishing_status_id": "status-uuid",
      "license_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
      "page_count": 275
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "data": {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "title": "New Book Title",
      "publishing_status_id": "status-uuid",
      "license_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
      "license_name": "Example License",
      "license_badge_colour": "#7C3AED",
      "page_count": 275,
      "updated_at": "2024-01-02T00:00:00Z"
    }
  }
  ```
</ResponseExample>
