/v1/management/customer-segments/queryBehavior
Server-only whole-business Contacts query under explicit contacts:segments:read plus contacts:read. Includes blocked contacts when requested. This grant reveals visit-derived membership and email-search matches, not raw appointment history or email values. It does not grant messaging or marketing consent. Name order compares the first 128 Unicode characters of the lowercase saved name using server C collation, then UUID, keeping pagination tokens bounded for legacy long names. joined orders newest signups first, then UUID. lastAppointment orders the latest appointment start across all statuses (including cancelled/future) descending, missing dates last, then the same name/UUID key. One current observation per response; pagination is not a frozen snapshot.
Authentication
ManagementCredential
Credential rules
One server-only owner-issued wbm_ API key can carry both management and integration permissions. Additional permissions require an explicit owner-issued grant. GET /v1/management returns the management discovery view, which may be empty for a booking-only key. For credentials with appointments:read, this discovery view omits whatsapp-templates:read, whatsapp-templates:write, whatsapp-profile:read and whatsapp-profile:write to preserve calendar-client compatibility. Discover these grants through GET /v1/management/messaging-capabilities. Template/profile command authorization still uses the stored grants. Server-only owner-issued Management authority with explicit application permissions. Calling this API does not expand a credential's grants. contacts:read/write/block/sync/fields:read/fields:write are separate approvals for canonical business contacts; fields also require current typed owner grants. contacts:record remains contact recording/recovery only. These grants create no customer phone proof, booking authority, messaging consent or automatic synchronization. Hours/blocks retain their independent resource grants. booking-policy:read/write separately delegate whole-business booking settings, without schedule/provider grants; write requires read. They preserve existing appointments and create no duration-rewrite authority. Provider duration policy additionally requires explicit provider-booking-policy:read/write and exact current providerIds; booking-duration:rewrite is separately approved and does not itself grant policy read/write. Service catalogue requires explicit services:read/write, independent of provider/calendar/schedule resources; write requires read. These operations do not expand an existing credential's grants. Public presentation and reviewed service selection require explicit website-content:read/write; write requires read, independently from services:* and provider resources. Existing provider metadata/activity/assignment additionally requires providers:read/write and a nonempty explicit current providerIds grant; write requires read. This grants no provider creation, deletion, login, invitation or schedule authority. WhatsApp template/profile management requires separate whatsapp-templates:read, whatsapp-templates:write, whatsapp-profile:read and whatsapp-profile:write application scopes. Write requires its matching read scope. These grants require explicit owner approval; Meta OAuth permissions remain separate.
Required application permissions
contacts:readcontacts:segments:read
Request
Request body · required
application/json · BusinessCustomerSegmentsQuery
Read-only query; no Idempotency-Key or If-Match. countQueries IDs must be unique. Each proposal replaces segments and shares the same base search/languages/status. Complete counts refuse beyond the supported 20,000-contact ceiling; no partial totals.
-
searchstringOptionalNormalized name words, phone or email match. Email is searchable under this explicit scope but is not returned.
maxLength:200default:""pattern:"^[^\\u0000-\\u001f\\u007f]*$" -
languagesarrayOptionalmaxItems:3uniqueItems:truedefault:[]View nested fields
-
[]stringArray itemAllowed values:
["he","ar","en"]
-
-
statusstringOptionalAllowed values:
["all","active","blocked"]default:"all" -
segmentsobjectOptionalAND-combined Contacts criteria, including retained legacy choices. Both visit dates are required together. False toggles are ignored. Message-history criteria are not accepted.
dependentRequired:{"visitedFrom":["visitedTo"],"visitedTo":["visitedFrom"]}View nested fields
-
awaystringOptionalAllowed values:
["3w","1m","2m","3m"] -
visitsstringOptionalAllowed values:
["none","one","recentRegular","regular"] -
backToBackstringOptionalAllowed values:
["once","repeated"] -
lateRegularbooleanOptional -
noUpcomingbooleanOptional -
recentMissedbooleanOptional -
newCustomersbooleanOptional -
lastVisitstringOptionalAllowed values:
["within30","notSince60","notSince90"] -
overduebooleanOptional -
missedbooleanOptional -
providerIdstring · uuidOptional -
visitedFromstring · dateOptional -
visitedTostring · dateOptional -
additionalPropertiesno value allowedSchema rule
-
-
sortstringOptionalAllowed values:
["name","joined","lastAppointment"]default:"name" -
limitintegerOptionalminimum:1maximum:100default:50 -
cursorstring | nullOptionalOpaque encrypted and authenticated current-query pagination token with a 15-minute expiry. Keep the complete query unchanged; restart after credential rotation, INVALID_CURSOR or expiry. Not a frozen history snapshot or a synchronization cursor. Do not decode or construct it.
maxLength:2048pattern:"^cs1\\.[A-Za-z0-9_-]+\\.[a-f0-9]{64}$" -
countQueriesarrayOptionalmaxItems:32View nested fields
-
[]objectArray itemView nested fields
-
idstringRequiredpattern:"^[A-Za-z0-9_-]{1,64}$" -
segmentsobjectRequiredAND-combined Contacts criteria, including retained legacy choices. Both visit dates are required together. False toggles are ignored. Message-history criteria are not accepted.
dependentRequired:{"visitedFrom":["visitedTo"],"visitedTo":["visitedFrom"]}View nested fields
-
awaystringOptionalAllowed values:
["3w","1m","2m","3m"] -
visitsstringOptionalAllowed values:
["none","one","recentRegular","regular"] -
backToBackstringOptionalAllowed values:
["once","repeated"] -
lateRegularbooleanOptional -
noUpcomingbooleanOptional -
recentMissedbooleanOptional -
newCustomersbooleanOptional -
lastVisitstringOptionalAllowed values:
["within30","notSince60","notSince90"] -
overduebooleanOptional -
missedbooleanOptional -
providerIdstring · uuidOptional -
visitedFromstring · dateOptional -
visitedTostring · dateOptional -
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
-
-
-
additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
{
"type": "object",
"additionalProperties": false,
"properties": {
"search": {
"type": "string",
"maxLength": 200,
"default": "",
"description": "Normalized name words, phone or email match. Email is searchable under this explicit scope but is not returned.",
"pattern": "^[^\\u0000-\\u001f\\u007f]*$"
},
"languages": {
"type": "array",
"items": {
"enum": [
"he",
"ar",
"en"
]
},
"maxItems": 3,
"uniqueItems": true,
"default": []
},
"status": {
"enum": [
"all",
"active",
"blocked"
],
"default": "all"
},
"segments": {
"type": "object",
"additionalProperties": false,
"properties": {
"away": {
"type": "string",
"enum": [
"3w",
"1m",
"2m",
"3m"
]
},
"visits": {
"type": "string",
"enum": [
"none",
"one",
"recentRegular",
"regular"
]
},
"backToBack": {
"type": "string",
"enum": [
"once",
"repeated"
]
},
"lateRegular": {
"type": "boolean"
},
"noUpcoming": {
"type": "boolean"
},
"recentMissed": {
"type": "boolean"
},
"newCustomers": {
"type": "boolean"
},
"lastVisit": {
"type": "string",
"enum": [
"within30",
"notSince60",
"notSince90"
]
},
"overdue": {
"type": "boolean"
},
"missed": {
"type": "boolean"
},
"providerId": {
"type": "string",
"format": "uuid"
},
"visitedFrom": {
"type": "string",
"format": "date"
},
"visitedTo": {
"type": "string",
"format": "date"
}
},
"required": [],
"dependentRequired": {
"visitedFrom": [
"visitedTo"
],
"visitedTo": [
"visitedFrom"
]
},
"description": "AND-combined Contacts criteria, including retained legacy choices. Both visit dates are required together. False toggles are ignored. Message-history criteria are not accepted."
},
"sort": {
"enum": [
"name",
"joined",
"lastAppointment"
],
"default": "name"
},
"limit": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 50
},
"cursor": {
"type": [
"string",
"null"
],
"maxLength": 2048,
"pattern": "^cs1\\.[A-Za-z0-9_-]+\\.[a-f0-9]{64}$",
"description": "Opaque encrypted and authenticated current-query pagination token with a 15-minute expiry. Keep the complete query unchanged; restart after credential rotation, INVALID_CURSOR or expiry. Not a frozen history snapshot or a synchronization cursor. Do not decode or construct it."
},
"countQueries": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z0-9_-]{1,64}$"
},
"segments": {
"type": "object",
"additionalProperties": false,
"properties": {
"away": {
"type": "string",
"enum": [
"3w",
"1m",
"2m",
"3m"
]
},
"visits": {
"type": "string",
"enum": [
"none",
"one",
"recentRegular",
"regular"
]
},
"backToBack": {
"type": "string",
"enum": [
"once",
"repeated"
]
},
"lateRegular": {
"type": "boolean"
},
"noUpcoming": {
"type": "boolean"
},
"recentMissed": {
"type": "boolean"
},
"newCustomers": {
"type": "boolean"
},
"lastVisit": {
"type": "string",
"enum": [
"within30",
"notSince60",
"notSince90"
]
},
"overdue": {
"type": "boolean"
},
"missed": {
"type": "boolean"
},
"providerId": {
"type": "string",
"format": "uuid"
},
"visitedFrom": {
"type": "string",
"format": "date"
},
"visitedTo": {
"type": "string",
"format": "date"
}
},
"required": [],
"dependentRequired": {
"visitedFrom": [
"visitedTo"
],
"visitedTo": [
"visitedFrom"
]
},
"description": "AND-combined Contacts criteria, including retained legacy choices. Both visit dates are required together. False toggles are ignored. Message-history criteria are not accepted."
}
},
"required": [
"id",
"segments"
]
},
"maxItems": 32
}
},
"required": [],
"description": "Read-only query; no Idempotency-Key or If-Match. countQueries IDs must be unique. Each proposal replaces segments and shares the same base search/languages/status. Complete counts refuse beyond the supported 20,000-contact ceiling; no partial totals."
} Successful responses
200 · BusinessCustomerSegmentsResult
Current authorized result.
Cache-Control
{
"const": "no-store"
} application/json · BusinessCustomerSegmentsResult
total and language counts cover all business contacts; base applies search/languages/status; matched applies segments; query counts evaluate each replacement proposal over base. No appointment rows, raw visit statistics, email values or private notes. Each response is a current read; pages may change as the business changes.
-
customersarrayRequiredmaxItems:100View nested fields
-
[]objectArray itemCurrent basic canonical contact projection, including unmapped and blocked contacts. An unavailable stored name/phone/language is null with its fieldUnavailableReasons entry; source data is preserved. Notes, email, arbitrary custom data, consent, customer proof and booking history are absent.
View nested fields
-
businessCustomerIdstring · uuidRequired -
versionstringRequiredDatabase-owned canonical customer revision. Read a current customer and its ETag before a basic or block command. Native and API edits share this revision; no-op writes do not increment it. It is not a customer-mapping version.
pattern:"^c(0|[1-9][0-9]{0,18})$" -
displayNamestring | nullRequiredmaxLength:4096 -
phonestring | nullRequiredpattern:"^\\+[1-9][0-9]{7,14}$" -
languageanyOf (string | null)RequiredAt least one of these variants must match.
View nested fields
-
anyOf 1stringSchema branchAllowed values:
["he","ar","en"] -
anyOf 2nullSchema branch
-
-
isBlockedbooleanRequired -
createdAtstring · date-timeRequired -
fieldUnavailableReasonsobjectRequiredView nested fields
-
displayNamestringOptionalAllowed values:
["too_large","invalid_stored_value"] -
phonestringOptionalAllowed values:
["too_large","invalid_stored_value"] -
languagestringOptionalAllowed values:
["too_large","invalid_stored_value"] -
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
-
-
-
nextCursorstring | nullRequiredOpaque encrypted and authenticated current-query pagination token with a 15-minute expiry. Keep the complete query unchanged; restart after credential rotation, INVALID_CURSOR or expiry. Not a frozen history snapshot or a synchronization cursor. Do not decode or construct it.
maxLength:2048pattern:"^cs1\\.[A-Za-z0-9_-]+\\.[a-f0-9]{64}$" -
observedAtstring · date-timeRequired -
timezonestringRequiredminLength:1 -
countsobjectRequiredView nested fields
-
totalintegerRequiredminimum:0maximum:20000 -
baseintegerRequiredminimum:0maximum:20000 -
matchedintegerRequiredminimum:0maximum:20000 -
languagesobjectRequiredView nested fields
-
heintegerRequiredminimum:0maximum:20000 -
arintegerRequiredminimum:0maximum:20000 -
enintegerRequiredminimum:0maximum:20000 -
additionalPropertiesno value allowedSchema rule
-
-
queriesarrayRequiredmaxItems:32View nested fields
-
[]objectArray itemView nested fields
-
idstringRequiredpattern:"^[A-Za-z0-9_-]{1,64}$" -
countintegerRequiredminimum:0maximum:20000 -
additionalPropertiesno value allowedSchema rule
-
-
-
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
{
"type": "object",
"additionalProperties": false,
"properties": {
"customers": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"businessCustomerId": {
"type": "string",
"format": "uuid"
},
"version": {
"type": "string",
"pattern": "^c(0|[1-9][0-9]{0,18})$",
"description": "Database-owned canonical customer revision. Read a current customer and its ETag before a basic or block command. Native and API edits share this revision; no-op writes do not increment it. It is not a customer-mapping version."
},
"displayName": {
"type": [
"string",
"null"
],
"maxLength": 4096
},
"phone": {
"type": [
"string",
"null"
],
"pattern": "^\\+[1-9][0-9]{7,14}$"
},
"language": {
"anyOf": [
{
"type": "string",
"enum": [
"he",
"ar",
"en"
]
},
{
"type": "null"
}
]
},
"isBlocked": {
"type": "boolean"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"fieldUnavailableReasons": {
"type": "object",
"additionalProperties": false,
"properties": {
"displayName": {
"enum": [
"too_large",
"invalid_stored_value"
]
},
"phone": {
"enum": [
"too_large",
"invalid_stored_value"
]
},
"language": {
"enum": [
"too_large",
"invalid_stored_value"
]
}
},
"required": []
}
},
"required": [
"businessCustomerId",
"version",
"displayName",
"phone",
"language",
"isBlocked",
"createdAt",
"fieldUnavailableReasons"
],
"description": "Current basic canonical contact projection, including unmapped and blocked contacts. An unavailable stored name/phone/language is null with its fieldUnavailableReasons entry; source data is preserved. Notes, email, arbitrary custom data, consent, customer proof and booking history are absent."
},
"maxItems": 100
},
"nextCursor": {
"type": [
"string",
"null"
],
"maxLength": 2048,
"pattern": "^cs1\\.[A-Za-z0-9_-]+\\.[a-f0-9]{64}$",
"description": "Opaque encrypted and authenticated current-query pagination token with a 15-minute expiry. Keep the complete query unchanged; restart after credential rotation, INVALID_CURSOR or expiry. Not a frozen history snapshot or a synchronization cursor. Do not decode or construct it."
},
"observedAt": {
"type": "string",
"format": "date-time"
},
"timezone": {
"type": "string",
"minLength": 1
},
"counts": {
"type": "object",
"additionalProperties": false,
"properties": {
"total": {
"type": "integer",
"minimum": 0,
"maximum": 20000
},
"base": {
"type": "integer",
"minimum": 0,
"maximum": 20000
},
"matched": {
"type": "integer",
"minimum": 0,
"maximum": 20000
},
"languages": {
"type": "object",
"additionalProperties": false,
"properties": {
"he": {
"type": "integer",
"minimum": 0,
"maximum": 20000
},
"ar": {
"type": "integer",
"minimum": 0,
"maximum": 20000
},
"en": {
"type": "integer",
"minimum": 0,
"maximum": 20000
}
},
"required": [
"he",
"ar",
"en"
]
},
"queries": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"pattern": "^[A-Za-z0-9_-]{1,64}$"
},
"count": {
"type": "integer",
"minimum": 0,
"maximum": 20000
}
},
"required": [
"id",
"count"
]
},
"maxItems": 32
}
},
"required": [
"total",
"base",
"matched",
"languages",
"queries"
]
}
},
"required": [
"customers",
"nextCursor",
"observedAt",
"timezone",
"counts"
],
"description": "total and language counts cover all business contacts; base applies search/languages/status; matched applies segments; query counts evaluate each replacement proposal over base. No appointment rows, raw visit statistics, email values or private notes. Each response is a current read; pages may change as the business changes."
} Errors and recovery
Error responses declared in the contract (8)
The preview contract shares generic error definitions across operations. This list is not an exhaustive list of runtime errors.
401 · Missing, invalid or expired server Management credential.
application/json · Error
-
errorobjectRequiredView nested fields
-
codestringRequired -
requestIdstring · uuidRequired -
retryAfterintegerOptionalminimum:1 -
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
{
"type": "object",
"additionalProperties": false,
"properties": {
"error": {
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
},
"requestId": {
"type": "string",
"format": "uuid"
},
"retryAfter": {
"type": "integer",
"minimum": 1
}
},
"required": [
"code",
"requestId"
]
}
},
"required": [
"error"
]
} 403 · Current tenant, integration, scope or resource access refused. Browser Origin is refused.
application/json · Error
-
errorobjectRequiredView nested fields
-
codestringRequired -
requestIdstring · uuidRequired -
retryAfterintegerOptionalminimum:1 -
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
{
"type": "object",
"additionalProperties": false,
"properties": {
"error": {
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
},
"requestId": {
"type": "string",
"format": "uuid"
},
"retryAfter": {
"type": "integer",
"minimum": 1
}
},
"required": [
"code",
"requestId"
]
}
},
"required": [
"error"
]
} 405 · Unsupported method.
application/json · Error
-
errorobjectRequiredView nested fields
-
codestringRequired -
requestIdstring · uuidRequired -
retryAfterintegerOptionalminimum:1 -
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
{
"type": "object",
"additionalProperties": false,
"properties": {
"error": {
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
},
"requestId": {
"type": "string",
"format": "uuid"
},
"retryAfter": {
"type": "integer",
"minimum": 1
}
},
"required": [
"code",
"requestId"
]
}
},
"required": [
"error"
]
} 413 · Request body exceeds this operation’s byte limit.
application/json · Error
-
errorobjectRequiredView nested fields
-
codestringRequired -
requestIdstring · uuidRequired -
retryAfterintegerOptionalminimum:1 -
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
{
"type": "object",
"additionalProperties": false,
"properties": {
"error": {
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
},
"requestId": {
"type": "string",
"format": "uuid"
},
"retryAfter": {
"type": "integer",
"minimum": 1
}
},
"required": [
"code",
"requestId"
]
}
},
"required": [
"error"
]
} 415 · application/json required.
application/json · Error
-
errorobjectRequiredView nested fields
-
codestringRequired -
requestIdstring · uuidRequired -
retryAfterintegerOptionalminimum:1 -
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
{
"type": "object",
"additionalProperties": false,
"properties": {
"error": {
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
},
"requestId": {
"type": "string",
"format": "uuid"
},
"retryAfter": {
"type": "integer",
"minimum": 1
}
},
"required": [
"code",
"requestId"
]
}
},
"required": [
"error"
]
} 422 · Invalid query or INVALID_CURSOR (including tampering or expiry): restart the query. CUSTOMER_SEGMENT_LIMIT_EXCEEDED: more than 20,000 contacts; no partial totals are returned.
application/json · Error
-
errorobjectRequiredView nested fields
-
codestringRequired -
requestIdstring · uuidRequired -
retryAfterintegerOptionalminimum:1 -
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
{
"type": "object",
"additionalProperties": false,
"properties": {
"error": {
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
},
"requestId": {
"type": "string",
"format": "uuid"
},
"retryAfter": {
"type": "integer",
"minimum": 1
}
},
"required": [
"code",
"requestId"
]
}
},
"required": [
"error"
]
} 429 · Request or snapshot limit reached; honor Retry-After.
application/json · Error
-
errorobjectRequiredView nested fields
-
codestringRequired -
requestIdstring · uuidRequired -
retryAfterintegerOptionalminimum:1 -
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
{
"type": "object",
"additionalProperties": false,
"properties": {
"error": {
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
},
"requestId": {
"type": "string",
"format": "uuid"
},
"retryAfter": {
"type": "integer",
"minimum": 1
}
},
"required": [
"code",
"requestId"
]
}
},
"required": [
"error"
]
} 503 · Temporary failure. Read operations can retry; retain an uncertain checkpoint’s original operation UUID and exact cursor.
application/json · Error
-
errorobjectRequiredView nested fields
-
codestringRequired -
requestIdstring · uuidRequired -
retryAfterintegerOptionalminimum:1 -
additionalPropertiesno value allowedSchema rule
-
-
additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
{
"type": "object",
"additionalProperties": false,
"properties": {
"error": {
"type": "object",
"additionalProperties": false,
"properties": {
"code": {
"type": "string"
},
"requestId": {
"type": "string",
"format": "uuid"
},
"retryAfter": {
"type": "integer",
"minimum": 1
}
},
"required": [
"code",
"requestId"
]
}
},
"required": [
"error"
]
}