Skip to content

Order Management API Documentation

The Order Management API provides comprehensive functionality for managing orders, tracking order status, maintaining order timelines, and generating order analytics. This API supports the complete order lifecycle from creation to completion.

Base URL

https://api.talkingshops.com/v1

Authentication

All API requests require authentication using an API key. Include your API key in the request header:

x-tenant-api-key: your_api_key_here

API keys are tenant-specific and automatically provide access to the correct order data for your business.

Rate Limiting

The API implements rate limiting to prevent abuse. By default, each tenant is limited to 100 requests per minute.

Endpoints

Get Orders

GET /orders

Retrieve a paginated list of orders with advanced filtering, sorting, and search capabilities.

Query Parameters

ParameterTypeDescription
pagenumberPage number (default: 1)
limitnumberResults per page (1-100, default: 10)
statusstringFilter by order status
startDatestringFilter by creation date (ISO 8601)
endDatestringFilter by creation date (ISO 8601)
searchTermstringSearch in order ID, customer name, or mobile
sortBystringSort field (created_at, updated_at, final_amount, status, name, mobile, referenceId)
sortDirectionstringSort direction (asc, desc)

Response (200 OK)

json
{
  "orders": [
    {
      "_id": "64a1b2c3d4e5f6789abc1234",
      "referenceId": "ORD-001",
      "status": "processing",
      "created_at": "2023-06-21T14:35:12Z",
      "updated_at": "2023-06-21T15:20:30Z",
      "mobile": "919876543210",
      "name": "John Doe",
      "final_amount": 1250.50,
      "delivery_method": "home_delivery",
      "product_items": [
        {
          "name": "Premium T-Shirt",
          "quantity": 2,
          "price": 500.00
        },
        {
          "name": "Jeans",
          "quantity": 1,
          "price": 750.50
        }
      ]
    }
  ],
  "total": 256,
  "totalPages": 26
}

Get Order by ID

GET /orders/{orderId}

Retrieve detailed information about a specific order.

Parameters

ParameterTypeRequiredDescription
orderIdstringYesUnique order ID

Response (200 OK)

json
{
  "_id": "64a1b2c3d4e5f6789abc1234",
  "referenceId": "ORD-001",
  "status": "processing",
  "created_at": "2023-06-21T14:35:12Z",
  "updated_at": "2023-06-21T15:20:30Z",
  "mobile": "919876543210",
  "name": "John Doe",
  "email": "john@example.com",
  "final_amount": 1250.50,
  "delivery_method": "home_delivery",
  "payment_status": "paid",
  "delivery_details": {
    "address": "123 Main St, City, State",
    "tracking_number": "TRK123456789",
    "estimated_delivery": "2023-06-25T18:00:00Z"
  },
  "product_items": [
    {
      "name": "Premium T-Shirt",
      "quantity": 2,
      "price": 500.00,
      "sku": "TSH-PREM-001"
    }
  ],
  "order_history": [
    {
      "status": "confirmed",
      "timestamp": "2023-06-21T14:35:12Z",
      "note": "Order confirmed by customer"
    }
  ]
}

Update Order

PUT /orders/{orderId}

Update order information.

Parameters

ParameterTypeRequiredDescription
orderIdstringYesUnique order ID

Request

json
{
  "updates": {
    "status": "shipped",
    "delivery_method": "express_delivery",
    "payment_status": "paid",
    "delivery_details": {
      "tracking_number": "TRK987654321",
      "estimated_delivery": "2023-06-23T18:00:00Z"
    }
  }
}

Response (200 OK)

json
{
  "success": true,
  "message": "Order updated successfully"
}

Update Order Status

PUT /orders/{orderId}/status

Update only the order status with automatic timeline generation.

Parameters

ParameterTypeRequiredDescription
orderIdstringYesUnique order ID

Request

json
{
  "status": "shipped"
}

Response (200 OK)

json
{
  "success": true,
  "message": "Order status updated to shipped"
}

Get Order Timeline

GET /orders/{orderId}/timeline

Retrieve the complete timeline of events for an order.

Parameters

ParameterTypeRequiredDescription
orderIdstringYesUnique order ID

Response (200 OK)

json
[
  {
    "id": "evt_001",
    "title": "Order Confirmed",
    "description": "Customer confirmed the order",
    "type": "success",
    "timestamp": "2023-06-21T14:35:12Z",
    "metadata": {
      "payment_method": "online",
      "amount": 1250.50
    }
  },
  {
    "id": "evt_002", 
    "title": "Payment Received",
    "description": "Payment processed successfully",
    "type": "success",
    "timestamp": "2023-06-21T14:37:45Z",
    "metadata": {
      "transaction_id": "txn_abc123"
    }
  },
  {
    "id": "evt_003",
    "title": "Order Shipped",
    "description": "Order dispatched from warehouse",
    "type": "info",
    "timestamp": "2023-06-22T10:15:30Z",
    "metadata": {
      "tracking_number": "TRK987654321"
    }
  }
]

Add Timeline Event

POST /orders/{orderId}/timeline

Add a custom event to the order timeline.

Parameters

ParameterTypeRequiredDescription
orderIdstringYesUnique order ID

Request

json
{
  "event": {
    "title": "Customer Called",
    "description": "Customer contacted regarding delivery preference",
    "type": "info",
    "metadata": {
      "agent": "John Support",
      "duration": "5 minutes"
    }
  }
}

Event Types

TypeDescriptionColor Indicator
successPositive events (completion)Green
pendingIn-progress eventsYellow
errorIssues or problemsRed
infoInformational eventsBlue

Response (201 Created)

json
{
  "success": true,
  "message": "Timeline event added successfully",
  "eventId": "evt_004"
}

Get Order Statistics

GET /orders/stats

Retrieve comprehensive order analytics and statistics.

Query Parameters

ParameterTypeDescription
periodstringStatistics period (daily, weekly, monthly)

Response (200 OK)

json
{
  "totalOrders": 1250,
  "revenue": 325750.50,
  "averageOrderValue": 260.60,
  "period": {
    "start": "2023-06-01T00:00:00Z",
    "end": "2023-06-30T23:59:59Z"
  }
}

Export Orders

GET /orders/export

Export orders to CSV format with optional filtering.

Query Parameters

ParameterTypeDescription
statusstringFilter by order status
startDatestringFilter by creation date (ISO 8601)
endDatestringFilter by creation date (ISO 8601)
searchTermstringSearch in orders

Response (200 OK)

Returns a CSV file with the following headers:

  • Order ID
  • Reference ID
  • Customer Name
  • Mobile
  • Status
  • Amount
  • Created Date
  • Updated Date
Content-Type: text/csv
Content-Disposition: attachment; filename=orders-2023-06-21.csv

Data Types

Order Object

FieldTypeDescription
_idstringUnique order identifier
referenceIdstringHuman-readable order reference
statusstringCurrent order status
created_atstringOrder creation timestamp (ISO 8601)
updated_atstringLast update timestamp (ISO 8601)
mobilestringCustomer mobile number
namestringCustomer name
emailstringCustomer email
final_amountnumberTotal order amount
delivery_methodstringDelivery method
payment_statusstringPayment status
delivery_detailsobjectDelivery information
product_itemsarrayList of ordered products

Timeline Event Object

FieldTypeDescription
idstringUnique event identifier
titlestringEvent title
descriptionstringEvent description
typestringEvent type (success, pending, error, info)
timestampstringEvent timestamp (ISO 8601)
metadataobjectAdditional event data

Common Order Statuses

StatusDescription
pendingOrder placed, awaiting confirmation
confirmedOrder confirmed by customer
processingOrder being prepared
shippedOrder dispatched
deliveredOrder delivered to customer
completedOrder completed successfully
cancelledOrder cancelled
refundedOrder refunded

Error Handling

The API uses standard HTTP status codes and returns errors in a consistent format:

json
{
  "error": {
    "code": "ErrorType",
    "message": "Human-readable error message",
    "details": {
      // Additional error details, if applicable
    }
  }
}

Common Error Codes

CodeStatusDescription
AuthenticationError401Invalid or missing API key
ValidationError400Invalid request parameters
NotFoundError404Order not found
InternalServerError500Server error

Best Practices

  1. Use pagination: Always implement pagination when fetching order lists to avoid performance issues.

  2. Track order timeline: Use timeline events to maintain a complete audit trail of order progress.

  3. Implement status updates: Regularly update order status to keep customers informed.

  4. Monitor order metrics: Use order statistics to analyze business performance and identify trends.

  5. Handle errors gracefully: Implement proper error handling for all API calls.

  6. Use filtering: Leverage filtering options to efficiently find specific orders.

  7. Export for analysis: Use the export functionality for offline analysis and reporting.

Workflow Examples

Complete Order Lifecycle

  1. Order Creation: Order is created with status pending
  2. Confirmation: Status updated to confirmed
  3. Processing: Status updated to processing
  4. Shipping: Status updated to shipped with tracking details
  5. Delivery: Status updated to delivered
  6. Completion: Status updated to completed

Timeline Management

  • Automatically generated events for status changes
  • Custom events for customer interactions
  • Integration points for external systems
  • Historical audit trail maintenance

Integration Notes

  • Orders are linked to customers through mobile numbers
  • Timeline events support rich metadata for custom integrations
  • Export functionality supports business intelligence tools
  • Status updates can trigger webhook notifications (if configured)
  • Compatible with WhatsApp messaging API for order notifications

Transform WhatsApp into Your Business Growth Engine