Update Customer
Update customer details and preferences.
Updated
On this page
Overview
Update the authenticated customer's profile fields. Only send the fields you want to change.
SDK Usage
import dash from "@/lib/dash"
const { customer } = await dash.auth.updateProfile({
first_name: "Jane",
last_name: "Smith",
phone: "555-9876",
address_line1: "456 Oak Ave",
city: "Dallas",
state: "TX",
zip_code: "75001",
country: "US",
accepts_marketing: false,
})
Editable Fields
| Field | Type | Description |
|---|---|---|
first_name | string | First name |
last_name | string | Last name |
phone | string | Phone number |
address_line1 | string | Street address |
address_line2 | string | Apt, suite, etc. |
city | string | City |
state | string | State/province |
zip_code | string | Postal code |
country | string | Country code (e.g., "US") |
accepts_marketing | boolean | Marketing email opt-in |
Profile Form Example
"use client"
import { useState, useEffect } from "react"
import dash from "@/lib/dash"
export function ProfileForm() {
const [form, setForm] = useState({ first_name: "", last_name: "", phone: "" })
const [saving, setSaving] = useState(false)
useEffect(() => {
dash.auth.getProfile().then(({ customer }) => {
setForm({
first_name: customer.first_name || "",
last_name: customer.last_name || "",
phone: customer.phone || "",
})
})
}, [])
async function handleSave() {
setSaving(true)
await dash.auth.updateProfile(form)
setSaving(false)
}
return (
<form onSubmit={e => { e.preventDefault(); handleSave() }}>
<input value={form.first_name}
onChange={e => setForm(f => ({ ...f, first_name: e.target.value }))}
placeholder="First name" />
<input value={form.last_name}
onChange={e => setForm(f => ({ ...f, last_name: e.target.value }))}
placeholder="Last name" />
<input value={form.phone}
onChange={e => setForm(f => ({ ...f, phone: e.target.value }))}
placeholder="Phone" />
<button type="submit" disabled={saving}>
{saving ? "Saving..." : "Save Changes"}
</button>
</form>
)
}
REST API
POST /storefront/auth/profile
Authorization: Bearer {access_token}
Content-Type: application/json
{ "first_name": "Jane", "last_name": "Smith", "phone": "555-9876" }
Next Steps
- Custom Fields — Store arbitrary metadata
- Customer Addresses — Managing addresses