Problem with Consistency on two requests

Hello. In one scenario, our system makes two requests to Pipedrive, one instantly after the other. One is creating new Person, the other one should update it. Why’s and how’s are not important at the moment.
Facts are important and fact is that decision of creating / updating is based on response from:

$client->persons->findByName($email, ['search_by_name' => 1]);

If person is found then we do update, otherwise we do create.

Problem is that after first request user is indeed created, but when second request arrives (almost instantly after the first one), Pipedrive responds - no, there is no such Person, and user is created second time (with the same email). Looks like some problem with consistency between requests. Which is probably related to your infrastructure/internals (indexing/propagation/caching).

There are couple of questions here:

  1. Is there a method for “syncing” that would create / or update based on email?
  2. Is there an option to force “waiting” for some propagation / indexing? Which I could pass as an option.
  3. Alternatively what to you recommend to solve this problem? Timeout(??)
  4. And last one - why is that Pipedrive allows Person with same email twice or more in the first place?

Hey Luke,

It seems to me like using a webhook for new person.added which might be your best choice for updating once a Person is added.

As for the situation you’re finding yourself, findByName uses search and I believe that there is some cache going on there (it doesn’t go directly to database)
I’d suggest to use webhooks and listen
As for “same email twice”, there isn’t any simple answer to this other than that was how Pipedrive was originally setup - likely due to the usage of multiple people under 1 email (suppert@pipedrive type of thing).