> ## Documentation Index
> Fetch the complete documentation index at: https://docs.openbridge.shop/llms.txt
> Use this file to discover all available pages before exploring further.

# .update()

> Update the customer profile

```javascript theme={null}
openbridge.customer.update(input)
```

Updates the current customer's profile information.

## Parameters

| Param   | Type                  | Required | Description      |
| ------- | --------------------- | -------- | ---------------- |
| `input` | `CustomerUpdateInput` | Yes      | Fields to update |

### CustomerUpdateInput

| Field              | Type      | Description            |
| ------------------ | --------- | ---------------------- |
| `firstName`        | `string`  | First name             |
| `lastName`         | `string`  | Last name              |
| `phone`            | `string`  | Phone number           |
| `acceptsMarketing` | `boolean` | Marketing email opt-in |

## Returns

`Promise<ShopifyCustomer>` - The updated customer object.

## Throws

* `Error` - If not logged in or update fails.

## Examples

### Update name

```javascript theme={null}
const customer = await openbridge.customer.update({
    firstName: 'John',
    lastName: 'Doe'
})

console.log(`Updated: ${customer.displayName}`)
```

### Profile form handler

```javascript theme={null}
document.querySelector('#profile-form').addEventListener('submit', async (e) => {
    e.preventDefault()

    const formData = new FormData(e.target)

    try {
        await openbridge.customer.update({
            firstName: formData.get('firstName'),
            lastName: formData.get('lastName'),
            phone: formData.get('phone'),
            acceptsMarketing: formData.get('newsletter') === 'on'
        })

        showSuccess('Profile updated!')
    } catch (error) {
        showError(error.message)
    }
})
```

### Toggle marketing preference

```javascript theme={null}
async function toggleNewsletter(optIn) {
    await openbridge.customer.update({
        acceptsMarketing: optIn
    })

    showToast(optIn ? 'Subscribed to newsletter' : 'Unsubscribed')
}
```

<Info>
  Updates trigger all subscribers, so your UI will automatically reflect changes.
</Info>
