Skip to main content

Create Customer Address

Creates a new address for a specific customer.

HTTP Request

POST/api/customers/:id/addresses

Authorization

Authorization

  • Required: Yes
  • Permission: Staff with CustomerAddressPermission or Admin
  • Permission Code: 1421
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the customer

Request Body

FieldTypeRequiredDescription
defaultBooleanNoWhether this should be the default address (default: false)
countryIntegerYesCountry ID
stateIntegerYesState ID (must belong to the specified country)
cityIntegerYesCity ID (must belong to the specified state)
addressStringYesStreet address
postal_codeStringYesPostal/ZIP code
first_nameStringYesFirst name on the address
last_nameStringYesLast name on the address
national_codeStringNoNational identification code
mobile_numberStringYesMobile phone number for this address

Example Requests

1import requests
2
3# Create a new customer address
4response = requests.post('http://www.example.com/api/customers/123/addresses', 
5  json={
6      'default': True
7      'country': 1,
8      'state': 5,
9      'city': 25,
10      'address': '123 Main Street',
11      'postal_code': '8651989917',
12      'first_name': 'John',
13      'last_name': 'Doe',
14      'national_code': '1234567890',
15      'mobile_number': '09102356598',
16  },
17  headers={'Authorization': 'Token <your_api_key>'}
18)
19print(response.json())

Response Fields

FieldTypeDescription
idIntegerUnique ID of the address
defaultBooleanWhether this is the customer's default address
country_dataObjectCountry information with id, name, etc.
state_dataObjectState information with id, name, etc.
city_dataObjectCity information with id, name, etc.
addressStringStreet address
postal_codeStringPostal/ZIP code
first_nameStringFirst name on the address
last_nameStringLast name on the address
national_codeStringNational identification code (nullable)
mobile_numberStringMobile phone number for this address
textStringAddress text (computed field)
created_atString (ISO 8601)Timestamp when address was created
updated_atString (ISO 8601)Timestamp when address was last updated

Country Data Structure

FieldTypeDescription
idIntegerUnique ID of the country
nameStringName of the country
codeStringISO country code (e.g., US, CA)

State Data Structure

FieldTypeDescription
idIntegerUnique ID of the state
nameStringName of the state
codeStringState code (if applicable)

City Data Structure

FieldTypeDescription
idIntegerUnique ID of the city
nameStringName of the city

Example Response

{
"id": 5,
"default": true,
"country_data": {
"id": 1,
"name": "ایران",
"code": "IR"
},
"state_data": {
"id": 1,
"name": "آذربایجان شرقی",
"code": "EA"
},
"city_data": {
"id": 1,
"name": "اسکو"
},
"address": "47152 Kirlin Summit",
"postal_code": "8651989917",
"first_name": "فرشام",
"last_name": "جهان‌آرا",
"national_code": null,
"mobile_number": "09036167607",
"text": "ایران-آذربایجان شرقی-اسکو-47152 Kirlin Summit",
"created_at": "2025-12-22T12:34:43.994555Z",
"updated_at": "2025-12-22T12:34:43.994563Z"
}

Notes

  • text is a computed field comprised of country, state, city and address fields (country name-state name- citry name-address)
  • The chosen country, state and city should be valid together, so the city should exist in the state and the state should exist in the country
  • postal_code must be a valid iraninan postal code
  • mobile_number must be a valid iraninan mobile number (eg 09121236545)