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.