# Queries / Customers

# Customers

**Query**
## customer — Returns [Customer](/documentation/Objects/Customers#Customer)

**Scopes required:** see_customers

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

**Example Query**

```graphql
query GetCustomer($id: ID!) {
    customer(id: $id) {
        id,
        name,
        parent,
        deleted,
        clientId
    }
}

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

**Query**
## customerPayment — Returns [CustomerPayment](/documentation/Objects/Customers#CustomerPayment)

**Scopes required:** see_customers

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

**Example Query**

```graphql
query GetCustomerPayment($id: ID!) {
    customerPayment(id: $id) {
        id,
        reference,
        status,
        startBalance,
        amount
    }
}

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

**Query**
## customerPayments — Returns [ConnectionType](/documentation/General/Connections) of [CustomerPayment](/documentation/Objects/Customers#CustomerPayment)

**Scopes required:** see_customers

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

- timestamp
- amount

| Arguments | Type | Description |
| --- | --- | --- |
| customer | [ID](/documentation/Types/UUID#UUID) | The customer to retrieve the payments for, if not specified payments for all customers will be returned |
| status | [CustomerPaymentStatusEnum](/documentation/Enums/Customer-Payment-Status-Enum#CustomerPaymentStatusEnum) | The status of payments to retrieve |

**Example Query**

```graphql
query GetCustomerPayments($customer: ID) {
    customerPayments(customer: $customer) {
        edges {
            node {
                id,
                reference,
                status,
                startBalance,
                amount
            }
        },
        pageInfo {
            hasNextPage,
            endCursor
        }
    }
}

# Example variables
{
    "customer": "<CUSTOMER>"
}
```

**Query**
## customers — Returns [ConnectionType](/documentation/General/Connections) of [Customer](/documentation/Objects/Customers#Customer)

**Scopes required:** see_customers

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

- firstName
- lastName
- company

| Arguments | Type | Description |
| --- | --- | --- |
| codes | *[String!]* | Return the customers which have these customer codes |
| hasLoyaltyPoints | *Boolean* | Whether the customers has loyalty points or not, if unset loyalty points will be ignored |
| hasAccountBalance | *Boolean* | Whether the customers has account balances or not, if unset account balance will be ignored |
| customerGroup | [ID](/documentation/Types/UUID#UUID) | Filters the customers by their customer group, null will select customers without customer groups, if unset customer groups will be ignored |
| createdBefore | [DateTime](/documentation/Types/Date-Time#DateTime) | Filters users that have been created before or on the provided date time |
| createdAfter | [DateTime](/documentation/Types/Date-Time#DateTime) | Filters users that have been created after or on the provided date time |
| lastSaleBefore | [DateTime](/documentation/Types/Date-Time#DateTime) | Get the customers that have had a sale before this date (inclusive) |
| lastSaleAfter | [DateTime](/documentation/Types/Date-Time#DateTime) | Get the customers that have had a sale after this date (inclusive) |
| name | *String* | Filters customers by their name |
| email | [Email](/documentation/Types/Email#Email) | Filters customers to return those which contain this email address |
| phone | *String* | Filters customers to return those which contain this phone number |

**Example Query**

```graphql
query GetCustomers($codes: [String!]) {
    customers(codes: $codes) {
        edges {
            node {
                id,
                name,
                parent,
                deleted,
                clientId
            }
        },
        pageInfo {
            hasNextPage,
            endCursor
        }
    }
}

# Example variables
{
    "codes": [
        "<CODES>"
    ]
}
```