Retrieving the Zendesk user id of a caller

When an agent receives a call, the telephony system can use the caller's phone number to search for the caller in Zendesk Support. If a user profile exists with the caller's number, the system can link the call to the existing user in Support. If a profile doesn't exist, it can create one for the caller. See Creating a user profile for a caller.

Use the following Search endpoint to look for a user in Support with the caller's phone number:

GET /api/v2/search.json?query={search_string}

Query syntax

The following query syntax searches for a specific user using the caller's phone number:

query=role:end-user phone:{number}

You can search for the caller's phone number or automatic number association (ANI).

The number should not contain any non-numeric characters like spaces, dashes, or parentheses. The '+' sign preceding a country code should not be included either. To specify a phone number in different formats, add a leading * (asterisk) to the number.

query=role:end-user phone:*5135557611

The search returns a user who has any of the following numbers in their profile:

  • +1 513.555.7611
  • (513) 555-7611
  • 513 555 7611
  • 513-555-7611
  • 513.555.7611

If custom fields have been defined for users in the Support account, consider searching the custom fields if they contain phone numbers. See Searching custom user and organization fields.

Because the search is an HTTP request, make sure to url-encode the search string before sending the request:

query=role%3Aend-user%20phone%3A*5135557611