Solved

Contacts list API q parameter

  • 27 March 2023
  • 4 replies
  • 61 views

Badge +3

I am attempting to query the contacts list api and including a parameter to only get contacts updated in the last 3 days.   

I understand how to construct the UNIX time stamp (I think.)

My question is when I do the curl command below and update a single contact in our testing instance of Front I get back all contacts no matter the updated_at date.  Am I misunderstanding how the q works and should I only get a list of the ones that have been updated?

curl --request GET \
--url 'https://api2.frontapp.com/contacts?q=\[update_after\]=1679933002.000' \
--header 'accept: application/json' \
--header 'authorization: Bearer <token>'

Result for contact when it has not been updated

"updated_at": 1679932512.707,

Result for contact after I update it

"updated_at": 1679933920.514,

In both cases I am still getting a list of all contacts.

icon

Best answer by jason 27 March 2023, 20:03

View original

4 replies

Userlevel 4
Badge +7

Hi Tom,

There’s a minor mistake in how you’re using the q query param. You’re setting the value of q to [update_after]

What we want to do is set the value of q[update_after] to the timestamp. The following snippet should have the effect you’re looking for:

curl --request GET \
--url 'https://api2.frontapp.com/contacts?q\[update_after\]=1679933002.000' \
--header 'accept: application/json' \
--header 'authorization: Bearer <token>'

Let me know how that goes!

Badge +3

Hi Jason,

Thanks for the reply.

The curl command is updated to

curl --request GET \
--url 'https://api2.frontapp.com/contacts?q\[update_after\]=1679931601.000' \
--header 'accept: application/json' \
--header 'authorization: Bearer <token>'

I am still getting back every result including the one I have updated.  Should this be returning only the results that match (in my case 1 match?)

Userlevel 4
Badge +7

🤦‍♂️ Sorry I didn’t spot this sooner - we have a typo!

 

The param is updated_after, not update_after - I think editing this should fix the issue 🤞

Badge +3

That fixed it.  Thank you.

 

For any future readers make sure to double-check the spelling :)

Reply