Skip to main content
Customer registration allows new users to create accounts in the system. This endpoint is publicly accessible and does not require authentication.

Create Customer Account

This endpoint is defined in customers/views.py:28-31 and uses the CustomerCreateView class.

Endpoint

POST /api/v1/customers/

Permission

  • AllowAny - No authentication required

Request Body

email
string
required
Customer’s email address (used as the primary identifier)
first_name
string
required
Customer’s first name
last_name
string
required
Customer’s last name
password
string
required
Account password (validated against Django’s password validators)
password2
string
required
Password confirmation (must match password)
date_of_birth
string
Customer’s date of birth in YYYY-MM-DD format

Password Validation

Passwords are validated using Django’s built-in validators (configured in config/settings.py:120-133):
  • UserAttributeSimilarityValidator - Password cannot be too similar to user attributes
  • MinimumLengthValidator - Minimum password length requirement
  • CommonPasswordValidator - Password cannot be a commonly used password
  • NumericPasswordValidator - Password cannot be entirely numeric

Example Request

curl -X POST https://api.example.com/api/v1/customers/ \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "first_name": "John",
    "last_name": "Doe",
    "password": "SecurePass123!",
    "password2": "SecurePass123!",
    "date_of_birth": "1990-05-15"
  }'

Response

email
string
Customer’s email address
first_name
string
Customer’s first name
last_name
string
Customer’s last name
slug
string
Auto-generated slug from customer’s full name
date_of_birth
string
Customer’s date of birth
address
object
Customer’s address (null for new registrations)
last_purchase_date
string
Date of last purchase (null for new customers)

Success Response (201 Created)

{
  "email": "[email protected]",
  "first_name": "John",
  "last_name": "Doe",
  "slug": "john-doe",
  "date_of_birth": "1990-05-15",
  "address": null,
  "last_purchase_date": null
}

Error Responses

{
  "error": "Passwords don't match"
}
This error occurs when password and password2 fields don’t match (validated in customers/serializers.py:39-44).
{
  "password": [
    "This password is too common.",
    "This password is entirely numeric."
  ]
}
Password fails Django’s password validation rules.
{
  "email": [
    "customer with this email address already exists."
  ]
}
The email is already registered in the system (emails must be unique).
{
  "first_name": [
    "This field is required."
  ],
  "last_name": [
    "This field is required."
  ]
}
Required fields are missing from the request.

Customer Model Structure

The Customer model (defined in customers/models.py:32-67) extends Django’s AbstractUser with the following custom fields:
FieldTypeDescription
emailEmailFieldPrimary identifier (unique, indexed)
slugAutoSlugFieldAuto-generated from full name
date_of_birthDateFieldCustomer’s birth date
addressOneToOneFieldReference to Address model
is_vendorBooleanFieldVendor status flag
last_purchase_dateDateTimeFieldLast purchase timestamp
products_bought_countPositiveIntegerFieldTotal products purchased
total_units_boughtPositiveIntegerFieldTotal units purchased
products_boughtManyToManyFieldProducts purchased by customer
redeemed_vouchersManyToManyFieldVouchers redeemed by customer
The username field is explicitly set to None and email is used as the USERNAME_FIELD (see customers/models.py:54-56).

After Registration

Once a customer account is created:
  1. Obtain tokens - Use the /auth/token/ endpoint to get access and refresh tokens
  2. Update profile - Add address information and other details
  3. Start shopping - Browse products and make purchases

Next: Obtain JWT Tokens

Learn how to authenticate with your new account and obtain JWT tokens

Build docs developers (and LLMs) love