Use the dataSets object to get information about your audience.

  • The name and ID of your audience. The ID is required for mutations.
  • The names and IDs of consent groups in your audience. The IDs are necessary for updating contacts' consent statuses.
  • The contact attributes available in your audience. You may need them for adding and updating contacts.
  • The reference sets directly connected to your audience. To get the list of all reference sets in your Connect subscription, see Query reference sets.

Getting the audience profile

Here is how to check basic information about your audience (name, ID and consent groups).

query {
    dataSets(filter: [{ field: "type", eq: "AUDIENCE" }]) {
    nodes {
      dataSetId
      name
      consentGroups {
        id
        name
      }
    }
  }
}
{
  "data": {
    "dataSets": {
      "nodes": [
        {
          "dataSetId": "123456789-0000000000000000000",
          "name": "Demo audience",
          "consentGroups": [
            {
              "id": "1111111111-0000-00000-00000000000",
              "name": "Newsletters"
            },
            {
              "id": "1111111111-0000-00000-00000000000",
              "name": "Promotions"
            },
            {
              "id": "1111111111-0000-00000-00000000000",
              "name": "Information"
            },
            {
              "id": "1111111111-0000-00000-00000000000",
              "name": "Custom"
            }
          ]
        }
      ]
    }
  }
}

Arguments

Arguments supported by the dataSets object

ArgumentNested fieldValuesDefinition
filterfieldString. Valid value: type.You can use this filter for other fields as well, but in the current query it is important to specify the type of the dataset you need.

⚠️If you omit this filter, you will get both the audience and reference sets in the response.
eqString. Valid value:
AUDIENCE.
The value that the type field must be equal to.

Fields

The query returns the fields nested into the nodes field

FieldNested fieldValuesRequired?Definition
dataSetIdIDRequiredThe ID of an audience (assigned automatically)
nameStringOptionalThe name of the audience
typeString. Valid value:AUDIENCE.OptionalThe type of the dataset you are querying
consentGroupsidIDOptionalThe ID of a consent group
nameStringOptionalThe name of a consent group

Possible error messages

Error codeDefinition
CONSENT_GROUPS_FOR_DATASET_NOT_DEFINEDThere are no consent groups in the audience at the moment.

Getting contact attributes

Contact attributes are the fields that modify contacts in your audience (name, email address, location, age group and so on). You can get them using the attributes field.

query {
  dataSets(filter: [{ field: "type", eq: "AUDIENCE" }]) {
    nodes {
      attributes {
        name
        type
        category
        identifyAs {
          key
          channels
        }
      }
    }
  }
}
{
  "data": {
    "dataSets": {
      "nodes": [
        {
          "attributes": [
            {
              "name": "Unique ID",
              "type": "TEXT",
              "category": "Contact information",
              "identifyAs": {
                "key": true,
                "channels": null
              }
            },
            {
              "name": "Email Address",
              "type": "TEXT",
              "category": "Contact information",
              "identifyAs": {
                "key": null,
                "channels": [
                  "EMAIL"
                ]
              }
            },
            {
              "name": "SMS Phone Number",
              "type": "TEXT",
              "category": "Contact information",
              "identifyAs": {
                "key": null,
                "channels": [
                  "SMS"
                ]
              }
            },
            {
              "name": "First Name",
              "type": "TEXT",
              "category": "Contact information",
              "identifyAs": null
            },
            {
              "name": "iPhone user",
              "type": "BOOLEAN",
              "category": "Demographic",
              "identifyAs": null
            },
            {
              "name": "Opt-In Date",
              "type": "DATE",
              "category": "Demographic",
              "identifyAs": null
            }
          ]
        }
      ]
    }
  }
}

Arguments

Arguments supported by the dataSets object

ArgumentNested fieldValuesDefinition
filterfieldString. Valid value: type.You can use this filter for other fields as well, but in the current query it is important to specify the type of the dataset you need.

⚠️If you omit this filter, you will get both the audience and reference sets in the response.
eqString. Valid value:
AUDIENCE.
The value that the type field must be equal to.

Fields

The query returns the fields nested into the nodes field

FieldValuesDefinition
attributesObjectAn object containing contact attributes

Fields nested into the attributes field

FieldNested fieldValuesDefinition
nameStringThe name of an attribute
typeOne of the following values:

- TEXT
- NUMBER
- BOOLEAN
- DATE
The data format of an attribute
decimalPrecisionInteger from 0 to 14.

For non-numeric fields, the value is null.
The number of decimal places displayed. Applies to numeric values only
category StringThe category that an attribute belongs to.

Query the dataSetAttributeCategories object to get all available attribute categories.
identifyAskeyBoolean

- true. The attribute acts as a key value in the dataset.
- false. The attribute is marked as addressable.
- null. The attribute is neither a key value, nor an addressable.
Lets you check if an attribute acts as a key value in the dataset or is marked as addressable.
channelsEither of the following values:

- EMAIL
- SMSApplies to attributes marked as addressable.
Communication channel. Applies to addressable attributes (the key value for them is false).

Getting connected reference sets

To get the reference sets connected to your audience, use the associations field in the dataSets query. Note that this query returns only those reference sets that are connected to the audience directly, not through another reference set.

query  {
  dataSets(filter: [{ field: "type", eq: "AUDIENCE" }]) {
    nodes {
      associations {
        to {
          dataSetId
          name
        }
        mappings {
          fromAttribute
          toAttribute
        }
      }
    }
  }
}
{
  "data": {
    "dataSets": {
      "nodes": [
        {
          "associations": [
            {
              "to": {
                "dataSetId": "e83a688c-e53e-4a1c-8565-0000000001",
                "name": "Physical store clients"
              },
              "mappings": [
                {
                  "fromAttribute": "Unique ID",
                  "toAttribute": "ID"
                }
              ]
            },
            {
              "to": {
                "dataSetId": "b4fc145e-680a-4fc6-9d7a-0000000000002",
                "name": "Focus group participants"
              },
              "mappings": [
                {
                  "fromAttribute": "Unique ID",
                  "toAttribute": "ID"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}

Arguments

Arguments supported by the dataSets object

ArgumentNested fieldValuesDefinition
filterfieldString. Valid value: type.You can use this filter for other fields as well, but in the current query it is important to specify the type of the dataset you need.

⚠️If you omit this filter, you will get both the audience and reference sets in the response.
eqString. Valid value:
AUDIENCE.
The value that the type field must be equal to.

Fields

The query returns the fields nested into the nodes field

FieldValuesRequired?Description
associationsObjectOptionalSee nested fields

Fields nested into to associations field

FieldNested fieldRequired?Definition
todataSetIdOptionalThe ID of the reference set connected to your audience
nameOptionalThe name of the reference set connected to your audience
mappingsfromAttributeOptionalThe attribute in the audience that has been linked to a reference set
toAttributeOptionalThe attribute in a reference set that has been linked to the audience