Set the Product Category in GraphQL using the Taxonomy ID

Topic summary

A developer is attempting to set product categories in Shopify’s GraphQL productCreate mutation using the Taxonomy ID (e.g., 5173) instead of the full GID (e.g., gid://shopify/TaxonomyCategory/sg-4-17-2-17).

Current Status:

  • The mutation works successfully with the full GID format
  • The developer wants to simplify by using just the numeric Taxonomy ID

Community Response:

  • Eric-HAN confirmed that the category field is available in API version 2024-07 and above
  • Shared working GraphQL examples demonstrating the taxonomy category implementation
  • Included screenshots showing the mutation structure

Unresolved Question:

  • The original poster acknowledged the GID method works but remains uncertain whether using the Taxonomy ID directly (instead of the full GID) is still supported
  • No definitive answer yet on whether the numeric ID alone can be used in the mutation
Summarized with AI on November 7. AI used: claude-sonnet-4-5-20250929.

I am currently setting the product category on productCreate using the category GID (ex. snowboard is: gid://shopify/TaxonomyCategory/sg-4-17-2-17). I would like to use the Shopify Taxonomy ID instead (5173 in this case). I can’t figure how to specify this in GraphQL. Any ideas? Here is the working mutation with the GID:

# GraphQL mutation for creating a product
mutation = '''
mutation CreateProduct($input: ProductInput!) {
  productCreate(input: $input) {
    product {
      id
      title
      vendor
      descriptionHtml
      productType
      tags
      category {
       id
      }
    }
    userErrors {
      field
      message
    }
  }
}
'''

# Variables for the mutation
variables = {
    "input": {
        "title": "Café Racer",
        "vendor": "Korua",
        "descriptionHtml": "A Fantastic Snowboard",
        "productType": "Snowboard",
        "tags": ["winter", "2025"],
        "category": "gid://shopify/TaxonomyCategory/sg-4-17-2-17"
    }
}

HI, there

which API version you use?

2024-07 and above category is available.

Here is my graphql below

Thanks Eric. I can get it to work that way too (using taxonomy category)!
What I am trying to achieve is get it to work using the taxonomy ID instead.
Not sure if this method is supported anymore.