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

# getProfile / updateProfile

> Read and update the logged-in customer's name and marketing consent.

Read the customer's profile with `getProfile`, and update their name and marketing consent with `updateProfile`. Both return the standard wrapped response shape.

<Note>
  To update the customer's date of birth, use [updateCustomerDob](/js-sdk/customers/update-customer-dob).
</Note>

## getProfile

```javascript theme={null}
MageSDK.getProfile().then(function(resp) {
  if (resp.success) {
    console.log(resp.data.profile.firstName, resp.data.profile.lastName);
  }
});
```

### Response

<ResponseField name="success" type="boolean">
  Whether the request was successful.
</ResponseField>

<ResponseField name="data.profile" type="object">
  The customer's profile.

  <Expandable title="Profile properties">
    <ResponseField name="firstName" type="string">
      Customer first name.
    </ResponseField>

    <ResponseField name="lastName" type="string">
      Customer last name.
    </ResponseField>

    <ResponseField name="email" type="string">
      Customer email address.
    </ResponseField>

    <ResponseField name="acceptsMarketing" type="boolean">
      Whether the customer is subscribed to email marketing.
    </ResponseField>
  </Expandable>
</ResponseField>

## updateProfile

```javascript theme={null}
MageSDK.updateProfile({
  firstName: 'Jane',
  lastName: 'Doe',
  acceptsMarketing: true
}).then(function(resp) {
  if (resp.success) {
    console.log('Updated:', resp.data.profile);
  } else {
    console.log('Error:', resp.error);
  }
});
```

### Parameters

<ParamField body="firstName" type="string" required>
  The customer's first name.
</ParamField>

<ParamField body="lastName" type="string" required>
  The customer's last name.
</ParamField>

<ParamField body="acceptsMarketing" type="boolean">
  Whether the customer opts in to email marketing.
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Whether the update was successful.
</ResponseField>

<ResponseField name="data.profile" type="object">
  The updated profile (`firstName`, `lastName`).
</ResponseField>

## Example: Profile form

```html theme={null}
<form id="profile-form">
  <input name="firstName" id="firstName" placeholder="First name" />
  <input name="lastName" id="lastName" placeholder="Last name" />
  <label><input type="checkbox" id="marketing" /> Email me offers</label>
  <button type="submit">Save</button>
</form>

<script>
  var form = document.getElementById('profile-form');

  MageSDK.getProfile().then(function(resp) {
    if (!resp.success) return;
    document.getElementById('firstName').value = resp.data.profile.firstName;
    document.getElementById('lastName').value = resp.data.profile.lastName;
    document.getElementById('marketing').checked = resp.data.profile.acceptsMarketing;
  });

  form.addEventListener('submit', function(event) {
    event.preventDefault();
    MageSDK.updateProfile({
      firstName: document.getElementById('firstName').value,
      lastName: document.getElementById('lastName').value,
      acceptsMarketing: document.getElementById('marketing').checked
    }).then(function(resp) {
      alert(resp.success ? 'Saved' : 'Error: ' + resp.error);
    });
  });
</script>
```
