# Reading data (queries)


The operations that read data.

#### Lists

A list is a connection. Pass exactly one of `first` or `last`, from 1 to 250, `after` only with
`first` and `before` only with `last`. Any other combination is refused with `VALIDATION`, and
`extensions.field` names the argument. A cursor belongs to the list it came from (and to its
`sortKey`): do not pass it to another list.

#### Partial results

A nullable field your API key may not read (`FORBIDDEN_ROLE`, `FORBIDDEN_SCOPE`), or a nested
page that could not be read, is null with an error at its path, and the rest of `data` is
returned. An error on a non-null field (marked `!`) nulls its parent instead: on a root list or
another root field marked `!`, `data` itself is null. Ask for such fields in separate requests
when one of them may fail.

A query for one record by its id (for example [`salesOrder`](/chameleoon-max/query/sales-order)) returns null, without an
error, when the record does not exist or your API key cannot see it. [`asset`](/chameleoon-max/query/asset),
[`printTemplate`](/chameleoon-max/query/print-template), [`emailTemplate`](/chameleoon-max/query/email-template) and [`emailMessage`](/chameleoon-max/query/email-message) answer
`NOT_FOUND` instead, as do [`stocktakeCountedLines`](/chameleoon-max/query/stocktake-counted-lines) and [`errorReports`](/chameleoon-max/query/error-reports) for
the record they name.

#### Cost

Every query is priced in points. See
[Limits and query cost](https://docs.chameleoon.sk/chameleoon-max/limits).

#### Changes

To learn what changed, follow [`events`](/chameleoon-max/query/events) or [`stockCardChanges`](/chameleoon-max/query/stock-card-changes) instead of
reading the lists again.

## All queries

### Orders

- [`salesOrder`](/chameleoon-max/query/sales-order) Returns one sales order.
- [`salesOrders`](/chameleoon-max/query/sales-orders) Returns a page of sales orders that match a filter, newest first by orderedAt, then by id.

### Receipts

- [`receiptAdvice`](/chameleoon-max/query/receipt-advice) Returns one receipt advice by its MAX id.
- [`receiptAdvices`](/chameleoon-max/query/receipt-advices) Returns a page of receipt advices that match a filter, newest first by advisedAt, then by id.
- [`receipts`](/chameleoon-max/query/receipts) Returns a page of receipts that match a filter, newest first by effectiveAt, then by when they were created, then by id.

### Transfers

- [`transferAdvice`](/chameleoon-max/query/transfer-advice) Returns one transfer advice by its MAX id.
- [`transferAdvices`](/chameleoon-max/query/transfer-advices) Returns a page of transfer advices that match a filter, newest issued first.
- [`transfers`](/chameleoon-max/query/transfers) Returns a page of transfers that match a filter, newest first by effectiveAt, then by when they were created, then by id.

### Products

- [`product`](/chameleoon-max/query/product) Returns one product, by its MAX id or by its code.
- [`products`](/chameleoon-max/query/products) Returns a page of products that match a filter, sorted by sortKey, then by id.

### Inventory

- [`stockCards`](/chameleoon-max/query/stock-cards) Returns a page of stock cards with their current figures, by variant, then warehouse.
- [`stockCardChanges`](/chameleoon-max/query/stock-card-changes) Returns the real changes of stock cards, oldest first, forward from a cursor.
- [`locations`](/chameleoon-max/query/locations) Returns a page of the bins of the named warehouses, by warehouse, code, then id.
- [`stockQuants`](/chameleoon-max/query/stock-quants) Returns what lies in which bin of the named warehouses: one row per variant, bin and lot with stock, in base units, by bin, variant, then row.
- [`stocktakeCountedLines`](/chameleoon-max/query/stocktake-counted-lines) Returns what a stocktake counted, by line, once MAX handed the stocktake over to the external system that manages the warehouse.
- [`warehouses`](/chameleoon-max/query/warehouses) Returns a page of the warehouses your API key may read, archived ones included, by code, then id.

### Stock planning

- [`planningCards`](/chameleoon-max/query/planning-cards) Returns a page of the stock cards that have a minimum, in the named warehouses, by variant, then warehouse: each with its figures (as stockCards computes…
- [`binRefills`](/chameleoon-max/query/bin-refills) Returns a page of the picking bins' levels in the named warehouses, by variant, bin code, then bin id.
- [`stockDemand`](/chameleoon-max/query/stock-demand) Returns a page of what confirmed orders wait for in the named warehouses, by variant, then warehouse: per product variant and warehouse, what is waiting, what…
- [`stockSources`](/chameleoon-max/query/stock-sources) Works out where needed goods could be taken from: each need is split over the free stock in the bins input.from reaches, in the order to take it.

### Invoices

- [`invoices`](/chameleoon-max/query/invoices) Returns a page of invoices that match a filter, newest issued first.
- [`invoice`](/chameleoon-max/query/invoice) Returns one invoice, by its MAX id or by its source and externalId.

### Shipments

- [`fulfilment`](/chameleoon-max/query/fulfilment) Returns one fulfilment by its MAX id.
- [`shipment`](/chameleoon-max/query/shipment) Returns one carrier shipment by its MAX id.
- [`carrierProfiles`](/chameleoon-max/query/carrier-profiles) Returns a page of the active carrier profiles from the Chameleoon carrier catalogue.

### Issues

- [`issues`](/chameleoon-max/query/issues) Returns a page of issues that match a filter, newest first by effectiveAt, then by when they were created, then by id.

### Documents

- [`document`](/chameleoon-max/query/document) Returns one document with its current version.

### Assets

- [`assets`](/chameleoon-max/query/assets) Returns the organisation's and the companies' assets, ordered by scope and code.
- [`asset`](/chameleoon-max/query/asset) Returns one asset by its MAX id.

### Print templates

- [`printTemplates`](/chameleoon-max/query/print-templates) Returns the organisation's print templates, ordered by kind, language and name.
- [`printTemplate`](/chameleoon-max/query/print-template) Returns one print template by its MAX id.
- [`builtInPrintTemplate`](/chameleoon-max/query/built-in-print-template) Returns the MAX built-in template of a kind in a language.

### Email templates

- [`emailTemplates`](/chameleoon-max/query/email-templates) Returns the e-mail templates: the MAX built-in templates first, then the organisation's own by name.
- [`emailTemplate`](/chameleoon-max/query/email-template) Returns one e-mail template, built-in or the organisation's, by its code.
- [`previewEmailTemplate`](/chameleoon-max/query/preview-email-template) Renders a template as sendEmail would, and stores and queues nothing.

### Emails

- [`emailMessages`](/chameleoon-max/query/email-messages) Returns the messages linked to a record, newest first.
- [`emailMessage`](/chameleoon-max/query/email-message) Returns one message by its MAX id.

### Tags

- [`tags`](/chameleoon-max/query/tags) Returns a page of the organisation's tags, by their order in MAX, then name.
- [`tagGroups`](/chameleoon-max/query/tag-groups) Returns a page of the organisation's tag groups, by their order in MAX, then name.

### Integrations

- [`errorReports`](/chameleoon-max/query/error-reports) Returns the error reports on one record, most recently seen first.
- [`events`](/chameleoon-max/query/events) Returns a page of the event log: what happened to the records listed below, read forward from a cursor, oldest first.
- [`externalSource`](/chameleoon-max/query/external-source) Returns the external source with this code.

### API access

- [`status`](/chameleoon-max/query/status) Returns whether the API is up and your API key works.
- [`apiKey`](/chameleoon-max/query/api-key) Returns the API key that you are calling with, as it applies right now.
