MngConvertClientsToLeadsByFilter¶
Converts every client matching the supplied filter into a lead, setting
customer_kind for all of them in one pass.
The confirm flag decides whether anything is written. With confirm: false the
command runs every check and returns the counters describing what would happen,
without touching a record. With confirm: true the same run also persists the
change. The response shape is identical in both modes.
The command is available through the manager command API only; there is no REST path for it. It is the bulk form of MngConvertClientToLead; for one record, use that command instead.
Access Control¶
Allowed sessions:
SESSION_MANAGERSESSION_ADMINSESSION_DEALERSESSION_CRM_MANAGERSESSION_CRM_ADMIN
The caller must have CRM access and both set_leads and set_clients: the
record leaves one half of the base and appears in the other, so either side alone
is not enough.
The requested deskFilter is first narrowed to the desks the caller may see, and
then every selected record is checked individually against the caller's brand and
desk scope.
Every call is written to the journal, successful ones included.
Request¶
Dry run:
{
"command": "MngConvertClientsToLeadsByFilter",
"extID": "1",
"data": {
"confirm": false,
"filter": {
"deskFilter": "*",
"limit": 100,
"offset": 0
}
}
}
Request Data¶
Top level:
| Field | Type | Required | Description |
|---|---|---|---|
confirm |
bool | Yes | false reports what would change without writing. true applies the change |
filter |
object | Yes | Record selection |
There is no fields object: the operation is a single one and there is nothing
to choose.
filter object:
| Field | Type | Required | Description |
|---|---|---|---|
deskFilter |
string | Yes | Desk wildcard mask, for example *, DESK_*, DESK_EU*,!DESK_EU_TEST. Must not be empty |
limit |
int | Yes | From 1 to 50000. Validated, but it does not limit how much is processed |
offset |
int | Yes | Minimum 0. Validated, but it does not limit how much is processed |
where |
array | No | [[field, operator, value], ...], all conditions must match |
orWhere |
array | No | OR comparison group; at least one condition must match |
whereNot |
array | No | [[field, value], ...] |
whereIn |
array | No | [[field, [values...]], ...] |
whereNotIn |
array | No | [[field, [values...]], ...] |
whereBetween |
array | No | [[field, [from, to]], ...] |
whereNotBetween |
array | No | [[field, [from, to]], ...] |
orderBy |
array | No | Example: [["created_time", "desc"]] |
Filter fields and operators are the same as for the customer table, including the
lifecycle_flags operators has_all, has_any, and has_none. Common filter
semantics are described in Table filter syntax; desk masks in
Desks TCP API.
Response Data¶
{
"confirm": true,
"matched": 240,
"updated": 240,
"skipped": 0,
"failed": 0
}
| Field | Type | Description |
|---|---|---|
confirm |
bool | Echo of the request flag |
matched |
int | Records selected by the filter, kind, brand scope, and desk mask |
updated |
int | Records actually converted. Always 0 when confirm is false |
skipped |
int | Always 0; see below |
failed |
int | Records that did not pass the per-record checks |
failures |
array | One entry per failure with customer_id, error, and an optional message. Present only when non-empty |
Why skipped Is Always Zero¶
A record of the other kind never enters the selection in the first place, so there is nothing to skip. The field is kept for a uniform response shape with the neighbouring bulk commands.
Reading the Counters¶
After an applied run the identity matched = updated + failed holds. On a dry
run updated is 0 by definition, and the number of records that would be
converted is matched - failed.
Response Statuses¶
| Status | Condition |
|---|---|
200 |
Dry run. Always, since nothing was meant to change |
200 |
Applied, at least one record written, no failures |
207 |
Applied, at least one record written, some failed |
409 |
Applied, nothing was written |
Errors¶
| HTTP | Error | Description |
|---|---|---|
400 |
INVALID_DATA |
Request validation failed |
403 |
RET_NOT_ENOUGH_RIGHTS |
Missing permission, missing scope, or the record is outside the caller's visibility |
404 |
RET_NOT_FOUND |
No customer with that identifier exists |
Every error carries a message field with free-form text. Its contents are not
part of the contract; branch on error.