---
updatedAt: 2026-08-18T18:39:20.000Z
agentTools:
  projectIndex: https://stockpit.readme.io/llms.txt
---

# Queries

Purchases are the purchase documents created for your suppliers.

# Available queries

### `Purchase` - Returns a single purchase based on the `id` provided

```graphql
query {
  Purchase (id: 100012) {
    id
    label
  }
}
```

### `Purchases` - Returns a list of purchases based on the filter define

```graphql
query {
  Purchases {
    data {
    	id
    	label
    }
  }
}
```

<br />

***

# Available fields

| id <span style={{ fontWeight: 'normal' }}> - [Int](/reference/data-types#int) </span> |
| ------------------------------------------------------------------------------------- |
| Unique identifier of the purchase                                                     |

| label <span style={{ fontWeight: 'normal' }}> - [String](/reference/data-types#string) </span> |
| ---------------------------------------------------------------------------------------------- |
| Title of the purchase                                                                          |

| notes <span style={{ fontWeight: 'normal' }}> - [String](/reference/data-types#string) </span> |
| ---------------------------------------------------------------------------------------------- |
| Notes attached to the purchase                                                                 |

| total\_units <span style={{ fontWeight: 'normal' }}> - [Float](/reference/data-types#float) </span> |
| --------------------------------------------------------------------------------------------------- |
| Total units of the purchase                                                                         |

| status <span style={{ fontWeight: 'normal' }}> - [String](/reference/data-types#string) </span> |
| ----------------------------------------------------------------------------------------------- |
| Status of the purchase (enum values :  active, archived, cancelled, completed, unpublished).    |

| update\_incoming <span style={{ fontWeight: 'normal' }}> - [Boolean](/reference/data-types#boolean) </span> |
| ----------------------------------------------------------------------------------------------------------- |
| If true, the purchase products have their incoming updated until they are delivered                         |

| dated\_at <span style={{ fontWeight: 'normal' }}> - [Date](/reference/data-types#date) </span> |
| ---------------------------------------------------------------------------------------------- |
| Date of the purchase                                                                           |

| created\_at <span style={{ fontWeight: 'normal' }}> - [DateTime](/reference/data-types#datetime) </span> |
| -------------------------------------------------------------------------------------------------------- |
| Creation date of the purchase                                                                            |

| supplier <span style={{ fontWeight: 'normal' }}> - [Supplier](/reference/supplier-queries) - Subquery </span> |
| ------------------------------------------------------------------------------------------------------------- |
| Supplier of the purchase                                                                                      |

| shipping\_at <span style={{ fontWeight: 'normal' }}> - [Date](/reference/data-types#date) </span> |
| ------------------------------------------------------------------------------------------------- |
| Date the shipping is planned                                                                      |

| shipping\_cost <span style={{ fontWeight: 'normal' }}> - [Float](/reference/data-types#float) </span> |
| ----------------------------------------------------------------------------------------------------- |
| Shipping costs of the purchase                                                                        |

| exchange\_rate <span style={{ fontWeight: 'normal' }}> - [Float](/reference/data-types#float) </span> |
| ----------------------------------------------------------------------------------------------------- |
| Exchange rate of the purchase                                                                         |

| currency <span style={{ fontWeight: 'normal' }}> - [String](/reference/data-types#string) </span> |
| ------------------------------------------------------------------------------------------------- |
| Currency code of the purchase (GBP, USD, ...)                                                     |

| committed <span style={{ fontWeight: 'normal' }}> - [Float](/reference/data-types#float) </span> |
| ------------------------------------------------------------------------------------------------ |
| Quantity already added to a purchase receipt                                                     |

| delivered <span style={{ fontWeight: 'normal' }}> - [Float](/reference/data-types#float) </span> |
| ------------------------------------------------------------------------------------------------ |
| Quantity already delivered                                                                       |

| purchase\_receipt <span style={{ fontWeight: 'normal' }}> - Array of [PurchaseReceipt](/reference/purchase-receipt-queries) - Subquery </span> |
| ---------------------------------------------------------------------------------------------------------------------------------------------- |
| List of the purchase receipts created from this purchase                                                                                       |

| orders <span style={{ fontWeight: 'normal' }}> - Array of [Order](/reference/order-queries) - Subquery </span> |
| -------------------------------------------------------------------------------------------------------------- |
| List of the orders the purchase is created from to reorder                                                     |

| line\_items <span style={{ fontWeight: 'normal' }}> - Array of [LineItem](/reference/line-item-queries) - Subquery </span> |
| -------------------------------------------------------------------------------------------------------------------------- |
| List of the line items of the purchase                                                                                     |

| integrations <span style={{ fontWeight: 'normal' }}> - [Integration](/reference/integration-queries) - Subquery </span> |
| ----------------------------------------------------------------------------------------------------------------------- |
| List of the ID of the items of the integrated solutions linked to this purchase                                         |

| has\_batch\_numbers <span style={{ fontWeight: 'normal' }}> - [Boolean](/reference/data-types#boolean) </span> |
| -------------------------------------------------------------------------------------------------------------- |
| Define if the purchase has batch numbers                                                                       |

| tracking\_completed <span style={{ fontWeight: 'normal' }}> - [Boolean](/reference/data-types#boolean) </span> |
| -------------------------------------------------------------------------------------------------------------- |
| If the purchase has batch numbers, are they all allocated                                                      |

<br />

***

# Filters

You can create filters based on following fields

| label                                                                    |
| :----------------------------------------------------------------------- |
| Example: \{ "column" : "LABEL", "operator" : "LIKE", "value" : "%011%" } |

| status                                                                         |
| :----------------------------------------------------------------------------- |
| Example: \{ column": "STATUS", "operator": "EQ", "value": \{"id": "completed"} |

| total\_units                                                          |
| :-------------------------------------------------------------------- |
| Example: \{ "column": "TOTAL\_UNITS", "operator": "GT", "value": 50 } |

| update\_incoming                                                           |
| :------------------------------------------------------------------------- |
| Example: \{ column": "UPDATE\_INCOMING", "operator": "EQ", "value": true } |

| dated\_at                                                                    |
| :--------------------------------------------------------------------------- |
| Example: \{ "column": "DATED\_AT", "operator": "EQ", "value": "2024-01-11" } |

| supplier\_id                                                              |
| :------------------------------------------------------------------------ |
| Example: \{ "column": "SUPPLIER\_ID", "operator": "EQ", "value": 100002 } |

| committed                                                              |
| :--------------------------------------------------------------------- |
| Example: \{ "column": "COMMITTED", "operator": "GT", "value": 149.09 } |

| shipping\_at                                                                    |
| :------------------------------------------------------------------------------ |
| Example: \{ "column": "SHIPPING\_AT", "operator": "LT", "value": "2024-01-11" } |

| delivered                                                           |
| :------------------------------------------------------------------ |
| Example: \{ "column": "DELIVERED", "operator": "LT", "value": 349 } |

| variant\_id                                                              |
| :----------------------------------------------------------------------- |
| Purchase containing this variant                                         |
| Example: \{ "column": "VARIANT\_ID", "operator": "EQ", "value": 100076 } |

| variant\_label                                                                    |
| :-------------------------------------------------------------------------------- |
| Example: \{ "column": "VARIANT\_LABEL", "operator": "EQ", "value": "NICE SHOES" } |

| variant\_sku                                                                 |
| :--------------------------------------------------------------------------- |
| Example: \{ "column": "VARIANT\_SKU", "operator": "EQ", "value": "10ABC45" } |

| location\_id                                                                |
| :-------------------------------------------------------------------------- |
| Example: \{ "column": "LOCATION\_ID", "operator": "EQ", "value": "100245" } |

| batch\_number\_id                                                                |
| :------------------------------------------------------------------------------- |
| Example: \{ "column": "BATCH\_NUMBER\_ID", "operator": "EQ", "value": "100024" } |

| tracking\_completed                                                                     |
| :-------------------------------------------------------------------------------------- |
| Example: \{ "column": "TRACKING\_COMPLETED", "operator": "EQ", "value": \{"id": true} } |

| has\_batch\_numbers                                                                    |
| :------------------------------------------------------------------------------------- |
| Example :\{ column": "HAS\_BATCH\_NUMBERS", "operator": "EQ", "value": \{"id": true} } |

***

# Sorting

You can sort data based on following fields : id, label, notes, total\_units, status, update\_incoming, dated\_at, created\_at, shipping\_at, supplier\_id, committed, delivered, currency

## Example of a query

```graphql
query Purchases(
  $orderBy: [QueryPurchasesOrderByOrderByClause!], 
  $where: QueryPurchasesWhereWhereConditions, 
  $first: Int = 50, 
  $page: Int
) {
  Purchases(
    orderBy: $orderBy
    where: $where
    first: $first
    page: $page
  ) {
    paginatorInfo {
      total
      count
      currentPage
      perPage
    }
    data {
      id
      label
      supplier {
        id
        label
      }
      line_items {
        id
        location {
          id
          label
        }
      }
      dated_at
      shipping_at
      total_units
      status
    }
  }
}
```

```json
{
  "orderBy": [
    {
      "order": "ASC",
      "column": "DATED_AT"
    }
  ],
  "first": 50,
  "page": 1,
  "where": {
    "AND": [
      {
        "AND": [
          {
            "column": "SHIPPING_AT",
            "operator": "GT",
            "value": "2023-10-03"
          }
        ]
      }
    ]
  }
}
```

## Example of data returned

```json
{
  "data": {
    "Purchases": {
      "paginatorInfo": {
        "total": 1,
        "count": 1,
        "currentPage": 1,
        "perPage": 50
      },
      "data": [
        {
          "id": 100011,
          "label": "P00000012",
          "supplier": null,
          "line_items": [
            {
              "id": 100231,
              "location": {
                "id": 100010,
                "label": "error"
              }
            },
            {
              "id": 100232,
              "location": {
                "id": 100010,
                "label": "error"
              }
            },
            {
              "id": 100233,
              "location": {
                "id": 100010,
                "label": "error"
              }
            }
          ],
          "dated_at": "2024-01-15",
          "shipping_at": "2023-10-14",
          "total_units": 2435933.23635,
          "status": "active"
        }
      ]
    }
  }
}

# Enums

## PurchaseStatus enum

| Value | Description |
| :--- | :--- |
| `active` | The purchase is active |
| `archived` | The purchase is archived |
| `cancelled` | The purchase is cancelled |
| `completed` | The purchase is completed |
| `unpublished` | The purchase is not yet published |
```