Customers
Manage customer profiles, loyalty points, reviews, and purchase analytics.
Overview
The Customers API provides full CRM capabilities — create and manage customer profiles, track purchase history, adjust loyalty points, handle reviews, and view per-customer analytics.
Customers
POST /customers
Create a new customer profile.
Auth: Bearer Token (Staff role or above)
curl -X POST https://api.ordeliya.com/customers \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..." \
-H "Content-Type: application/json" \
-d '{
"firstName": "Maria",
"lastName": "Nielsen",
"email": "maria@example.dk",
"phone": "+4520123456",
"acceptsMarketing": true,
"locale": "da-DK"
}'
| Field | Type | Required | Description |
|---|---|---|---|
firstName | string | no | Max 100 characters |
lastName | string | no | Max 100 characters |
email | string | no | Valid email address |
phone | string | no | E.164 format (e.g., +4520123456) |
acceptsMarketing | boolean | no | Newsletter opt-in. Default false |
locale | string | no | Preferred locale. Default da-DK |
defaultAddressLine | string | no | Street address |
defaultZipcode | string | no | Postal code |
defaultCity | string | no | City name |
adminNotes | string | no | Internal notes (not visible to customer) |
birthDate | string | no | ISO date (e.g., 1990-05-15) |
allergens | string[] | no | Allergen codes (e.g., ["GLUTEN", "DAIRY"]) |
Response 201 Created
{
"success": true,
"data": {
"id": "cust_n3k7m2",
"storeId": "store_r4k7",
"firstName": "Maria",
"lastName": "Nielsen",
"email": "maria@example.dk",
"phone": "+4520123456",
"acceptsMarketing": true,
"locale": "da-DK",
"isBlocked": false,
"totalSpentMinor": 0,
"totalOrders": 0,
"lastOrderAt": null,
"createdAt": "2026-03-15T10:00:00.000Z"
}
}
GET /customers
List customers with filtering and sorting.
Auth: Bearer Token or API Key (read:customers)
curl "https://api.ordeliya.com/customers?page=1&limit=20&sortBy=totalSpentMinor&sortDir=desc" \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..."
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number |
limit | integer | 20 | Items per page |
sortBy | string | createdAt | Sort field: createdAt, totalSpentMinor, totalOrders, lastOrderAt, firstName |
sortDir | string | desc | Sort direction: asc or desc |
acceptsMarketing | boolean | — | Filter by marketing opt-in |
isBlocked | boolean | — | Filter blocked customers |
hasOrders | boolean | — | true = has ordered, false = never ordered |
minSpent | integer | — | Minimum total spent (minor units) |
maxSpent | integer | — | Maximum total spent (minor units) |
lastOrderPeriod | string | — | today, 7d, 30d, 90d |
Response 200 OK
{
"success": true,
"data": [
{
"id": "cust_n3k7m2",
"firstName": "Maria",
"lastName": "Nielsen",
"email": "maria@example.dk",
"phone": "+4520123456",
"isBlocked": false,
"totalSpentMinor": 245600,
"totalOrders": 28,
"lastOrderAt": "2026-03-14T19:22:00.000Z",
"createdAt": "2025-11-01T08:00:00.000Z"
}
],
"meta": {
"total": 847,
"page": 1,
"limit": 20,
"totalPages": 43
}
}
GET /customers/:id
Get full customer detail including addresses, allergens, and admin notes.
Auth: Bearer Token or API Key (read:customers)
curl https://api.ordeliya.com/customers/cust_n3k7m2 \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..."
PATCH /customers/:id
Update a customer profile. Only provided fields are modified.
Auth: Bearer Token (Manager role or above)
curl -X PATCH https://api.ordeliya.com/customers/cust_n3k7m2 \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..." \
-H "Content-Type: application/json" \
-d '{
"adminNotes": "VIP customer — always prioritize orders",
"allergens": ["GLUTEN", "NUTS"]
}'
DELETE /customers/:id
Delete a customer profile.
Auth: Bearer Token (Admin or Owner role)
curl -X DELETE https://api.ordeliya.com/customers/cust_n3k7m2 \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..."
Response 204 No Content
POST /customers/:id/block
Block a customer from placing orders and making reservations.
Auth: Bearer Token (Manager role or above)
curl -X POST https://api.ordeliya.com/customers/cust_n3k7m2/block \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..." \
-H "Content-Type: application/json" \
-d '{ "reason": "Repeated no-shows for reservations" }'
Response 200 OK
{
"success": true,
"data": {
"id": "cust_n3k7m2",
"isBlocked": true
}
}
POST /customers/:id/unblock
Remove the block from a customer.
curl -X POST https://api.ordeliya.com/customers/cust_n3k7m2/unblock \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..."
GET /customers/:id/orders
Get a customer's order history.
Auth: Bearer Token or API Key (read:customers, read:orders)
curl https://api.ordeliya.com/customers/cust_n3k7m2/orders \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..."
POST /customers/:id/loyalty/adjust
Manually add or deduct loyalty points for a customer.
Auth: Bearer Token (Manager role or above)
curl -X POST https://api.ordeliya.com/customers/cust_n3k7m2/loyalty/adjust \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..." \
-H "Content-Type: application/json" \
-d '{
"delta": 500,
"reason": "Compensation for late delivery"
}'
| Field | Type | Required | Description |
|---|---|---|---|
delta | integer | yes | Points to add (positive) or deduct (negative) |
reason | string | yes | Reason for the adjustment |
Response 200 OK
{
"success": true,
"data": {
"customerId": "cust_n3k7m2",
"previousBalance": 2450,
"adjustment": 500,
"newBalance": 2950,
"reason": "Compensation for late delivery"
}
}
GET /customers/:id/analytics
Get purchase analytics for a specific customer.
Auth: Bearer Token or API Key (read:customers, read:analytics)
curl https://api.ordeliya.com/customers/cust_n3k7m2/analytics \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..."
Response 200 OK
{
"success": true,
"data": {
"totalOrders": 28,
"totalSpentMinor": 245600,
"averageOrderMinor": 8771,
"topProducts": [
{ "productId": "prod_8kx2m4n7", "productName": "Margherita Pizza", "orderCount": 15 },
{ "productId": "prod_3jn8v5q2", "productName": "Garlic Bread", "orderCount": 12 }
],
"topCategories": [
{ "categoryId": "cat_p1z2a3", "categoryName": "Pizzas", "orderCount": 22 }
]
}
}
Reviews
POST /reviews
Create a review for an order.
Auth: Bearer Token (any role)
curl -X POST https://api.ordeliya.com/reviews \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..." \
-H "Content-Type: application/json" \
-d '{
"orderId": "ord_v7k3m9n2",
"customerId": "cust_n3k7m2",
"rating": 5,
"foodRating": 5,
"deliveryRating": 4,
"comment": "Amazing pizza, slightly late delivery but worth the wait!"
}'
| Field | Type | Required | Description |
|---|---|---|---|
orderId | string | yes | The order being reviewed |
customerId | string | no | Customer who left the review |
rating | integer | yes | Overall rating (1-5) |
foodRating | integer | no | Food quality rating (1-5) |
deliveryRating | integer | no | Delivery experience rating (1-5) |
packagingRating | integer | no | Packaging quality rating (1-5) |
comment | string | no | Review text |
Response 201 Created
{
"success": true,
"data": {
"id": "rev_a1b2c3",
"orderId": "ord_v7k3m9n2",
"customerId": "cust_n3k7m2",
"rating": 5,
"foodRating": 5,
"deliveryRating": 4,
"packagingRating": null,
"comment": "Amazing pizza, slightly late delivery but worth the wait!",
"isApproved": false,
"isPublic": true,
"isFeatured": false,
"response": null,
"createdAt": "2026-03-15T20:00:00.000Z"
}
}
GET /reviews
List all reviews for the current store.
Auth: Bearer Token or API Key (read:orders)
curl "https://api.ordeliya.com/reviews?page=1&limit=20&minRating=4" \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..."
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number |
limit | integer | 20 | Items per page |
isApproved | boolean | — | Filter by approval status |
minRating | integer | — | Minimum rating (1-5) |
dateFrom | string | — | ISO date filter start |
dateTo | string | — | ISO date filter end |
GET /reviews/stats
Get aggregate review statistics.
Auth: Bearer Token or API Key (read:orders)
curl https://api.ordeliya.com/reviews/stats \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..."
Response 200 OK
{
"success": true,
"data": {
"totalReviews": 156,
"averageRating": 4.3,
"ratingDistribution": {
"1": 3,
"2": 8,
"3": 21,
"4": 52,
"5": 72
},
"approvedCount": 142,
"pendingCount": 14
}
}
PATCH /reviews/:id
Update review visibility and moderation status.
Auth: Bearer Token (Manager role or above)
curl -X PATCH https://api.ordeliya.com/reviews/rev_a1b2c3 \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..." \
-H "Content-Type: application/json" \
-d '{
"isApproved": true,
"isFeatured": true
}'
POST /reviews/:id/response
Add or update your response to a customer review.
Auth: Bearer Token (Manager role or above)
curl -X POST https://api.ordeliya.com/reviews/rev_a1b2c3/response \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..." \
-H "Content-Type: application/json" \
-d '{
"responseText": "Thank you Maria! We are working on improving delivery times."
}'
Response 200 OK
{
"success": true,
"data": {
"id": "rev_a1b2c3",
"response": {
"responseText": "Thank you Maria! We are working on improving delivery times.",
"respondedAt": "2026-03-15T21:00:00.000Z",
"respondedBy": "usr_4k7m2n8v"
}
}
}
DELETE /reviews/:id
Delete a review.
Auth: Bearer Token (Admin or Owner role)
curl -X DELETE https://api.ordeliya.com/reviews/rev_a1b2c3 \
-H "Authorization: Bearer ord_live_sk_7f3a9b2c..."
Response 204 No Content