Contacts deleted in Infusionsoft do not have their referrals deleted

This is not strictly about the API, however I am using the API to work with referrals and have run into a problem.

I have setup a system to sync referral records in infusionsoft to our website’s database so we can do something with the data then upload changes to the contact or trigger campaigns based on the referrals. The syncing works well and updating / triggering works well enough. However I have discovered 2 things when it comes to referrals.

  1. When a contact with referrals is deduplicated in infusionsoft, infusionsoft DOES change the referral’s contact id to match the deduplicated contact. This is good, however your syncing needs to take this into account in that you have to make sure you update those referral records, otherwise you get errors later if updating or triggering something based on the contact id because the old contact id no longer exists.

  2. When a contact with referrals is deleted in infusionsoft, infusionsoft DOES NOT delete the referrals, which is a huge problem as you run into the problem from 1, that you may try to preform an action on a contact id that no longer exists.

I am able to handle when the error happens with a try/catch, however this error will re-occur ever time you do anything that involves those referrals.

Is this expected behavior in that infusionsoft is not deleting the referrals when a contact is deleted (regardless of the method)? Unfortunately the API does not allow us to remove or update referrals via the api, you can only read and add.

The reason the referral is not deleted is because there may be transactions that have to remain having already happened and deleting them would remove their relative reference.

By transactions, are you referring to “Invoices” / “Jobs”?

Looking at the table schema (https://developer.infusionsoft.com/docs/table-schema/), near as I can tell no other table has a reference to the “Referral” table. There are tables that look like they reference the “Affiliate” table, and I think that is what Invoices/Jobs/Leads are pointing to?

If nothing else is directly referencing the Referral table, then why keep them around when a contact is deleted? Or am I missing something?

There are tables not exposed and I’m thinking more in regards to referral ledgers (payouts/clawbacks etc)