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 or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the customer

Request Body

FieldTypeRequiredDescription
countryIntegerYesCountry ID
stateIntegerYesState ID (must belong to the specified country)
cityIntegerYesCity ID (must belong to the specified state)
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 (default: false)

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

Status Codes

CodeDescription
201Customer address created successfully
400Bad request — invalid input or validation error
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404Customer 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