# Filter Contacts and Companies

**URL:** <https://integration.keap.com/t/filter-contacts-and-companies/93327>\
**Category:** API Q&A\
**Tags:** api, xml-rpc\
**Created:** [November 6, 2024, 3:51pm UTC](https://integration.keap.com/t/filter-contacts-and-companies/93327 "2024-11-06T15:51:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uriel\_Gonzalez](https://avatars.discourse-cdn.com/v4/letter/u/ecccb3/32.png) [@Uriel\_Gonzalez](https://integration.keap.com/u/Uriel_Gonzalez)\
**Post date:** [November 6, 2024, 3:51pm UTC](https://integration.keap.com/t/filter-contacts-and-companies/93327/1 "2024-11-06T15:51:23Z")

</div>

Hi,

With Infusionsfot XML RPC API ContactService.findByEmail method: How do I differentiate between a Company and a Contact? I was expecting to receive a ContactType for each Contact, but it’s not present

Or is this possible with the new API?

---

<div class="post-metadata">

**Author:** ![Marion\_Dorsett2](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/marion_dorsett2/32/14894_2.png) [@Marion\_Dorsett2](https://integration.keap.com/u/Marion_Dorsett2)\
**Post date:** [November 6, 2024, 4:35pm UTC](https://integration.keap.com/t/filter-contacts-and-companies/93327/2 "2024-11-06T16:35:05Z")

</div>

The ContactService.findByEmail will always return a contact. If you’re storing a company in your contacts you can set a custom Person Type as Company and set that on the contact records that are companies, and then use the ContactType to test when making your API requests.

You could also use the DataService.query and test for the email address where the ContactType = “Company” … if you setup the custom contact type as “Company”.

---

<div class="post-metadata">

**Author:** ![TomScott](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/tomscott/32/67_2.png) [@TomScott](https://integration.keap.com/u/TomScott)\
**Post date:** [November 6, 2024, 9:53pm UTC](https://integration.keap.com/t/filter-contacts-and-companies/93327/3 "2024-11-06T21:53:57Z")

</div>

On our newer API offerings (REST v2) we have split the objects logically into a Contact and Company records, regardless of how they are stored in the database. You can search on those by email address using the following syntax:

`GET https://api.infusionsoft.com/crm/rest/v2/contacts?fields=email_address&filter=email==test@gmail.com`

`GET https://api.infusionsoft.com/crm/rest/v2/companies?fields=email_address&filter=email==test@gmail.com`
