Creating Categories
Inside this guide:
Introduction
Create a Category
Next steps
Introduction
The createCoreProductCategory mutation allows you to create a Category.
Create a Category
Constructing the mutation and input
We'll be using the API Console to save time having to authenticate. Copy and paste this into your API console query section to get started. Reminder that fields can be removed from the query if you don't want the API to return them.
POST /graphql
Query
mutation ($input: CreateCoreProductCategoryInput!) {
createCoreProductCategory(input: $input) {
coreProductCategory {
id
name
}
errors {
path
message
}
}
}
Defining the variables
Copy and paste the block below into the query variables section of the API console and substitute the ACCOUNT_ID with the account id you want to associate with the category, keep in mind this needs to be a parent company account id and not a division account id.
Variables
{
"input": {
"accountId": ACCOUNT_ID,
"name": "Electronics"
}
}
Now press Execute Query (the play button) to send the request.
You should get back this response containing the category you created.
JSON Response
{
"data": {
"createCoreProductCategory": {
"coreProductCategory": {
"name": "Electronics",
"id": "73c513ce-c584-46e4-9c51-ddb7aba22575"
},
"errors": null
}
}
}
Next Steps
- Create Category - Learn how to create a category
- Query Category - Learn how to query a category
- Update Category - Learn how to update a category
- Delete Category - Learn how to delete a category
- Making your first call - If you're not sure how GraphQL works, start here.