Skip to main content

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

ParameterTypeRequiredDescription
customer_pkIntegerYesUnique ID of the customer
idIntegerYesUnique ID of the address

Request Body

FieldTypeRequiredDescription
countryIntegerNoCountry ID (Required for PUT)
stateIntegerNoState ID (must belong to the specified country, Required for PUT)
cityIntegerNoCity ID (must belong to the specified state, Required for PUT)
addressStringNoStreet address
postal_codeStringNoPostal/ZIP code
first_nameStringNoFirst name on the address
last_nameStringNoLast name on the address
national_codeStringNoNational identification code
mobile_numberStringNoMobile phone number for this address
textStringNoAdditional text/notes for the address
defaultBooleanNoWhether this should be the default address

Example Requests

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())

Status Codes

CodeDescription
200Customer address updated successfully
400Bad request — invalid input or validation error
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404Customer or address not found
500Internal server error

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
mobile_numberStringMobile phone number for this address
textStringAdditional text/notes for the address
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