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
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the customer |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| default | Boolean | No | Whether this should be the default address (default: false) |
| country | Integer | Yes | Country ID |
| state | Integer | Yes | State ID (must belong to the specified country) |
| city | Integer | Yes | City ID (must belong to the specified state) |
| address | String | Yes | Street address |
| postal_code | String | Yes | Postal/ZIP code |
| first_name | String | Yes | First name on the address |
| last_name | String | Yes | Last name on the address |
| national_code | String | No | National identification code |
| mobile_number | String | Yes | Mobile phone number for this address |
Example Requests
- 🐍 Python
- 🌐 Curl
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())1# Create a new customer address
2curl -X POST "http://www.example.com/api/customers/123/addresses" \
3-H "Authorization: Token <your_api_key>" \
4-H "Content-Type: application/json" \
5-d '{
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}'Response Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the address |
| default | Boolean | Whether this is the customer's default address |
| country_data | Object | Country information with id, name, etc. |
| state_data | Object | State information with id, name, etc. |
| city_data | Object | City information with id, name, etc. |
| address | String | Street address |
| postal_code | String | Postal/ZIP code |
| first_name | String | First name on the address |
| last_name | String | Last name on the address |
| national_code | String | National identification code (nullable) |
| mobile_number | String | Mobile phone number for this address |
| text | String | Address text (computed field) |
| created_at | String (ISO 8601) | Timestamp when address was created |
| updated_at | String (ISO 8601) | Timestamp when address was last updated |
Country Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the country |
| name | String | Name of the country |
| code | String | ISO country code (e.g., US, CA) |
State Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the state |
| name | String | Name of the state |
| code | String | State code (if applicable) |
City Data Structure
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the city |
| name | String | Name 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
textis a computed field comprised ofcountry,state,cityandaddressfields (country name-state name- citry name-address)- The chosen
country,stateandcityshould be valid together, so the city should exist in the state and the state should exist in the country postal_codemust be a valid iraninan postal codemobile_numbermust be a valid iraninan mobile number (eg 09121236545)