# Update Partner SKU

### Description

This service updates an existing Partner SKU associated with the logged-in partner. The specific record is identified by the `partner_sku_code` in the URL path.

***

### Request

#### Restrictions

* Authentication: Requires a successful partner login.
* Immutable Field: The partner SKU `code` is read-only. Attempting to change the code value in the request body will result in an error.

#### Endpoint

```
PUT https://<server-url>/api/v4/partner/skus/{partner_sku_code}
```

#### Path Parameters

| **Parameter**      | **Type** | **Description**                                                           |
| ------------------ | -------- | ------------------------------------------------------------------------- |
| `partner_sku_code` | String   | The current internal partner code assigned to the SKU you wish to update. |

#### Parameters

| **Parameter**  | **Location**   | **Description**                                                                        |
| -------------- | -------------- | -------------------------------------------------------------------------------------- |
| `touchpoint`   | Query / Header | The identifier for the touchpoint. Use `Thalamus-Touchpoint` for the header.           |
| `token`        | Query / Header | The authentication token for the partner session. Use `Thalamus-Token` for the header. |
| `Content-Type` | Header         | Must be `application/json`.                                                            |

#### Request Body Fields

| **Field**         | **Type** | **Description**                                                              |
| ----------------- | -------- | ---------------------------------------------------------------------------- |
| `skuCodeKey`      | String   | Required. The Reference code.                                                |
| `skuCode`         | String   | Required. The Thalamus SKU code.                                             |
| `code`            | String   | Read-Only. Must match the code in the URL path.                              |
| `name`            | String   | The updated name of the partner SKU.                                         |
| `equivalenceType` | Integer  | Mapping type: `1` (Equivalence), `2` (Unit), `3` (Package), `4` (Boxes).     |
| `equivalence`     | String   | A decimal value. Note: For types 2, 3, and 4, this value must be set to `1`. |

Example Body:

JSON

```
{  
   "skuCodeKey": "COD_BRA",
   "skuCode": "bra_cafe",
   "code": "pa6_cafe",
   "name": "Café negro",
   "equivalenceType": 1,
   "equivalence": "1.5"
}
```

***

### Response

#### ✅ Successful Response: `200 OK`

Returns the fully updated Partner SKU object.

JSON

JSON

```
{
    "name": "Café negro",
    "equivalenceType": 1,
    "equivalence": "1.5",
    "skuCodes": {
        "COD_BRA": "bra_cafe",
        "COD_COL": "col_cafe"
    },
    "code": "pa6_cafe"
}
```

***

### ❌ Unsuccessful Response

#### `400 Bad Request`

The following errors may be returned in the `errors` object:

| **Error Code**                      | **Field**            | **Description**                                            |
| ----------------------------------- | -------------------- | ---------------------------------------------------------- |
| `InvalidRoleForLoggedParty`         | `partner`            | Logged-in user lacks "Partner" privileges.                 |
| `code.mustNotChange`                | `code`               | The `code` in the body does not match the existing record. |
| `code.notFound`                     | `partnerSku code`    | No record exists for the provided path parameter.          |
| `field.required`                    | `skuCodeKey`         | The SKU Reference Code is missing.                         |
| `partnerSku.invalidSkuCode`         | `skuCodeKey+skuCode` | Invalid combination of reference code and SKU code.        |
| `partnerSku.invalidEquivalenceType` | `equivalenceType`    | Invalid integer provided for the mapping type.             |
| `equivalenceNaN`                    | `equivalence`        | The equivalence value must be a valid number string.       |
| `partnerSku.equivalenceDefault`     | `error.saving`       | If type is not `1`, the equivalence must be exactly `1.0`. |
| `InvalidJson`                       | N/A                  | The request body is not valid JSON.                        |
