Search Users from email or external_idUpdated 13/10/2019


This query returns all users who match BOTH external_id=1234 AND email=user@example.com OR "foo@bar.com"


Query

Note: Remove exact from the query if you wish to match on partial strings.

POST https://{{ organization}}/api/v1/search/user_report

{
    "query": {
        "bool": {
            "filter": [
                {
                    "terms": {
                        "email.exact": ["user@example.com", "foo@bar.com"]
                    }
                },
                {
                    "terms": {
                        "external_id.exact": ["1234"]
                    }
                }
            ]
        }
    }
}

Response

{
  "pagination": {
    "total": 1,
    "page": 1,
    "pages": 1,
    "per_page": 30
  },
  "data": [
    {
      "_id": "572f63eb8c35fc5d4300034e",
      "account": {
        "external_id": "123",
        "domain": "example.com",
        "name": "Hull",
        "created_at": "2017-06-06T10:01:39Z",
        "updated_at": "2019-08-31T02:51:58Z",
        "anonymous_ids": [ "hubspot:236264269" ],
        "indexed_at": "2019-08-31T03:02:53+00:00",
        "id": "59367d6ff3829c7dfd000001",
        ...
      },
      "anonymous_ids": [
        "1479906786-4b31d32d-43de-41e3-9a4f-ec986ecdcebe",
        "hubspot:718",
        ...
      ],
      "created_at": "2016-05-08T16:06:04Z",
      "domain": "example.com",
      "email": "user@example.com",
      "external_id": "user@example.com",
      "first_name": "Johnny",
      "first_seen_at": "2017-06-13T14:23:16Z",
      "first_session_id": "1497363796-31cdcadf-984d-41ba-910e-70441eebac31",
      "first_session_initial_referrer": "",
      "first_session_initial_url": "https://example.com/",
      "first_session_platform_id": "561fb665450f34b1cf00000f",
      "first_session_started_at": "2017-06-13T14:23:16Z",
      "id": "572f63eb8c35fc5d4300034e",
      "indexed_at": "2019-10-14T12:37:24+00:00",
      "is_approved": true,
      "last_known_ip": "216.239.36.21",
      "last_name": "Appleseed",
      "last_seen_at": "2019-03-15T09:48:15Z",
      "latest_session_id": "1506070466-db50f4e5-6679-4e52-8c73-906ca44df75c",
      "latest_session_initial_referrer": "https://google.com",
      "latest_session_initial_url": "https://example.com",
      "latest_session_platform_id": "5937d205fc9109971000002b",
      "latest_session_started_at": "2017-09-22T08:54:26Z",
      "name": "Johnny Appleseed",
      "organization_id": "561fb665450f34b1cf00000a",
      "phone": "+33620555666",
      "picture": "https://example.com/picture",
      "segment_ids": [
        "58a2e68b11111e9511008f7c",
        "590c781038eab4c5c7000443",
        "5798e61503777df344000559",
        "5a6f2881343eaf747a000024",
        "581a12d94b7f0db54200002d",
        "58a2e94411111e76110091b6",
        "59720148d38c1dba3c000003",
        "57f52f55fd0744481f000224",
        "580768974801599f52000008",
        "5c3cc2267c0877ccca00001a",
        "5d236a4ea4811e0e5d00157b"
      ],
      "signup_session_id": "1497363796-31cdcadf-984d-41ba-910e-70441eebac31",
      "signup_session_initial_referrer": "",
      "signup_session_initial_url": "https://example.com/",
      "signup_session_platform_id": "561fb665450f34b1cf00000f",
      "signup_session_started_at": "2017-06-13T14:23:16Z",
      ...
    }
  ]
}