Query list subscriptions
Use GraphQL to query list subscriptions for a specific customer.
To query list subscriptions for a specific customer, use thelist_member object to search for a specificlist_id. For example, if you have a newsletter list withlist_id = newsletter_list, you can run the following query to check if a customer is subscribed to that list.
customer(email: "[email protected]") { list_member(list_id: "newsletter_list") { subscribed } }You receive the following response:
{ "data": { "customer": { "list_member": { "subscribed": true } } }}You can also query list subscriptions for multiple lists by using aliases, shown below:
customer(email: "[email protected]") { newsletter_list: list_member(list_id: "newsletter_list") { subscribed } tv_list: list_member(list_id: "tv_hot_prices_list") { subscribed } }Which returns list subscription details in the response:
{ "data": { "customer": { "newsletter_list": { "subscribed": true }, "tv_list": { "subscribed": true } } }}If a user is not subscribed to the list that you query, you receive a null value in response. For example, if the customer is not subscribed to thelist_without_subscribers list and you make the following request:
customer(email: "[email protected]") { list_member(list_id: "list_without_subscribers") { subscribed } }The following result is returned:
{ "data": { "customer": { "list_member": null } }}📘
Requried field
list_idis required in thelist_memberobject.
Updated 27 days ago