User Addresses .: Create

API Reference / v15

Create a New Address for a User

This endpoint allows you to create a new address for a user. To create an address, you must have a user access token with the manage_user_addresses permission.

Request Endpoint

POST /v15/user_addresses

Authorization Required – User Token in Header

Authorization: token user="123897-99SCvr3kSe3TqqQid3DyPXfo2Kq98MyhF6CaNPqoDeMhJ18Uopq19uddcznu6R"

Request Body

{
  "user_address": {
    "address_type": "home",
    "street_address": "101 Arch Street",
    "extended_address": "Suite 555",
    "locality": "Boston",
    "region": "MA",
    "postal_code": "02114"
  }
}

Request Parameters

Parameters Type Description
address_type String The type of the address. Valid values are ‘billing’, 'delivery’, 'home’, 'other’, 'payment’, 'shipping’, and 'work’.
extended_address String The second portion of a user’s address.
locality String The city of the address.
postal_code String The ZIP code of the address.
region String The state of the address.
street_address String The street and number of the address.

cURL Example

curl https://sandbox.thelevelup.com/v15/user_addresses \
  -H Accept:application/json \
  -H Content-Type:application/json \
  -H 'Authorization:token user="123897-99SCvr3kSe3TqqQid3DyPXfo2Kq98MyhF6CaNPqoDeMhJ18Uopq19uddcznu6R"' \
  -d '{
    "user_address": {
      "address_type": "home",
      "street_address": "123 Main St",
      "extended_address": "Apt 1",
      "locality": "Boston",
      "region": "MA",
      "postal_code": "02114"
    }
  }'

Responses

The address was created successfully

HTTP/1.1 200 OK

{
  "user_address": {
      "address_type": "home",
      "extended_address": "Apt 1",
      "id": 123,
      "latitude": 42.362603,
      "locality": "Boston",
      "longitude": -71.065063,
      "postal_code": "02114",
      "region": "MA",
      "street_address": "123 Main St"
  }
}

The address details were invalid

HTTP/1.1 422 Unprocessable Entity

[
  {
    "error": {
      "object": "user_address",
      "property": "address_type",
      "message": "Address type is invalid."
    }
  }
]