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

# Create a rule

> Create a rule

### Request body

`CreateConversionRuleRequest`

<ParamField body="factor" type="string" required>
  Multiplier (`to_qty = from_qty × factor`) as a string.
</ParamField>

<ParamField body="from_uom_id" type="string" required />

<ParamField body="product_id" type="string,null" />

<ParamField body="rule_type" type="string" required>
  `SYSTEM` (global) or `SKU` (product-specific).
</ParamField>

<ParamField body="to_uom_id" type="string" required />

### Responses

<ResponseField name="201" type="ConversionRuleResponse" />

<ResponseField name="400" type="ErrorBody" />

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.stateset.com/api/v1/unit-conversion-rules' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "factor": "string",
    "from_uom_id": "string",
    "product_id": null,
    "rule_type": "string",
    "to_uom_id": "string"
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "factor": "string",
    "from_uom_id": "string",
    "id": "string",
    "product_id": null,
    "rule_type": "string",
    "to_uom_id": "string"
  }
  ```
</ResponseExample>
