# Customers

Customers are applied to Violet at the `Order` level and shared across all `Bags`. The model that Violet accepts for customers includes both Billing and Shipping addresses in the same request, as seen below:

```json
{
        "first_name": "First",
        "last_name": "Last",
        "email": "first.last@violet.com",
        "shipping_address": {
            "phone": "+19171111111",
            "address_1":"123 Brooklyn Street",
            "city":"Brooklyn",
            "country":"US",
            "postal_code":"11206",
            "state":"NY",
            "type":"SHIPPING"
        },
        "same_address": true //This denotes that Billing and Shipping addresses are the same
}
```

{% hint style="info" %}
The `phone` field is a part of the `OrderAddress` object because many e-commerce platforms require it as a shipping field, not a customer field. This is to assist during order delivery.
{% endhint %}

Violet currently only operates on the Guest Customer model and does not let you save these customers on our end for re-use. If you’re looking to power repeat customers, we recommend saving this information on your end and passing it in during cart creation.

***

## Apply Customer Details to a Cart

You can also add customer details, including address details, if desired, to a Violet `Cart` independent of Order Addresses using the [Apply Customer Details to Cart](https://app.gitbook.com/s/8lXIp71Ct5qCUhXjko2q/orders-and-checkout/cart-customer/apply-customer-to-cart) endpoint, as seen below:

```json
curl -X POST https://sandbox-api.violet.io/v1/checkout/cart/{cart_id}/customer \
-H "X-Violet-App-Id: your-app-id-here" \
-H "X-Violet-App-Secret: your-app-secret-here" \
-H "X-Violet-Token: your-token-here" \
-H "Content-type: application/json" \
-d '{"first_name": "Ultra", "last_name": "Violet", "email": "example@example.com"}'
```

***

## Apply Shipping and Billing Addresses to Cart

If Customer Details are added without an address, you’ll be required to add in addresses using the [Apply Address to Cart](https://app.gitbook.com/s/8lXIp71Ct5qCUhXjko2q/orders-and-checkout/cart-customer/set-shipping-address) endpoint before requesting shipping methods, as seen below:

```json
curl -X POST https://sandbox-api.violet.io/v1/checkout/cart/{cart_id}/shipping_address \
-H "X-Violet-App-Id: your-app-id-here" \
-H "X-Violet-App-Secret: your-app-secret-here" \
-H "X-Violet-Token: your-token-here" \
-H "Content-type: application/json" \
-d '{"phone": "+19171111111", "city": "Seattle", "state": "WA", "country": "US", "postal_code": "98104", "address_1": "925 4th Ave"}'
```

{% hint style="info" %}
**Postal Code Requirements**

The `postal_code` field is required for most countries. However, the following countries do not use postal codes and are exempt from this requirement:

AO, AG, AW, BH, BS, BZ, BJ, BM, BO, BQ, BW, BF, BI, CM, CF, TD, KM, CG, CD, CK, CI, CW, DJ, DM, GQ, ER, FJ, TF, GA, GM, GH, GD, GY, HM, HK, KI, KP, LY, MO, MW, ML, MR, NR, AN, NU, QA, RW, KN, SA, ST, SC, SL, SX, SB, SO, SR, SY, TL, TG, TK, TO, TT, TV, UG, AE, VU, YE, ZW
{% endhint %}

***

## Apply Shipping and Billing Addresses to Cart (Apple Pay)

When using Apple Pay, Apple does not provide a complete shipping and billing address until **after** payment authorization. In order to accommodate for this, Violet allows you to leave certain fields, such as `address_1`, blank. This can only be done if the Order has been marked with the field `wallet_based_checkout: true`. You can learn more about how to use Apple Pay and other wallet based payment methods, [here](https://docs.violet.io/prism/checkout-guides/guides/violet-checkout-with-apple-pay).

***

## Blocked Addresses

Violet maintains a list of blocked addresses that cannot be used for new carts or orders. These are addresses that have historically been used to place fraudulent orders through Violet using stolen card numbers. This list consists primarily of private/residential addresses however freight forwarders may also be included after they've handled multiple fraudulent orders.

When an attempt is made to apply a blocked address to a cart the following error will be returned.

```json
{
  "message": "The provided address has been blocked due to a history of being used for fraudulent orders.",
  "error": "blocked_address",
  "code": 4236
}
```

For testing purposes you can trigger this error using the postal code `99999` with the street address `10001 Purple Way`.

{% hint style="info" %}
If you wish to disable the address block list please open a ticket and request that it is disabled for your app(s).
{% endhint %}
