This endpoint creates a new customer and can optionally create associated accounts in integrated systems like Stripe.
Request Body
Customer’s email address. Must be unique and valid format. Example: customer@example.com
Customer’s first name. Must be 1-50 characters. Example: John
Customer’s last name. Must be 1-50 characters. Example: Doe
Customer’s phone number in E.164 format (recommended) or local format. Examples: +1-555-123-4567
, (555) 123-4567
Customer’s date of birth in ISO 8601 format (YYYY-MM-DD). Example: 1990-05-15
Customer’s primary address information. Secondary address line (apartment, suite, etc.)
State or province code (e.g., “CA”, “NY”, “ON”)
ISO 3166-1 alpha-2 country code (e.g., “US”, “CA”, “GB”)
Whether the customer has consented to marketing communications.
Customer tier for loyalty programs. Options: bronze
, silver
, gold
, platinum
How the customer found your business. Options: organic
, paid_search
, social_media
, referral
, email
, direct
, other
Existing Stripe customer ID if you’re syncing with an external Stripe account. Note: If not provided and Stripe integration is enabled, a new Stripe customer will be created automatically.
Internal notes about the customer (not visible to customer). Max length: 1000 characters
Array of tags for customer segmentation and organization. Example: ["vip", "wholesale", "early-adopter"]
Additional custom fields as key-value pairs. Keys must be alphanumeric with underscores. Example: {
"company_name" : "Acme Corp" ,
"industry" : "Technology" ,
"employee_count" : "50-100"
}
Customer communication preferences. Show Preference Properties
Allow email notifications
Preferred language (ISO 639-1 code)
Customer’s timezone (IANA timezone identifier)
Response
Unique identifier for the created customer Example: cust_1NXWPnCo6bFb1KQto6C8OWvE
Customer’s full name (computed field)
Customer’s address information
Associated Stripe customer ID (if Stripe integration is enabled)
ISO 8601 timestamp when the customer was created
ISO 8601 timestamp when the customer was last updated
Customer status: active
, inactive
, suspended
Customer’s lifetime value (computed from order history)
Total number of orders placed by this customer
Custom field key-value pairs
Customer communication preferences
Basic Customer
Complete Customer Profile
Node.js SDK
Python SDK
Ruby SDK
Go SDK
PHP SDK
Java SDK
GraphQL Mutation
curl -X POST https://api.stateset.com/v1/customers \
-H "Authorization: Bearer sk_live_51HqJx2eZvKYlo2CXcQhJZPiQdoJO4v_FGtbA8QTy9E4tY" \
-H "Content-Type: application/json" \
-d '{
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"phone": "+1-555-123-4567"
}'
Success Response (201 Created)
Error Response (400 Bad Request)
Error Response (409 Conflict)
Error Response (422 Unprocessable Entity)
{
"id" : "cust_1NXWPnCo6bFb1KQto6C8OWvE" ,
"email" : "sarah.wilson@techcorp.com" ,
"first_name" : "Sarah" ,
"last_name" : "Wilson" ,
"full_name" : "Sarah Wilson" ,
"phone" : "+1-555-987-6543" ,
"date_of_birth" : "1985-12-03" ,
"address" : {
"street1" : "123 Innovation Drive" ,
"street2" : "Suite 200" ,
"city" : "San Francisco" ,
"state" : "CA" ,
"postal_code" : "94105" ,
"country" : "US"
},
"customer_tier" : "gold" ,
"marketing_consent" : true ,
"referral_source" : "paid_search" ,
"stripe_customer_id" : "cus_ABC123DEF456" ,
"status" : "active" ,
"created_at" : "2024-01-15T10:30:00Z" ,
"updated_at" : "2024-01-15T10:30:00Z" ,
"lifetime_value" : 0.00 ,
"total_orders" : 0 ,
"tags" : [ "enterprise" , "tech" , "high-value" ],
"custom_fields" : {
"company_name" : "Tech Corp" ,
"job_title" : "CTO" ,
"industry" : "Technology"
},
"preferences" : {
"email_notifications" : true ,
"sms_notifications" : false ,
"language" : "en" ,
"timezone" : "America/Los_Angeles"
}
}
Additional Features
Idempotency
Use the Idempotency-Key
header to safely retry customer creation requests:
curl -X POST https://api.stateset.com/v1/customers \
-H "Idempotency-Key: customer-signup-form-abc123" \
-H "Authorization: Bearer sk_live_..." \
-d '{"email": "customer@example.com", ...}'
Stripe Integration
When Stripe integration is enabled:
A Stripe customer is automatically created if stripe_customer_id
is not provided
Customer data is synced between StateSet and Stripe
Payment methods can be attached to the Stripe customer
Webhook Events
Creating a customer triggers these webhook events:
customer.created
- Fired when customer is successfully created
customer.stripe_synced
- Fired when Stripe customer is created (if integration enabled)
Validation Rules
Field Validation email
Must be valid email format, unique across account first_name
1-50 characters, letters and spaces only last_name
1-50 characters, letters and spaces only phone
Valid phone number format date_of_birth
Valid date, customer must be at least 13 years old postal_code
Valid format for specified country country
Valid ISO 3166-1 alpha-2 country code
Rate Limiting
Customer creation is subject to rate limits:
Standard: 100 customers/minute
Enterprise: 1000 customers/minute
Consider using batch import for large datasets.