# Update sub products

`PUT /api/v1/Tenants/{tenantId}/Products/{productId}/SubProducts`

Core API · Products · base URL `https://core-api.ancon.io` · auth: `Access-Token` header · docs: https://ancon.dev/api/core/products/update-sub-products

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `tenantId` | string (uuid) | yes |  |
| `productId` | string (uuid) | yes |  |

## Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `correlationId` | string | no | Correlation Id for the request |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `addedSubProducts` | array<object> or null | no | List of sub products to add. |
| `addedSubProducts[].id` | string (uuid) or null | no | The id of the sub product that you want to edit. Set this to null when adding new sub products. |
| `addedSubProducts[].productId` | string (uuid) | no | The id of the product that you want to use as a sub product. |
| `addedSubProducts[].productVariantId` | string (uuid) or null | no | The optional id of a specific product variant that you want to use. Usually this is set. If it's not set then the POS user will get a popup to pick a specific variant to add the check. |
| `addedSubProducts[].price` | object or null | no | Override the price for this sub product. This price is used when <see cref="P:Ancon.Wildcat.Core.Api.Models.Public.V1.V0.Products.SubProducts.Commands.Update.SubProductModel.UseOverridePrice"></see> is true. |
| `addedSubProducts[].price.unitPrice` | number (double) | no | Gets or sets the price per unit. For example 10 per piece. Or 50 per cl. It depends on the unit of the product. |
| `addedSubProducts[].price.additionalPrice` | number (double) | no | Gets or sets the additional price. For example 50 per cl + 10 additional price. |
| `addedSubProducts[].materialCost` | object or null | no | Override the material cost for this sub product. This price is used when <see cref="P:Ancon.Wildcat.Core.Api.Models.Public.V1.V0.Products.SubProducts.Commands.Update.SubProductModel.UseOverridePrice"></see> is true. |
| `addedSubProducts[].materialCost.unitPrice` | number (double) | no | Gets or sets the price per unit. For example 10 per piece. Or 50 per cl. It depends on the unit of the product. |
| `addedSubProducts[].materialCost.additionalPrice` | number (double) | no | Gets or sets the additional price. For example 50 per cl + 10 additional price. |
| `addedSubProducts[].useOverridePrice` | boolean | no | Set this to true if you want to use a overrided price. |
| `addedSubProducts[].position` | integer (int32) | no | The position of this sub product, this is used to sort sub products on check, tickets, receipts etc. |
| `addedSubProducts[].quantity` | number (double) | no | This is the quantity of the sub product to be added to the check. min 1, max 99. |
| `updatedSubProducts` | array<object> or null | no | List of sub products you want to update. |
| `updatedSubProducts[].id` | string (uuid) or null | no | The id of the sub product that you want to edit. Set this to null when adding new sub products. |
| `updatedSubProducts[].productId` | string (uuid) | no | The id of the product that you want to use as a sub product. |
| `updatedSubProducts[].productVariantId` | string (uuid) or null | no | The optional id of a specific product variant that you want to use. Usually this is set. If it's not set then the POS user will get a popup to pick a specific variant to add the check. |
| `updatedSubProducts[].price` | object or null | no | Override the price for this sub product. This price is used when <see cref="P:Ancon.Wildcat.Core.Api.Models.Public.V1.V0.Products.SubProducts.Commands.Update.SubProductModel.UseOverridePrice"></see> is true. |
| `updatedSubProducts[].price.unitPrice` | number (double) | no | Gets or sets the price per unit. For example 10 per piece. Or 50 per cl. It depends on the unit of the product. |
| `updatedSubProducts[].price.additionalPrice` | number (double) | no | Gets or sets the additional price. For example 50 per cl + 10 additional price. |
| `updatedSubProducts[].materialCost` | object or null | no | Override the material cost for this sub product. This price is used when <see cref="P:Ancon.Wildcat.Core.Api.Models.Public.V1.V0.Products.SubProducts.Commands.Update.SubProductModel.UseOverridePrice"></see> is true. |
| `updatedSubProducts[].materialCost.unitPrice` | number (double) | no | Gets or sets the price per unit. For example 10 per piece. Or 50 per cl. It depends on the unit of the product. |
| `updatedSubProducts[].materialCost.additionalPrice` | number (double) | no | Gets or sets the additional price. For example 50 per cl + 10 additional price. |
| `updatedSubProducts[].useOverridePrice` | boolean | no | Set this to true if you want to use a overrided price. |
| `updatedSubProducts[].position` | integer (int32) | no | The position of this sub product, this is used to sort sub products on check, tickets, receipts etc. |
| `updatedSubProducts[].quantity` | number (double) | no | This is the quantity of the sub product to be added to the check. min 1, max 99. |
| `deletedSubProducts` | array<string (uuid)> or null | no | List of sub product ids you want to delete. |

### Example

```json
{
  "addedSubProducts": [
    {
      "id": null,
      "productId": "3d920ad6-e3a8-4d41-bbd5-24206bde721b",
      "productVariantId": "72ac5f19-15f5-48c5-94cc-2f6ced406cba",
      "price": {
        "unitPrice": 0,
        "additionalPrice": 0
      },
      "materialCost": {
        "unitPrice": 0,
        "additionalPrice": 0
      },
      "useOverridePrice": false,
      "position": 2,
      "quantity": 3
    }
  ],
  "updatedSubProducts": [
    {
      "id": "d9e1ad35-cb45-4161-8590-18a0ed5cae9f",
      "productId": "cf86aafb-29e7-4e57-a98e-46f3b0341547",
      "productVariantId": "8a547aed-2f0f-443a-a0a1-f3cbe9f5bc29",
      "price": {
        "unitPrice": 100,
        "additionalPrice": 0
      },
      "materialCost": {
        "unitPrice": 10,
        "additionalPrice": 0
      },
      "useOverridePrice": true,
      "position": 1,
      "quantity": 1
    }
  ],
  "deletedSubProducts": [
    "589488a8-a8f4-4f66-b047-5323a43ac892"
  ]
}
```

## Responses

| Status | Description |
| --- | --- |
| 200 | OK |
| 400 | Bad Request |
| 401 | Unauthorized |
| 404 | Not Found |

### 200 response (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | string or null | no |  |

#### Example (from schema)

```json
{
  "message": "string"
}
```

### 400 response (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | string or null | no |  |
| `errorCode` | string (uuid) | no |  |
| `additionalData` | any or null | no |  |

#### Delivery request is not valid

```json
{
  "message": "Delivery information is not valid!",
  "errorCode": "41fcedd1-dfef-4d0d-a5b3-2e28da7dfc9a",
  "additionalData": null
}
```

### 401 response (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | string or null | no |  |

#### Example (from schema)

```json
{
  "message": "string"
}
```

### 404 response (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | string or null | no |  |
| `errorCode` | string (uuid) | no |  |

#### Example (from schema)

```json
{
  "message": "string",
  "errorCode": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
```

## Example request

```bash
curl -X PUT "https://core-api.ancon.io/api/v1/Tenants/{tenantId}/Products/{productId}/SubProducts" \
  -H "Access-Token: $ANCON_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "addedSubProducts": [
    {
      "id": null,
      "productId": "3d920ad6-e3a8-4d41-bbd5-24206bde721b",
      "productVariantId": "72ac5f19-15f5-48c5-94cc-2f6ced406cba",
      "price": {
        "unitPrice": 0,
        "additionalPrice": 0
      },
      "materialCost": {
        "unitPrice": 0,
        "additionalPrice": 0
      },
      "useOverridePrice": false,
      "position": 2,
      "quantity": 3
    }
  ],
  "updatedSubProducts": [
    {
      "id": "d9e1ad35-cb45-4161-8590-18a0ed5cae9f",
      "productId": "cf86aafb-29e7-4e57-a98e-46f3b0341547",
      "productVariantId": "8a547aed-2f0f-443a-a0a1-f3cbe9f5bc29",
      "price": {
        "unitPrice": 100,
        "additionalPrice": 0
      },
      "materialCost": {
        "unitPrice": 10,
        "additionalPrice": 0
      },
      "useOverridePrice": true,
      "position": 1,
      "quantity": 1
    }
  ],
  "deletedSubProducts": [
    "589488a8-a8f4-4f66-b047-5323a43ac892"
  ]
}'
```
