Skip to main content

Order Management

Author: Josh S. Sakweli, Backend Lead Team
Last UpdatedUpdated:: 2025-10-1825
VersionVersion:: v1.0

Base URLURL:: https://api.nextgate.com/api/v1

Short Description:

The Order Management API enableshandles usersthe tocomplete manageorder lifecycle for the NextGate e-commerce orders,platform. includingIt retrievingsupports multiple purchase types (direct purchase, cart purchase, installment plans, and group purchases), order details,tracking, cancelingshipping orders, marking orders as shipped, confirming deliveries,management, and regeneratingsecure delivery confirmation codes. It is designed for authenticated buyers and shop owners to interact with order-relatedescrow operations securely.integration.

Hints:

  • Authentication Required: All endpoints require Bearer Tokentoken authentication (Authorization: Bearer your_token).
  • Responses use UTC timestamps in ISO 8601 format (e.g., 2025-10-18T11:32:00Z).
  • Rate limiting:Limiting: 100 requests per minute per user.user
  • EnsureOrder allSources: monetarySupports valuesDIRECT_PURCHASE, CART_PURCHASE, INSTALLMENT, and GROUP_PURCHASE
  • Delivery Confirmation: Uses secure 6-digit codes with SHA-256 hashing and salt
  • Escrow Integration: Automatic escrow hold and release on delivery confirmation
  • Pagination: Default page size is 10, maximum is 50
  • Timezone: All timestamps are in TanzanianISO Shillings8601 format (TZS) unless specified otherwise.UTC)
  • UseCurrency: theAll sandboxamounts environmentare atin https://sandbox.nextgate.com/api/v1TZS for(Tanzanian testing.Shilling) with 2 decimal precision

Standard Response Format

All API responses follow a consistent structure using ourthe Globe Response Builder pattern:

Success Response Structure

{
  "success": true,
  "httpStatus": "OK",
  "message": "Operation completed successfully",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": {
    // Actual response data goes here
  }
}

Error Response Structure

{
  "success": false,
  "httpStatus": "BAD_REQUEST",
  "message": "Error description",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": "Error description"
}

Standard Response Fields

Field Type Description
success boolean Always true for successful operations, false for errors
httpStatus string HTTP status name (OK, BAD_REQUEST, NOT_FOUND, etc.)
message string Human-readable message describing the operation result
action_time string ISO 8601 timestamp of when the response was generated
data object/string Response payload for success, error details for failures

HTTP Method Badge Standards

For better visual clarity, all endpoints use colored badges for HTTP methods:

  • GET - GET - Green (Safe, read-only operations)
  • POST - POST - Blue (Create new resources)
  • PUT - PUT - Yellow (Update/replace entire resource)
  • PATCH - PATCH - Orange (Partial updates)
  • DELETE - DELETE - Red (Remove resources)

Endpoints

1. Get Order by ID

PurposePurpose:: RetrievesRetrieve detailed information about a specific order byusing its unique ID.UUID.

EndpointEndpoint:: GET {base_url}/orders/{orderId}

Access LevelLevel:: 🔒 Protected (Buyer or ShopSeller Owner of the order)only)

AuthenticationAuthentication:: Bearer Token

Request HeadersHeaders::

Header Type Required Description
Authorization string Yes Bearer token for authentication (Bearer your_token)

Path ParametersParameters::

Parameter Type Required Description Validation
orderId UUID Yes Unique identifier of the order Valid UUID format

Success Response JSON SampleSample::

{
  "success": true,
  "httpStatus": "OK",
  "message": "Order retrieved successfully",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": {
    "orderId": "123e4567-e89b-12d3-a456-426614174000"550e8400-e29b-41d4-a716-446655440000",
    "orderNumber": "ORD-2025-12345",
    "buyer": {
      "accountId": "223e4567-123e4567-e89b-12d3-a456-426614174001"426614174000",
      "userName": "john_doe"johndoe",
      "email": "john@example.com",
      "firstName": "John",
      "lastName": "Doe"
    },
    "seller": {
      "shopId": "323e4567-e89b-12d3-a456-426614174002"789e0123-e45b-67d8-a901-234567890abc",
      "shopName": "Example Shop"TechStore",
      "shopLogo": "https://example.cdn.nextgate.com/logo.shops/techstore.png",
      "shopSlug": "example-shop"techstore"
    },
    "orderStatus": "SHIPPED",
    "deliveryStatus": "IN_TRANSIT",
    "orderSource": "DIRECT_PURCHASE",
    "items": [
      {
        "orderItemId": "423e4567-e89b-12d3-a456-426614174003"111e2222-e33b-44d5-a666-777788889999",
        "productId": "523e4567-e89b-12d3-a456-426614174004"abc12345-def6-7890-ghij-klmnopqrstuv",
        "productName": "SampleWireless Product"Headphones",
        "productSlug": "sample-product"wireless-headphones",
        "productImage": "https://example.cdn.nextgate.com/product.products/headphones.jpg",
        "quantity": 2,
        "unitPrice": "5000.00",85000.00,
        "subtotal": "10000.00",170000.00,
        "tax": "1800.00",0.00,
        "total": "11800.00"170000.00
      }
    ],
    "subtotal": "10000.00",170000.00,
    "shippingFee": "500.00",5000.00,
    "tax": "1800.00",0.00,
    "totalAmount": "12300.00",175000.00,
    "platformFee": "300.00",8750.00,
    "sellerAmount": "12000.00",166250.00,
    "currency": "TZS",
    "paymentMethod": "CARD"MPESA",
    "amountPaid": "12300.00",175000.00,
    "amountRemaining": "0.00",00,
    "deliveryAddress": "123 Main St, Dar es Salaam"Salaam, Tanzania",
    "trackingNumber": "TRK123456789"TRACK-550E8400",
    "carrier": "DHL"NextGate Shipping",
    "isDeliveryConfirmed": false,
    "deliveryConfirmedAt": null,
    "orderedAt": "2025-10-17T10:00:00Z"20T14:30:00",
    "shippedAt": "2025-10-17T15:00:00Z"21T09:15:00",
    "deliveredAt": null,
    "cancelledAt": null,
    "cancellationReason": null
  }
}

Success Response FieldsFields::

Field Description
orderId Unique identifier of the order
orderNumber UniqueHuman-readable order number (e.g.,format: ORD-2025-12345)YYYY-XXXXX)
buyer DetailsObject of thecontaining buyer (accountId,account userName, email, firstName, lastName)information
seller DetailsObject ofcontaining the shop/seller (shopId, shopName, shopLogo, shopSlug)information
orderStatus Current status of the order (e.g.,PENDING_PAYMENT, PENDING_SHIPMENT, SHIPPED)SHIPPED, DELIVERED, COMPLETED, CANCELLED, REFUNDED)
deliveryStatus Delivery tracking status (e.g., PENDING, IN_TRANSIT)SHIPPED, IN_TRANSIT, DELIVERED, CONFIRMED)
orderSource SourcePurchase of the ordertype (e.g., DIRECT_PURCHASE, INSTALLMENT)CART_PURCHASE, INSTALLMENT, GROUP_PURCHASE)
items ListArray of order items with product details
subtotal Total costSum of itemsall item totals before taxshipping and shippingtax
shippingFee CostShipping of shippingcost
tax Tax amount
totalAmount Total orderFinal amount including(subtotal tax and+ shipping + tax)
platformFee Platform feecommission charged(5% of total)
sellerAmount Amount payableseller toreceives theafter sellerplatform fee
currency Currency of the transactioncode (e.g., TZS)
paymentMethodisDeliveryConfirmed Payment method used (e.g., CARD)
amountPaidAmount paid by theWhether buyer
amountRemainingRemaining amount to be paid
deliveryAddressAddress forconfirmed delivery
trackingNumber TrackingShipping tracking number for shipment
carrierorderedAt ShippingOrder carriercreation (e.g., DHL)timestamp
isDeliveryConfirmedshippedAt WhetherShipping delivery is confirmed by the buyertimestamp
deliveryConfirmedAtdeliveredAt TimestampDelivery of delivery confirmation
orderedAtTimestamp when order was placed
shippedAtTimestamp when order was shipped
deliveredAtTimestamp when order was delivered
cancelledAtTimestamp when order was cancelled
cancellationReasonReason for cancellation, if applicabletimestamp

Error Response JSON SampleSample::

{
  "success": false,
  "httpStatus": "NOT_FOUND",
  "message": "Order not found"found: 550e8400-e29b-41d4-a716-446655440000",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": "Order not found"found: 550e8400-e29b-41d4-a716-446655440000"
}

Standard Error TypesTypes::

  • 400 BAD_REQUEST:BAD_REQUEST: InvalidAccess denied - user is not buyer or seller of this order ID format
  • 401 UNAUTHORIZED:UNAUTHORIZED: InvalidMissing or expiredinvalid authentication token
  • 403 FORBIDDEN: User is not the buyer or shop owner
  • 404 NOT_FOUND:NOT_FOUND: Order does not exist

2. Get Order by Order Number

PurposePurpose:: Retrieves detailed information about a specificRetrieve order bydetails itsusing the human-readable order number.

EndpointEndpoint:: GET {base_url}/orders/number/{orderNumber}

Access LevelLevel:: 🔒 Protected (Buyer or ShopSeller Owner of the order)only)

AuthenticationAuthentication:: Bearer Token

Request HeadersHeaders::

Header Type Required Description
Authorization string Yes Bearer token for authentication (Bearer your_token)

Path ParametersParameters::

Parameter Type Required Description Validation
orderNumber string Yes UniqueHuman-readable order number (e.g., ORD-2025-12345) Max 50 characters, formatFormat: ORD-YYYY-NNNNNXXXXX

Success Response JSON SampleSample::

{
  "success": true,
  "httpStatus": "OK",
  "message": "Order retrieved successfully",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": {
    "orderId": "123e4567-e89b-12d3-a456-426614174000"550e8400-e29b-41d4-a716-446655440000",
    "orderNumber": "ORD-2025-12345",
    "buyer": {
      "accountId": "223e4567-123e4567-e89b-12d3-a456-426614174001"426614174000",
      "userName": "john_doe"johndoe",
      "email": "john@example.com",
      "firstName": "John",
      "lastName": "Doe"
    },
    "seller": {
      "shopId": "323e4567-e89b-12d3-a456-426614174002"789e0123-e45b-67d8-a901-234567890abc",
      "shopName": "Example Shop"TechStore",
      "shopLogo": "https://example.cdn.nextgate.com/logo.shops/techstore.png",
      "shopSlug": "example-shop"techstore"
    },
    "orderStatus": "PENDING_SHIPMENT",
    "deliveryStatus": "PENDING",
    "orderSource": "CART_PURCHASE",
    "items": [
      {
        "orderItemId": "111e2222-e33b-44d5-a666-777788889999",
        "productId": "abc12345-def6-7890-ghij-klmnopqrstuv",
        "productName": "Smart Watch",
        "productSlug": "smart-watch",
        "productImage": "https://cdn.nextgate.com/products/watch.jpg",
        "quantity": 1,
        "unitPrice": 250000.00,
        "subtotal": 250000.00,
        "tax": 0.00,
        "total": 250000.00
      }
    ],
    "subtotal": 250000.00,
    "shippingFee": 8000.00,
    "tax": 0.00,
    "totalAmount": 258000.00,
    "platformFee": 12900.00,
    "sellerAmount": 245100.00,
    "currency": "TZS",
    "paymentMethod": "TIGOPESA",
    "amountPaid": 258000.00,
    "amountRemaining": 0.00,
    "deliveryAddress": "456 Commerce Road, Arusha, Tanzania",
    "trackingNumber": null,
    "carrier": null,
    "isDeliveryConfirmed": false,
    "deliveryConfirmedAt": null,
    "orderedAt": "2025-10-25T08:20:00",
    "shippedAt": null,
    "deliveredAt": null,
    "cancelledAt": null,
    "cancellationReason": null
  }
}

Success Response Fields:

FieldDescription
Same as Get Order by IDAll fields identical to endpoint #1

Error Response JSON Sample:

{
  "success": false,
  "httpStatus": "NOT_FOUND",
  "message": "Order not found: ORD-2025-12345",
  "action_time": "2025-10-25T10:30:45",
  "data": "Order not found: ORD-2025-12345"
}

Standard Error Types:

  • 400 BAD_REQUEST: Access denied - user is not buyer or seller of this order
  • 401 UNAUTHORIZED: Missing or invalid authentication token
  • 404 NOT_FOUND: Order with specified order number does not exist

3. Get My Orders (Customer)

Purpose: Retrieve all orders for the authenticated customer.

Endpoint: GET {base_url}/orders/my-orders

Access Level: ðŸ”’ Protected (Customer only)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Success Response JSON Sample:

{
  "success": true,
  "httpStatus": "OK",
  "message": "Orders retrieved successfully",
  "action_time": "2025-10-25T10:30:45",
  "data": [
    {
      "orderId": "550e8400-e29b-41d4-a716-446655440000",
      "orderNumber": "ORD-2025-12345",
      "buyer": {
        "accountId": "123e4567-e89b-12d3-a456-426614174000",
        "userName": "johndoe",
        "email": "john@example.com",
        "firstName": "John",
        "lastName": "Doe"
      },
      "seller": {
        "shopId": "789e0123-e45b-67d8-a901-234567890abc",
        "shopName": "TechStore",
        "shopLogo": "https://cdn.nextgate.com/shops/techstore.png",
        "shopSlug": "techstore"
      },
      "orderStatus": "SHIPPED",
      "deliveryStatus": "IN_TRANSIT",
      "orderSource": "DIRECT_PURCHASE",
      "items": [
        {
          "orderItemId": "423e4567-e89b-12d3-a456-426614174003"111e2222-e33b-44d5-a666-777788889999",
          "productId": "523e4567-e89b-12d3-a456-426614174004"abc12345-def6-7890-ghij-klmnopqrstuv",
          "productName": "SampleWireless Product"Headphones",
          "productSlug": "sample-product"wireless-headphones",
          "productImage": "https://example.cdn.nextgate.com/product.products/headphones.jpg",
          "quantity": 2,
          "unitPrice": "5000.00",85000.00,
          "subtotal": "10000.00",170000.00,
          "tax": "1800.00",0.00,
          "total": "11800.00"170000.00
        }
      ],
      "subtotal": "10000.00",170000.00,
      "shippingFee": "500.00",5000.00,
      "tax": "1800.00",0.00,
      "totalAmount": "12300.00",175000.00,
      "platformFee": "300.00",8750.00,
      "sellerAmount": "12000.00",166250.00,
      "currency": "TZS",
      "paymentMethod": "CARD"MPESA",
      "amountPaid": "12300.00",175000.00,
      "amountRemaining": "0.00",00,
      "deliveryAddress": "123 Main St, Dar es Salaam"Salaam, Tanzania",
      "trackingNumber": "TRK123456789"TRACK-550E8400",
      "carrier": "DHL"NextGate Shipping",
      "isDeliveryConfirmed": false,
      "deliveryConfirmedAt": null,
      "orderedAt": "2025-10-17T10:00:00Z"20T14:30:00",
      "shippedAt": "2025-10-17T15:00:00Z"21T09:15:00",
      "deliveredAt": null,
      "cancelledAt": null,
      "cancellationReason": null
    }
  ]
}

Success Response FieldsFields::

Field Description
orderIddata Unique identifier of the order
orderNumberUnique order number (e.g., ORD-2025-12345)
buyerDetails of the buyer (accountId, userName, email, firstName, lastName)
sellerDetails of the seller (shopId, shopName, shopLogo, shopSlug)
orderStatusCurrent status of the order (e.g., PENDING_SHIPMENT, SHIPPED)
deliveryStatusDelivery status (e.g., PENDING, IN_TRANSIT)
orderSourceSource of the order (e.g., DIRECT_PURCHASE, INSTALLMENT)
itemsListArray of order itemsobjects, with product details
subtotalTotal cost of items before tax and shipping
shippingFeeCost of shipping
taxTax amount
totalAmountTotal order amount including tax and shipping
platformFeePlatform fee charged
sellerAmountAmount payable to the seller
currencyCurrency of the transaction (e.g., TZS)
paymentMethodPayment method used (e.g., CARD)
amountPaidAmount paidordered by theorderedAt buyer
amountRemainingRemaining amount to be paid
deliveryAddressAddress for delivery
trackingNumberTracking number for shipment
carrierShipping carrierdescending (e.g.,newest DHL)
isDeliveryConfirmedWhether delivery is confirmed by the buyer
deliveryConfirmedAtTimestamp of delivery confirmation
orderedAtTimestamp when order was placed
shippedAtTimestamp when order was shipped
deliveredAtTimestamp when order was delivered
cancelledAtTimestamp when order was cancelled
cancellationReasonReason for cancellation, if applicablefirst)

Error Response JSON SampleSample::

{
  "success": false,
  "httpStatus": "NOT_FOUND"UNAUTHORIZED",
  "message": "OrderUser not found"authenticated",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": "OrderUser not found"authenticated"
}

Standard Error TypesTypes::

  • 400 BAD_REQUEST: Invalid order number format
  • 401 UNAUTHORIZED:UNAUTHORIZED: InvalidMissing or expiredinvalid authentication token
  • 403404 FORBIDDEN:NOT_FOUND: User isaccount not the buyer or shop owner
  • 404 NOT_FOUND: Order does not existfound

3.

4. Get My Orders

 by Status (Customer)

PurposePurpose:: RetrievesRetrieve a list ofcustomer orders placedfiltered by thespecific authenticatedorder buyer.status.

EndpointEndpoint:: GET {base_url}/orders/my-ordersorders/status/{status}

Access LevelLevel:: 🔒 Protected (BuyerCustomer only)

AuthenticationAuthentication:: Bearer Token

Request HeadersHeaders::

(Beareryour_token)
Header Type Required Description
Authorization string Yes Bearer token for authentication

Path Parameters:

ParameterTypeRequiredDescriptionValidation
statusenumYesOrder status to filter byMust be: PENDING_PAYMENT, PENDING_SHIPMENT, SHIPPED, DELIVERED, COMPLETED, CANCELLED, or REFUNDED

Success Response JSON SampleSample::

{
  "success": true,
  "httpStatus": "OK",
  "message": "Orders retrieved successfully",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": [
    {
      "orderId": "123e4567-e89b-12d3-a456-426614174000"550e8400-e29b-41d4-a716-446655440000",
      "orderNumber": "ORD-2025-12345",
      "buyer": {
        "accountId": "223e4567-123e4567-e89b-12d3-a456-426614174001"426614174000",
        "userName": "john_doe"johndoe",
        "email": "john@example.com",
        "firstName": "John",
        "lastName": "Doe"
      },
      "seller": {
        "shopId": "323e4567-e89b-12d3-a456-426614174002"789e0123-e45b-67d8-a901-234567890abc",
        "shopName": "Example Shop"TechStore",
        "shopLogo": "https://example.cdn.nextgate.com/logo.shops/techstore.png",
        "shopSlug": "example-shop"techstore"
      },
      "orderStatus": "SHIPPED",
      "deliveryStatus": "IN_TRANSIT",
      "orderSource": "DIRECT_PURCHASE"CART_PURCHASE",
      "items": [
        {
          "orderItemId": "423e4567-e89b-12d3-a456-426614174003"111e2222-e33b-44d5-a666-777788889999",
          "productId": "523e4567-e89b-12d3-a456-426614174004"abc12345-def6-7890-ghij-klmnopqrstuv",
          "productName": "SampleLaptop Product"Bag",
          "productSlug": "sample-product"laptop-bag",
          "productImage": "https://example.cdn.nextgate.com/product.products/bag.jpg",
          "quantity": 2,1,
          "unitPrice": "5000.00",45000.00,
          "subtotal": "10000.00",45000.00,
          "tax": "1800.00",0.00,
          "total": "11800.00"45000.00
        }
      ],
      "subtotal": "10000.00",45000.00,
      "shippingFee": "500.00",3000.00,
      "tax": "1800.00",0.00,
      "totalAmount": "12300.00",48000.00,
      "platformFee": "300.00",2400.00,
      "sellerAmount": "12000.00",45600.00,
      "currency": "TZS",
      "paymentMethod": "CARD"AIRTEL_MONEY",
      "amountPaid": "12300.00",48000.00,
      "amountRemaining": "0.00",00,
      "deliveryAddress": "123789 MainBusiness St,Ave, DarMwanza, es Salaam"Tanzania",
      "trackingNumber": "TRK123456789"TRACK-550E8401",
      "carrier": "DHL"NextGate Shipping",
      "isDeliveryConfirmed": false,
      "deliveryConfirmedAt": null,
      "orderedAt": "2025-10-17T10:00:00Z"24T11:45:00",
      "shippedAt": "2025-10-17T15:00:00Z"25T07:30:00",
      "deliveredAt": null,
      "cancelledAt": null,
      "cancellationReason": null
    }
  ]
}

Success Response FieldsFields::

Field Description
data Array of orders,order eachobjects containingwith thematching samestatus, fields as the Get Orderordered by IDorderedAt responsedescending

Error Response JSON SampleSample::

{
  "success": false,
  "httpStatus": "NOT_FOUND"BAD_REQUEST",
  "message": "NoInvalid ordersorder foundstatus: for user"INVALID_STATUS",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": "NoInvalid ordersorder foundstatus: for user"INVALID_STATUS"
}

Standard Error TypesTypes::

  • 401400 UNAUTHORIZED:BAD_REQUEST: Invalid status value provided
  • 401 UNAUTHORIZED: Missing or expiredinvalid authentication token
  • 404 NOT_FOUND:NOT_FOUND: NoUser ordersaccount not found for the authenticated user

4.

5. Get ShopMy Orders

 with Pagination (Customer)

PurposePurpose:: RetrievesRetrieve a list ofcustomer orders with pagination support for abetter specific shop, accessible only by the shop owner.performance.

EndpointEndpoint:: GET {base_url}/orders/shop/{shopId}/ordersmy-orders/paged

Access LevelLevel:: 🔒 Protected (Shop OwnerCustomer only)

AuthenticationAuthentication:: Bearer Token

Request HeadersHeaders::

Header Type Required Description
Authorization string Yes Bearer token for authentication

Query Parameters:

ParameterTypeRequiredDescriptionValidationDefault
pageintegerNoPage number (1-based)Must be >= 11
sizeintegerNoNumber of items per pageMust be > 0, max 5010

Success Response JSON Sample:

{
  "success": true,
  "httpStatus": "OK",
  "message": "Orders retrieved successfully",
  "action_time": "2025-10-25T10:30:45",
  "data": {
    "orders": [
      {
        "orderId": "550e8400-e29b-41d4-a716-446655440000",
        "orderNumber": "ORD-2025-12345",
        "buyer": {
          "accountId": "123e4567-e89b-12d3-a456-426614174000",
          "userName": "johndoe",
          "email": "john@example.com",
          "firstName": "John",
          "lastName": "Doe"
        },
        "seller": {
          "shopId": "789e0123-e45b-67d8-a901-234567890abc",
          "shopName": "TechStore",
          "shopLogo": "https://cdn.nextgate.com/shops/techstore.png",
          "shopSlug": "techstore"
        },
        "orderStatus": "COMPLETED",
        "deliveryStatus": "CONFIRMED",
        "orderSource": "DIRECT_PURCHASE",
        "items": [
          {
            "orderItemId": "111e2222-e33b-44d5-a666-777788889999",
            "productId": "abc12345-def6-7890-ghij-klmnopqrstuv",
            "productName": "USB Cable",
            "productSlug": "usb-cable",
            "productImage": "https://cdn.nextgate.com/products/cable.jpg",
            "quantity": 3,
            "unitPrice": 5000.00,
            "subtotal": 15000.00,
            "tax": 0.00,
            "total": 15000.00
          }
        ],
        "subtotal": 15000.00,
        "shippingFee": 2000.00,
        "tax": 0.00,
        "totalAmount": 17000.00,
        "platformFee": 850.00,
        "sellerAmount": 16150.00,
        "currency": "TZS",
        "paymentMethod": "MPESA",
        "amountPaid": 17000.00,
        "amountRemaining": 0.00,
        "deliveryAddress": "321 Tech Road, Dodoma, Tanzania",
        "trackingNumber": "TRACK-550E8402",
        "carrier": "NextGate Shipping",
        "isDeliveryConfirmed": true,
        "deliveryConfirmedAt": "2025-10-23T16:20:00",
        "orderedAt": "2025-10-20T10:15:00",
        "shippedAt": "2025-10-21T08:00:00",
        "deliveredAt": "2025-10-23T16:20:00",
        "cancelledAt": null,
        "cancellationReason": null
      }
    ],
    "currentPage": 1,
    "pageSize": 10,
    "totalElements": 25,
    "totalPages": 3,
    "hasNext": true,
    "hasPrevious": false,
    "isFirst": true,
    "isLast": false
  }
}

Success Response Fields:

FieldDescription
ordersArray of order objects for current page
currentPageCurrent page number (1-based)
pageSizeNumber of items per page
totalElementsTotal number of orders across all pages
totalPagesTotal number of pages available
hasNextWhether there is a next page
hasPreviousWhether there is a previous page
isFirstWhether this is the first page
isLastWhether this is the last page

Error Response JSON Sample:

{
  "success": false,
  "httpStatus": "BAD_REQUEST",
  "message": "Invalid pagination parameters",
  "action_time": "2025-10-25T10:30:45",
  "data": "Page must be >= 1 and size must be > 0"
}

Standard Error Types:

  • 400 BAD_REQUEST: Invalid page or size parameters
  • 401 UNAUTHORIZED: Missing or invalid authentication token
  • 404 NOT_FOUND: User account not found

6. Get My Orders by Status with Pagination (Customer)

Purpose: Retrieve customer orders filtered by status with pagination support.

Endpoint: GET {base_url}/orders/my-orders/status/{status}/paged

Access Level: ðŸ”’ Protected (Customer only)

Authentication: Bearer your_token)Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path ParametersParameters::

Parameter Type Required Description Validation
statusenumYesOrder status to filter byMust be: PENDING_PAYMENT, PENDING_SHIPMENT, SHIPPED, DELIVERED, COMPLETED, CANCELLED, or REFUNDED

Query Parameters:

ParameterTypeRequiredDescriptionValidationDefault
pageintegerNoPage number (1-based)Must be >= 11
sizeintegerNoNumber of items per pageMust be > 0, max 5010

Success Response JSON Sample:

{
  "success": true,
  "httpStatus": "OK",
  "message": "Orders retrieved successfully",
  "action_time": "2025-10-25T10:30:45",
  "data": {
    "orders": [
      {
        "orderId": "550e8400-e29b-41d4-a716-446655440000",
        "orderNumber": "ORD-2025-12345",
        "buyer": {
          "accountId": "123e4567-e89b-12d3-a456-426614174000",
          "userName": "johndoe",
          "email": "john@example.com",
          "firstName": "John",
          "lastName": "Doe"
        },
        "seller": {
          "shopId": "789e0123-e45b-67d8-a901-234567890abc",
          "shopName": "TechStore",
          "shopLogo": "https://cdn.nextgate.com/shops/techstore.png",
          "shopSlug": "techstore"
        },
        "orderStatus": "SHIPPED",
        "deliveryStatus": "IN_TRANSIT",
        "orderSource": "INSTALLMENT",
        "items": [
          {
            "orderItemId": "111e2222-e33b-44d5-a666-777788889999",
            "productId": "abc12345-def6-7890-ghij-klmnopqrstuv",
            "productName": "Gaming Console",
            "productSlug": "gaming-console",
            "productImage": "https://cdn.nextgate.com/products/console.jpg",
            "quantity": 1,
            "unitPrice": 500000.00,
            "subtotal": 500000.00,
            "tax": 0.00,
            "total": 500000.00
          }
        ],
        "subtotal": 500000.00,
        "shippingFee": 10000.00,
        "tax": 0.00,
        "totalAmount": 510000.00,
        "platformFee": 25500.00,
        "sellerAmount": 484500.00,
        "currency": "TZS",
        "paymentMethod": "MPESA",
        "amountPaid": 153000.00,
        "amountRemaining": 357000.00,
        "deliveryAddress": "555 Gaming Street, Dar es Salaam, Tanzania",
        "trackingNumber": "TRACK-550E8403",
        "carrier": "NextGate Shipping",
        "isDeliveryConfirmed": false,
        "deliveryConfirmedAt": null,
        "orderedAt": "2025-10-23T13:00:00",
        "shippedAt": "2025-10-24T10:30:00",
        "deliveredAt": null,
        "cancelledAt": null,
        "cancellationReason": null
      }
    ],
    "currentPage": 1,
    "pageSize": 10,
    "totalElements": 8,
    "totalPages": 1,
    "hasNext": false,
    "hasPrevious": false,
    "isFirst": true,
    "isLast": true
  }
}

Success Response Fields:

FieldDescription
ordersArray of order objects matching status for current page
currentPageCurrent page number (1-based)
pageSizeNumber of items per page
totalElementsTotal number of matching orders across all pages
totalPagesTotal number of pages available
hasNextWhether there is a next page
hasPreviousWhether there is a previous page
isFirstWhether this is the first page
isLastWhether this is the last page

Error Response JSON Sample:

{
  "success": false,
  "httpStatus": "BAD_REQUEST",
  "message": "Invalid order status: INVALID_STATUS",
  "action_time": "2025-10-25T10:30:45",
  "data": "Invalid order status: INVALID_STATUS"
}

Standard Error Types:

  • 400 BAD_REQUEST: Invalid status value or pagination parameters
  • 401 UNAUTHORIZED: Missing or invalid authentication token
  • 404 NOT_FOUND: User account not found

7. Get Shop Orders (Non-Paginated)

Purpose: Retrieve all orders for a specific shop (shop owner only).

Endpoint: GET {base_url}/orders/shop/{shopId}/orders

Access Level: ðŸ”’ Protected (Shop Owner only)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

ParameterTypeRequiredDescriptionValidation
shopId UUID Yes Unique identifier of the shop Valid UUID format

Success Response JSON SampleSample::

{
  "success": true,
  "httpStatus": "OK",
  "message": "Shop ordersOrders retrieved successfully",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": [
    {
      "orderId": "123e4567-e89b-12d3-a456-426614174000"550e8400-e29b-41d4-a716-446655440000",
      "orderNumber": "ORD-2025-12345",
      "buyer": {
        "accountId": "223e4567-123e4567-e89b-12d3-a456-426614174001"426614174000",
        "userName": "john_doe"johndoe",
        "email": "john@example.com",
        "firstName": "John",
        "lastName": "Doe"
      },
      "seller": {
        "shopId": "323e4567-e89b-12d3-a456-426614174002"789e0123-e45b-67d8-a901-234567890abc",
        "shopName": "Example Shop"TechStore",
        "shopLogo": "https://example.cdn.nextgate.com/logo.shops/techstore.png",
        "shopSlug": "example-shop"techstore"
      },
      "orderStatus": "SHIPPED"PENDING_SHIPMENT",
      "deliveryStatus": "IN_TRANSIT"PENDING",
      "orderSource": "DIRECT_PURCHASE",
      "items": [
        {
          "orderItemId": "423e4567-e89b-12d3-a456-426614174003"111e2222-e33b-44d5-a666-777788889999",
          "productId": "523e4567-e89b-12d3-a456-426614174004"abc12345-def6-7890-ghij-klmnopqrstuv",
          "productName": "Sample Product"Keyboard",
          "productSlug": "sample-product"keyboard",
          "productImage": "https://example.cdn.nextgate.com/product.products/keyboard.jpg",
          "quantity": 2,1,
          "unitPrice": "5000.00",75000.00,
          "subtotal": "10000.00",75000.00,
          "tax": "1800.00",0.00,
          "total": "11800.00"75000.00
        }
      ],
      "subtotal": "10000.00",75000.00,
      "shippingFee": "500.00",4000.00,
      "tax": "1800.00",0.00,
      "totalAmount": "12300.00",79000.00,
      "platformFee": "300.00",3950.00,
      "sellerAmount": "12000.00",75050.00,
      "currency": "TZS",
      "paymentMethod": "CARD"TIGOPESA",
      "amountPaid": "12300.00",79000.00,
      "amountRemaining": "0.00",00,
      "deliveryAddress": "123 MainOffice St,Complex, DarMorogoro, es Salaam"Tanzania",
      "trackingNumber": "TRK123456789",null,
      "carrier": "DHL",null,
      "isDeliveryConfirmed": false,
      "deliveryConfirmedAt": null,
      "orderedAt": "2025-10-17T10:25T09:00:00Z"00",
      "shippedAt": "2025-10-17T15:00:00Z",null,
      "deliveredAt": null,
      "cancelledAt": null,
      "cancellationReason": null
    }
  ]
}

Success Response FieldsFields::

Field Description
data Array of orders,all eachorder containingobjects for the sameshop, fields as the Get Orderordered by IDorderedAt responsedescending

Error Response JSON SampleSample::

{
  "success": false,
  "httpStatus": "FORBIDDEN"BAD_REQUEST",
  "message": "Access denied. You are not the owner of this shop",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": "Access denied. You are not the owner of this shop"
}

Standard Error TypesTypes::

  • 400 BAD_REQUEST: Invalid shop ID format
  • 401 UNAUTHORIZED: Invalid or expired token
  • 403 FORBIDDEN:BAD_REQUEST: User is not the owner of the specified shop owner
  • 401 UNAUTHORIZED: Missing or invalid authentication token
  • 404 NOT_FOUND:NOT_FOUND: Shop does not existfound or nohas ordersbeen founddeleted

5.

8. Get Shop Orders by Status

 (Non-Paginated)

PurposePurpose:: RetrievesRetrieve a list ofshop orders for a specific shop filtered by specific order status, accessible only by the shop owner.status.

EndpointEndpoint:: GET {base_url}/orders/shop/{shopId}/orders/status/{status}

Access LevelLevel:: 🔒 Protected (Shop Owner only)

AuthenticationAuthentication:: Bearer Token

Request HeadersHeaders::

Header Type Required Description
Authorization string Yes Bearer token for authentication (Bearer your_token)

Path ParametersParameters::

Parameter Type Required Description Validation
shopId UUID Yes Unique identifier of the shop Valid UUID format
status stringenum Yes Order status to filter by Enum:Must be: PENDING_PAYMENT, PENDING_SHIPMENT, SHIPPED, DELIVERED, COMPLETED, CANCELLED, or REFUNDED

Success Response JSON SampleSample::

{
  "success": true,
  "httpStatus": "OK",
  "message": "Shop ordersOrders retrieved successfully",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": [
    {
      "orderId": "123e4567-e89b-12d3-a456-426614174000"550e8400-e29b-41d4-a716-446655440000",
      "orderNumber": "ORD-2025-12345",
      "buyer": {
        "accountId": "223e4567-123e4567-e89b-12d3-a456-426614174001"426614174000",
        "userName": "john_doe"johndoe",
        "email": "john@example.com",
        "firstName": "John",
        "lastName": "Doe"
      },
      "seller": {
        "shopId": "323e4567-e89b-12d3-a456-426614174002"789e0123-e45b-67d8-a901-234567890abc",
        "shopName": "Example Shop"TechStore",
        "shopLogo": "https://example.cdn.nextgate.com/logo.shops/techstore.png",
        "shopSlug": "example-shop"techstore"
      },
      "orderStatus": "SHIPPED"PENDING_SHIPMENT",
      "deliveryStatus": "IN_TRANSIT"PENDING",
      "orderSource": "DIRECT_PURCHASE"GROUP_PURCHASE",
      "items": [
        {
          "orderItemId": "423e4567-e89b-12d3-a456-426614174003"111e2222-e33b-44d5-a666-777788889999",
          "productId": "523e4567-e89b-12d3-a456-426614174004"abc12345-def6-7890-ghij-klmnopqrstuv",
          "productName": "SamplePhone Product"Case",
          "productSlug": "sample-product"phone-case",
          "productImage": "https://example.cdn.nextgate.com/product.products/case.jpg",
          "quantity": 2,1,
          "unitPrice": "5000.00",12000.00,
          "subtotal": "10000.00",12000.00,
          "tax": "1800.00",0.00,
          "total": "11800.00"12000.00
        }
      ],
      "subtotal": "10000.00",12000.00,
      "shippingFee": "500.00",2000.00,
      "tax": "1800.00",0.00,
      "totalAmount": "12300.00",14000.00,
      "platformFee": "300.00",700.00,
      "sellerAmount": "12000.00",13300.00,
      "currency": "TZS",
      "paymentMethod": "CARD"MPESA",
      "amountPaid": "12300.00",14000.00,
      "amountRemaining": "0.00",00,
      "deliveryAddress": "123999 MainGroup St,Buy DarLane, esMbeya, Salaam"Tanzania",
      "trackingNumber": "TRK123456789",null,
      "carrier": "DHL",null,
      "isDeliveryConfirmed": false,
      "deliveryConfirmedAt": null,
      "orderedAt": "2025-10-17T10:00:00Z"25T08:45:00",
      "shippedAt": "2025-10-17T15:00:00Z",null,
      "deliveredAt": null,
      "cancelledAt": null,
      "cancellationReason": null
    }
  ]
}

Success Response FieldsFields::

Field Description
data Array of orders,order eachobjects containingmatching status for the sameshop, fields as the Get Orderordered by IDorderedAt responsedescending

Error Response JSON SampleSample::

{
  "success": false,
  "httpStatus": "FORBIDDEN"BAD_REQUEST",
  "message": "Invalid order status: INVALID_STATUS",
  "action_time": "2025-10-25T10:30:45",
  "data": "Invalid order status: INVALID_STATUS"
}

Standard Error Types:

  • 400 BAD_REQUEST: Invalid status value or user is not shop owner
  • 401 UNAUTHORIZED: Missing or invalid authentication token
  • 404 NOT_FOUND: Shop not found or has been deleted

9. Get Shop Orders with Pagination

Purpose: Retrieve shop orders with pagination support for better performance.

Endpoint: GET {base_url}/orders/shop/{shopId}/orders/paged

Access Level: ðŸ”’ Protected (Shop Owner only)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

ParameterTypeRequiredDescriptionValidation
shopIdUUIDYesUnique identifier of the shopValid UUID format

Query Parameters:

ParameterTypeRequiredDescriptionValidationDefault
pageintegerNoPage number (1-based)Must be >= 11
sizeintegerNoNumber of items per pageMust be > 0, max 5010

Success Response JSON Sample:

{
  "success": true,
  "httpStatus": "OK",
  "message": "Orders retrieved successfully",
  "action_time": "2025-10-25T10:30:45",
  "data": {
    "orders": [
      {
        "orderId": "550e8400-e29b-41d4-a716-446655440000",
        "orderNumber": "ORD-2025-12345",
        "buyer": {
          "accountId": "123e4567-e89b-12d3-a456-426614174000",
          "userName": "johndoe",
          "email": "john@example.com",
          "firstName": "John",
          "lastName": "Doe"
        },
        "seller": {
          "shopId": "789e0123-e45b-67d8-a901-234567890abc",
          "shopName": "TechStore",
          "shopLogo": "https://cdn.nextgate.com/shops/techstore.png",
          "shopSlug": "techstore"
        },
        "orderStatus": "SHIPPED",
        "deliveryStatus": "IN_TRANSIT",
        "orderSource": "CART_PURCHASE",
        "items": [
          {
            "orderItemId": "111e2222-e33b-44d5-a666-777788889999",
            "productId": "abc12345-def6-7890-ghij-klmnopqrstuv",
            "productName": "Monitor",
            "productSlug": "monitor",
            "productImage": "https://cdn.nextgate.com/products/monitor.jpg",
            "quantity": 1,
            "unitPrice": 350000.00,
            "subtotal": 350000.00,
            "tax": 0.00,
            "total": 350000.00
          }
        ],
        "subtotal": 350000.00,
        "shippingFee": 15000.00,
        "tax": 0.00,
        "totalAmount": 365000.00,
        "platformFee": 18250.00,
        "sellerAmount": 346750.00,
        "currency": "TZS",
        "paymentMethod": "MPESA",
        "amountPaid": 365000.00,
        "amountRemaining": 0.00,
        "deliveryAddress": "777 Tech Hub, Dar es Salaam, Tanzania",
        "trackingNumber": "TRACK-550E8404",
        "carrier": "NextGate Shipping",
        "isDeliveryConfirmed": false,
        "deliveryConfirmedAt": null,
        "orderedAt": "2025-10-24T15:20:00",
        "shippedAt": "2025-10-25T09:00:00",
        "deliveredAt": null,
        "cancelledAt": null,
        "cancellationReason": null
      }
    ],
    "currentPage": 1,
    "pageSize": 10,
    "totalElements": 42,
    "totalPages": 5,
    "hasNext": true,
    "hasPrevious": false,
    "isFirst": true,
    "isLast": false
  }
}

Success Response Fields:

FieldDescription
ordersArray of order objects for current page
currentPageCurrent page number (1-based)
pageSizeNumber of items per page
totalElementsTotal number of shop orders across all pages
totalPagesTotal number of pages available
hasNextWhether there is a next page
hasPreviousWhether there is a previous page
isFirstWhether this is the first page
isLastWhether this is the last page

Error Response JSON Sample:

{
  "success": false,
  "httpStatus": "BAD_REQUEST",
  "message": "Access denied. You are not the owner of this shop",
  "action_time": "2025-10-18T11:32:00Z"25T10:30:45",
  "data": "Access denied. You are not the owner of this shop"
}

Standard Error TypesTypes::

  • 400 BAD_REQUEST:BAD_REQUEST: Invalid shoppagination IDparameters or statususer formatis not shop owner
  • 401 UNAUTHORIZED:UNAUTHORIZED: InvalidMissing or expiredinvalid authentication token
  • 404 NOT_FOUND: Shop not found or has been deleted

10. Get Shop Orders by Status with Pagination

Purpose: Retrieve shop orders filtered by status with pagination support.

Endpoint: GET 403{base_url}/orders/shop/{shopId}/orders/status/{status}/paged

FORBIDDEN

Access Level: ðŸ”’ Protected (Shop Owner only)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

ParameterTypeRequiredDescriptionValidation
shopIdUUIDYesUnique identifier of the shopValid UUID format
statusenumYesOrder status to filter byMust be: PENDING_PAYMENT, PENDING_SHIPMENT, SHIPPED, DELIVERED, COMPLETED, CANCELLED, or REFUNDED

Query Parameters:

ParameterTypeRequiredDescriptionValidationDefault
pageintegerNoPage number (1-based)Must be >= 11
sizeintegerNoNumber of items per pageMust be > 0, max 5010

Success Response JSON Sample:

{
  "success": Usertrue,
  "httpStatus": "OK",
  "message": "Orders retrieved successfully",
  "action_time": "2025-10-25T10:30:45",
  "data": {
    "orders": [
      {
        "orderId": "550e8400-e29b-41d4-a716-446655440000",
        "orderNumber": "ORD-2025-12345",
        "buyer": {
          "accountId": "123e4567-e89b-12d3-a456-426614174000",
          "userName": "johndoe",
          "email": "john@example.com",
          "firstName": "John",
          "lastName": "Doe"
        },
        "seller": {
          "shopId": "789e0123-e45b-67d8-a901-234567890abc",
          "shopName": "TechStore",
          "shopLogo": "https://cdn.nextgate.com/shops/techstore.png",
          "shopSlug": "techstore"
        },
        "orderStatus": "PENDING_SHIPMENT",
        "deliveryStatus": "PENDING",
        "orderSource": "DIRECT_PURCHASE",
        "items": [
          {
            "orderItemId": "111e2222-e33b-44d5-a666-777788889999",
            "productId": "abc12345-def6-7890-ghij-klmnopqrstuv",
            "productName": "Mouse Pad",
            "productSlug": "mouse-pad",
            "productImage": "https://cdn.nextgate.com/products/mousepad.jpg",
            "quantity": 2,
            "unitPrice": 8000.00,
            "subtotal": 16000.00,
            "tax": 0.00,
            "total": 16000.00
          }
        ],
        "subtotal": 16000.00,
        "shippingFee": 2000.00,
        "tax": 0.00,
        "totalAmount": 18000.00,
        "platformFee": 900.00,
        "sellerAmount": 17100.00,
        "currency": "TZS",
        "paymentMethod": "AIRTEL_MONEY",
        "amountPaid": 18000.00,
        "amountRemaining": 0.00,
        "deliveryAddress": "444 Startup Hub, Dodoma, Tanzania",
        "trackingNumber": null,
        "carrier": null,
        "isDeliveryConfirmed": false,
        "deliveryConfirmedAt": null,
        "orderedAt": "2025-10-25T07:15:00",
        "shippedAt": null,
        "deliveredAt": null,
        "cancelledAt": null,
        "cancellationReason": null
      }
    ],
    "currentPage": 1,
    "pageSize": 10,
    "totalElements": 15,
    "totalPages": 2,
    "hasNext": true,
    "hasPrevious": false,
    "isFirst": true,
    "isLast": false
  }
}

Success Response Fields:

FieldDescription
ordersArray of order objects matching status for current page
currentPageCurrent page number (1-based)
pageSizeNumber of items per page
totalElementsTotal number of matching orders across all pages
totalPagesTotal number of pages available
hasNextWhether there is a next page
hasPreviousWhether there is a previous page
isFirstWhether this is the first page
isLastWhether this is the last page

Error Response JSON Sample:

{
  "success": false,
  "httpStatus": "BAD_REQUEST",
  "message": "Invalid order status: INVALID_STATUS",
  "action_time": "2025-10-25T10:30:45",
  "data": "Invalid order status: INVALID_STATUS"
}

Standard Error Types:

  • 400 BAD_REQUEST: Invalid status value, pagination parameters, or user is not shop owner
  • 401 UNAUTHORIZED: Missing or invalid authentication token
  • 404 NOT_FOUND: Shop not found or has been deleted

11. Mark Order as Shipped (Seller Action)

Purpose: Allows seller to mark an order as shipped, generates delivery confirmation code, and sends notification to buyer.

Endpoint: POST {base_url}/orders/{orderId}/ship

Access Level: ðŸ”’ Protected (Shop Owner/Seller only)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

ParameterTypeRequiredDescriptionValidation
orderIdUUIDYesUnique identifier of the orderValid UUID format

Success Response JSON Sample:

{
  "success": true,
  "httpStatus": "OK",
  "message": "Order marked as shipped",
  "action_time": "2025-10-25T10:30:45",
  "data": {
    "orderId": "550e8400-e29b-41d4-a716-446655440000",
    "orderNumber": "ORD-2025-12345",
    "shippedAt": "2025-10-25T10:30:45",
    "message": "Order marked as shipped. Confirmation code sent to customer.",
    "confirmationCodeSent": true,
    "codeExpiresAt": "2025-11-24T10:30:45",
    "maxVerificationAttempts": 5
  }
}

Success Response Fields:

FieldDescription
orderIdUUID of the shipped order
orderNumberHuman-readable order number
shippedAtTimestamp when order was marked as shipped
messageConfirmation message
confirmationCodeSentWhether confirmation code was sent to customer
codeExpiresAtWhen the confirmation code expires (30 days from generation)
maxVerificationAttemptsMaximum number of code verification attempts allowed

Error Response JSON Sample:

{
  "success": false,
  "httpStatus": "BAD_REQUEST",
  "message": "Cannot ship order with status: COMPLETED. Order must be PENDING_SHIPMENT",
  "action_time": "2025-10-25T10:30:45",
  "data": "Cannot ship order with status: COMPLETED. Order must be PENDING_SHIPMENT"
}

Standard Error Types:

  • 400 BAD_REQUEST: Order status is not PENDING_SHIPMENT, user is not the shopseller, owneror confirmation code generation failed
  • 401 UNAUTHORIZED: Missing or invalid authentication token
  • 404 NOT_FOUND:NOT_FOUND: Shop doesOrder not existfound

12. Confirm Delivery (Customer Action)

Purpose: Allows customer to confirm order delivery using the 6-digit confirmation code, releases escrow to seller.

Endpoint: POST {base_url}/orders/{orderId}/confirm-delivery

Access Level: ðŸ”’ Protected (Buyer/Customer only)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication
User-AgentstringNoDevice information for verification tracking
X-Forwarded-ForstringNoClient IP address (if behind proxy)
X-Real-IPstringNoReal client IP address

Path Parameters:

ParameterTypeRequiredDescriptionValidation
orderIdUUIDYesUnique identifier of the orderValid UUID format

Request JSON Sample:

{
  "confirmationCode": "123456"
}

Request Body Parameters:

ParameterTypeRequiredDescriptionValidation
confirmationCodestringYes6-digit confirmation code sent to customerMust be exactly 6 digits (0-9)

Success Response JSON Sample:

{
  "orderId": "550e8400-e29b-41d4-a716-446655440000",
  "orderNumber": "ORD-2025-12345",
  "deliveredAt": "2025-10-25T10:30:45",
  "confirmedAt": "2025-10-25T10:30:45",
  "escrowReleased": true,
  "sellerAmount": 166250.00,
  "currency": "TZS",
  "message": "Delivery confirmed successfully. Order completed!"
}

Success Response Fields:

FieldDescription
orderIdUUID of the confirmed order
orderNumberHuman-readable order number
deliveredAtTimestamp when order was marked as delivered
confirmedAtTimestamp when delivery was confirmed
escrowReleasedWhether escrow funds were released to seller
sellerAmountAmount released to seller after platform fee
currencyCurrency code
messageConfirmation message

Error Response JSON Sample:

{
  "success": false,
  "httpStatus": "BAD_REQUEST",
  "message": "Invalid confirmation code. 4 attempts remaining.",
  "action_time": "2025-10-25T10:30:45",
  "data": "Invalid confirmation code. 4 attempts remaining."
}

Standard Error Types:

  • 400 BAD_REQUEST: Invalid confirmation code, order status is not SHIPPED, user is not the buyer, maximum attempts exceeded, code expired, no escrow found, or escrow already released
  • 401 UNAUTHORIZED: Missing or invalid authentication token
  • 404 NOT_FOUND: Order not found or no ordersactive foundconfirmation code exists
  • 422 UNPROCESSABLE_ENTITY: Validation error on confirmation code format

13. Regenerate Confirmation Code (Customer Action)

Purpose: Allows customer to request a new delivery confirmation code if previous code was lost or expired.

Endpoint: POST {base_url}/orders/{orderId}/regenerate-code

Access Level: ðŸ”’ Protected (Buyer/Customer only)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication

Path Parameters:

ParameterTypeRequiredDescriptionValidation
orderIdUUIDYesUnique identifier of the orderValid UUID format

Success Response JSON Sample:

{
  "success": true,
  "httpStatus": "OK",
  "message": "Confirmation code regenerated successfully",
  "action_time": "2025-10-25T10:30:45",
  "data": {
    "orderId": "550e8400-e29b-41d4-a716-446655440000",
    "orderNumber": "ORD-2025-12345",
    "codeSent": true,
    "destination": "email",
    "codeExpiresAt": "2025-11-24T10:30:45",
    "maxAttempts": 5,
    "message": "New confirmation code sent to your email"
  }
}

Success Response Fields:

FieldDescription
orderIdUUID of the order
orderNumberHuman-readable order number
codeSentWhether new code was successfully sent
destinationWhere the code was sent (email, sms, or both)
codeExpiresAtWhen the new code expires (30 days from generation)
maxAttemptsMaximum number of verification attempts allowed
messageConfirmation message

Error Response JSON Sample:

{
  "success": false,
  "httpStatus": "BAD_REQUEST",
  "message": "Cannot regenerate code. Order status: COMPLETED. Order must be SHIPPED.",
  "action_time": "2025-10-25T10:30:45",
  "data": "Cannot regenerate code. Order status: COMPLETED. Order must be SHIPPED."
}

Standard Error Types:

  • 400 BAD_REQUEST: Order status is not SHIPPED, user is not the buyer, or delivery already confirmed
  • 401 UNAUTHORIZED: Missing or invalid authentication token
  • 404 NOT_FOUND: Order not found

Quick Reference Guide

HTTP Method Badge Code Templates

GET Badge:

<span style="background-color: #28a745; color: white; padding: 4px 8px; border-radius: 4px; font-family: monospace; font-size: 12px; font-weight: bold;">GET</span>

POST Badge:

<span style="background-color: #007bff; color: white; padding: 4px 8px; border-radius: 4px; font-family: monospace; font-size: 12px; font-weight: bold;">POST</span>

PUT Badge:

<span style="background-color: #ffc107; color: black; padding: 4px 8px; border-radius: 4px; font-family: monospace; font-size: 12px; font-weight: bold;">PUT</span>

PATCH Badge:

<span style="background-color: #fd7e14; color: white; padding: 4px 8px; border-radius: 4px; font-family: monospace; font-size: 12px; font-weight: bold;">PATCH</span>

DELETE Badge:

<span style="background-color: #dc3545; color: white; padding: 4px 8px; border-radius: 4px; font-family: monospace; font-size: 12px; font-weight: bold;">DELETE</span>

Common HTTP Status Codes

  • 200 OK:OK: Successful GET/PUT/PATCH request
  • 201 Created:Created: Successful POST request
  • 204 No Content:Content: Successful DELETE request
  • 400 Bad Request:Request: Invalid request datadata, business logic error, or item already exists
  • 401 Unauthorized:Unauthorized: Authentication required/failed (missing, invalid, expired, or malformed token)
  • 403 Forbidden:Forbidden: Insufficient permissionspermissions, access denied, verification required
  • 404 Not Found:Found: Resource not found
  • 422 Unprocessable Entity:Entity: Validation errors
  • 429 Too Many Requests:Requests: Rate limit exceeded
  • 500 Internal Server Error:Error: Server error

Authentication Types

  • Bearer TokenToken:: Include Authorization: Bearer your_token in headers


    Order Status Flow

    1. PENDING_PAYMENT â†’ Payment not yet completed
    2. PENDING_SHIPMENT â†’ Payment completed, awaiting seller to ship
    3. SHIPPED â†’ Seller marked as shipped, awaiting delivery confirmation
    4. DELIVERED â†’ Seller claims delivery (legacy status)
    5. COMPLETED â†’ Customer confirmed delivery, escrow released
    6. CANCELLED â†’ Order cancelled
    7. REFUNDED â†’ Order refunded

    Delivery Status Values

    • PENDING: Not yet shipped
    • SHIPPED: Seller marked as shipped
    • IN_TRANSIT: Package in transit (physical goods)
    • DELIVERED: Seller claims delivered
    • CONFIRMED: Buyer confirmed receipt with code

    Order Source Types

    • DIRECT_PURCHASE: Normal buy now (full payment upfront)
    • CART_PURCHASE: Purchase made through shopping cart
    • INSTALLMENT: Pay over time with installment plan
    • GROUP_PURCHASE: Group buying

    Data Format Standards

    • DatesDates:: Use ISO 8601 format (2025-10-18T11:32:25T14:30:00Z)
    • CurrencyCurrency:: TZS (Tanzanian ShillingsShilling), (TZS)amounts in decimal with 2 precision
    • IDsIDs:: UUID format
    • PaginationPagination:: Not1-based implementedindexing in(page these1 endpointsis first page)

    Security Notes

    • Confirmation Codes: 6-digit numeric codes, SHA-256 hashed with salt
    • Code Expiry: 30 days from generation
    • Max Attempts: 5 verification attempts per code
    • IP Tracking: Verification attempts tracked by IP and device
    • Escrow Protection: Funds held until delivery confirmation

    Pagination Best Practices

    • Default page size: 10 items
    • Maximum page size: 50 items
    • Always use 1-based page numbering
    • Check hasNext and hasPrevious for navigation
    • Use totalPages and totalElements for UI display