# Get contact by other field than ID via API

**URL:** <https://forum.mautic.org/t/get-contact-by-other-field-than-id-via-api/20964>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [September 22, 2021, 5:36pm UTC](https://forum.mautic.org/t/get-contact-by-other-field-than-id-via-api/20964 "2021-09-22T17:36:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [September 22, 2021, 5:36pm UTC](https://forum.mautic.org/t/get-contact-by-other-field-than-id-via-api/20964/1 "2021-09-22T17:36:50Z")

</div>

Is it possible to get a contact via the API with another field than the ID? For example an email address or a custom field like ‘accesscode’?

```auto
$contact = $contactApi->get($id);

```

I only see [ID as a option in documentation](https://developer.mautic.org/?php#get-contact) and other code examples online.

**Your software**  
My Mautic version is: 4  
My PHP version is: 7.4  
My Database type and version is: latest

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [September 22, 2021, 10:55pm UTC](https://forum.mautic.org/t/get-contact-by-other-field-than-id-via-api/20964/2 "2021-09-22T22:55:59Z")

</div>

Hi, as I understand you should be able to get details about contacts with specific email by using this method here: \< [api-library/Contacts.php at 9087ddec6400eb0c8aa43859eb7710cc9948c1ce · mautic/api-library · GitHub](https://github.com/mautic/api-library/blob/9087ddec6400eb0c8aa43859eb7710cc9948c1ce/lib/Api/Contacts.php#L84) \>, then you use details to get lead id and use lead id from that point on.

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [September 22, 2021, 11:26pm UTC](https://forum.mautic.org/t/get-contact-by-other-field-than-id-via-api/20964/3 "2021-09-22T23:26:09Z")

</div>

Thanks @mzagmajster. How would I use that method via the API? Something like this?

$contactApi-\>getIdentified($email)

If so, is there a whole list of functions available to use via the API?

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [September 23, 2021, 1:03am UTC](https://forum.mautic.org/t/get-contact-by-other-field-than-id-via-api/20964/4 "2021-09-23T01:03:54Z")

</div>

Since method actually triggers search as I understand it, I would go with something like:

```auto
$search = 'email: ' . $email;
$minimal = true;
$contactAp->getIdentified($search, 0, 0, '', 'ASC', true, $minimal);

```

The exact values for specific parameters depends on your situation, and I leave the experimenting to you, but the above I think basically captures what you want.
