Requires unauthenticated_write_customers access scope.

Creates a new customer.


The fields used to create a new customer.


Was this section helpful?

The created customer object.

The list of errors that occurred from executing the mutation.

The list of errors that occurred from executing the mutation. Use customerUserErrors instead.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation customerCreate($input: CustomerCreateInput!) {
  customerCreate(input: $input) {
    customer {
      firstName
      lastName
      email
      phone
      acceptsMarketing
    }
    customerUserErrors {
      field
      message
      code
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/api/2024-10/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \
-d '{
"query": "mutation customerCreate($input: CustomerCreateInput!) { customerCreate(input: $input) { customer { firstName lastName email phone acceptsMarketing } customerUserErrors { field message code } } }",
 "variables": {
    "input": {
      "firstName": "John",
      "lastName": "Smith",
      "email": "johnsmith@shopify.com",
      "phone": "+15146669999",
      "password": "5hopify",
      "acceptsMarketing": true
    }
  }
}'
const { storefront } = await unauthenticated.storefront(
  'your-development-store.myshopify.com'
);

const response = await storefront.graphql(
  `#graphql
  mutation customerCreate($input: CustomerCreateInput!) {
    customerCreate(input: $input) {
      customer {
        firstName
        lastName
        email
        phone
        acceptsMarketing
      }
      customerUserErrors {
        field
        message
        code
      }
    }
  }`,
  {
    variables: {
      "input": {
        "firstName": "John",
        "lastName": "Smith",
        "email": "johnsmith@shopify.com",
        "phone": "+15146669999",
        "password": "5hopify",
        "acceptsMarketing": true
      }
    },
  },
);

const data = await response.json();
const client = new shopify.clients.Storefront({
  domain: 'your-development-store.myshopify.com',
  storefrontAccessToken,
});
const data = await client.query({
  data: {
    "query": `mutation customerCreate($input: CustomerCreateInput!) {
      customerCreate(input: $input) {
        customer {
          firstName
          lastName
          email
          phone
          acceptsMarketing
        }
        customerUserErrors {
          field
          message
          code
        }
      }
    }`,
    "variables": {
      "input": {
        "firstName": "John",
        "lastName": "Smith",
        "email": "johnsmith@shopify.com",
        "phone": "+15146669999",
        "password": "5hopify",
        "acceptsMarketing": true
      }
    },
  },
});
use Shopify\Clients\Graphql;

$client = new ShopifyClientsStorefront("your-development-store.myshopify.com", $storefrontAccessToken);
$query = <<<QUERY
  mutation customerCreate($input: CustomerCreateInput!) {
    customerCreate(input: $input) {
      customer {
        firstName
        lastName
        email
        phone
        acceptsMarketing
      }
      customerUserErrors {
        field
        message
        code
      }
    }
  }
QUERY;

$variables = [
  "input" => [
    "firstName" => "John",
    "lastName" => "Smith",
    "email" => "johnsmith@shopify.com",
    "phone" => "+15146669999",
    "password" => "5hopify",
    "acceptsMarketing" => true,
  ],
];

$response = $client->query(["query" => $query, "variables" => $variables]);
import {useShopQuery} from '@shopify/hydrogen';

const QUERY = gql`
  mutation customerCreate($input: CustomerCreateInput!) {
  customerCreate(input: $input) {
    customer {
      firstName
      lastName
      email
      phone
      acceptsMarketing
    }
    customerUserErrors {
      field
      message
      code
    }
  }
}`;

const {data} = useShopQuery({
  query: QUERY,
  variables: {
    input: {
      firstName: "John",
      lastName: "Smith",
      email: "johnsmith@shopify.com",
      phone: "+15146669999",
      password: "5hopify",
      acceptsMarketing: true
    }
  },
});
Hide code
Input variables
Copy
{
  "input": {
    "firstName": "John",
    "lastName": "Smith",
    "email": "johnsmith@shopify.com",
    "phone": "+15146669999",
    "password": "5hopify",
    "acceptsMarketing": true
  }
}
Hide code
Response
JSON
{
  "customerCreate": {
    "customer": {
      "firstName": "John",
      "lastName": "Smith",
      "email": "johnsmith@shopify.com",
      "phone": "+15146669999",
      "acceptsMarketing": true
    },
    "customerUserErrors": []
  }
}