Updates the profile of the currently authenticated customer
import { createClient } from '@spree/sdk'
const client = createClient({
baseUrl: 'https://your-store.com',
publishableKey: '<api-key>',
})
const customer = await client.customer.update({
first_name: 'John',
last_name: 'Doe',
metadata: { preferred_contact: 'email' },
}, {
bearerToken: '<token>',
}){
"id": "cus_UkLWZg9DAJ",
"email": "nicol_hermiston@dickiullrich.biz",
"first_name": "Updated",
"last_name": "Name",
"phone": "555-555-0199",
"accepts_email_marketing": false,
"available_store_credit_total": "0",
"display_available_store_credit_total": "$0.00",
"addresses": [
{
"id": "addr_gbHJdmfrXB",
"first_name": "John",
"last_name": "Doe",
"full_name": "John Doe",
"address1": "97 Lovely Street",
"address2": "Northwest",
"postal_code": "35005",
"city": "Herndon",
"phone": "555-555-0199",
"company": "Company",
"country_name": "United States of America",
"country_iso": "US",
"state_text": "STATE_ABBR_104",
"state_abbr": "STATE_ABBR_104",
"quick_checkout": false,
"is_default_billing": true,
"is_default_shipping": false,
"state_name": "STATE_NAME_104"
},
{
"id": "addr_UkLWZg9DAJ",
"first_name": "John",
"last_name": "Doe",
"full_name": "John Doe",
"address1": "96 Lovely Street",
"address2": "Northwest",
"postal_code": "35005",
"city": "Herndon",
"phone": "555-555-0199",
"company": "Company",
"country_name": "United States of America",
"country_iso": "US",
"state_text": "STATE_ABBR_103",
"state_abbr": "STATE_ABBR_103",
"quick_checkout": false,
"is_default_billing": false,
"is_default_shipping": true,
"state_name": "STATE_NAME_103"
}
],
"default_billing_address": {
"id": "addr_gbHJdmfrXB",
"first_name": "John",
"last_name": "Doe",
"full_name": "John Doe",
"address1": "97 Lovely Street",
"address2": "Northwest",
"postal_code": "35005",
"city": "Herndon",
"phone": "555-555-0199",
"company": "Company",
"country_name": "United States of America",
"country_iso": "US",
"state_text": "STATE_ABBR_104",
"state_abbr": "STATE_ABBR_104",
"quick_checkout": false,
"is_default_billing": true,
"is_default_shipping": false,
"state_name": "STATE_NAME_104"
},
"default_shipping_address": {
"id": "addr_UkLWZg9DAJ",
"first_name": "John",
"last_name": "Doe",
"full_name": "John Doe",
"address1": "96 Lovely Street",
"address2": "Northwest",
"postal_code": "35005",
"city": "Herndon",
"phone": "555-555-0199",
"company": "Company",
"country_name": "United States of America",
"country_iso": "US",
"state_text": "STATE_ABBR_103",
"state_abbr": "STATE_ABBR_103",
"quick_checkout": false,
"is_default_billing": false,
"is_default_shipping": true,
"state_name": "STATE_NAME_103"
}
}Publishable API key for store access
JWT token for authenticated customers
"John"
"Doe"
"customer@example.com"
"newpassword123"
"newpassword123"
true
"+1 555 123 4567"
{ "preferred_contact": "email" }
profile updated
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
import { createClient } from '@spree/sdk'
const client = createClient({
baseUrl: 'https://your-store.com',
publishableKey: '<api-key>',
})
const customer = await client.customer.update({
first_name: 'John',
last_name: 'Doe',
metadata: { preferred_contact: 'email' },
}, {
bearerToken: '<token>',
}){
"id": "cus_UkLWZg9DAJ",
"email": "nicol_hermiston@dickiullrich.biz",
"first_name": "Updated",
"last_name": "Name",
"phone": "555-555-0199",
"accepts_email_marketing": false,
"available_store_credit_total": "0",
"display_available_store_credit_total": "$0.00",
"addresses": [
{
"id": "addr_gbHJdmfrXB",
"first_name": "John",
"last_name": "Doe",
"full_name": "John Doe",
"address1": "97 Lovely Street",
"address2": "Northwest",
"postal_code": "35005",
"city": "Herndon",
"phone": "555-555-0199",
"company": "Company",
"country_name": "United States of America",
"country_iso": "US",
"state_text": "STATE_ABBR_104",
"state_abbr": "STATE_ABBR_104",
"quick_checkout": false,
"is_default_billing": true,
"is_default_shipping": false,
"state_name": "STATE_NAME_104"
},
{
"id": "addr_UkLWZg9DAJ",
"first_name": "John",
"last_name": "Doe",
"full_name": "John Doe",
"address1": "96 Lovely Street",
"address2": "Northwest",
"postal_code": "35005",
"city": "Herndon",
"phone": "555-555-0199",
"company": "Company",
"country_name": "United States of America",
"country_iso": "US",
"state_text": "STATE_ABBR_103",
"state_abbr": "STATE_ABBR_103",
"quick_checkout": false,
"is_default_billing": false,
"is_default_shipping": true,
"state_name": "STATE_NAME_103"
}
],
"default_billing_address": {
"id": "addr_gbHJdmfrXB",
"first_name": "John",
"last_name": "Doe",
"full_name": "John Doe",
"address1": "97 Lovely Street",
"address2": "Northwest",
"postal_code": "35005",
"city": "Herndon",
"phone": "555-555-0199",
"company": "Company",
"country_name": "United States of America",
"country_iso": "US",
"state_text": "STATE_ABBR_104",
"state_abbr": "STATE_ABBR_104",
"quick_checkout": false,
"is_default_billing": true,
"is_default_shipping": false,
"state_name": "STATE_NAME_104"
},
"default_shipping_address": {
"id": "addr_UkLWZg9DAJ",
"first_name": "John",
"last_name": "Doe",
"full_name": "John Doe",
"address1": "96 Lovely Street",
"address2": "Northwest",
"postal_code": "35005",
"city": "Herndon",
"phone": "555-555-0199",
"company": "Company",
"country_name": "United States of America",
"country_iso": "US",
"state_text": "STATE_ABBR_103",
"state_abbr": "STATE_ABBR_103",
"quick_checkout": false,
"is_default_billing": false,
"is_default_shipping": true,
"state_name": "STATE_NAME_103"
}
}