---
title: "customerCreate"
description: "创建新客户"
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/mutations/customer-create'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/mutations/customer-create.md'
---
# customerCreate

创建新客户

- **Required Scopes:** `write_customers`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Mutation

## Required Permissions

* `write_customers`

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

## Arguments

* `input`

  [CustomerInput!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/inputs/customer-input.md)

  用于创建客户的输入字段

## Returns

* `customer`

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

  创建的客户

* `userErrors`

  [[BusinessCustomerUserError]](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/objects/business-customer-user-error.md)

  错误信息

## Examples

### 创建客户

创建客户信息

**Request:**

```json
{
  "input": {
    "addresses": [
      {
        "address1": "Chestnut Street 92",
        "address2": "Apartment 2",
        "city": "Louisville",
        "company": "C*****",
        "country": "United States",
        "countryCode": "US",
        "firstName": "S*****",
        "lastName": "T*****",
        "phone": "0086185****1234",
        "province": "Kentucky",
        "provinceCode": "4200021",
        "zip": "40202",
        "district":"district",
        "town":"Street"
      }
    ],
    "email": "******@example.com",
    "emailMarketingConsent": {
      "consentUpdatedAt": null,
      "marketingState": "SUBSCRIBED"
    },
    "firstName": "S*****",
    "lastName": "T*****",
    "note": "Placed an order that had a fraud warning",
    "phone": "0086185****1234",
    "smsMarketingConsent": {
      "consentUpdatedAt": null,
      "marketingState": "SUBSCRIBED"
    },
    "tags": [
      "test1"
    ],
    "taxExempt":true,
    "taxExemptions": [
        {
        "countryCode":"US",
        "provinceGCodeList":["AL","AK"]
        }
    ]
  }
}

```

**Response:**

```json
{
  "data": {
    "data": {
      "customerCreate": {
        "customer": {
          "email": "******@example.com",
          "lastName": "T*****",
          "note": "Placed an order that had a fraud warning",
          "phone": "0086185****1234",
          "tags": [
            "test1"
          ],
          "taxExempt": true,
          "taxExemptions": [
            {
              "countryCode": "US",
              "provinceGCodeList": [
                "AL",
                "AK"
              ]
            }
          ],
          "addresses": [
            {
              "city": "Louisville",
              "district": "district",
              "lastName": "T****",
              "province": "Kentucky",
              "firstName": "S*****",
              "phone": "0086185****1234",
              "address1": "Chestnut Street 92",
              "address2": "Apartment 2",
              "company": "C*****",
              "countryCodeV2": "US",
              "zip": "40202",
              "country": "United States",
              "id": "gid://shopline/MailingAddress/SL201UA6288180448515858676",
              "provinceCode": null,
              "town": "Street"
            }
          ],
          "createdAt": "2024-01-13T08:01:09.761Z",
          "firstName": "S*****",
          "id": "gid://shopline/Customer/4600508354",
          "updatedAt": "2024-01-13T08:01:10.541Z",
          "verifiedEmail": false,
          "defaultAddress": {
            "city": "Louisville",
            "district": "district",
            "phone": "0086185****1234",
            "company": "C*****",
            "lastName": "T*****",
            "provinceCode": null,
            "town": "Street",
            "zip": "40202",
            "province": "Kentucky",
            "address1": "Chestnut Street 92",
            "address2": "Apartment 2",
            "country": "United States",
            "firstName": "S*****",
            "id": "gid://shopline/MailingAddress/SL201UA6288180448515858676",
            "countryCodeV2": "US"
          }
        },
        "userErrors": null
      }
    }
  }
}
```

## 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)。

