Skip to content

Create Customer Address

Add a new address to the customer's address book.

Endpoint

POST /api/shop/customer-addresses

Request Headers

HeaderRequiredDescription
Content-TypeYesapplication/json
X-STOREFRONT-KEYYesYour storefront API key
AuthorizationYesBearer token (customer login required)

Request Body

json
{
  "firstName": "Jane",
  "lastName": "Doe",
  "companyName": "ANC Corporation",
  "vatId": "GB123456789",
  "email": "[email protected]",
  "phone": "9876543210",
  "address1": "456 Oak Ave",
  "address2": "Suite 200",
  "city": "Los Angeles",
  "state": "CA",
  "country": "US",
  "postcode": "90001",
  "defaultAddress": false
}

Request Parameters

ParameterTypeRequiredDescription
firstNamestringYesFirst name on the address.
lastNamestringYesLast name on the address.
address1stringYesStreet address. Note the read endpoints return this value under the key address.
citystringYesCity.
address2stringNoSecond street line.
companyNamestringNoCompany name.
vatIdstringNoVAT identification number.
emailstringNoContact email stored with the address.
phonestringNoContact phone stored with the address.
statestringNoState or region code.
countrystringNoTwo-letter country code.
postcodestringNoPostal code.
defaultAddressbooleanNoMarks this address as the customer's default and clears the flag on the previous one. Defaults to false.

The four required fields are the ones the address record cannot be stored without. Everything else — including country, state, and postcode — is accepted as sent and is not checked against the store's country list, so validate those on the client if the checkout depends on them.

Response Fields (201 Created)

The response is the created address itself, flat — there is no wrapper object and no message.

FieldTypeDescription
id / addressIdintegerThe new address ID, returned under both keys.
firstName / lastNamestringName as stored.
companyName / vatIdstringEchoed back, null when not sent.
email / phonestringEchoed back, null when not sent.
address1 / address2stringStreet lines as stored.
country / state / city / postcodestringLocation as stored.
defaultAddressbooleanWhether this address is now the default.

Use Cases

  • Save an address during checkout — create it here, then send the same fields to Set Shipping Address; checkout takes address fields, not an address ID.
  • First address for a new customer — pass defaultAddress: true so later screens have a default to pre-select.
  • Switch the default — creating with defaultAddress: true clears the flag on the previous default in the same call, so no second request is needed.

Best Practices

  • Send address1, never address — an unrecognised key is ignored silently and the address is stored with an empty street.
  • Validate country, state, and postcode client-side — the endpoint stores whatever is sent, so a typo surfaces only later at checkout.
  • Keep the returned addressId — update and delete address the row by that ID, and the create response is the only place it is handed back.

Released under the MIT License.