Create Customer Address
Creates a new address for a specific customer.
HTTP Request
POST/api/customers/:id/addresses
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- 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 |
|---|---|---|---|
| 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 | No | Street address |
| postal_code | String | No | Postal/ZIP code |
| first_name | String | No | First name on the address |
| last_name | String | No | Last name on the address |
| national_code | String | No | National identification code |
| mobile_number | String | No | Mobile phone number for this address |
| text | String | No | Additional text/notes for the address |
| default | Boolean | No | Whether this should be the default address (default: false) |
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 'country': 1,
7 'state': 5,
8 'city': 25,
9 'address': '123 Main Street',
10 'postal_code': '12345',
11 'first_name': 'John',
12 'last_name': 'Doe',
13 'national_code': '1234567890',
14 'mobile_number': '+1234567890',
15 'text': 'Home address',
16 'default': True
17 },
18 headers={'Authorization': 'Token <your_api_key>'}
19)
20print(response.json())
21
22# Create minimal address
23response = requests.post('http://www.example.com/api/customers/123/addresses',
24 json={
25 'country': 1,
26 'state': 5,
27 'city': 25,
28 'address': '456 Oak Avenue'
29 },
30 headers={'Authorization': 'Token <your_api_key>'}
31)
32print(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 "country": 1,
7 "state": 5,
8 "city": 25,
9 "address": "123 Main Street",
10 "postal_code": "12345",
11 "first_name": "John",
12 "last_name": "Doe",
13 "national_code": "1234567890",
14 "mobile_number": "+1234567890",
15 "text": "Home address",
16 "default": true
17}'
18
19# Create minimal address
20curl -X POST "http://www.example.com/api/customers/123/addresses" \
21-H "Authorization: Token <your_api_key>" \
22-H "Content-Type: application/json" \
23-d '{
24 "country": 1,
25 "state": 5,
26 "city": 25,
27 "address": "456 Oak Avenue"
28}'Status Codes
| Code | Description |
|---|---|
| 201 | Customer address created successfully |
| 400 | Bad request — invalid input or validation error |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Customer not found |
| 500 | Internal server error |
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 |
| mobile_number | String | Mobile phone number for this address |
| text | String | Additional text/notes for the address |
| 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 |