createUOM
Requires permission products:product:create.
Create a unit of measure. The code must be unique in the organization, ignoring case. A COUNT unit must have 0 decimal places and cannot allow fractions. Marking the unit as base clears the base flag from the category's current base unit. Needs the products create permission.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation CreateUOM($data: CreateUOMInput!) {
createUOM(data: $data) {
id
code
colorCode
name
pluralName
createdAt
conversionFrom {
id
createdAt
conversionFactor
deletedAt
deletedBy
enteredBy
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CreateUOM($data: CreateUOMInput!) {\n createUOM(data: $data) {\n id\n code\n colorCode\n name\n pluralName\n createdAt\n conversionFrom {\n id\n createdAt\n conversionFactor\n deletedAt\n deletedBy\n enteredBy\n }\n }\n}",
"variables": {
"data": {
"allowFractional": true,
"category": "AREA",
"code": "string",
"decimalPlaces": 0,
"displayOrder": 0,
"isBase": true,
"name": "string",
"symbol": "string"
}
}
}
EOF
Variables:
{
"data": {
"allowFractional": true,
"category": "AREA",
"code": "string",
"decimalPlaces": 0,
"displayOrder": 0,
"isBase": true,
"name": "string",
"symbol": "string"
}
}
Response:
{
"data": {
"createUOM": {
"id": "id",
"code": "string",
"colorCode": "string",
"name": "string",
"pluralName": "string",
"createdAt": "2025-01-15T00:00:00Z",
"conversionFrom": [
{
"id": "id",
"createdAt": "2025-01-15T00:00:00Z",
"conversionFactor": 0,
"deletedAt": "2025-01-15T00:00:00Z",
"deletedBy": "string",
"enteredBy": "string"
}
]
}
}
}
createUOM(
data: CreateUOMInput!
): UnitOfMeasure!
Arguments
createUOM.data ● CreateUOMInput! non-null input
The unit to create.
Type
UnitOfMeasure object
A unit of measure in the organization's catalog, with its category, decimal rules and display settings.