> For the complete documentation index, see [llms.txt](https://zrpl-co-1.gitbook.io/zrpl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zrpl-co-1.gitbook.io/zrpl/reference/api-reference/create-customer.md).

# Create Customer

<mark style="color:green;">`POST`</mark> `{{Base_url}}/rest/V1/customers`

This endpoint is used to create a **new customer account** in a Magento store. It allows administrators or third-party integrations to programmatically add customers. They can gain access to several features and benefits that enhance their shopping experience.

**Body**

{% tabs %}
{% tab title="Request Sample" %}

```json
{
  "customer": {
    "group_id": 1,
    "created_in": "ZEPP Store view",
    "email": "xyz@gmail.com",
    "firstname": "xyz",
    "lastname": "test",
    "store_id": 1,
    "website_id": 1,
    "custom_attributes": [
      {
        "attribute_code": "mobile_number",
        "value": "1234567890"
      }
    ]
  },
  "password": "xyz@123"
}
```

{% endtab %}
{% endtabs %}

#### **Root-Level Attributes**

1. **`customer`**
   * Contains all the details about the customer being created. It is an object encapsulating customer-specific fields.
2. **`password`**
   * The password for the customer's account, used for login purposes.

***

#### **Attributes within `customer`**

1. **`group_id`**
   * The ID of the customer group to which the customer belongs (e.g., General, Wholesale, or Retail).
2. **`created_in`**
   * The name of the store view where the account was created.
3. **`email`**
   * The customer's email address, used as the login username.
4. **`firstname`**
   * The first name of the customer.
5. **`lastname`**
   * The last name of the customer.
6. **`store_id`**
   * The ID of the store view associated with the customer.
7. **`website_id`**
   * The ID of the website where the customer account is being created.
8. **`custom_attributes`**
   * An array of custom attributes specific to the customer. Each custom attribute is represented as an object.

***

#### **Attributes within `custom_attributes`**

1. **`attribute_code`**
   * The code of the custom attribute being set (e.g., `mobile_number`).
2. **`value`**
   * The value assigned to the corresponding custom attribute (e.g., `1234567890` for `mobile_number`).

{% tabs %}
{% tab title="Curl" %}

```javascript
curl --location '{{Base_url}}/rest/V1/customers' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjU1LCJ1dHlwaWQiOjIsImlhdCI6MTczNzcxNDQxOCwiZXhwIjoxNzM3NzE4MDE4fQ.KsBdv1kC2b645s8ni_IgYFuXKVXfcAy3rpeR1Sh0e14' \
--header 'Cookie: PHPSESSID=6t4unirh1unu87ef0stp2sv3kv; private_content_version=5ab80b7def0c212f723edead3c971a19' \
--data-raw '{
  "customer": {
    "group_id": 1,
    "created_in": "ZEPP Store view",
    "email": "xyz@gmail.com",
    "firstname": "xyz",
    "lastname": "test",
    "store_id": 1,
    "website_id": 1,
    "custom_attributes": [
      {
        "attribute_code": "mobile_number",
        "value": "1234567890"
      }
    ]
  },
  "password": "xyz@123"
}'
```

{% endtab %}
{% endtabs %}

**Responses**

{% tabs %}
{% tab title="Success Response 200" %}

```javascript
{
    "id": 229223,
    "group_id": 1,
    "created_at": "2025-01-24 11:18:55",
    "updated_at": "2025-01-24 11:18:55",
    "created_in": "Default Store View",
    "email": "xyz@gmail.com",
    "firstname": "xyz",
    "lastname": "test",
    "store_id": 1,
    "website_id": 1,
    "addresses": [],
    "disable_auto_group_change": 0,
    "extension_attributes": {
        "is_subscribed": false
    },
    "custom_attributes": [
        {
            "attribute_code": "mobile_number",
            "value": "1234567890"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

1. **`id`**
   * The unique identifier of the customer in Magento (primary key for the customer record).
2. **`group_id`**
   * The ID of the customer group. This determines the customer's pricing and tax rules (e.g., General, Wholesale).
3. **`created_at`**
   * The timestamp when the customer account was created (`YYYY-MM-DD HH:MM:SS` format).
4. **`updated_at`**
   * The timestamp of the last update made to the customer account (`YYYY-MM-DD HH:MM:SS` format).
5. **`created_in`**
   * The name of the store view where the customer account was created (e.g., "Default Store View").
6. **`email`**
   * The email address associated with the customer account, used as their login username.
7. **`firstname`**
   * The first name of the customer.
8. **`lastname`**
   * The last name of the customer.
9. **`store_id`**
   * The ID of the store view to which the customer is associated.
10. **`website_id`**

* The ID of the website where the customer account is registered.

11. **`addresses`**

* An empty array because the customer currently has no saved addresses.

12. **`disable_auto_group_change`**

* A flag that indicates whether the customer can be automatically moved to another group.
* Value `0`: Auto-group change is allowed.
* Value `1`: Auto-group change is disabled.

***

#### **Extension Attributes**

1. **`is_subscribed`**
   * A boolean flag indicating whether the customer is subscribed to the newsletter.
   * `false`: The customer is not subscribed.

***

#### **Custom Attributes**

The `custom_attributes` array contains custom fields for the customer.

1. **`attribute_code`**
   * The code of the custom attribute (e.g., `mobile_number`).
2. **`value`**
   * The value of the custom attribute (e.g., `1234567890`).

{% tabs %}
{% tab title="Same Customer Response 400 " %}

```javascript
{
    "message": "A customer with the same email address already exists in an associated website."
}
```

{% endtab %}

{% tab title="Invalid Url 404" %}

```python
{
    "message": "Request does not match any route.",
    "trace": null
}
```

{% endtab %}
{% endtabs %}
