Find users by phone number
You can find a user based on the phone_number attribute. The response is always a paginated list of the matching contacts, so many isn't needed here and has no effect.
Attributes
Optional unless marked required
- phone_number
- A user phone number.
Handling phone number formats
The search matches the number exactly as it's stored on the contact, spaces and other characters included: a contact saved as +48 123 456 789 isn't found with +48123456789, and the other way round. Store numbers in one format, preferably the clean one (+48123456789), and search in the same format.
Formats you may find on contacts (each one matches only itself):
- International with formatting:
+1 (555) 123-4567 - With spaces and hyphens:
48 123-456-789 - Clean format:
+48123456789
When making API requests:
-
Using HTTP Client Libraries (Recommended)
- Most modern HTTP clients handle URL encoding automatically
- Example with Python requests:
# Clean format (recommended for consistency)params = {"phone_number": "+48123456789"}# A number stored with spaces and hyphens: search with the same charactersparams = {"phone_number": "+48 123-456-789"}response = requests.get(url, params=params, headers=headers) -
Manual URL Encoding
- If building the URL manually, make sure to encode all special characters:
from urllib.parse import quote# With formattingphone_formatted = "+48 123-456-789"phone_encoded = quote(phone_formatted) # Results in: %2B48%20123-456-789# Clean formatphone_clean = "+48123456789"phone_encoded = quote(phone_clean) # Results in: %2B48123456789url = f"{base_url}?phone_number={phone_encoded}"
Request
- cURL
- JavaScript
- PHP
- Python
curl -X GET "https://<your_app_subdomain>.user.com/api/public/users/search/?phone_number=:phone_number" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2"
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/users/search/?phone_number=:phone_number",
{
method: "GET",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
},
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/users/search/?phone_number=:phone_number",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.get(
"https://<your_app_subdomain>.user.com/api/public/users/search/?phone_number=:phone_number",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
)
print(response.json())
Response examples
- 200 OK
{"count": 1,"next": null,"previous": null,"results": [{"id": 1947,"user_key": "g7lvoickax9e","name": "John Doe","email": "johndoe+1@example.com","gender": "unknown","status": "user","phone_number": "48 123-456-789","first_seen": "2025-04-07T08:59:22.364896Z","last_seen": "2025-04-07T09:25:44.809546Z","page_views": 14,"last_ip": "54.38.139.0","timezone": "Europe/Kaliningrad","city": "Warsaw","region": "Mazovia","country": "Poland","unsubscribed": false,"browser_language": "pl","widget_language": null,"score": 0,"browser": "Chrome","os_type": "Mac OS X","resolution": "2560x1440","created_at": "2025-04-07T08:59:22.381018Z","updated_at": "2025-04-08T11:21:29.044044Z","companies": ,1 item"gravatar_url": null,"lists": [],"tags": [],"notifications": true,"facebook_url": null,"linkedin_url": null,"twitter_url": null,"google_url": null,"last_contacted": "2025-04-07T09:28:07.247131Z","custom_id": null,"web_push_subscription": false,"assigned_to": null,"most_active_time": null,"lt_opened_email": null,"lt_clicked_email": null,"email_mx_valid": true,"referrer": "https://srv71624.seohost.com.pl/test-site/koszyk/","last_heard_from": "2025-04-07T09:12:28.758234Z","spambounced": false,"softbounced": false,"hardbounced": false,"marked_email_as_spam": true}]}Response fields
Fields returned in the 200 OK response body.
- count
- Number of results across all pages. It can lag behind recent changes; see Response pagination.
- next
- URL of the next page of results. null on the last page.
- previous
- URL of the previous page of results. null on the first page.
- results
- Results on this page.
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.