To create a new contact attribute, use the updateDataSet mutation. You must submit the type of operation (create) as an argument.

mutation {
  updateDataSet(
    where: { dataSetId: "4fe4136f-c007-44a3-b38f-92220xxxxxxxx" }
    to: {
      attributes: {
        create: {
          name: "Delivery address"
          type: TEXT
          category: "Contact information"
        }
      }
    }
  ) {
    dataSetId
  }
}
{
  "data": {
    "updateDataSet": {
      "dataSetId": "4fe4136f-c007-44a3-b38f-92220xxxxxxxx"
    }
  }
}

Use an array to create multiple contact attributes simultaneously.

mutation {
  updateDataSet(
    where: { dataSetId: "4fe4136f-c007-44a3-b38f-92220xxxxxxxx" }
    to: {
      attributes: {
        create: [
          { name: "Last order", type: DATE, category: "Demographic" }
          { name: "Avg. order amount", type: NUMBER, category: "Demographic", decimalPrecision: 0 }
        ]
      }
    }
  ) {
    dataSetId
  }
}
{
  "data": {
    "updateDataSet": {
      "dataSetId": "4fe4136f-c007-44a3-b38f-92220xxxxxxxx"
    }
  }
}

Arguments

Arguments required by the updateDataSet object

Argument nameNested fieldValuesDefinition
wheredataSetIdIDThe ID of the audience to update
toattributesSee nested fieldsThe changes you want to make

You must nest the create field into attributes. Here are the fields you can nest into attributes > create.

Nested field - level 1Nested field - level 2ValuesRequired?Definition
nameString (case-sensitive)

The name must be unique within the dataset.
RequiredThe name to assign to the new contact attribute
categoryString

Use the Get all categories query to get the list of supported values.
Optional The name of a new category for the contact attribute.
typeOne of the following values:

- TEXT
- NUMBER
- BOOLEAN
- DATE
RequiredThe data format of the attribute
decimalPrecisionIntegerOptional Number of decimal places to display. Applies to numeric attributes
identifyAschannelsOne of the following values:

- EMAIL
- SMS
Required for primary contact informationMarks a phone number or an email as addressable and ties it to a communication channel.

Note on attributes related to contact information

When creating an attribute for contact information, you can specify which channel it applies to. The attribute will be marked as addressable in the system and tied to consent.

mutation {
  updateDataSet(
    where: { dataSetId: "4fe4136f-c007-44a3-b38f-92220xxxxxxxx" }
    to: {
      attributes: {
        create: {
          name: "Cell phone"
          type: TEXT
          category: "Contact information"
          identifyAs: {
          channels: SMS
        }
        }
      }
    }
  ) {
    dataSetId
  }
}
{
  "data": {
    "updateDataSet": {
      "dataSetId": "4fe4136f-c007-44a3-b38f-92220xxxxxxxx"
    }
  }
}

Fields

Fields returned the updateDataSet mutation

FieldValuesRequired?Definition
dataSetIdIDRequiredThe ID of your audience

Possible error messages

Error codeDefinition
ATTRIBUTE_ALREADY_EXISTSAn attribute with the same name is already available.
ORDERED_ATTRIBUTES_SIZE_EXCEEDED
INVALID_ATTRIBUTE_VALUE