Get subscription eligibility for a user

The Attentive Graph supports queries to list all subscription types and channels a user is subscribed to, analogous to the GET /subscriptions REST endpoint.

You can use this endpoint to check if a subscriber is eligible to receive SMS or email campaigns. You can query for a subscriber using either their phone number or email. One of the query parameters is required in order to look up subscription eligibilities. You can query for one to many users at a time if you use aliases, as seen in the example. With GraphQl, you can also retrieve additional information about the user along with their subscription eligibilities.

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
query {
  viewer {
    installedApplication {
      installerCompany {
        phonesubscriber: user(phone: "5555555555") {
          subscriptions {
            subscriptionEligibilities {
              subscription {
                channel
                type
              }
              eligibility {
                isEligible
              }
            }
          }
        }
        emailSubscriber: user(email: "test@gmail.com") {
          subscriptions {
            subscriptionEligibilities {
              subscription {
                channel
                type
              }
              eligibility {
                isEligible
              }
            }
          }
        }
      }
    }
  }
}

Example Response

Copy
Copied
{
    "data": {
        "viewer": {
            "installedApplication": {
                "installerCompany": {
                    "phonesubscriber": {
                        "subscriptions": {
                            "subscriptionEligibilities": [
                                {
                                    "subscription": {
                                        "channel": "CHANNEL_TEXT",
                                        "type": "TYPE_MARKETING"
                                    },
                                    "eligibility": {
                                        "isEligible": false
                                    }
                                }
                            ]
                        }
                    },
                    "emailSubscriber": {
                        "subscriptions": {
                            "subscriptionEligibilities": [
                                {
                                    "subscription": {
                                        "channel": "CHANNEL_EMAIL",
                                        "type": "TYPE_TRANSACTIONAL"
                                    },
                                    "eligibility": {
                                        "isEligible": true
                                    }
                                },
                                {
                                    "subscription": {
                                        "channel": "CHANNEL_TEXT",
                                        "type": "TYPE_MARKETING"
                                    },
                                    "eligibility": {
                                        "isEligible": true
                                    }
                                },
                                {
                                    "subscription": {
                                        "channel": "CHANNEL_EMAIL",
                                        "type": "TYPE_MARKETING"
                                    },
                                    "eligibility": {
                                        "isEligible": true
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        }
    },
    "extensions": {
        "traceId": "0000"
    }
}