mutation customerCreate($input: CustomerInput!) {
customerCreate(input: $input) {
userErrors {
field
message
}
customer {
id
email
phone
taxExempt
emailMarketingConsent {
marketingState
marketingOptInLevel
consentUpdatedAt
}
firstName
lastName
amountSpent {
amount
currencyCode
}
smsMarketingConsent {
marketingState
marketingOptInLevel
}
addresses {
address1
city
country
phone
zip
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation customerCreate($input: CustomerInput!) { customerCreate(input: $input) { userErrors { field message } customer { id email phone taxExempt emailMarketingConsent { marketingState marketingOptInLevel consentUpdatedAt } firstName lastName amountSpent { amount currencyCode } smsMarketingConsent { marketingState marketingOptInLevel } addresses { address1 city country phone zip } } } }",
"variables": {
"input": {
"email": "steve.lastnameson@example.com",
"phone": "+16465555555",
"firstName": "Steve",
"lastName": "Lastname",
"emailMarketingConsent": {
"marketingOptInLevel": "CONFIRMED_OPT_IN",
"marketingState": "SUBSCRIBED"
},
"addresses": [
{
"address1": "412 fake st",
"city": "Ottawa",
"province": "ON",
"phone": "+16469999999",
"zip": "A1A 4A1",
"lastName": "Lastname",
"firstName": "Steve",
"countryCode": "CA"
}
]
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation customerCreate($input: CustomerInput!) {
customerCreate(input: $input) {
userErrors {
field
message
}
customer {
id
email
phone
taxExempt
emailMarketingConsent {
marketingState
marketingOptInLevel
consentUpdatedAt
}
firstName
lastName
amountSpent {
amount
currencyCode
}
smsMarketingConsent {
marketingState
marketingOptInLevel
}
addresses {
address1
city
country
phone
zip
}
}
}
}`,
{
variables: {
"input": {
"email": "steve.lastnameson@example.com",
"phone": "+16465555555",
"firstName": "Steve",
"lastName": "Lastname",
"emailMarketingConsent": {
"marketingOptInLevel": "CONFIRMED_OPT_IN",
"marketingState": "SUBSCRIBED"
},
"addresses": [
{
"address1": "412 fake st",
"city": "Ottawa",
"province": "ON",
"phone": "+16469999999",
"zip": "A1A 4A1",
"lastName": "Lastname",
"firstName": "Steve",
"countryCode": "CA"
}
]
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation customerCreate($input: CustomerInput!) {
customerCreate(input: $input) {
userErrors {
field
message
}
customer {
id
email
phone
taxExempt
emailMarketingConsent {
marketingState
marketingOptInLevel
consentUpdatedAt
}
firstName
lastName
amountSpent {
amount
currencyCode
}
smsMarketingConsent {
marketingState
marketingOptInLevel
}
addresses {
address1
city
country
phone
zip
}
}
}
}`,
"variables": {
"input": {
"email": "steve.lastnameson@example.com",
"phone": "+16465555555",
"firstName": "Steve",
"lastName": "Lastname",
"emailMarketingConsent": {
"marketingOptInLevel": "CONFIRMED_OPT_IN",
"marketingState": "SUBSCRIBED"
},
"addresses": [
{
"address1": "412 fake st",
"city": "Ottawa",
"province": "ON",
"phone": "+16469999999",
"zip": "A1A 4A1",
"lastName": "Lastname",
"firstName": "Steve",
"countryCode": "CA"
}
]
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation customerCreate($input: CustomerInput!) {
customerCreate(input: $input) {
userErrors {
field
message
}
customer {
id
email
phone
taxExempt
emailMarketingConsent {
marketingState
marketingOptInLevel
consentUpdatedAt
}
firstName
lastName
amountSpent {
amount
currencyCode
}
smsMarketingConsent {
marketingState
marketingOptInLevel
}
addresses {
address1
city
country
phone
zip
}
}
}
}
QUERY
variables = {
"input": {
"email": "steve.lastnameson@example.com",
"phone": "+16465555555",
"firstName": "Steve",
"lastName": "Lastname",
"emailMarketingConsent": {
"marketingOptInLevel": "CONFIRMED_OPT_IN",
"marketingState": "SUBSCRIBED"
},
"addresses": [
{
"address1": "412 fake st",
"city": "Ottawa",
"province": "ON",
"phone": "+16469999999",
"zip": "A1A 4A1",
"lastName": "Lastname",
"firstName": "Steve",
"countryCode": "CA"
}
]
}
}
response = client.query(query: query, variables: variables)