Ordeliya Docs

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"
  }'
FieldTypeRequiredDescription
firstNamestringnoMax 100 characters
lastNamestringnoMax 100 characters
emailstringnoValid email address
phonestringnoE.164 format (e.g., +4520123456)
acceptsMarketingbooleannoNewsletter opt-in. Default false
localestringnoPreferred locale. Default da-DK
defaultAddressLinestringnoStreet address
defaultZipcodestringnoPostal code
defaultCitystringnoCity name
adminNotesstringnoInternal notes (not visible to customer)
birthDatestringnoISO date (e.g., 1990-05-15)
allergensstring[]noAllergen 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..."
ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger20Items per page
sortBystringcreatedAtSort field: createdAt, totalSpentMinor, totalOrders, lastOrderAt, firstName
sortDirstringdescSort direction: asc or desc
acceptsMarketingbooleanFilter by marketing opt-in
isBlockedbooleanFilter blocked customers
hasOrdersbooleantrue = has ordered, false = never ordered
minSpentintegerMinimum total spent (minor units)
maxSpentintegerMaximum total spent (minor units)
lastOrderPeriodstringtoday, 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"
  }'
FieldTypeRequiredDescription
deltaintegeryesPoints to add (positive) or deduct (negative)
reasonstringyesReason 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!"
  }'
FieldTypeRequiredDescription
orderIdstringyesThe order being reviewed
customerIdstringnoCustomer who left the review
ratingintegeryesOverall rating (1-5)
foodRatingintegernoFood quality rating (1-5)
deliveryRatingintegernoDelivery experience rating (1-5)
packagingRatingintegernoPackaging quality rating (1-5)
commentstringnoReview 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..."
ParameterTypeDefaultDescription
pageinteger1Page number
limitinteger20Items per page
isApprovedbooleanFilter by approval status
minRatingintegerMinimum rating (1-5)
dateFromstringISO date filter start
dateTostringISO 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