Find contacts by phone number
Phone numbers are converted to international notation when stored in Codemeta OS
(+49 6561 12340). So that you can still find a contact in any
dialing format, the API keeps, alongside the displayed number, a
canonical search key without separators (phoneDigits) — both
approaches shown here target it.
Approach 1 — Exact search (GET /parties?phoneDigits=)
The direct way when you need exactly those party/parties with a specific number — programmatic, without ranking, without partial matches.
Sign in and set the tenant (see First ticket, steps 1–2).
export TENANT="0192f2c0-8d1c-7a3b-9e4f-d3e7f1a2b5c8"Filter by the number. Pass the number in any format as
phoneDigits:curl -G https://os.codemeta.de/api/v1/parties \ -H "X-Tenant-Id: $TENANT" \ -b cookies.txt \ --data-urlencode "phoneDigits=004965611234388"Read the response. You get the normal list response — only the parties that carry exactly this number (no suffix matches, no partial matches):
{ "data": [ { "id": "0193a1b2-…", "partyType": "PERSON", "displayName": "Max Mustermann", "contactChannels": [ { "type": "MOBILE", "value": "+49 6561 1234388" } ] } ], "meta": { "nextCursor": null, "hasMore": false, "limit": 50, "total": null } }
If you need the relationship edge itself instead (with personPartyId /
organizationPartyId), filter the same number on the relationships:
curl -G https://os.codemeta.de/api/v1/party_relationships \
-H "X-Tenant-Id: $TENANT" \
-b cookies.txt \
--data-urlencode "phoneDigits=004965611234388"
Approach 2 — Tolerant search (GET /search)
The approach for caller recognition and the command palette: it forgives dialing format variants and country code differences and returns results sorted by relevance (exact number matches first).
curl -G https://os.codemeta.de/api/v1/search \
-H "X-Tenant-Id: $TENANT" \
-b cookies.txt \
--data-urlencode "q=0049656112340" \
--data-urlencode "entities=parties"
A query recognized as phone-like (at least six digits, only phone characters) matches via the canonical digit key: an exact number match is ranked to the top, and in addition a comparison of the last eight digits provides country code tolerance. The response is grouped by entity type:
{
"query": "0049656112340",
"results": {
"parties": [
{ "id": "0193c4d5-…", "displayName": "Musterfirma GmbH", "partyType": "ORGANIZATION" }
]
},
"totalGroups": 1
}
Which approach when?
| Criterion | GET /parties?phoneDigits= |
GET /search |
|---|---|---|
| Match type | exact number | tolerant (exact first, then suffix) |
| Sorting | list sorting (sort) |
relevance |
| Relationship numbers | yes (→ person) | yes (→ person) |
| Pagination / filters | full list features | limited per group (max. 100) |
| Typical use | integration, reconciliation | command palette, caller recognition |
Where to go from here
- Create a party – the numbers end up in
contactChannelswith typePHONE,MOBILEorFAX. - Concept: Multi-tenancy – why every request needs the
X-Tenant-Idheader.