> For the complete documentation index, see [llms.txt](https://docs.flowretail.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flowretail.com/docs/developers/api-documentation/order/get-counts-of-orders.md).

# Get counts of orders

Get counts of orders. Required permissions: SALES\_ORDER,RETURN\_ORDER

```json
{"openapi":"3.0.2","info":{"title":"Flow Retail API version 2","version":"2.0.0"},"tags":[{"name":"Order","description":"Order"}],"servers":[{"description":"Flow Retail Production","url":"https://api.flowretail.com/v2"},{"description":"Flow Retail Stage","url":"https://api.stage.flowretail.com/v2"}],"security":[{"accessToken":[]},{"authToken":[]},{"integrationToken":[]}],"components":{"securitySchemes":{"accessToken":{"description":"Access token recevied after user login with a deviceToken","scheme":"bearer","type":"http"},"authToken":{"description":"Token received from the auth service","scheme":"bearer","type":"http"},"integrationToken":{"scheme":"bearer","type":"http"}},"responses":{"OrdersCountResponse":{"description":"Example response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderCountResponseListSchema"}}}}},"schemas":{"OrderCountResponseListSchema":{"title":"OrderCountResponseListSchema","type":"object","required":["results","deviations"],"properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/OrderCountResponseSchema"}},"deviations":{"$ref":"#/components/schemas/OrderDeviationCountsSchema"}}},"OrderCountResponseSchema":{"title":"OrderCountResponseSchema","type":"object","required":["queryKey","count"],"properties":{"queryKey":{"type":"string","description":"Used for correlating requests and responses. Can be any value."},"count":{"type":"integer"}}},"OrderDeviationCountsSchema":{"title":"OrderDeviationCountsSchema","type":"object","required":["results"],"description":"One count of orders with open deviations per query, with the queryKey of the query. Empty when includeDeviations was not set.","properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/OrderCountResponseSchema"}}}},"OrderCountRequestListSchema":{"title":"OrderCountRequestListSchema","type":"object","required":["queries"],"properties":{"queries":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/OrderCountRequestSchema"}},"includeDeviations":{"type":"boolean","default":false,"description":"When true, the response also counts, for each query, the orders with at least one open deviation, in `deviations.results` with the same `queryKey`. Only `storeUids` and `organizationUids` of the query are used (when both are given an order must match both). Every deviation type counts, and an order counts once. The other filters of the query do not apply. To count orders with deviations under the whole query, set `hasDeviations` in the query.\n"}}},"OrderCountRequestSchema":{"title":"OrderCountRequestSchema","type":"object","required":["queryKey","query"],"properties":{"queryKey":{"type":"string","description":"Used for correlating requests and responses. Can be any value."},"query":{"$ref":"#/components/schemas/TenantOrderSearchSchema"}}},"TenantOrderSearchSchema":{"description":"Search for orders in all stores on tenant. \n\nThe search is not limited to the stores the caller works at: it reaches every store of the tenant, and so does the order counts endpoint that takes this same body. Send storeUids or organizationUids to narrow it.\n\nKeys combine: every key the request supplies narrows the search, and where a key sits in the object means nothing.\n\nAn empty string will be ignored, and handled as if the key did not exist in the payload.\n\nFuzzy search means that it will try to find words that contains the query string that is supplied. The search is case-insensitive. \nExample: If you search for \"Ol\" you will get \"Olsen\", \"Olstad\", \"Bolset\", \"Ormebol\", kolstad@example.com, etc ..","title":"TenantOrderSearchSchema","type":"object","properties":{"hasDeviations":{"type":"boolean","description":"true: only orders with at least one open deviation. false: only orders without an open deviation. Leave it out for no filter. Also applies to the order counts endpoint that takes this body.\n"},"storeUids":{"type":"array","items":{"$ref":"#/components/schemas/UID"}},"organizationUids":{"type":"array","items":{"$ref":"#/components/schemas/UID"}},"customerQuery":{"description":"Search for orders containting this customer. The customer can be specific by firstname, lastname, phonenumber or email. This is a fuzzy search.","type":"string"},"customerUid":{"$ref":"#/components/schemas/UID"},"fromDateTime":{"format":"date-time","type":"string","deprecated":true},"createdAtFrom":{"format":"date-time","type":"string"},"settledAtFrom":{"format":"date-time","type":"string"},"lastModifiedAtFrom":{"format":"date-time","type":"string"},"orderNumber":{"description":"Search for an order with a specific ordernumber. This is an exact lookup","type":"string"},"serviceNumber":{"description":"Search for the sales orders a service order was billed on, by that service order's service number — the sales orders post-serviceorders-orders created from it, which list-orders-serviceorders reports as BILLED. This is an exact lookup: the whole service number, never a prefix, and only the tenant's own service orders are looked at. A service order billed more than once returns each of its sales orders the search covers, and a service number no service order of the tenant holds returns none. A cancelled sales order is left out unless orderStates or orderStatuses asks for one, which is this search's own default rather than this key's doing.\nLike orderNumber, it narrows the search together with every other key sent, so it is sent alone to find the sale of a service number scanned off a service paper or the intake slip.\nUnlike a service number in query, it is honoured by the counts of post-tenants-tenantUid-orders-search-counts, which take this schema too: they count the sales orders it finds.","type":"string"},"externalOrderNumber":{"description":"Search for an order with a specific externalOrderNumber. This is an exact lookup","type":"string"},"externalVoucherNumber":{"description":"Search for an order with a specific externalVouchermber. This is an exact lookup","type":"string","deprecated":true},"externalIdKey":{"description":"Search for orders with an external ID for the given key. Must be used together with externalIdValue.","type":"string"},"externalIdValue":{"description":"Exact match on external ID value for the given externalIdKey.","type":"string"},"serialnumber":{"description":"Search for the order a serialised unit was sold on. An order matches when any of its product lines carries this serial number.\nThe value is matched against the serial number recorded on the line — a serial or an IMEI, whichever was captured — whole and case insensitively, never partially.\nA line matches on a quote, on a credit line and on a line that was never handed over; narrow with orderTypes, orderStates and deliveryStates to leave those out. A cancelled order is left out unless orderStates or orderStatuses asks for one, which is this search's own default rather than this key's doing. Nothing here tells a credit line from the sale it reverses.\nSo a scanned serial finds the sale wherever in the tenant the unit was bought, which is what intake needs.","type":"string"},"productSku":{"description":"Search for orders containing the product. This must be a SKU and is an exact lookup.","type":"string"},"toDateTime":{"format":"date-time","type":"string","deprecated":true},"createdAtTo":{"format":"date-time","type":"string"},"settledAtTo":{"format":"date-time","type":"string"},"lastModifiedAtTo":{"format":"date-time","type":"string"},"tenantUserUids":{"type":"array","items":{"$ref":"#/components/schemas/UID"}},"orderStates":{"type":"array","description":"Reference to a list of orderStates.","items":{"$ref":"#/components/schemas/OrderOrderStateENUM"}},"settleStates":{"type":"array","description":"Reference to a list of settleStates.","items":{"$ref":"#/components/schemas/OrderSettleStateENUM"}},"deliveryStates":{"type":"array","description":"Reference to an array of deliveryStates.","items":{"$ref":"#/components/schemas/OrderDeliveryStateENUM"}},"orderStatuses":{"type":"array","description":"Reference to a list of orderStatuses.","items":{"$ref":"#/components/schemas/OrderStatusENUM"}},"orderTypes":{"type":"array","description":"Reference to a list of orderTypes","items":{"$ref":"#/components/schemas/OrderTypeENUM"}},"orderHandlingStates":{"type":"array","items":{"$ref":"#/components/schemas/HandlingStateENUM"}},"orderHandlingUids":{"type":"array","items":{"$ref":"#/components/schemas/UID"}},"deliverFromStoreUids":{"type":"array","items":{"$ref":"#/components/schemas/UID"}},"query":{"type":"string","description":"General fuzzy search.\nIn post-tenants-orders-search, a query of one word that is the service number of one of the tenant's service orders also finds, among the sales orders the search covers, every sales order that service order was billed on — the sales orders post-serviceorders-orders created from it, which list-orders-serviceorders reports as BILLED — so a service number scanned off a service paper or the intake slip finds the sale. The service number is matched exactly, never as a prefix, and a service order billed more than once returns each of its sales orders. A service number is a plain number and can equal an order or voucher number; the query then returns both.\nThe counts of post-tenants-tenantUid-orders-search-counts, which take this schema too, do not match a service number."},"productUids":{"type":"array","items":{"$ref":"#/components/schemas/UID"}},"tenantPaymentMethodUids":{"type":"array","description":"Search for order containing one of the specified payment methods.","items":{"$ref":"#/components/schemas/UID"}},"reservationTypes":{"type":"array","items":{"$ref":"#/components/schemas/SalesReservationTypeENUM"}},"isCustomerOrder":{"type":"boolean","description":"If true, returns orders with orderlines that has either reservationType='REQUEST_PURCHASEORDER' or has a link to a purchaseOrder item"},"hasReservedLines":{"type":"boolean","description":"When true, the search returns only orders that include at least one order line with a reservation (reservedQuantity <> 0).\nWhen omitted or false, reservation state does not affect the results."},"amountRange":{"$ref":"#/components/schemas/AmountRangeSchema"},"orderDateFrom":{"type":"string","format":"date-time"},"orderDateTo":{"type":"string","format":"date-time"}}},"UID":{"title":"UID","type":"string","pattern":"^[A-Za-z0-9-_]+"},"OrderOrderStateENUM":{"description":"|ENUM | Description |\n| --- | --- |\n| OPEN | Order is open and beeing edited by someone|\n| PARKED | Order is parked|\n| CANCELED | Order is canceled/deleted|\n| COMPLETE | Order is complete|\n| CONFIRMED | Order is confirmed|\n","enum":["OPEN","PARKED","CANCELED","COMPLETE","CONFIRMED"],"title":"OrderOrderStateENUM","type":"string"},"OrderSettleStateENUM":{"description":"|ENUM      | Description |\n| ---------------- | ------------ |\n| NOT_STARTED | Settlement not started|\n| IN_PROGRESS | Settlement is in progress and the order cannot be changed|\n| COMPLETE | Settlement is complete|","enum":["NOT_STARTED","IN_PROGRESS","COMPLETE"],"title":"OrderSettleStateENUM","type":"string"},"OrderDeliveryStateENUM":{"description":"|ENUM      | Description |\n| ---------------- | ------------ |\n| NOT_STARTED | Delivery not started|\n| IN_PROGRESS | Delivery is in progress. Some order lines are still reserved|\n| COMPLETE | Delivery is complete. All order lines are delivered|","enum":["NOT_STARTED","IN_PROGRESS","COMPLETE"],"title":"OrderDeliveryStateENUM","type":"string"},"OrderStatusENUM":{"description":"|ENUM      | Description |\n| ---------------- | ------------ |\n| OPEN | Order is open and beeing edited by someone|\n| PARKED | Order is parked|\n| CANCELED | Order is canceled/deleted|\n| DELIVERED | Order is completely delivered|\n| READY_FOR_DELIVERY | Order is settled and ready to be delivered|\n| UNPAID | Order is settled with settlementCode INVOICE and is not fully paid|\n| CONFIRMED | Order is confirmed|","enum":["OPEN","PARKED","CANCELED","READY_FOR_DELIVERY","DELIVERED","UNPAID","CONFIRMED"],"title":"OrderStatusENUM","type":"string"},"OrderTypeENUM":{"enum":["OFFER","ORDER","PAYMENT"],"title":"OrderTypeENUM","type":"string"},"HandlingStateENUM":{"description":"|ENUM      | Description |\n| ---------------- | ------------ |\n| NOT_STARTED | Handling has not been started. |\n| IN_PROGRESS | Handling is in progress. |\n| ON_HOLD | Handling is paused (on hold). |\n| COMPLETE | Handling is complete. |","enum":["NOT_STARTED","IN_PROGRESS","ON_HOLD","COMPLETE"],"title":"HandlingStateENUM","type":"string"},"SalesReservationTypeENUM":{"title":"SalesReservationTypeENUM","type":"string","enum":["NONE","WAREHOUSE","PURCHASEORDER","REQUEST_PURCHASEORDER","PURCHASEORDER_CONFIRMED"],"description":""},"AmountRangeSchema":{"title":"AmountRangeSchema","type":"object","description":"Search for an amount range","required":["from","to"],"properties":{"from":{"type":"integer"},"to":{"type":"integer"}}}},"requestBodies":{"OrdersCountRequest":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderCountRequestListSchema"}}}}}},"paths":{"/tenants/{tenantUid}/orders/search/counts":{"post":{"summary":"Get counts of orders","tags":["Order"],"responses":{"200":{"$ref":"#/components/responses/OrdersCountResponse"}},"operationId":"post-tenants-tenantUid-orders-search-counts","description":"Get counts of orders. Required permissions: SALES_ORDER,RETURN_ORDER\n","requestBody":{"$ref":"#/components/requestBodies/OrdersCountRequest"}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flowretail.com/docs/developers/api-documentation/order/get-counts-of-orders.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
