findOrCreateUOM
Requires permission products:product:create.
Find a unit of measure by name, ignoring case, or create it. A new unit gets the CUSTOM category, a code and symbol built from the name, and whole-number quantities. Used when importing product sheets. 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 FindOrCreateUOM($name: String!) {
findOrCreateUOM(name: $name) {
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 FindOrCreateUOM($name: String!) {\n findOrCreateUOM(name: $name) {\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": {
"name": "string"
}
}
EOF
Variables:
{
"name": "string"
}
Response:
{
"data": {
"findOrCreateUOM": {
"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"
}
]
}
}
}
findOrCreateUOM(
name: String!
): UnitOfMeasure!
Arguments
findOrCreateUOM.name ● String! non-null scalar
The unit's name. It is matched ignoring case and surrounding spaces.
Type
UnitOfMeasure object
A unit of measure in the organization's catalog, with its category, decimal rules and display settings.