events query
events is a GraphQL query of the Chameleoon MAX API. Send it as POST https://max-api.chameleoon.sk/api/v1/graphql with your API key, see Chameleoon MAX.
Returns a page of the event log: what happened to the records listed below, read forward from a cursor, oldest first. Use it as a change feed, so that your system learns about changes in MAX without reading every list again.
The log covers orders, receipts, issues, transfers, consignments, shipments, transfer advices, receipt advices, invoices imported from the accounting system, and documents attached to orders or to invoices.
Permissions
- Each entity type requires its own read permission, listed on
EventEntityType. - Entity types that your API key may not read are left out without an error.
- If your API key is limited to legal entities or warehouses, you see only their events.
Errors
| Code | When |
|---|---|
FORBIDDEN_ROLE | You name in types or entityTypes an entity type that your API key may not read, or your API key may read none of the entity types. |
VALIDATION | A name in types is not an event type that the feed writes. |
VALIDATION at wait | wait is outside 0 to 25. |
VALIDATION with extensions.reason CURSOR_EXPIRED | The events after the cursor are no longer kept (about 30 days), so some changes cannot be replayed. Read the current state from the lists again, then start the feed without a cursor and skip the events that what you read already reflects (see Paging). |
Paging
- The feed is forward-only. Pass
pageInfo.endCursorasafterwhilepageInfo.hasNextPageistrue, then keep polling with it. - There is no
last, nobeforeand no total count. firstis required, from 1 to 250. Every edge carries its own cursor.- One entity's events come in
versionorder. - Without
after, the feed starts with the oldest event kept, about 30 days back, and returns every event since. It does not start at the head, asstockCardChangesdoes. - You can receive an event that you have already applied: when you start again without a
cursor, or when you retry with an older cursor. Skip an event whose
versionis not higher than the version you hold for itsentityTypeandentityId. - Receipts, issues, transfers and shipments return their last event's
versionwhen you read them (null while an event is being written: read again). For the other entity types, keep theversionof the last event you applied; after you read their state again you hold none, so take each of their events as a sign to read the record again rather than applying itstransitions.
Waiting
wait is a number of seconds, from 0 (the default) to 25.
- MAX waits only when you pass
after, and only when the page would be empty withhasNextPagefalse. - It answers as soon as an event that you may see arrives.
- When the time is up, or the server is shutting down, it answers with an empty page and an
advanced
endCursor. An empty answer is never an error: poll again with itsendCursor. - Your API key holds at most 4 waits open on one server, those of
stockCardChangesincluded. A further wait lastswaitor 5 seconds, whichever is less, without watching for events, then answers with what is there by then.
Event types
| Entity type | Event types |
|---|---|
SALES_ORDER | sales_order.confirmed, sales_order.completed, sales_order.reopened, sales_order.cancelled, sales_order.merged, sales_order.changed |
RECEIPT | receipt.opened, receipt.completed, receipt.cancelled, receipt.revised, receipt.changed |
ISSUE | issue.opened, issue.completed, issue.cancelled, issue.revised, issue.changed |
TRANSFER | transfer.opened, transfer.completed, transfer.cancelled, transfer.revised, transfer.changed |
FULFILMENT | fulfilment.created, fulfilment.shipped, fulfilment.cancelled, fulfilment.reset, fulfilment.changed |
SHIPMENT | shipment.created, shipment.changed, shipment.cancelled |
TRANSFER_ADVICE | transfer_advice.opened, transfer_advice.changed, transfer_advice.closed, transfer_advice.cancelled |
RECEIPT_ADVICE | receipt_advice.opened, receipt_advice.changed, receipt_advice.closed, receipt_advice.cancelled |
DOCUMENT | document.attached, document.version_added, document.removed |
INVOICE | invoice.created, invoice.changed |
STOCKTAKE | stocktake.handed_over |
New event types and enum values are added without notice. Ignore those you do not know.
A page costs 2 + first × the cost of one node.
Arguments
first:Intafter:Stringtypes:[String!]entityTypes:[EventEntityType!]wait:Int
Returns
EventConnection!: a page of Event.
Example
Query
Code
Variables
Code
Response
Code
Values are illustrative: replace IDs and codes with your own before you send the call.