Creating Attributes

Inside this guide:
Introduction
Create an Attribute
Next steps

Introduction

The createCoreProductAttribute mutation allows you to create an Attribute.

Create an Attribute

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: CreateCoreProductAttributeInput!) {
    createCoreProductAttribute(input: $input) {
        coreProductAttribute {
            id
            name
            type
        }
        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 attribute, keep in mind this needs to be a parent company account id and not a division account id.

NOTE: The below block is creating an attribute of type TEXT, other supported types are NUMBER and DATE. Variables


{
  "input": {
    "accountId": ACCOUNT_ID,
    "name": "Electronics",
    "type" : "TEXT"
  }
}

Now press Execute Query (the play button) to send the request.

You should get back this response containing the attribute you created.

JSON Response

{
  "data": {
    "createCoreProductAttribute": {
      "coreProductAttribute": {
        "id": "73c513ce-c584-46e4-9c51-ddb7aba22575",
        "name": "Electronics",
        "type": "TEXT"
      },
      "errors": null
    }
  }
}

Next Steps