# Queries / Stocktakes

# Stocktakes

**Query**
## externalStocktake — Returns [ExternalStocktake](/documentation/Objects/Stocktake#ExternalStocktake)

**Scopes required:** see_stocktake

| Arguments | Type | Description |
| --- | --- | --- |
| id | [ID!](/documentation/Types/UUID#UUID) | The ID of the external stocktake to retrieve |

**Example Query**

```graphql
query GetExternalStocktake($id: ID!) {
    externalStocktake(id: $id) {
        id,
        zeroStock,
        overrideStock,
        status,
        timestamp
    }
}

# Example variables
{
    "id": "<ID>"
}
```

**Query**
## externalStocktakes — Returns [ConnectionType](/documentation/General/Connections) of [ExternalStocktake](/documentation/Objects/Stocktake#ExternalStocktake)

**Scopes required:** see_stocktake

### Sortable Fields
*Fields from [ExternalStocktake](/documentation/Objects/Stocktake#ExternalStocktake) that can be used to sort the connection items*

- createdAt

**Example Query**

```graphql
query GetExternalStocktakes {
    externalStocktakes {
        edges {
            node {
                id,
                zeroStock,
                overrideStock,
                status,
                timestamp
            }
        },
        pageInfo {
            hasNextPage,
            endCursor
        }
    }
}
```

**Query**
## stocktake — Returns [Stocktake](/documentation/Objects/Stocktake#Stocktake)

**Scopes required:** see_stocktake

| Arguments | Type | Description |
| --- | --- | --- |
| id | [ID!](/documentation/Types/UUID#UUID) | The ID of the stocktake to retrieve |

**Example Query**

```graphql
query GetStocktake($id: ID!) {
    stocktake(id: $id) {
        id,
        name,
        type,
        status,
        displayExpected
    }
}

# Example variables
{
    "id": "<ID>"
}
```

**Query**
## stocktakes — Returns [ConnectionType](/documentation/General/Connections) of [Stocktake](/documentation/Objects/Stocktake#Stocktake)

**Scopes required:** see_stocktake

### Sortable Fields
*Fields from [Stocktake](/documentation/Objects/Stocktake#Stocktake) that can be used to sort the connection items*

- name
- createdAt
- completedAt

| Arguments | Type | Description |
| --- | --- | --- |
| source | [[StocktakeSourceEnum!]](/documentation/Enums/Stocktake-Source-Enum#StocktakeSourceEnum) | Which source of the stocktakes to filter by, defaults to advanced stocktakes only |
| status | [StocktakeStatusEnum](/documentation/Enums/Stocktake-Status-Enum#StocktakeStatusEnum) | The status of the stocktakes to filter by |
| createdStart | [Date](/documentation/Types/Date#Date) | The start of when the stocktakes were created (inclusive) |
| createdEnd | [Date](/documentation/Types/Date#Date) | The end of when the stocktakes were created (inclusive) |
| completedStart | [Date](/documentation/Types/Date#Date) | The start of when the stocktakes were completed (inclusive) |
| completedEnd | [Date](/documentation/Types/Date#Date) | The end of when the stocktakes were completed (inclusive) |
| outlets | [[ID!]](/documentation/Types/UUID#UUID) | The outlets to get stocktakes from |

**Example Query**

```graphql
query GetStocktakes($source: [StocktakeSourceEnum!]) {
    stocktakes(source: $source) {
        edges {
            node {
                id,
                name,
                type,
                status,
                displayExpected
            }
        },
        pageInfo {
            hasNextPage,
            endCursor
        }
    }
}

# Example variables
{
    "source": [
        "EXTERNAL"
    ]
}
```