# stockCardChanges query


`stockCardChanges` 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](/chameleoon-max).

Returns the real changes of stock cards, oldest first, forward from a cursor. Use it to keep the
stock in an external source up to date after a full export with [`stockCards`](/chameleoon-max/query/stock-cards).

Without `after`, the answer is an empty page whose `endCursor` is the head ("now"). Take it
before a full export.

#### Permissions

Requires the `stockCard.read` permission. Records of warehouses outside your API key's
warehouse, legal-entity or country scope are left out without an error.

#### Paging

A forward-only feed, as [`events`](/chameleoon-max/query/events).

- `first` is required, from 1 to 250.
- Pass `pageInfo.endCursor` as `after` while `pageInfo.hasNextPage` is `true`, then keep polling
  with it.
- There is no `last`, no `before` and no total count.
- The cursors are this feed's own and bound to your API key's organisation. An events cursor,
  or another organisation's, returns `VALIDATION` at `after`.
- A cursor older than 30 days returns `VALIDATION` with `extensions.reason` `CURSOR_EXPIRED`.
  Export again and start without a cursor.
- A page costs 2 + first × the cost of one node.

#### Filters

The server applies the filters, and the cursor moves past the records they leave out.

- `warehouseIds` (at most 50) keeps the records of those warehouses.
- `changed` keeps the records in which at least one of the named figures changed.
- An omitted (or null) list matches all records, and an empty list matches none.

#### Waiting

`wait` holds the answer while nothing is waiting, until something is or the time is up.

- `wait` is in seconds, from 0 (the default) to 25. Any other value returns `VALIDATION` at
  `wait`.
- It waits only with `after`, and only when the page would be empty with `hasNextPage` `false`.
- It answers as soon as a record it would show 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 its `endCursor`.
- Your API key holds at most 4 waits open on one server, those of [`events`](/chameleoon-max/query/events) included.
  A further one waits the lesser of `wait` and 5 seconds without watching for records, then
  answers what is there by then.

#### Good to know

- The records of one card come in version order.
- A record can be read about 1 to 3 seconds after the stock write.

## Arguments

- `first`: `Int`
- `after`: `String`
- `warehouseIds`: [`[UUID!]`](/chameleoon-max/type/uuid)
- `changed`: [`[StockFigure!]`](/chameleoon-max/type/stock-figure)
- `wait`: `Int`

## Returns

[`StockCardChangeConnection!`](/chameleoon-max/type/stock-card-change-connection): a page of [`StockCardChange`](/chameleoon-max/type/stock-card-change).

## Example

**Query**

```graphql
query stockCardChanges($first: Int) {
  stockCardChanges(first: $first) {
    edges {
      cursor
    }
    nodes {
      id
      warehouseId
      variantId
      version
      occurredAt
      origin
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
```

**Variables**

```json
{
  "first": 10
}
```

**Response**

```json
{
  "data": {
    "stockCardChanges": {
      "edges": [
        {
          "cursor": "example"
        }
      ],
      "nodes": [
        {
          "id": "00000000-0000-4000-8000-000000000001",
          "warehouseId": "00000000-0000-4000-8000-000000000001",
          "variantId": "00000000-0000-4000-8000-000000000001",
          "version": 1,
          "occurredAt": "2026-01-01T00:00:00Z",
          "origin": "LIVE"
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "endCursor": "example"
      }
    }
  }
}
```

Values are illustrative: replace IDs and codes with your own before you send the call.
