---
title: "customer"
description: "按ID返回客户信息"
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/queries/customer'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/queries/customer.md'
---
# customer

按ID返回客户信息

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

## Required Permissions

* `read_customers`

接口访问需要令牌，具体如何获取令牌参考：[身份认证](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md)。

## Arguments

* `id`

  [ID!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  要返回的客户的ID

## Returns

* `addresses`

  [[MailingAddress]](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/objects/mailing-address.md)

  地址信息

* `amountSpent`

  [MoneyV2](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/objects/money-v2.md)

  总花费金额

* `canDelete`

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

  能否被删除

* `createdAt`

  [Date](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/date.md)

  创建时间

* `defaultAddress`

  [MailingAddress](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/objects/mailing-address.md)

  默认地址

* `displayName`

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

  全名

* `email`

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

  邮箱

* `emailMarketingConsent`

  [CustomerEmailMarketingConsentState](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/objects/customer-email-marketing-consent-state.md)

  邮箱订阅信息

* `firstName`

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

  名字

* `id`

  [ID](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  客户id

* `lastName`

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

  姓氏

* `lifetimeDuration`

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

  客户加入店铺的时间，举例，例如 一天、一周、一年

* `locale`

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

  语言

* `note`

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

  备注

* `numberOfOrders`

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

  订单数

* `phone`

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

  手机号

* `smsMarketingConsent`

  [CustomerSmsMarketingConsentState](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/objects/customer-sms-marketing-consent-state.md)

  短信订阅状态

* `state`

  [CustomerState](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/enums/customer-state.md)

  客户状态

* `tags`

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

  标签

* `taxExempt`

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

  客户的订单能免税标识，true:能免税，false：不能免税

* `taxExemptions`

  [[FreeAreas]](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/objects/free-areas.md)

  客户免税列表

* `updatedAt`

  [Date](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/date.md)

  更新时间

* `validEmailAddress`

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

  邮箱地址校验，不保证邮箱地址真实性

* `verifiedEmail`

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

  邮箱是否验证

## Examples

### 查看客户详情

按ID查看客户详情

**Request:**

```json
query {
  customer(id: "gid://shopline/Customer/4600419107") {
    locale
    id
    state
    firstName
    lastName
    email
    phone
    createdAt
    updatedAt
    note
    verifiedEmail
    tags
    lifetimeDuration
    validEmailAddress
    amountSpent{
        amount
        currencyCode
    }
    taxExempt
        taxExemptions{
            countryCode
            provinceGCodeList
    }
    numberOfOrders
    lifetimeDuration
    validEmailAddress
    defaultAddress {
      address1
      address2
      city
      company
      country
      countryCodeV2
      firstName
      lastName
      id
      phone
      province
      provinceCode
      zip
      district
      town
    }
    addresses {
      address1
      address2
      city
      company
      country
      countryCodeV2
      firstName
      lastName
      id
      phone
      province
      provinceCode
      zip
      district
      town
    }
    canDelete
  }
}

```

**Response:**

```json
{
  "data": {
    "data": {
      "customer": {
        "canDelete": true,
        "id": "gid://shopline/Customer/4600419107",
        "lifetimeDuration": "14 days ago",
        "state": "NOT_INVITED",
        "tags": [
          "test1"
        ],
        "taxExemptions": [
          {
            "countryCode": "US",
            "provinceGCodeList": [
              "AK",
              "AL"
            ]
          }
        ],
        "addresses": [
          {
            "address1": "Chestnut Street 92",
            "district": "district",
            "firstName": "S*****",
            "lastName": "T*****",
            "city": "Louisville",
            "country": "United States",
            "phone": "0086138****1234",
            "province": "Kentucky",
            "zip": "40202",
            "address2": "Apartment 2",
            "provinceCode": null,
            "town": "Street",
            "company": "C*****",
            "countryCodeV2": "US",
            "id": "gid://shopline/MailingAddress/SL201UA6266776363820652562"
          }
        ],
        "createdAt": "2023-12-29T13:38:06.534Z",
        "defaultAddress": {
          "district": "district",
          "id": "gid://shopline/MailingAddress/SL201UA6266776363820652562",
          "lastName": "T*****",
          "phone": "0086138****1234",
          "provinceCode": null,
          "address1": "Chestnut Street 92",
          "address2": "Apartment 2",
          "province": "Kentucky",
          "zip": "40202",
          "country": "United States",
          "town": "Street",
          "city": "Louisville",
          "company": "C*****",
          "countryCodeV2": "US",
          "firstName": "S*****"
        },
        "email": "*****@example.com",
        "lastName": "T*****",
        "numberOfOrders": 0,
        "taxExempt": true,
        "updatedAt": "2023-12-29T13:38:08.470Z",
        "firstName": "S*****",
        "locale": null,
        "validEmailAddress": true,
        "verifiedEmail": true,
        "note": "Placed an order that had a fraud warning",
        "phone": "0086138****1234",
        "amountSpent": {
          "amount": "0",
          "currencyCode": "CLP"
        }
      }
    }
  }
}
```

## Error Handling

关于更多通用错误码说明，参考：[状态码和错误码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes)。

