# planningCards query


`planningCards` 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 a page of the stock cards that have a minimum, in the named warehouses, by variant, then
warehouse: each with its figures (as [`stockCards`](/chameleoon-max/query/stock-cards) computes them), its levels and what
to order to cover it. Use it to plan purchases or transfers between warehouses.

- Requires the `stockCard.read` permission.
- Only cards with a minimum are returned.
- Cards of warehouses outside your API key's warehouse, legal-entity or country scope are left
  out, as in [`stockCards`](/chameleoon-max/query/stock-cards).
- The connection has no total count.

`filter.exceptAdviceIds` names OPEN transfer advices that nobody has started, at most 20. The
answer reads as if they were not there: their remaining quantity is left out of `advised`. A
workflow that plans again uses it to see the stock without the transfer advice it wrote last
time.

- It requires the `transferAdvice.read` permission when it is not empty. Without it, the query
  returns `FORBIDDEN_ROLE` with `extensions.field` `exceptAdviceIds`.
- Any OPEN transfer advice your API key may read can be named, whoever wrote it.
- An advice somebody has started (a transfer links it) returns `VALIDATION` at
  `exceptAdviceIds` with `extensions.reason` `ADVICE_STARTED`.
- Any other id (an advice of another status, outside your scope, or unknown) changes nothing.

Pass exactly one of `first` or `last`, from 1 to 250. `first` (with `after`) pages forward;
`last` (with `before`) pages backward. `last` alone returns the last page. Every edge carries
its own cursor.

A page costs 2 + first (or last) × the cost of one node.

## Arguments

- `filter`: [`PlanningCardFilter!`](/chameleoon-max/type/planning-card-filter) · required
- `first`: `Int`
- `after`: `String`
- `last`: `Int`
- `before`: `String`

## Returns

[`PlanningCardConnection!`](/chameleoon-max/type/planning-card-connection): a page of [`PlanningCard`](/chameleoon-max/type/planning-card).

## Example

**Query**

```graphql
query planningCards($filter: PlanningCardFilter!, $first: Int) {
  planningCards(filter: $filter, first: $first) {
    edges {
      cursor
    }
    nodes {
      variantId
      warehouseId
      quantity
      reserved
      waiting
      available
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
  }
}
```

**Variables**

```json
{
  "filter": {
    "warehouseIds": [
      "00000000-0000-4000-8000-000000000001"
    ]
  },
  "first": 10
}
```

**Response**

```json
{
  "data": {
    "planningCards": {
      "edges": [
        {
          "cursor": "example"
        }
      ],
      "nodes": [
        {
          "variantId": "00000000-0000-4000-8000-000000000001",
          "warehouseId": "00000000-0000-4000-8000-000000000001",
          "quantity": "10.00",
          "reserved": "10.00",
          "waiting": "10.00",
          "available": "10.00"
        }
      ],
      "pageInfo": {
        "hasNextPage": true,
        "hasPreviousPage": true,
        "startCursor": "example",
        "endCursor": "example"
      }
    }
  }
}
```

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