Search code examples
sendgrid

Error - unknown identifier: "opens_count"


I am trying to get records with following filter: status -> delivered, query -> last_event_time between 2 datetime, opens_count more than 1, and custom subject message.

part of request:

Array
(
    [status] => delivered
    [query] => last_event_time BETWEEN TIMESTAMP '2022-03-25T00:00:00.000Z' AND TIMESTAMP '2022-03-25T23:59:59.000Z' AND opens_count >= 1 AND subject LIKE "query string%"
    [limit] => 2
)

response:

Array
(
    [errors] => Array
        (
            [0] => Array
                (
                    [message] => unknown identifier: "opens_count"
                    [field] => query
                )

        )

)

I see opens_count is not in list of available filters.

I am using SendGrid-PHP library. My code is working fine if I remove opens_count filter, but then it returns all records including opens_count with 0.

How can I get records opened more than 1 time?


Solution

  • I see opens_count is not in list of available filters.

    You've very much diagnosed your own issue here. opens_count is not an available filter, so you can't filter by it in an API request.

    In this case you are probably best served by dropping the opens_count filter from the API request and filtering out the messages that have an opens_count of 0 once you have fetched them all.