Skip to main content

Customer API

The Customer API provides endpoints for retrieving paginated lists of customers linked to stores that the authenticated user has access to.
All Customer API endpoints require authentication and a valid x-store-id header to identify the store context.

Overview

Customers can be:
  • Linked to a store (created automatically when a store is created)
  • Linked to a user account (created when a user signs up)
  • Created manually with a local name and optional default price list
  • Assigned or updated with a default price list
  • Filtered and sorted by various criteria
  • Retrieved in paginated lists
  • Bulk deleted from a store (remove multiple customer-store relations)

Endpoint Details

Base URL: /customers
Content-Type: application/json

Required Headers

All routes require a valid x-store-id header. Users must have an active relation with the store to access its customers.

Get Customers

GET /customers Retrieve a paginated list of customers linked to a store that the authenticated user has access to. Requires Authentication: Bearer token in Authorization header

Required Headers

Query Parameters

Success Response

Status Code: 200 OK

Response Fields

Customer Object

Pagination Object

Possible Errors

Example Requests

Get all customers with default pagination:
Search customers by name:
Filter by active status:
Filter by exact name:

Create Customer

POST /customers Create a new customer and link them to the current store. You can optionally assign a default price list. Requires Authentication: Bearer token in Authorization header

Required Headers

Request Body

Request Body Fields

Success Response

Status Code: 200 OK

Response Fields

Customer Object

CustomerStore Object

Possible Errors

Example Request

Create customer without price list:

Set Customer Price List

PUT /customers/:customerId/price-list Assign or update the default price list of a customer. Optionally update the customer’s name at the same time. Requires Authentication: Bearer token in Authorization header

Required Headers

Path Parameters

Request Body

Request Body Fields

Success Response

Status Code: 200 OK

Response Fields

Possible Errors

Example Requests

Set price list only:
Set price list with customer name update:

Remove Customer Price List

DELETE /customers/:customerId/price-list Remove the default price list from a customer. Requires Authentication: Bearer token in Authorization header

Required Headers

Path Parameters

Success Response

Status Code: 200 OK

Response Fields

Possible Errors

Example Request


Bulk Delete Customers

DELETE /customers/bulk Remove multiple customers from the current store in one request. This deletes the customer-store relations for the provided IDs; it does not delete the underlying customer records globally. Requires Authentication: Bearer token in Authorization header

Required Headers

Request Body

Request Body Fields

Success Response

Status Code: 200 OK

Possible Errors

Example Request


Data Models

CustomerResponseDto

PaginationDto

PaginatedCustomersResponseDto


Summary


Security & Validation

  • All routes require a valid x-store-id header
  • User must have an active relation with the store to access its customers
  • Store ID validation prevents unauthorized access
  • Pagination limits are enforced (max 100 items per page)

Business Logic

Customer Creation

  • Customers can be created manually via POST /customers with a localName
  • When creating a customer, you can optionally assign a defaultPriceListId
  • Creating a customer automatically creates a CustomerStore relation linking the customer to the store
  • The price list must exist and be active if provided

Customer Price List Management

  • Customers can have a default price list assigned via PUT /customers/:customerId/price-list
  • The price list must exist and be active (verified by verifyPriceList())
  • Optionally, you can update the customer’s name when setting the price list by including the name field in the request
  • Price lists can be removed via DELETE /customers/:customerId/price-list
  • Removing a price list sets defaultPriceListId to null

Customer Retrieval

  • Returns paginated lists of customers for a specific store
  • Supports filtering by name (exact or partial match) and active status
  • Supports sorting by name, isActive, updatedAt, or createdAt
  • Default sorting is by createdAt in descending order (newest first)
  • Pagination is 1-based (first page is page 1)

Internal Methods

These methods are part of the internal business logic and are not exposed as public endpoints:

Validation Rules

  • Page number must be >= 1
  • Limit must be between 1 and 100
  • SortBy must be one of: name, isActive, updatedAt, createdAt
  • SortOrder must be either asc or desc
  • User must have access to the specified store
  • localName is required when creating a customer
  • priceListId must be a valid UUID and reference an existing, active price list
  • Bulk delete requires at least one valid UUID in ids
  • Only customers linked to the specified store will be removed

Error Responses

Common Error Codes

Error Response Format

Example Error Responses

403 Forbidden:
400 Bad Request:
500 Internal Server Error: