> ## 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.

# .register()

> Create a new customer account

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

Creates a new customer account in Shopify. On success, automatically logs in the customer and returns their data.

## Parameters

| Param   | Type                    | Required | Description          |
| ------- | ----------------------- | -------- | -------------------- |
| `input` | `CustomerRegisterInput` | Yes      | Registration details |

### CustomerRegisterInput

| Field              | Type      | Required | Description      |
| ------------------ | --------- | -------- | ---------------- |
| `email`            | `string`  | Yes      | Customer's email |
| `password`         | `string`  | Yes      | Account password |
| `firstName`        | `string`  | No       | First name       |
| `lastName`         | `string`  | No       | Last name        |
| `phone`            | `string`  | No       | Phone number     |
| `acceptsMarketing` | `boolean` | No       | Marketing opt-in |

## Returns

`Promise<ShopifyCustomer>` - The newly created and authenticated customer.

## Throws

* `Error` - If registration fails (e.g., email already exists).

## Examples

### Basic registration

```javascript theme={null}
try {
    const customer = await openbridge.customer.register({
        email: 'newuser@example.com',
        password: 'securePassword123'
    })

    console.log(`Account created for ${customer.email}`)
} catch (error) {
    console.error(error.message) // "Email has already been taken"
}
```

### Full registration form

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

    const formData = new FormData(e.target)

    try {
        const customer = await openbridge.customer.register({
            email: formData.get('email'),
            password: formData.get('password'),
            firstName: formData.get('firstName'),
            lastName: formData.get('lastName'),
            phone: formData.get('phone'),
            acceptsMarketing: formData.get('marketing') === 'on'
        })

        // Customer is now logged in
        window.location.href = '/welcome'
    } catch (error) {
        showError(error.message)
    }
})
```

<Info>
  After successful registration, the customer is automatically logged in. No need to call `.login()` separately.
</Info>
