Unsubscribe a user

Make a call to this endpoint to unsubscribe a user from a subscription type or channel. If no subscriptions are present in the request, the user is unsubscribed from all subscriptions. If subscriptions are present in the request, the user is unsubscribed from the requested type or channel combination(s). By default, if a subscription exists, but the user is already unsubscribed, it records the attempt to unsubscribe the subscription(s) again. For TEXT subscriptions, a message is sent to the person indicating that they are unsubscribed.

For the user object, the email data point determines which email subscriptions a user has and the phone data point determines which text (or sms) subscriptions a user has. Passing in an email does not locate, nor unsubscribe, a user from any sms subscriptions. Similarly, passing in a phone does not locate, nor unsubscribe, a user from any email subscriptions.

The following input fields are provided:

user - Required. The user being subscribed. Note that this is a visitor to the site and does not need to be actively subscribed to Attentive. An email, phone, or both can be provided.

subscriptions - Optional. Array of type/channel combinations indicating the desired subscriptions to remove.

notification - Optional notification properties to override. disable: true can be used to prevent a notification. Language can override english as the notification language. Takes standard language tags as defined by the ISO. Currently only supports en-US and fr-CA. Case sensitive, must match exactly.

The response will provide a list of channel/type combinations of the removed subscriptions.

Example Query

Make sure to set the Authorization: Bearer <Unique API Key> on the request. For more information about obtaining a unique API Key please see the Authentication Docs

POST https://api.attentivemobile.com/v1/graphql

Copy
Copied
mutation callUnsubscribe ($input: UnsubscribeInput!) {
  unsubscribe(input: $input) {
    unsubscribeResults {
      channel
      type
    }
  }
}

Example Input Variable

Copy
Copied
{
    "input": {
      "user": {
        "phone": "8606707777"
      },
      "subscriptions": [
        {
            "channel": "CHANNEL_TEXT",
            "type": "TYPE_MARKETING"
        }
      ]
    }
 }

Example Response

Copy
Copied
{
    "data": {
        "unsubscribe": {
            "unsubscribeResults": [
                {
                    "channel": "CHANNEL_TEXT",
                    "type": "TYPE_MARKETING"
                }
            ]
        }
    },
    "extensions": {
        "traceId": "00000"
    }
}