Create an address

How to create an address via API

To create a new address, send a POST request to the /api/addresses endpoint, passing the resource arguments in the request body.

Request

POST https://yourdomain.commercelayer.io/api/addresses

Arguments

Body ParameterTypeRequired

type

string

Required

attributes.business

boolean

Optional, default is 'false'

attributes.first_name

string

Required if 'business' is 'false'

attributes.last_name

string

Required if 'business' is 'false'

attributes.company

string

Required if 'business' is 'true'

attributes.line_1

string

Required

attributes.line_2

string

Optional

attributes.city

string

Required

attributes.zip_code

string

Required, but for some countries

attributes.state_code

string

Required

attributes.country_code

string

Required

attributes.phone

string

Required

attributes.email

string

Optional

attributes.notes

string

Optional

attributes.lat

float

Optional

attributes.lng

float

Optional

attributes.billing_info

string

Optional

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.geocoder

object

Optional

relationships.tags

array

Optional

Example

The following request creates a new address:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/addresses' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "addresses",
    "attributes": {
      "first_name": "John",
      "last_name": "Smith",
      "company": "The Red Brand Inc.",
      "line_1": "2883 Geraldine Lane",
      "city": "New York",
      "zip_code": "10013",
      "state_code": "NY",
      "country_code": "US",
      "phone": "(212) 646-338-1228"
    }
  }
}'

Last updated