Find or Create

To save some roundtrips to the API you should consider implementing some sort of “Find or Create” endpoints. Especially for persons and companies.

The “Find Or Create method” will attempt to locate a database record using the given column / value pairs. If the model can not be found in the database, a record will be inserted with the attributes resulting from merging the first array argument with the optional second array argument.

Something like if it doesn’t find a record with the email some@email.com, it will create a new person with the second array:

Persons->findOrCreate(
[“email” => “some@email.com”],
[“name” => “Some name”, “email” => [[“value” => “some@email.com”, “primary” => true]], “phone” => [[“label” => “mobile”, “value” => “+4712341234”, “primary” => true]], “visible_to” => 7]
)

And return a person instance.

And you should have the possibility to chain on creating f.ex. a lead and attach products to it in the same call.

!'m sorry if this is already possible. I have only had the pleasure of reading the docs for the last 2-3 hours. I’m new to Pipedrive :slight_smile: