Why does `verificationReasons` return an empty response for unverified Cards?

  • 18 December 2020
  • 6 replies
  • 15 views

Userlevel 3
Can anyone tell me why `verificationReasons` from the cards endpoints (both https://api.getguru.com/api/v1/cards/some-card-id and https://api.getguru.com/api/v1/cards/slug) sometimes returns as an empty array for unverified cards? I have a script that checks for cards that are unverified due to being stale, usually referred to as "EXPIRED" in verificationReasons.
Checking for expired works fine for most cards, but there are some instances where an expired card doesn't have this designation. I assume the information is coming from somewhere since the web app is able to render these cards as expired despite the empty array, but I'm not sure how. Can anyone point me in the right direction? Thanks for any help!

Mary Houston 3 years ago

Hey Dillon! Any card which is past its verification interval since its last verification (lastVerified date field returned on the card) will have an `EXPIRED` reason in the `verificationReasons` array. If the card was updated or requested before expiration then you will see multiple reasons for verification in the array but if its just from being stale then it will only contain `EXPIRED`

Would you be able to provide some Card IDs or share the JSON responses of the cards that have empty arrays (you can DM me the card IDs/responses directly for privacy purposes)? That will help troubleshoot!
View original

6 replies

Userlevel 4
Badge
Hey Dillon! Any card which is past its verification interval since its last verification (lastVerified date field returned on the card) will have an `EXPIRED` reason in the `verificationReasons` array. If the card was updated or requested before expiration then you will see multiple reasons for verification in the array but if its just from being stale then it will only contain `EXPIRED`
Would you be able to provide some Card IDs or share the JSON responses of the cards that have empty arrays (you can DM me the card IDs/responses directly for privacy purposes)? That will help troubleshoot!
Userlevel 3
Thanks Mary! Sent you the info.
Userlevel 4
Badge
Hey @dillon! Our backend engineers did some digging and found that an empty array will ALWAYS mean the card is `expired` due to time (i.e. past verification date). So for your script, perhaps you can add the reference to the empty array as well?
Userlevel 3
Ok cool, so I should check for expired or an empty array in verificationReasons. Thanks for looking into this, @mhouston. Really appreciate it!
Userlevel 4
Badge
yes! it was a great question/find.

Hey I've run into something similar while working with the Guru API. It seems that verificationReasons doesn't always populate as expected, particularly for expired cards.

One workaround I found was to also fetch the lastVerifiedDate attribute. You can compare this date to the card's expiration settings to determine if it's stale or not. It's not as straightforward as simply checking for "EXPIRED" in verificationReasons, but it can be a reliable alternative when that field is empty.

Another thing you might want to look into is the API rate limit or data cache, as sometimes stale or incomplete data might be served. But based on my experience, checking lastVerifiedDate was the most consistent way to go.

I agree that it's a bit weird how the web app seems to have that information while the API endpoint doesn't. Maybe they're using some internal logic that's not exposed via the API.

Hope this helps, and let me know if you find a better solution! 

Reply