# customerAccessTokenCreate - storefront - MUTATION Version: 2024-10 ## Description Creates a customer access token. The customer access token is required to modify the customer object in any way. ### Access Scopes `unauthenticated_write_customers` access scope. ## Arguments * [input](/docs/api/storefront/2024-10/input-objects/CustomerAccessTokenCreateInput): CustomerAccessTokenCreateInput! - The fields used to create a customer access token. ## Returns * [customerAccessToken](/docs/api/storefront/2024-10/objects/CustomerAccessToken): CustomerAccessToken The newly created customer access token object. * [customerUserErrors](/docs/api/storefront/2024-10/objects/CustomerUserError): CustomerUserError! The list of errors that occurred from executing the mutation. * [userErrors](/docs/api/storefront/2024-10/objects/UserError): UserError! The list of errors that occurred from executing the mutation. ## Examples ### Create a customer access token Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \\\n-d '{\n\"query\": \"mutation customerAccessTokenCreate { customerAccessTokenCreate(input: {email: \\\"ghaida@example.com\\\", password: \\\"7dx2gx2Z\\\"}) { customerAccessToken { accessToken } customerUserErrors { message } } }\"\n}'\n" Node example: "const client = new shopify.clients.Storefront({\n domain: 'your-development-store.myshopify.com',\n storefrontAccessToken,\n});\nconst data = await client.query({\n data: `mutation customerAccessTokenCreate {\n customerAccessTokenCreate(input: {email: \"ghaida@example.com\", password: \"7dx2gx2Z\"}) {\n customerAccessToken {\n accessToken\n }\n customerUserErrors {\n message\n }\n }\n }`,\n});\n" Ruby example: null Remix example: "const { storefront } = await unauthenticated.storefront(\n 'your-development-store.myshopify.com'\n);\n\nconst response = await storefront.graphql(\n `#graphql\n mutation customerAccessTokenCreate {\n customerAccessTokenCreate(input: {email: \"ghaida@example.com\", password: \"7dx2gx2Z\"}) {\n customerAccessToken {\n accessToken\n }\n customerUserErrors {\n message\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "mutation customerAccessTokenCreate {\n customerAccessTokenCreate(input: {email: \"ghaida@example.com\", password: \"7dx2gx2Z\"}) {\n customerAccessToken {\n accessToken\n }\n customerUserErrors {\n message\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "customerAccessTokenCreate": { "customerAccessToken": { "accessToken": "ghaidas_token" }, "customerUserErrors": [] } } } ### Get a customer by access token Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Storefront-Access-Token: {storefront_access_token}' \\\n-d '{\n\"query\": \"query { customer(customerAccessToken: \\\"bobs_token\\\") { id firstName lastName acceptsMarketing email phone } }\"\n}'\n" Node example: "const client = new shopify.clients.Storefront({\n domain: 'your-development-store.myshopify.com',\n storefrontAccessToken,\n});\nconst data = await client.query({\n data: `query {\n customer(customerAccessToken: \"bobs_token\") {\n id\n firstName\n lastName\n acceptsMarketing\n email\n phone\n }\n }`,\n});\n" Ruby example: null Remix example: "const { storefront } = await unauthenticated.storefront(\n 'your-development-store.myshopify.com'\n);\n\nconst response = await storefront.graphql(\n `#graphql\n query {\n customer(customerAccessToken: \"bobs_token\") {\n id\n firstName\n lastName\n acceptsMarketing\n email\n phone\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n customer(customerAccessToken: \"bobs_token\") {\n id\n firstName\n lastName\n acceptsMarketing\n email\n phone\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "customer": { "id": "gid://shopify/Customer/410535040", "firstName": "John", "lastName": "Smith", "acceptsMarketing": false, "email": "johnsmith@example.com", "phone": "+16134504533" } } }