How to create a customer with password in the graphql storefront API? Password field is not accepted

Solved
juanlet
Tourist
6 0 1

Hey, I want to create a customer with password using the graphql api. I followed the documentation to create a customer with password to avoid the activation process by email, this is the query I'm sending:

mutation  {
      customerCreate(
        input: {
          firstName: "dave",
          lastName: "smith",
          email: "someone@gmail.com",
          password: "12345"
          acceptsMarketing: true,
          
            }
      ) {
        customer {
          id
          firstName
          lastName
          email
        }
        userErrors {
          field
          message
        }
        customer {
          id
          
        }
      }
    }

But I'm getting this error as if the specification changed:


{
  "errors": [
    {
      "message": "InputObject 'CustomerInput' doesn't accept argument 'password'",
      "locations": [
        {
          "line": 7,
          "column": 11
        }
      ],
      "path": [
        "mutation",
        "customerCreate",
        "input",
        "password"
      ],
      "extensions": {
        "code": "argumentNotAccepted",
        "name": "CustomerInput",
        "typeName": "InputObject",
        "argumentName": "password"
      }
    }
  ]
}

How do I do to achieve this? Thanks!

0 Likes
Zameer
Shopify Staff (Retired)
Shopify Staff (Retired)
295 32 76

This is an accepted solution.

Hey there,

 

You might be seeing this error because your request is targeting the GraphQL Admin API and not the Storefront API. I would take a look at this guide which outlines the steps you need to follow.

 

Namely, you need to be using the proper GraphQL endpoint - `POST https://my-store-name.myshopify.com/api/graphql` and you need to provide the `X-Shopify-Storefront-Access-Token` header with your Storefront Access Token which is different from your Admin Access Token.

0 Likes
juanlet
Tourist
6 0 1

Thanks!

0 Likes
nick-mealey
Shopify Expert
49 0 25

I realize this thread is a bit old and marked as "Solved", but it's worth mentioning that not supporting a password field from the Admin API is a real issue. It doesn't make sense that the only way you can create an account with a password is with the Storefront API. There are other fields (e.g. locale) in the Admin API that we require anyway, so we'd have to use a combination of both. It looks like for now we might have to use a combo of the REST and GraphQL Admin API.

Helium Development Shopify Developer, Website Design, App Development