---
title: "Shoppers"
description: "Create shopper details."
canonical: "https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/shoppers"
---

# Shoppers

> Create shopper details.

Source: https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/shoppers

Create shopper details.

## Create New Shopper

Creates an address including name for the shopper.

```
POST /ps/api/public/v1/merchants/{merchant_key}/shoppers
```

**Identifiers**

| Name | Type | Description |
| - | - | - |
| merchant\_key | MerchantKey | The key of the merchant. |

**Parameters**

_Not applicable._

**Request**

| Field | Type | M | Description |
| - | - | :-: | - |
| shopper\_reference | String(1, 50) | M | The shopper reference from the merchant. |
| type | Enum(35) | M | Type of customer. The default value is 'CONSUMER'. |
| _name_ | _Block_ | _M_ | _The shopper name for the address._ |
| + initials | String(1, 35) | O | The initials. This field is commonly omitted. |
| + first | String(1, 35) | M | The first given name. It depends on `type`. |
| + middle | String(1, 35) | O | Any subsequent given name or names. May also be used as middle initial. |
| + last | String(1, 100) | M | The family or inherited name(s). The maximum length depends on `type`. |
| _address_ | _Block_ | _M_ | _The address details._ |
| + street | String(1, 100) | M | The street. |
| + housenumber | String(1, 35) | M | The house number. |
| + housenumber\_addition | String(1, 35) | O | The addition to the house number. |
| + postal\_code | String(1, 35) | O | The postal or zip code. |
| + city | String(1, 35) | M | The city. |
| + state | String(1, 40) | C | For PayPal payment method, state should only be provided under certain conditions as mentioned [here](https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/payment-method-details/paypal). |
| + country | Country | M | The country as ISO 3166-1 Alpha 2. |
| email | String(1, 200) | M | The email address of the shopper. |
| gender | Enum(1) | O | The gender of the shopper: "M" (Male), "F" (Female), or "U" (Unknown). |
| date\_of\_birth | Date | O | The date of birth of the shopper (yyyy-mm-dd). |
| phone\_number | String(1, 50) | O | The phone number of the shopper. |

Note :

- `gender`, `date_of_birth` and `phone_number` are only used for the payment methods Riverty, Klarna, ELV, E-Financing, and Capayable.
- The address fields `street`, `city` and `state` can accept apostrophes at the beginning.

The following values are supported for `type`:

| Value | Maximum Length `name.last` | Notes |
| - | - | - |
| CONSUMER | 35 | The shopper is a consumer. |
| BUSINESS | 100 | The shopper is a business. The `name.first` cannot be filled in. |

**Response**

| Field | Type | M | Description |
| - | - | - | - |
| shopper\_key | ShopperKey | M | The key of the created or existing shopper. |
| address\_key | AddressKey | M | The key of the created address. |

**HTTP Status**

| Status | Meaning |
| - | - |
| 201 (Created) | The order is successfully created. |
| 400 (Bad Request) | The request was not valid. |
| 404 (Not Found) | The merchant key was not found. |

**Create New shopper address example**

```bash
> curl \
    -X POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Basic RG9jZGF0YVBGOkJXazJhZkpV' \
    https://secure.sandbox.pay.cm.com/ps/api/public/v1/merchants/4ef08825-993a-424d-a769-3ee97116a1b6/shoppers \
    -d '{
        "shopper_reference" : "vk20170224p",
        "name" : {
             "first"  : "Johan",
             "middle" : "de",
             "last"   : "Vries"
        },
        "address"   : {
             "street"      : "Hoofdstraat",
             "housenumber" : "82",
             "housenumber_addition": "A",
             "postalcode"  : "3972LB",
             "city"        : "Driebergen-Rijsenburg",
             "state"       : "Utrecht",
             "country"     : "DE"
        },
        "email"         : "johan.devries@cm.com",
        "gender"        : "M",
        "date_of_birth" : "1996-12-01",
        "phone_number"  : "+31611223344"
    }'
 
< Http 201 Created
<    '{
        "shopper_key" : "ec11cd24-e667-4f9e-a677-5ffe0d4aee5e",
        "address_key" : "ec11cd24-e667-4f9e-a677-5ffe0d4aee5e"
    }'
```

Note :

- Currently, the same key is generated for shopper\_key and address\_key. In the future it will be different.

## Return addresses of a shopper

Return the shopper addresses for given shopper key along with shopper information.

```
GET /ps/api/public/v1/merchants/{merchant_key}/shoppers/{shopper_key}/addresses
```

**Identifiers**

| Name | Type | Description |
| - | - | - |
| shopper\_key | ShopperKey | The key of the shopper. |
| merchant\_key | MerchantKey | The key of the merchant. |

**Parameters**

_Not applicable._

**Request**

_Not applicable._

**Response**

Array of:

| Field | Type | M | Description |
| - | - | :-: | - |
| shopper\_reference | String(1, 50) | M | The shopper reference from the merchant. |
| _name_ | _Block_ | _M_ | _The shopper name for the address._ |
| + initials | String(1, 35) | O | The initials. This field is commonly omitted. |
| + first | String(1, 35) | M | The first given name. |
| + middle | String(1, 35) | O | Any subsequent given name or names. May also be used as middle initial. |
| + last | String(1, 35) | M | The family or inherited name(s). |
| _address_ | _Block_ | _M_ | _The address details._ |
| + street | String(1, 100) | M | The street. |
| + housenumber | String(1, 35) | M | The house number. |
| + housenumber\_addition | String(1, 35) | O | The addition to the house number. |
| + postal\_code | String(1, 35) | O | The postal or zip code. |
| + city | String(1, 35) | M | The city. |
| + state | String(1, 40) | C | For PayPal payment method, state should only be provided under certain conditions as mentioned [here](https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/payment-method-details/paypal). |
| + country | Country | O | The country as ISO 3166-1 Alpha 2. |
| email | String(1, 200) | C | The email address of the shopper. |
| gender | Enum(1) | O | The gender of the shopper: "M" (Male), "F" (Female), or "U" (Unknown). |
| date\_of\_birth | Date | O | The date of birth of the shopper (yyyy-mm-dd). |
| phone\_number | String(1, 50) | O | The phone number of the shopper. |

Notes:

- The email address may not be filled if the order is created without an email address and the Payment is authorized with an iDEAL | Wero Fast checkout.
- The country may not be filled if the order is created without a country and the Payment is authorized with an iDEAL | Wero Fast checkout.

**HTTP Status**

| Status | Meaning |
| - | - |
| 200 (OK) | Success. |
| 401 (Unauthorized) | Authorization header missing or invalid. |
| 403 (Forbidden) | The merchant key is not allowed. |
| 404 (Not Found) | The shopper key / merchant key were not found. |

**Get shopper addresses example**

```bash
> curl \
    -X GET \
    --header 'Authorization: Basic RG9jZGF0YVBGOkJXazJhZkpV' \
    https://secure.sandbox.pay.cm.com/ps/api/public/v1/merchants/4ef08825-993a-424d-a769-3ee97116a1b6/shoppers/ec11cd24-e667-4f9e-a677-5ffe0d4aee5e/addresses
 
< Http 200 Ok
<    '[
        {
            "shopper_reference": "ceedb1d0-020d-49a5-b1be-6c0a8d6f8ccd",
            "name": {
                "initials": "A",
                "first": "Johan",
                "middle": "de",
                "last": "Vries"
            },
            "address": {
                "street": "Hoofdstraat",
                "housenumber": "82",
                "housenumber_addition": "A",
                "postal_code": "3972LB",
                "city": "Driebergen-Rijsenburg",
                "state": "Utrecht",
                "country": "NL"
            },
            "email": "M",
            "date_of_birth": "1996-12-01",
            "phone_number": "+31611223344"
        }
      ]'
```
