createProduct
Requires permission products:product:create.
Creates a product with its variants. Setting opening stock needs the permission to adjust stock. Requires permission to create products.
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 CreateProduct($input: CreateProductInput!) {
createProduct(input: $input) {
id
name
status
createdAt
basePrice
baseUOMId
baseUOM {
id
code
colorCode
name
pluralName
createdAt
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation CreateProduct($input: CreateProductInput!) {\n createProduct(input: $input) {\n id\n name\n status\n createdAt\n basePrice\n baseUOMId\n baseUOM {\n id\n code\n colorCode\n name\n pluralName\n createdAt\n }\n }\n}",
"variables": {
"input": {
"imageUrls": [
"string"
],
"name": "string",
"status": "ACTIVE",
"tags": [
"string"
]
}
}
}
EOF
Variables:
{
"input": {
"imageUrls": [
"string"
],
"name": "string",
"status": "ACTIVE",
"tags": [
"string"
]
}
}
Response:
{
"data": {
"createProduct": {
"id": "id",
"name": "string",
"status": "ACTIVE",
"createdAt": "2025-01-15T00:00:00Z",
"basePrice": 0,
"baseUOMId": "id",
"baseUOM": {
"id": "id",
"code": "string",
"colorCode": "string",
"name": "string",
"pluralName": "string",
"createdAt": "2025-01-15T00:00:00Z"
}
}
}
}
createProduct(
input: CreateProductInput!
): Product!
Arguments
createProduct.input ● CreateProductInput! non-null input
The details of the product and its variants.
Type
Product object
A product: the master record with its variants, categories, units of measure and stock.