Create a contact attribute

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

The maximum number of attributes in the audience is 2000.

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

ArgumentNested field - level 1Nested field - level 2ValuesDefinition
wheredataSetIdIDThe ID of the audience to update
toattributescreateObject or array of objectsThe changes you want to make

Here are the fields supported by the create object.

FieldNested fieldValuesRequired?Definition
categoryStringOptional Assigns an attribute to a category.

💡Use the Get all categories query to get the list of available values.
decimalPrecisionIntegerOptionalThe number of decimal places to display. Applies to numeric attributes.
identifyAschannelsEnumeration or array. Valid values:

- EMAIL
- SMS
- WHATSAPP
OptionalMarks an attribute (Phone number or Email address) as addressable and ties it to the respective communication channel.
keyBoolean. Default value - false.OptionalMarks an attribute as key. The key attribute stores unique identifiers for contacts.
nameString (case-sensitive)RequiredThe name to assign to the new contact attribute. The name must be unique within the audience.
typeEnumeration. Valid values:

- TEXT
- NUMBER
- BOOLEAN
- DATE
RequiredThe data format of the attribute

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.

💡You can map the Phone number attribute to two channels: WhatsApp and SMS.

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

If your audience was created without a key attribute, you can add this attribute any time later. Use the key field for this purpose. Other values to submit:

  • name: any string
  • type: TEXT
  • category: skip this field or submit Contact information (it's the default value for the key attribute)

⚠️ Once added, the key attribute cannot be removed from the audience.

mutation {
  updateDataSet(
    where: { dataSetId: "4fe4136f-c007-44a3-b38f-92220xxxxxxxx" }
    to: {
      attributes: {
        create: {
          name: "Contact key"
          type: TEXT
          identifyAs: { key: true }
        }
      }
    }
  ) {
    dataSetId
  }
}
{
  "data": {
    "updateDataSet": {
      "dataSetId": "4fe4136f-c007-44a3-b38f-92220xxxxxxxx"
    }
  }
}

Fields

Fields returned by 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 in the audience.
KEY_CATEGORY_NOT_ALLOWEDThis error appears if you try to add the Contact key attribute and assign it to a category other than Contact information.

💡 Change the category value to Contact information or remove the field from the mutation.
KEY_CREATION_NOT_ALLOWED The audience already has a key attribute.