What this is about
With POST {basis}/query you get a list of objects of a model, for example all customers from Köln, sorted by name, 25 per page. The body has two parts:
responsesays which fields each object in the list has. This is the same field selection as for reading, see Field selection withresponse.parametersays which objects come back, and in which order.
A complete request
{
"response": ["id", "name", "city"],
"parameter": {
"query": {
"type": "AND",
"filter": [
{ "key": "city", "value": "Köln", "param": "EQ" }
],
"group": []
},
"order": [ { "field": "name", "order": "ASC" } ],
"page": 0,
"limit": 25,
"meta": true
}
}
flowchart TB
B["Body of POST /query"] --> R["response<br/>which fields"]
B --> P["parameter"]
P --> Q["query<br/>which objects (filter tree)"]
P --> O["order<br/>in which order"]
P --> S["page + limit<br/>which slice"]
P --> M["meta<br/>information about the list"]
Q --> T["type: AND or OR"]
Q --> F["filter: single conditions<br/>key, value, param"]
Q --> G["group: subgroups<br/>again with type, filter, group"]
| Part | Meaning | |
|---|---|---|
query.type | how the entries of this group are combined: AND or OR | AND/OR groups |
query.filter | single conditions: field (key), value (value), operator (param) | All filter operators |
query.group | subgroups with their own type | AND/OR groups |
order | sort criteria in order of their importance | Sorting |
page, limit | which page and how many objects per page | Paging and match count |
meta | whether information about the list comes along | Paging and match count |
Default values
Everything in parameter may be left out. Then these values apply:
| Setting | Default | Effect |
|---|---|---|
parameter | empty | all visible objects, no sorting |
query | none | no filter from the client |
query.type | OR | entries of the group are combined with OR |
filter[].param | LIKE | comparison with a search pattern |
order | none | order is not defined |
page | 0 | first page, counted from 0 |
limit | -1 | all matches at once |
meta | true | information about the list comes along |
The response
POST /api/rest/crm/customer/query
{ "response": ["id", "name"],
"parameter": { "limit": 2, "order": [{ "field": "name", "order": "ASC" }] } }{
"data": [
{ "id": "5a2b…", "name": "Alt-Muster AG" },
{ "id": "7c1d…", "name": "Muster GmbH" }
],
"meta": {
"error": false,
"totalCount": 42,
"currentPage": 0,
"currentLimit": 2
}
}data is the list of objects on this page. Among other things, meta contains totalCount, the number of all matches across all pages. The response is shortened, see Paging and match count for all information in meta.
What happens along the way
-
1Client→CDMSsends
responseandparameter -
2CDMSresolves the
responseinto fields. If it is missing → 400 -
3CDMSchecks the read role of
customer. If it is missing → 403missing-permission|customer-read -
4CDMScombines your filter tree with AND with the filters that always run along: own data, attribute filters, required filters
-
5CDMS→Databasecounts the matches, determines the page and reads the requested columns
-
6CDMS→Clientreturns
dataandmeta
A search needs the same read role as reading a single object. The endpoint exists only if the model enables it, see Which endpoints a model has.
All variants
When: You want to see everything, for example to try things out.
{ "response": ["id", "name"] } returns all visible objects, unsorted, without pages.
Result: All matches at once. Not suitable for large tables.
When: You are looking for specific objects.
"parameter": { "query": { "type": "AND", "filter": [{ "key": "city", "value": "Köln", "param": "EQ" }] } }
Result: Only the customers from Köln.
When: The order matters, for example in a table.
"order": [{ "field": "name", "order": "ASC" }]
Result: Alphabetical by name.
When: A table shows 25 rows per page.
"page": 0, "limit": 25 for the first page, "page": 1 for the second.
Result: At most 25 objects, plus totalCount for the page bar.
When: Production.
Filter with an explicit type, sorting, page and limit, and in response only the fields that the UI shows.
Result: Stable, fast and predictable.