Skip to main content

Create Customer

Create Customer Mutation

This mutation creates a new customer account in the store with personal information, addresses, and preferences.

Use Cases​

  • Customer Registration: Create new customer accounts during signup
  • Admin Customer Management: Manually create customer profiles
  • Import Operations: Bulk import customers from external systems
  • Order Processing: Create customer profiles during checkout
  • CRM Integration: Sync customers from external CRM systems

Key Features​

Customer Information​

  • Personal Details: First name, last name, email, and phone
  • Account Status: Active/inactive status and verification state
  • Localization: Language and regional preferences
  • Contact Preferences: Marketing and communication settings

Address Management​

  • Multiple Addresses: Support for shipping and billing addresses
  • Geographic Data: Country, state, city, and region information
  • Contact Details: Phone numbers and delivery notes
  • Address Validation: Ensure proper geographic relationships

Customer Segmentation​

  • Tags: Categorize customers for marketing and analysis
  • Preferences: Store customer preferences and settings
  • Order History: Track customer purchase behavior
  • Loyalty Status: Manage VIP and loyalty program memberships

Input Parameters​

  • $input: CustomerInput! - Complete customer information including:
    • storeId: Store identifier where the customer will be created
    • firstName: Customer's first name
    • lastName: Customer's last name
    • email: Primary email address (must be unique)
    • phone: Primary phone number
    • isActive: Whether the customer account is active
    • locale: Customer's preferred language
    • addresses: Array of customer addresses
    • tags: Customer tags for segmentation
    • preferences: Customer preferences and settings

Response Structure​

The mutation would return a CreateCustomerPayload containing:

  • customer: Complete customer object with all created data
  • Generated customer ID and timestamps
  • Associated addresses and preferences
  • Order history and account status

Customer Fields Detail​

Basic Information​

  • id - Unique customer identifier
  • firstName/lastName - Customer name
  • email - Primary email address
  • phone - Primary phone number
  • isActive - Account status
  • isVerified - Email/phone verification status
  • locale - Preferred language
  • createdAt/updatedAt - Account timestamps

Associated Data​

  • addresses - Customer addresses with geographic data
  • orders - Order history with basic order information
  • tags - Customer segmentation tags
  • preferences - Account and marketing preferences

Example Response​

{
"data": {
"createCustomer": {
"customer": {
"id": "Customer_john_smith_001",
"firstName": "John",
"lastName": "Smith",
"email": "john.smith@example.com",
"phone": "+1-555-123-4567",
"isActive": true,
"isVerified": false,
"locale": "en",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z",
"addresses": [
{
"id": "Address_001",
"addressLine1": "123 Main Street",
"addressLine2": "Apt 4B",
"phone": "+1-555-123-4567",
"postalCode": "10001",
"areaSnapshot": {
"cityName": "New York",
"stateName": "New York",
"countryName": "United States"
}
}
],
"orders": {
"totalCount": 0,
"nodes": []
},
"tags": [
{
"id": "Tag_vip_001",
"name": "VIP",
"color": "#FFD700"
}
]
}
}
}
}

Implementation Notes​

Validation Requirements​

  • Email address must be unique within the store
  • Phone number format validation
  • Address geographic data must be valid
  • Required fields must be provided

Best Practices​

  • Implement email verification workflows
  • Validate phone numbers with proper formatting
  • Use proper address validation services
  • Set up customer segmentation from creation
  • Configure appropriate privacy settings

Error Handling​

  • Handle duplicate email addresses gracefully
  • Validate geographic data relationships
  • Check store customer limits
  • Ensure proper data privacy compliance

Security Considerations​

  • Hash and secure sensitive customer data
  • Implement proper access controls
  • Follow data privacy regulations (GDPR, CCPA)
  • Set up audit trails for customer data changes

Alternative Implementation​

Since this mutation may not be directly available, customer creation might happen through:

  1. Order Creation: Customers created automatically during checkout
  2. Authentication System: Customer registration through auth flows
  3. Import Tools: Bulk customer import functionality
  4. Admin Interface: Manual customer creation through admin panels
  • updateCustomer - Update existing customer information
  • createOrder - Create orders for customers
  • addCustomerAddress - Add addresses to customer accounts
  • tagCustomer - Add tags to customers for segmentation

GraphQL Endpoint​

https://graphql.wuilt.com

Operation: CreateCustomer​

Try It Out​

Query​

mutation CreateCustomer(
$storeId: ID!
$input: customerUserWithoutPasswordInput
) {
createCustomer(storeId: $storeId, input: $input) {
id
name
email
phone
storeId
isGuest
createdAt
updatedAt
addresses {
id
addressLine1
addressLine2
phone
secondPhone
postalCode
notes
isDefault
country {
id
name
__typename
}
state {
id
name
__typename
}
city {
id
name
__typename
}
region {
id
name
__typename
}
__typename
}
__typename
}
}

Query Variables

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

Note: Make sure to change the storeId with your store ID. For guidance on how to get your store ID, reference the Store ID guide.

Authentication​

To use this query, you will need an API key. Click the "API Key" button in the navigation bar to enter your credentials.