Update Customer Address
Updates an existing customer address.
HTTP Request
PATCH/api/customers/:customer_pk/addresses/:id
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| customer_pk | Integer | Yes | Unique ID of the customer |
| id | Integer | Yes | Unique ID of the address |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| country | Integer | No | Country ID (Required for PUT) |
| state | Integer | No | State ID (must belong to the specified country, Required for PUT) |
| city | Integer | No | City ID (must belong to the specified state, Required for PUT) |
| 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 |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3# Partial update (PATCH)
4response = requests.patch('http://www.example.com/api/customers/123/addresses/456',
5 json={
6 'address': '789 New Street',
7 'postal_code': '54321',
8 'default': True
9 },
10 headers={'Authorization': 'Token <your_api_key>'}
11)
12print(response.json())
13
14# Update location
15response = requests.patch('http://www.example.com/api/customers/123/addresses/456',
16 json={
17 'country': 2,
18 'state': 10,
19 'city': 50
20 },
21 headers={'Authorization': 'Token <your_api_key>'}
22)
23print(response.json())
24
25# Full update (PUT)
26response = requests.put('http://www.example.com/api/customers/123/addresses/456',
27 json={
28 'country': 1,
29 'state': 5,
30 'city': 25,
31 'address': '123 Updated Street',
32 'postal_code': '12345',
33 'first_name': 'John',
34 'last_name': 'Smith',
35 'default': True
36 },
37 headers={'Authorization': 'Token <your_api_key>'}
38)
39print(response.json())1# Partial update (PATCH)
2curl -X PATCH "http://www.example.com/api/customers/123/addresses/456" \
3-H "Authorization: Token <your_api_key>" \
4-H "Content-Type: application/json" \
5-d '{
6 "address": "789 New Street",
7 "postal_code": "54321",
8 "default": true
9}'
10
11# Update location
12curl -X PATCH "http://www.example.com/api/customers/123/addresses/456" \
13-H "Authorization: Token <your_api_key>" \
14-H "Content-Type: application/json" \
15-d '{
16 "country": 2,
17 "state": 10,
18 "city": 50
19}'Status Codes
| Code | Description |
|---|---|
| 200 | Customer address updated successfully |
| 400 | Bad request — invalid input or validation error |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | Customer or address 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 |