Creates a new customer account and returns a JWT token
JavaScript
import { createClient } from '@spree/sdk' const client = createClient({ baseUrl: 'https://your-store.com', publishableKey: '<api-key>', }) const auth = await client.customers.create({ email: 'newuser@example.com', password: 'password123', password_confirmation: 'password123', first_name: 'John', last_name: 'Doe', phone: '+1234567890', accepts_email_marketing: true, metadata: { source: 'storefront' }, })
{ "token": "eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX3R5cGUiOiJjdXN0b21lciIsImp0aSI6ImIyZGZiZDFiLWE5NGItNDVhYi04Y2YxLTExNjVlZGI4OWQ5OSIsImlzcyI6InNwcmVlIiwiYXVkIjoic3RvcmVfYXBpIiwiZXhwIjoxNzc0NzAxODY1fQ.EHiaf5YSt3nevdCg0WDb3j3oxg8K7JKUncwNBWrLhh4", "refresh_token": "sPsJbH7r4zV8hkctor6Vzv6L", "user": { "id": "cus_UkLWZg9DAJ", "email": "newuser@example.com", "first_name": "John", "last_name": "Doe", "phone": "+1234567890", "accepts_email_marketing": true, "available_store_credit_total": "0", "display_available_store_credit_total": "$0.00", "addresses": [], "default_billing_address": null, "default_shipping_address": null } }
Publishable API key for store access
"newuser@example.com"
6
"password123"
"John"
"Doe"
"+1234567890"
true
{ "source": "storefront" }
registration successful
JWT access token
Refresh token for obtaining new access tokens
Show child attributes
Was this page helpful?