**版本：202701**

# 创建顾客

**POST** `/openapi/2027-01/customers`

使用提供的详情创建新顾客。

## 请求

**application/json**

**请求体 | 示例**

**请求体 (required)**

- `customer` object (required)

  顾客信息

  - `contact_type` string (required)

    phone 或 email。若为 phone，则电话参数必填；否则邮箱参数必填
  - `first_name` string

    顾客的名
  - `last_name` string

    顾客的姓
  - `password` string

    顾客的密码
  - `password_confirmation` string

    密码确认
  - `tags` string[]

    顾客的标签
  - `registered_at` string

    创建时间，格式为 ISO-8601
  - `addresses` object[]

    顾客对象下的地址列表

    *   Array \[

    - `country` string (required)

      地址所在国家名称，至少 1 个字符，如 "China"
    - `country_code` string (required)

      ISO 国家代码，至少 1 个字符，如中国为 "CN"
    - `first_name` string

      收件人的名
    - `last_name` string

      收件人的姓
    - `address1` string

      地址，如门牌号和街道名称，用于指定地址的主要位置
    - `address2` string

      附加地址，如公寓号或套房号，用于提供更具体的地址信息
    - `area` string

      地址所在区域或地区
    - `city` string

      地址所在城市，指定城市或乡镇的名称
    - `province` string

      地址所在省份或州，指定国家内的行政区划或地区
    - `province_code` string

      地址所在省份代码，指定省份或州的简称或标准化代码
    - `company` string

      与地址关联的公司名称
    - `phone` string

      收件人的电话号码
    - `phone_area_code` string

      电话号码区号，用于标识特定地理区域的电话代码
    - `zip` string

      地址的邮政编码，用于标识特定地理区域的邮件投递代码
    - `gender` string

      人员性别，可选字段。可接受值为 "male" 和 "female"
    - `email` string

      收件人的电子邮件地址，用于指定收件人的邮箱
    - `default` boolean

      是否为默认地址。若为用户创建的第一个地址则为 "true"，否则为 "false"
    *   \]
  - `email` string

    电子邮件地址，当 contact\_type 为 email 时必填
  - `phone` string

    含区号的电话号码，当 contact\_type 为 phone 时必填
  - `accepts_marketing` boolean

    是否订阅营销邮件活动，默认为 true

    **默认值：** `true`
  - `accepts_sms_marketing` boolean

    是否订阅短信营销活动，默认为 true

    **默认值：** `true`

```json
{
  "customer": {
    "contact_type": "string",
    "first_name": "string",
    "last_name": "string",
    "password": "string",
    "password_confirmation": "string",
    "tags": [
      "string"
    ],
    "registered_at": "string",
    "addresses": [
      {
        "country": "string",
        "country_code": "string",
        "first_name": "string",
        "last_name": "string",
        "address1": "string",
        "address2": "string",
        "area": "string",
        "city": "string",
        "province": "string",
        "province_code": "string",
        "company": "string",
        "phone": "string",
        "phone_area_code": "string",
        "zip": "string",
        "gender": "string",
        "email": "string",
        "default": true
      }
    ],
    "email": "string",
    "phone": "string",
    "accepts_marketing": true,
    "accepts_sms_marketing": true
  }
}
```

## 响应

**200**

OK

**application/json**

**数据结构 | 示例**

**数据结构**

- `code` string

  错误码
- `message` string

  错误信息
- `data` object

  - `customer` object

    顾客信息

    - `id` string

      顾客的唯一标识
    - `email` string

      顾客的电子邮件地址
    - `created_at` string

      顾客创建时间，ISO-8601 格式
    - `updated_at` string

      顾客最后更新时间，ISO-8601 格式
    - `first_name` string

      顾客的名
    - `last_name` string

      顾客的姓
    - `phone` string

      顾客的电话号码
    - `tags` string[]

      顾客标签
    - `name` string

      顾客的名字
    - `phone_area_code` string

      电话号码的区号
    - `contact_type` string

      联系方式类型，邮箱或电话
    - `sms_subscribed_flag` int32

      顾客的短信订阅状态标志
    - `addresses` object[]

      顾客的所有地址列表

      *   Array \[

      - `id` string

        地址的唯一标识
      - `customer_id` string

        顾客 ID
      - `first_name` string

        收件人的名
      - `last_name` string

        收件人的姓
      - `company` string

        公司名称
      - `city` string

        地址所在城市
      - `province` string

        地址所在省份或州
      - `country` string

        地址所在国家名称
      - `zip` string

        邮政编码
      - `province_code` string

        省份代码
      - `country_code` string

        ISO 国家代码
      - `gender` string

        收件人的性别
      - `phone` string

        与地址关联的电话号码
      - `phone_area_code` string

        电话号码的区号
      - `area` string

        地址所在区域或地区
      - `email` string

        与地址关联的电子邮件
      - `name` string

        收件人的全名
      - `address1` string

        地址1
      - `address2` string

        地址2
      - `country_name` string

        国家全称
      - `default` boolean

        是否为默认地址
      *   \]
    - `accepts_marketing` boolean

      顾客是否订阅了营销邮件
    - `source` string

      顾客数据来源
    - `free_tax` boolean

      顾客是否享有税收豁免
    - `registered` boolean

      顾客是否已注册
    - `orders_count` int32

      顾客的累计下单数量
    - `first_order_at` string

      首次下单时间
    - `last_order_at` string

      顾客最后一次下单时间
    - `total_spent` string

      顾客的累计消费金额
    - `subscribed_flag` int32

      顾客的营销订阅状态
    - `accepts_sms_marketing` boolean

      顾客是否订阅了短信营销活动

```json
{
  "code": "string",
  "message": "string",
  "data": {
    "customer": {
      "id": "string",
      "email": "string",
      "created_at": "string",
      "updated_at": "string",
      "first_name": "string",
      "last_name": "string",
      "phone": "string",
      "tags": [
        "string"
      ],
      "name": "string",
      "phone_area_code": "string",
      "contact_type": "string",
      "sms_subscribed_flag": 0,
      "addresses": [
        {
          "id": "string",
          "customer_id": "string",
          "first_name": "string",
          "last_name": "string",
          "company": "string",
          "city": "string",
          "province": "string",
          "country": "string",
          "zip": "string",
          "province_code": "string",
          "country_code": "string",
          "gender": "string",
          "phone": "string",
          "phone_area_code": "string",
          "area": "string",
          "email": "string",
          "name": "string",
          "address1": "string",
          "address2": "string",
          "country_name": "string",
          "default": true
        }
      ],
      "accepts_marketing": true,
      "source": "string",
      "free_tax": true,
      "registered": true,
      "orders_count": 0,
      "first_order_at": "string",
      "last_order_at": "string",
      "total_spent": "string",
      "subscribed_flag": 0,
      "accepts_sms_marketing": true
    }
  }
}
```
