Developer docs / v1
From delivered order to published review.
Connect your store once, send delivery events, and let reviewlo handle the customer conversation. This guide covers onboarding, the npm package, the API, payload schemas, and the complete event lifecycle.
01 / Quickstart
Install it beside your order flow.
After your account is provisioned and approved, copy the API key and tenant ID from your dashboard. Keep both values server-side in environment variables. Do not expose the API key in browser code or mobile apps.
npm install @kxp/order-trackerInitialize the client once when your server-side application starts. The endpoint defaults to https://api.kxpreview.com; set endpoint only when using a different ingestion API. The package buffers events in memory and sends them asynchronously, so tracking does not wait for the network request.
import { init, orderDelivered } from "@kxp/order-tracker";
init({
apiKey: process.env.REVIEWLO_API_KEY!,
tenantId: process.env.REVIEWLO_TENANT_ID!,
});Call orderDelivered after your system has confirmed fulfillment. This is the event that schedules a review request.
orderDelivered({
orderId: order.id,
status: "delivered",
deliveredAt: new Date().toISOString(),
customer: {
customerId: customer.id,
name: customer.name,
phone: customer.phone,
email: customer.email,
},
products: order.items.map((item) => ({
productId: item.productId,
name: item.name,
quantity: item.quantity,
price: item.price,
})),
});02 / Payload schema
The order event contract.
Every npm helper accepts one OrderData object. The SDK validates this object before sending it. The same order shape is used for created, fulfilled, delivered, cancelled, and refunded events.
type OrderData = {
orderId: string; // required
status: string; // required
deliveredAt?: string; // optional, ISO 8601
customer: {
customerId: string; // required
name?: string; // optional
phone: string; // required, international format
email?: string; // optional, valid email if supplied
};
products: Array<{
productId: string; // required
name: string; // required
quantity: number; // required, positive integer
price: number; // required, zero or greater
}>; // required, at least one product
};orderIdYesYour stable order ID. Must not be empty.statusYesCurrent order status, such as delivered.deliveredAtNoISO 8601 timestamp, for example 2026-09-13T12:30:00.000Z.customerYesObject containing the person who placed the order.productsYesArray with at least one product.Customer fields
customerIdis required and should stay consistent for the same customer.phoneis required for WhatsApp and must contain 8-15 international digits, for example+919389884955. Spaces, brackets, dots, and hyphens are normalized.nameandemailare optional. If email is supplied, it must be valid.
Product fields
productIdandnameare required and must not be empty.quantitymust be a positive whole number, such as1or3.pricemust be a number greater than or equal to zero. Use the price for one item.
For a delivered order, send orderDelivered(order). Use orderCancelled(order) or orderRefunded(order) if the customer should no longer receive a pending review request. The other supported methods are orderCreated(order) and orderFulfilled(order).
Complete valid example
{
"orderId": "order_123",
"status": "delivered",
"deliveredAt": "2026-09-13T12:30:00.000Z",
"customer": {
"customerId": "customer_456",
"name": "Jane Doe",
"phone": "+919389884955",
"email": "jane@example.com"
},
"products": [
{
"productId": "product_789",
"name": "Running Shoes",
"quantity": 1,
"price": 49.99
}
]
}03 / REST API
Use the API from any backend.
The npm package is the recommended integration for order systems, but the same ingestion API can be called directly. Authenticate every request with the API key from your dashboard using a Bearer token. The API resolves the tenant from that key; each canonical event must include the matching tenantId.
POST/v1/eventsAccepts an events array containing canonical events. The API returns HTTP 202 when events are accepted for asynchronous processing.
Required header: Authorization: Bearer YOUR_API_KEY. The tenant is resolved from the API key, and the event body must contain the matching tenantId.
Direct integrations must wrap each order in a canonical event. The event ID should be unique; use eventVersion: "1.0" and keep tenantId aligned with the API key. The SDK creates the event ID and timestamp automatically.
{
"events": [
{
"eventId": "evt_123",
"eventType": "order.delivered",
"eventVersion": "1.0",
"tenantId": "tenant_123",
"timestamp": "2026-09-13T12:30:00.000Z",
"data": {
"order": {
"orderId": "order_123",
"status": "delivered",
"deliveredAt": "2026-09-13T12:30:00.000Z",
"customer": {
"customerId": "customer_456",
"name": "Jane Doe",
"phone": "+919389884955",
"email": "jane@example.com"
},
"products": [
{
"productId": "product_789",
"name": "Running Shoes",
"quantity": 1,
"price": 49.99
}
]
}
}
}
]
}curl -X POST "https://api.kxpreview.com/v1/events" \
-H "Authorization: Bearer $REVIEWLO_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @events.jsonHTTP 202 includes { status: "accepted", results: [{ eventId, status }] }. Each event result reports accepted, duplicate, invalid, or rate_limited; a missing or non-array events field returns HTTP 400.
GET/v1/reviewsReturns reviews, ordered newest first. Optional query filters are productId, orderId, rating, and status.
Example: list reviews:
curl "https://api.kxpreview.com/v1/reviews" \
-H "Authorization: Bearer YOUR_API_KEY"Both review endpoints require the same Bearer API key. The list response is an object containing a reviews array; each review includes product and customer details, rating, text, image data, completion status (complete or partial), and submission time. The list is ordered newest first.
GET/v1/reviews/:idReturns one review by ID with the same fields as a list item. A missing review returns 404.
04 / Lifecycle
What happens after delivery.
Accepted
The API validates and queues the event.
Scheduled
A review request is scheduled for the delivered item.
Conversation
The customer rates, writes, and can attach a photo.
Complete
The review is stored and available through /v1/reviews.
Review conversations are isolated by tenant, customer, and reviewable product. A customer with several products can complete each review independently.
05 / Operations
Production notes and troubleshooting.
Duplicate events
The SDK creates an event ID and the API applies an idempotency check. Retrying an event with the same ID returns a duplicate result instead of creating another order event.
Rate limits
Event ingestion is limited to 5 requests per minute per tenant, with a customer-level limit of 5 events per minute. Reviews can be read at up to 300 requests per minute.
Graceful shutdown and delivery
Events are buffered in process memory, not persisted. Call await flush() before a worker or web process exits, then call stop() to clear the background timer. Failed sends are retried up to three attempts with backoff and logged; because a flush removes its batch from the in-memory buffer before sending, keep your own durable retry mechanism if events must never be lost.
No API key yet?
Complete activation from your dashboard. After the database is provisioned and an administrator approves the account, the API key appears in the dashboard.