Skip to main content

Create Customer

Creates a new customer in the system.

HTTP Request

POST/api/customers

Authorization

Authorization

  • Required: Yes
  • Permission: Staff or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Request Body

FieldTypeRequiredDescription
first_nameStringNoCustomer's first name
last_nameStringNoCustomer's last name
emailStringNoCustomer's email address
mobile_numberStringNoCustomer's mobile phone number
national_codeStringNoCustomer's national identification code
birth_dateString (YYYY-MM-DD)NoCustomer's birth date in YYYY-MM-DD format
genderStringNoCustomer's gender (male, female)
notesStringNoAdditional notes about the customer

Example Requests

1import requests
2
3# Create a new customer with full details
4response = requests.post('http://www.example.com/api/customers', 
5  json={
6      'first_name': 'John',
7      'last_name': 'Doe',
8      'email': 'john.doe@example.com',
9      'mobile_number': '+1234567890',
10      'national_code': '1234567890',
11      'birth_date': '1990-01-15',
12      'gender': 'male',
13      'notes': 'VIP customer'
14  },
15  headers={'Authorization': 'Token <your_api_key>'}
16)
17print(response.json())
18
19# Create minimal customer
20response = requests.post('http://www.example.com/api/customers', 
21  json={
22      'email': 'jane.smith@example.com',
23      'first_name': 'Jane'
24  },
25  headers={'Authorization': 'Token <your_api_key>'}
26)
27print(response.json())

Status Codes

CodeDescription
201Customer created successfully
400Bad request — invalid input or validation error
401Unauthorized — authentication required
403Forbidden — insufficient permissions
409Conflict — customer with this email already exists
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the customer
first_nameStringCustomer's first name
last_nameStringCustomer's last name
emailStringCustomer's email address
mobile_numberStringCustomer's mobile phone number
national_codeStringCustomer's national identification code
birth_dateString (YYYY-MM-DD)Customer's birth date
genderStringCustomer's gender (male/female)
notesStringAdditional notes about the customer
is_activeBooleanWhether the customer account is active
date_joinedString (ISO 8601)Timestamp when customer was created
is_profile_completedBooleanWhether the customer has completed their profile
last_loginString (ISO 8601)Timestamp of customer's last login (null if never logged in)
total_ordersIntegerTotal number of orders placed by this customer
total_spentString (Decimal)Total amount spent by this customer

Notes

    • All fields are optional when creating a customer
    • Email addresses must be unique across the system
    • Gender field accepts only 'M' (Male) or 'F' (Female)
    • Birth date must be in YYYY-MM-DD format
    • Mobile number should include country code
    • New customers are automatically set to active status
    • total_orders and total_spent are calculated fields that start at 0