---
title: "segments"
description: "List of stores segment the market"
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/docs/admin-graph-ql-api/customers/queries/segments'
  md: 'https://developer.shopline.com/docs/admin-graph-ql-api/customers/queries/segments.md'
---
# segments

List of stores segment the market

- **Required Scopes:** `read_customers`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Query

## Type Signature

`SegmentConnection`

## Required Permissions

* `read_customers`

An access token is required to call this API. Refer to [Authorization](https://developer.shopline.com/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md) for more information about how to obtain the token.

## Arguments

* `first`

  [Int](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/int.md)

  Returns the first n elements in the list. 

* `last`

  [Int](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/int.md)

  Returns the last n elements in the list. 

* `reverse`

  [Boolean](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/boolean.md)

  Whether to reverse the order of the list. 
  
  ● true: reverse
  
  ● false: do not reverse
  
  Default value: false

* `sortKey`

  [SegmentSortKeys](https://developer.shopline.com/docs/admin-graph-ql-api/customers/enums/segment-sort-keys.md)

  Sort by specified key value

* `rawQuery`

  [String](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/string.md)

  Query conditions, such as segment name

* `after`

  [String](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/string.md)

  Returns elements following the specified cursor. The `first` argument must also be specified when using this argument.

* `before`

  [String](https://developer.shopline.com/docs/admin-graph-ql-api/common/scalars/string.md)

  Returns elements preceding the specified cursor. The `last` argument must also be specified when using this argument.

## Returns

* `edges`

  [[SegmentEdge!]](https://developer.shopline.com/docs/admin-graph-ql-api/customers/objects/segment-edge.md)

  edges list

* `nodes`

  [[Segment]](https://developer.shopline.com/docs/admin-graph-ql-api/customers/objects/segment.md)

  node list

* `pageInfo`

  [PageInfo!](https://developer.shopline.com/docs/admin-graph-ql-api/common-objects/objects/page-info.md)

  Information to aid in pagination.

## Code Example

```graphql
 {
	segments(first, last, reverse, sortKey, rawQuery, after, before ) 
		 {
			# SegmentConnection fields
		}
}
```

## Examples

### query segments

Query customer segment list

**Request:**

```json
query {
  segments (first: 2, rawQuery: null,after:null,before:null,reverse:true,sortKey:LAST_EDIT_DATE) {
    edges {
      cursor
      node {
        id
        name
        query
        creationDate
        lastEditDate
      }
    }
    nodes {
        id
        name
        query
        creationDate
        lastEditDate
    }
    pageInfo {
        endCursor
        hasNextPage
        hasPreviousPage
        startCursor
    }
  }
}

```

**Response:**

```json
{
  "data": {
    "data": {
      "segments": {
        "edges": [
          {
            "cursor": "39C77C6A85E202FDAAB6A0D829D4F007",
            "node": {
              "creationDate": "2022-09-13T11:20:19.745Z",
              "id": "gid://shopline/Segment/GROUP5582449353606848831",
              "lastEditDate": "2023-12-29T12:29:46.589Z",
              "name": "New",
              "query": "{\"conditions\":{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"37a6365b-67bf-4c3e-86c2-f0b086db63db\\\"}\",\"children\":[{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"26ba86d5-9658-4b2b-beed-7c27612eb7af\\\"}\",\"children\":[{\"type\":0,\"blockType\":0,\"metafield\":false,\"key\":\"payOrderCnt\",\"value\":[1],\"operator\":\"LT\"}]}]},\"not\":{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"8efe7f6f-96d4-457b-bccb-a5418abc200a\\\"}\",\"children\":[{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"53f86c31-aebe-4fab-9f20-b9f6f150322c\\\"}\",\"children\":[]}]}}"
            }
          },
          {
            "cursor": "AF52536A1951B28A30AAE8825A2B69B9",
            "node": {
              "name": "Returning",
              "query": "{\"conditions\":{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"2ddd694c-43bf-4e51-8267-e81ae609f748\\\"}\",\"children\":[{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"556149a7-de15-4525-83c8-14079adc017d\\\"}\",\"children\":[{\"type\":0,\"blockType\":0,\"metafield\":false,\"key\":\"payOrderCnt\",\"value\":[1],\"operator\":\"GT\"}]}]},\"not\":{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"65b327aa-e627-4df7-8276-af7649cade78\\\"}\",\"children\":[{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"9adf2014-c753-4b68-b247-201f35ba98db\\\"}\",\"children\":[]}]}}",
              "creationDate": "2022-09-13T11:20:19.762Z",
              "id": "gid://shopline/Segment/GROUP5582449353892061504",
              "lastEditDate": "2023-12-29T12:29:46.589Z"
            }
          }
        ],
        "nodes": [
          {
            "creationDate": "2022-09-13T11:20:19.745Z",
            "id": "gid://shopline/Segment/GROUP5582449353606848831",
            "lastEditDate": "2023-12-29T12:29:46.589Z",
            "name": "New",
            "query": "{\"conditions\":{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"37a6365b-67bf-4c3e-86c2-f0b086db63db\\\"}\",\"children\":[{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"26ba86d5-9658-4b2b-beed-7c27612eb7af\\\"}\",\"children\":[{\"type\":0,\"blockType\":0,\"metafield\":false,\"key\":\"payOrderCnt\",\"value\":[1],\"operator\":\"LT\"}]}]},\"not\":{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"8efe7f6f-96d4-457b-bccb-a5418abc200a\\\"}\",\"children\":[{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"53f86c31-aebe-4fab-9f20-b9f6f150322c\\\"}\",\"children\":[]}]}}"
          },
          {
            "creationDate": "2022-09-13T11:20:19.762Z",
            "id": "gid://shopline/Segment/GROUP5582449353892061504",
            "lastEditDate": "2023-12-29T12:29:46.589Z",
            "name": "Returning",
            "query": "{\"conditions\":{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"2ddd694c-43bf-4e51-8267-e81ae609f748\\\"}\",\"children\":[{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"556149a7-de15-4525-83c8-14079adc017d\\\"}\",\"children\":[{\"type\":0,\"blockType\":0,\"metafield\":false,\"key\":\"payOrderCnt\",\"value\":[1],\"operator\":\"GT\"}]}]},\"not\":{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"65b327aa-e627-4df7-8276-af7649cade78\\\"}\",\"children\":[{\"type\":1,\"blockType\":0,\"metafield\":false,\"relation\":\"and\",\"extInfo\":\"{\\\"id\\\":\\\"9adf2014-c753-4b68-b247-201f35ba98db\\\"}\",\"children\":[]}]}}"
          }
        ],
        "pageInfo": {
          "endCursor": "AF52536A1951B28A30AAE8825A2B69B9",
          "hasNextPage": true,
          "hasPreviousPage": false,
          "startCursor": "39C77C6A85E202FDAAB6A0D829D4F007"
        }
      }
    }
  }
}
```

## Error Handling

For detailed information about common codes, see [Status and error codes](https://developer.shopline.com/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes).

