PUT /api/v1/clients/client-id overwrites existing contacts

Hi,

When I want to add an additional contact, I use this API Call:

Method: PUT
Route: /api/v1/clients/client-id
Body:

{
  "contacts": [
    {
      "first_name": "Vorname2",
      "last_name": "Nachname2",
      "email": "email2@gmx.de",
      "is_primary": false,
      "phone": "+4930123456789"
    },
    {
      "first_name": "Vorname3",
      "last_name": "Nachname3",
      "email": "email@gmx.de",
      "is_primary": false,
      "phone": "+4930123456789"
    }
    {
      "first_name": "Vorname4",
      "last_name": "Nachname4",
      "email": "email@gmx.de",
      "is_primary": false,
      "phone": "+4930123456789"
    }
  ]
}

When there is already an existing contact for this client, then it will be overwritten by this API Call. In order to “fix” this, I need to use a GET /api/v1/clients/client-id Call to get all the client details and then combine the existing contact with my new contacts and update all at once at the client.

I know that this is “by design” but eventuelly you could overthink this and don’t overwrite existings contacts.

Thank you,
Gijs

Hi,

Thanks for reporting this!

cc @david

1 Like

@hillel, do we change the design here? contacts have always been deeply connected to the client and the API currently requires all contacts to be present in all client requests.

options include creating a dedicated contact route. so that existing functionality is preserved, and this type of functionality can be integrated.

My preference would be to use the id if it’s present, if not fall back to the email address.