> For the complete documentation index, see [llms.txt](https://docs.digitalriver.com/commerce-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digitalriver.com/commerce-api/shopper-apis/shopper-basics/common-use-cases/creating-a-customer.md).

# Creating a customer

Creating a customer account enables shoppers to purchase when guest checkout is unavailable. This guide will help you understand how to create a customer account by leveraging the API key or access token to authenticate the request. Follow the steps below to successfully set up a new customer account for shoppers on your site.

You can make this request without an access token by passing in your API key as a query parameter. You can also send this request with a valid anonymous or authenticated customer token.

## Creating a shopper

To create a shopper, send a [`POST /v1/shoppers`](https://docs.digitalriver.com/commerce-api-references/shopper-apis/shoppers/shoppers#v1-shoppers-client-hosted-shopper) request with the customer's information in the request payload. This request requires either an access token or an API key.

If Digital River manages the customer login credentials, include `username` and `password` in the request body, with a base64 encoded `password`.

If your company manages the customer login credentials, include the `externalReferenceId` in the payload. If you do not specify an `externalReferenceId`, Digital River will assign a `shopperId`.

{% hint style="info" %}
**Best Practices**: Explicitly set the `locale` and `currency` for a customer at the start of a session.
{% endhint %}

{% tabs %}
{% tab title="cURL for a Digital River-hosted shopper" %}

```javascript
curl --location --request POST 'https://api.digitalriver.com/v1/shoppers' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {{access_token}}' \
--header 'Cookie: {{token}}' \
--data-raw '{
  "shopper": {
    "username": "jdoe@dr.com",
    "firstName": "Jane",
    "lastName": "Doe",
    "emailAddress": jdoe@dr.com,
    "password": "jdoepassword",
    "currency": "USD"    
    "locale": "en_US",
  }
}'
```

{% endtab %}

{% tab title="cURL for a client-hosted shopper" %}

```javascript
curl --location -g --request POST 'api.digitalriver.com/v1/shoppers' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic {{access_token}}' \
--header 'Cookie: {{token}}' \
--data-raw '{
  "shopper": {
    "username": "jdoe@acme.com",
    "firstName": "Jane",
    "lastName": "Doe",
    "emailAddress": jdoe@acme.com,
    "currency": "USD"    
    "locale": "en_US",
    "externalReferenceId": "efe44307-ef82-46ed-bef4-e87ebec2ba28"
  }
}'
```

{% endtab %}
{% endtabs %}

## Required payload contents

The required payload contents depend on whether Digital River or your company manages the customer login credentials. Here are the minimum required fields:

* `username`
* `password` (base64 encoded): Only required for a Digital River-hosted shopper.
* `emailAddress`
* `externalReferenceId`: Only required for a client-hosted shopper.
* `firstName`
* `lastName`

{% tabs %}
{% tab title="Payload example" %}

```javascript
{
  "shopper": {
    "username": "jdoe@dr.com",
    "firstName": "Jane",
    "lastName": "Doe",
    "emailAddress": jdoe@dr.com,
    "password": "jdoepassword",
    "currency": "USD"    
    "locale": "en_US",
  }
}
```

{% endtab %}
{% endtabs %}

The response from the server will be an HTTP Status `201 Created`.

After creating the base customer record, you can obtain an authenticated customer token.

{% tabs %}
{% tab title="cURL with an access token" %}

```html
curl --location --request POST 'https://api.digitalriver.com/v1/shoppers' \
--header 'Authorization: bearer {{access_token}}' \ 
...
```

{% endtab %}
{% endtabs %}

The following example passes in your API key instead of an access token:

{% tabs %}
{% tab title="Request sample without an access token" %}

```http
curl --location --request POST 'https://api.digitalriver.com/v1/shoppers? apiKey=your_api_key' \ 
...
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.digitalriver.com/commerce-api/shopper-apis/shopper-basics/common-use-cases/creating-a-customer.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
