How do I add a contact without overwriting previous contacts on the client account

Hi,

I am using the following url to search if a contact’s email exist and to retrieve the ID

url:${this.invoice_ninja.$auth.domain}/api/v1/clients/?email=${contactEmail},

Recently, for two accounts where the contact existed, it returned 0 records. This led to a downstream function creating the contact on the client. However, instead of adding the contact to the client, this endpoint overwrote all contacts on the client leading to just one contact now on the account. Invoice Ninja API Spec (invoicing.co)

let clientData = {
                    "contacts": contact_props
                }

                var updateClient = await axios($, {
                    url: `${this.invoice_ninja.$auth.domain}/api/v1/clients/${client_id}`,
                    method: 'put',
                    headers: {
                        "X-api-Token": `${this.invoice_ninja.$auth.api_token}`,
                        'Content-Type': 'application/json'
                    },
                    data: clientData
                })

Am I sending this wrong, how do I add a contact without overwriting previous contacts on the client account.

Hi,

I believe you’d need to send back all current contacts with the request.

Many thanks for the reply.

By doing that, I am guessing the previous ID will be deleted and a new one will be set, am I right? I need a way to make sure the ID doesnt change for other contacts because an integration is dependent on those IDs.

Is this possible?

That’s correct. If you send back all of the existing contacts with the request the id’s won’t change.