To update consent statuses for your contacts, use the updateContacts
mutation.
You can do it by adding contacts to respective consent groups or by specifying their preferences on a per-channel basis. The way you format these mutations depends on the approach your marketing team pursues.
Option A: update statuses within a consent group
The following example demonstrates how to add a contact to several consent groups or to update existing statuses within a consent group. Note that we set the OPT_IN
status for the first consent group. In the second consent group, we limit preference to a particular channel within the consent group (EMAIL
).
mutation {
updateContacts(
dataSetId: "4fe4136f-c007-44a3-b38f-92220xxxxxxxx"
updateContactInputs: [
{
key: "PISCX-098724242477"
to: {
consent: {
consentGroups: [
{
consentGroupId: "97660d76-02d8-5fd6-xxxx-000000000000"
status: OPT_IN
}
{
consentGroupId: "97660d76-02d8-5fd6-xxxx-000000000010"
channels: [{ channel: EMAIL, status: OPT_IN_UNVERIFIED }]
}
]
}
}
}
]
) {
modifiedCount
}
}
{
"data": {
"updateContacts": {
"modifiedCount": 1
}
}
}
Option B: update consent statuses per channel
In this example, we will subscribe one contact to emails and unsubscribe another one from text messages.
mutation {
updateContacts(
dataSetId: "4fe4136f-c007-44a3-b38f-92220xxxxxxxx"
updateContactInputs: [
{
key: "PISCX-098724242477"
to: {
attributes: [
{ name: "Email", value: "[email protected]" }
]
consent: { channels: { channel: EMAIL, status: OPT_IN } }
}
}
{
key: "PISCX-032724242417"
to: {
consent: { channels: { channel: SMS, status: OPT_OUT } }
}
}
]
) {
modifiedCount
}
}
{
"data": {
"updateContacts": {
"modifiedCount": 2
}
}
}
Arguments
Arguments supported by the updateContacts
object:
Argument | Values | Required? | Definition |
---|---|---|---|
dataSetId | ID | Required | The ID of your audience |
updateContactInputs | Array | Optional | See nested fields below. |
Optional fields nested inside the updateContactInputs
argument:
Field | Nested field | Values | Definition |
---|---|---|---|
key | String | The unique identifier of the contact in your audience | |
to | consent | Array | See nested fields below. |
Input fields nested inside the consent
field:
Field | Nested field - level 1 | Nested field - level 2 | Values | Definition |
---|---|---|---|---|
channels | channel | Either of the following values: - EMAIL - SMS | The type of communication channel | |
status | One of the following values: - OPT_IN - OPT_OUT - OPT_IN_UNVERIFIED - null | Indicates if the contact has agreed to receive communication through the channel. | ||
consentGroups | channels | channel | Either of the following values: - EMAIL - SMS | The communication channel associated with the consent group |
status | One of the following values: - OPT_IN - OPT_OUT - OPT_IN_UNVERIFIED - null | The contact's consent status in relation to the communication channel | ||
consentGroupId | String | The ID of the consent group the contact has been added to | ||
status | One of the following values: - OPT_IN - OPT_OUT - OPT_IN_UNVERIFIED - null | The contact's status within the consent group (applies to all of its channels) |
Fields
Fields returned by the updateContacts
mutation:
Field | Values | Required? | Definition |
---|---|---|---|
modifiedCount | Integer | Required | The number of contacts that have been updated |
Possible error messages
Error code | Definition |
---|---|
INVALID_CHANNEL_TYPE | |
INVALID_CONSENT_FIELD_NAME | |
CONSENT_GROUP_NOT_FOUND | |
CHANNEL_NOT_DEFINED | |
CONSENT_UPDATE_FOR_UNSET_ATTRIBUTE | |
CHANNELS_DUPLICATE_PROVIDED | |
CHANNELS_ALREADY_ASSIGNED | |
CONTACT_NOT_FOUND_BY_KEY | A contact with the specified key is not available in the audience. Use the Get all contacts query to get the list of existing contacts. |