# Unit Handling Tutorial

### How to add a new unit

To add a new measurement unit to your configuration, you need to send a request to the [Adding a new unit](https://emporix.gitbook.io/documentation-portal/api-references/api-guides-and-references/configuration/unit-handling-service/api-reference/unit-conversion#put-unit-handling-tenant-units-convert-unit-commands) endpoint.

{% hint style="warning" %}
Unit names are localized. When creating a new unit, you can specify the unit name in two different ways — in one language or in multiple languages.

Looking for more info on localization? Check out [*Standard practices*](https://github.com/emporix/api-references/blob/main/content/standard-practices/README.md).
{% endhint %}

{% hint style="success" %}
To test the endpoint, open the API reference below or check the example of a curl request.
{% endhint %}

{% content-ref url="api-reference" %}
[api-reference](https://developer.emporix.io/api-references/~/changes/115/api-guides-and-references/configuration/unit-handling-service/api-reference)
{% endcontent-ref %}

```bash
curl -L \
  --request POST \
  --url 'https://api.emporix.io/unit-handling/{tenant}/units' \
  --header 'Content-Language: fr' \
  --header 'Content-Type: application/json' \
  --data '{
    "code": "kg",
    "name": "kilogram",
    "type": "mass",
    "baseUnit": true,
    "symbol": "kg",
    "factor": 1
  }'
```

### How to convert units

You can convert between any measurement units that share the same base unit, such as kilograms to grams, or centimeters to meters.

To convert between units, you need to send a request to the [Converting units ](https://github.com/emporix/api-references/blob/main/configuration/unit-handling-service/broken-reference/README.md)endpoint.

{% hint style="success" %}
To test the endpoint, open the API reference below or check the example of a curl request.
{% endhint %}

[https://github.com/emporix/api-references/blob/main/configuration/unit-handling-service/broken-reference/README.md](https://github.com/emporix/api-references/blob/main/configuration/unit-handling-service/broken-reference/README.md "mention")

<pre class="language-bash"><code class="lang-bash">curl -L \
<strong>  --request PUT \
</strong>  --url 'https://api.emporix.io/unit-handling/{tenant}/units/convert-unit-commands' \
  --header 'Content-Type: application/json' \
  --data '{
    "commandUuid": "text",
    "input": {
      "sourceUnitAmount": 100,
      "sourceUnit": "g",
      "targetUnit": "kg"
    }
  }'
</code></pre>
