Create a customer address

How to create a customer address via API

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

Request

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

Arguments

Body Parameter
Type
Required

type

string

Required

attributes.customer_email

string

Required

attributes.reference

string

Optional

attributes.reference_origin

string

Optional

attributes.metadata

object

Optional

relationships.customer

object

Required

relationships.address

object

Required

Example

The following request creates a new customer address:

curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/customer_addresses' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "customer_addresses",
    "attributes": {
      "customer_email": "john@example.com"
    },
    "relationships": {
      "customer": {
        "data": {
          "type": "customers",
          "id": "ABCRtyUpBa"
        }
      },
      "address": {
        "data": {
          "type": "addresses",
          "id": "BCDRtyUpBa"
        }
      }
    }
  }
}'

Last updated