---
title: "Assign a choice to a product"
method: POST
path: "/products/{product_id}/choices"
---

# Assign a choice to a product

`POST /products/{product_id}/choices`

## Request

- Base URL: `https://api.ecommerceapi.uk/v1`
- URL: `https://api.ecommerceapi.uk/v1/products/{product_id}/choices`
- Auth: HTTP basic

Assigns a choice (set + value) to a product, with optional custom price and cost price.

## Path parameters

- `product_id` integer, required

## Request body

- ProductChoiceCreate
  - `set` integer, required: ID of the choice set.
  - `value` integer, required: ID of the choice value.
  - `customPrice` number, float: Custom price for this product choice (optional).
  - `costPrice` number, float: Custom cost price for this product choice (optional).

## Response `201`

Product choice assigned successfully.

- ProductChoice
  - `id` integer: Unique ID of the product choice.
  - `set` object: The choice set.
    - `id` integer: ID of the choice set.
    - `name` string: Name of the choice set.
  - `value` object: The value from the choice set.
    - `id` integer: ID of the choice value.
    - `name` string: Name of the choice value.
  - `customPrice` number, float: Custom price for this product choice (overrides default).
  - `costPrice` number, float: Custom cost price for this product choice.

## Other responses

- `400`: Invalid request data.
- `401`: Unauthorized.
- `404`: Product or choice set/value not found.
- `422`: Validation error.

---

[API](https://skmtc.dev/ecommerceapi/apis/product-choices.md) - [All operations](https://skmtc.dev/ecommerceapi/apis/product-choices/llms.txt) - [OpenAPI document](https://skmtc.dev/ecommerceapi/apis/product-choices/revisions/97e33148c0e5?raw)
