Skip to main content

Shop Management

Author: Josh S. Sakweli, Backend Lead Team
Last Updated: 2025-09-232026-05-19
Version: v1.v2.0

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

Short Description: The Shop Management API provides comprehensive endpoints for creating, managing, and retrieving shop information withinon the NextGate platform. This API handlesCovers shop registration, updates, approvals, categorization,WABA (WhatsApp Business) integration, AI chatbot toggling, and includesconversation integrated rating and review data for enhanced shop profiles.history.

Hints:

  • All shop operationsendpoints requireuse properthe authenticationprefix via Bearer tokenapi/v1/e-commerce/shops
  • Shop creation requires validauthentication; categorypublic IDusers andcan owneronly authenticationread
  • Pagination uses 1-based page numbering (page=1 for first page)
  • Shop approval operations require SUPER_ADMINROLE_SUPER_ADMIN or STAFF_ADMIN rolesROLE_STAFF_ADMIN
  • Featured shops are randomized on each request for better discovery
  • Rating and review data is automatically included in shop responses (read-only — managed by separate review service)
  • WABA = WhatsApp Business Account integration for the shop's AI-powered chatbot

Standard Response Format

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

Success Response Structure

{
  "success": true,
  "httpStatus": "OK",
  "message": "Operation completed successfully",
  "action_time": "2025-09-23T10:2026-05-19T10:30:45",
  "data": { // Actual response data goes here
  }
}

Error Responseresponses Structure

follow
the same envelope with {
  "success": false,false "httpStatus":and "BAD_REQUEST",
  "message": "Error description",
  "action_time": "2025-09-23T10:30:45",
  "data": "Errorset description"to // or detailedthe error object
}

Standard Response Fields

FieldTypeDescription
successbooleanAlways true for successful operations, false for errors
httpStatusstringHTTP status name (OK, BAD_REQUEST, NOT_FOUND, etc.)
messagestringHuman-readable message describing the operation result
action_timestringISO 8601 timestamp of when the response was generated
dataobject/stringResponse payload for success, error details for failures
string.


Endpoints

1. Create Shop

Purpose: Creates a new shop with all required information including owner details, category assignment, and location data

Endpoint: POST {base_url}/api/v1/e-commerce/shops

Access Level: 🔒 Protected (Requires Bearer Token Authentication)

Authentication: Bearer Token

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authenticated user
Content-TypestringYesapplication/json

Request JSON Sample:

{
  "shopName": "Mama Lucy's Restaurant",
  "shopDescription": "Authentic Tanzanian cuisine served with love in the heart of Dar es Salaam",
  "tagline": "Taste of home",
  "logoUrl": "https://example.com/logo.jpg",
  "bannerUrl": "https://example.com/banner.jpg",
  "shopImages": [
    "https://example.com/shop1.jpg",
    "https://example.com/shop2.jpg"
  ],
  "categoryId": "550e8400-e29b-41d4-a716-446655440000",
  "shopType": "HYBRID",
  "phoneNumber": "+255123456789",
  "email": "info@mamalucy.co.tz",
  "websiteUrl": "https://mamalucy.co.tz",
  "socialMediaLinks": [
    "https://facebook.com/mamalucy",
    "https://instagram.com/mamalucy"
  ],
  "address": "Msimbazi Street, Block 45",
  "city": "Dar es Salaam",
  "region": "Dar es Salaam",
  "postalCode": "12345",
  "countryCode": "TZ",
  "latitude": -6.7924,
  "longitude": 39.2083,
  "locationNotes": "Near the main bus stop",
  "businessRegistrationNumber": "REG123456",
  "taxNumber": "TAX789012",
  "licenseNumber": "LIC345678",
  "promotionText": "Grand opening - 20% off all meals!"
}

Request Body Parameters:

Parameter Type Required Description Validation
shopName string Yes Name of the shop Min: 2, Max: 100 characterschars
shopDescription string Yes Detailed description of the shop Max: 1000 characters
categoryIdUUIDYesShop category identifierMust be valid category IDchars
phoneNumber string Yes Contact phone number Pattern: ^\+?[0-9]{10,15}$
city string Yes City location Min: 2, Max: 50 characterschars
region string Yes Region/state location Min: 2, Max: 50 characters
taglinestringNoShort promotional taglineMax: 50 characterschars
logoUrl string No URL to shopShop logo imageURL Must be validValid URL, Max:max 1000 chars
bannerUrl string No URL to shopShop banner imageURL Must be validValid URL, Max:max 1000 chars
shopImages array No Array of shop image URLs EachValid URLURLs, max 1000 chars
shopTypestringNoType of shopenum: PHYSICAL, ONLINE, HYBRID (default: HYBRID)each
email string No Shop contactContact email Must be validValid email, Max:max 100 chars
websiteUrlstringNoShop website URLMust be valid URL, Max: 200 chars
socialMediaLinksarrayNoArray of social media URLsEach URL max 500 chars
addressstringNoStreet addressMax: 200 characters
postalCodestringNoPostal/ZIP codeMax: 10 characters
countryCode string No Country code Max: 3 charschars, (default:Default: "TZ")
streetAddressstringNoStreet addressMax: 255 chars
landmarkstringNoLandmark / location notesMax: 300 chars
latitude decimal No LatitudeGPS coordinatelatitude Range: -90.0 to 90.0
longitude decimal No LongitudeGPS coordinatelongitude Range: -180.0 to 180.0
locationNotesstringNoAdditional location detailsMax: 300 characters
businessRegistrationNumberstringNoBusiness registration numberMax: 50 characters
taxNumberstringNoTax identification numberMax: 50 characters
licenseNumberstringNoBusiness license numberMax: 50 characters
promotionTextstringNoCurrent promotion messageMax: 200 characters

SuccessRequest JSON Sample:

{
  "shopName": "Mama Lucy's Restaurant",
  "shopDescription": "Authentic Tanzanian cuisine in the heart of Dar es Salaam",
  "phoneNumber": "+255123456789",
  "city": "Dar es Salaam",
  "region": "Dar es Salaam",
  "logoUrl": "https://example.com/logo.jpg",
  "bannerUrl": "https://example.com/banner.jpg",
  "shopImages": ["https://example.com/shop1.jpg"],
  "email": "info@mamalucy.co.tz",
  "countryCode": "TZ",
  "streetAddress": "Msimbazi Street, Block 45",
  "landmark": "Near the main bus stop",
  "latitude": -6.7924,
  "longitude": 39.2083
}

Response JSON Sample:

{
  "success": true,
  "httpStatus": "OK",
  "message": "Shop created successfully",
  "action_time": "2025-09-23T10:2026-05-19T10:30:45",
  "data": {
    "shopId": "123e4567-e89b-12d3-a456-426614174000",
    "shopName": "Mama Lucy's Restaurant",
    "shopSlug": "mama-lucys-restaurant",
    "shopDescription": "Authentic Tanzanian cuisine served with love in the heart of Dar es Salaam",
    cuisine..."tagline": "Taste of home",
    "logoUrl": "https://example.com/logo.jpg",
    "bannerUrl": "https://example.com/banner.jpg",
    "shopImages": [
      "https://example.com/shop1.jpg",
      "https://example.com/shop2.jpg"
    ],
    "ownerId": "456e7890-e89b-12d3-a456-426614174001",
    "ownerName": "Lucy Mwalimu",
    "categoryId": "550e8400-e29b-41d4-a716-446655440000",
    "categoryName": "Restaurant & Food",
    "shopType": "HYBRID",
    "status": "PENDING",
    "phoneNumber": "+255123456789",
    "email": "info@mamalucy.co.tz",
    "websiteUrl": "https://mamalucy.co.tz",
    "socialMediaLinks": [
      "https://facebook.com/mamalucy",
      "https://instagram.com/mamalucy"
    ],
    "address"streetAddress": "Msimbazi Street, Block 45",
    "city": "Dar es Salaam",
    "region": "Dar es Salaam",
    "postalCode": "12345",
    "countryCode": "TZ",
    "latitude": -6.7924,
    "longitude": 39.2083,
    "locationNotes"landmark": "Near the main bus stop",
    "businessRegistrationNumber": "REG123456",
    "taxNumber": "TAX789012",
    "licenseNumber": "LIC345678",
    "establishedYear": null,
    "isVerified": false,
    "verificationBadge": null,
    "trustScore": 0.00,
    "lastSeenTime": null,
    "isFeatured": false,
    "featuredUntil": null,
    "promotionText": "Grand opening - 20% off all meals!",
    "isApproved": true,
    "createdAt": "2025-09-23T10:2026-05-19T10:30:45",
    "updatedAt": "2025-09-23T10:2026-05-19T10:30:45",
    "approvedAt": null,
    "averageRating": null,
    "totalRatings": 0,
    "totalActiveReviews": 0,
    "reviews": []
  }
}

SuccessError Response FieldsResponses:

  • 400:
  • alreadyexists
  • 401:
  • FieldDescription
    shopIdUnique identifier for the shop
    shopSlugURL-friendly version of shopShop name
    statusShopAuthentication statusrequired (PENDING,
  • 422: ACTIVE,Validation SUSPENDED,errors
  • CLOSED, UNDER_REVIEW)
    isApprovedWhether shop has been approved by admin
    averageRatingAverage rating score (null if no ratings)
    totalRatingsTotal number of ratings received
    totalActiveReviewsNumber of active reviews
    reviewsArray of review objects

    2. Get All Shops (List)

    Purpose: Retrieves all shops in the system without pagination

    Endpoint: GET {base_url}/api/v1/e-commerce/shops/all

    Access Level: 🌐 Public (No authentication required)

    Authentication:Returns None

    a

    Successlist Responseof JSON Sample:

    {
      "success": true,
      "httpStatus": "OK",
      "message": "Allall shops retrievedwith successfully",summary "action_time": "2025-09-23T10:30:45",
      "data": [
        {
          "shopId": "123e4567-e89b-12d3-a456-426614174000",
          "shopName": "Mama Lucy's Restaurant",
          "shopSlug": "mama-lucys-restaurant",
          "averageRating": 4.5,
          "totalRatings": 25,
          "totalActiveReviews": 12,
          "topReviews": [
            {
              "reviewId": "rev-123",
              "userName": "John Doe",
              "reviewText": "Amazing foodinfo and greattop service!",5 "createdAt":reviews "2025-09-22T14:30:00"per }
          ]
        }
      ]
    }
    
    shop.


    3. Get All Shops (Paginated)

    Purpose: Retrieves all shops with pagination support for better performance

    Endpoint: GET {base_url}/api/v1/e-commerce/shops/all-paged

    Access Level: 🌐 Public (No authentication required)

    Authentication: None

    Query Parameters:

    Parameter Type RequiredDefault DescriptionValidationDefault
    page integer No1 Page number (1-based)Min: 11
    size integer No10 Number of itemsItems per page Min:(max: 1, Max: 10010100)

    Success Response JSON Sample:

    {
      "success": true,
      "httpStatus": "OK",
      "message": "Shops retrieved successfully",
      "action_time": "2025-09-23T10:2026-05-19T10:30:45",
      "data": {
        "shops": [ { "shopId":...ShopSummary fields..."123e4567-e89b-12d3-a456-426614174000",
            "shopName": "Mama Lucy's Restaurant",
            "averageRating": 4.5,
            "totalRatings": 25,
            "city": "Dar es Salaam",
            "region": "Dar es Salaam" } ],
        "currentPage": 1,
        "pageSize": 10,
        "totalElements": 150,
        "totalPages": 15,
        "hasNext": true,
        "hasPrevious": false,
        "isFirst": true,
        "isLast": false
      }
    }
    

    4. Update Shop

    Purpose: Updates shop information (only shop owners can update their shops)

    Endpoint: PUT {base_url}/api/v1/e-commerce/shops/{shopId}

    Access Level: 🔒 Protected (Shop Owner Only)

    Authentication: Bearer Tokenonly)

    Path Parameters:

    Parameter Type RequiredDescriptionValidation
    shopId UUID YesUnique identifierID of the shopMust be valid UUID

    RequestAll Headers:

    request bodyfieldsareoptionalonlyprovidedfieldsare
    Header Type Required Description
    AuthorizationstringYesBearer token for authenticated user
    Content-TypestringYesapplication/json

    Request JSON Sample:

    {
    	"shopName": "Mama Juma's Kitchen - Tabora",
    	"shopDescription": "Authentic Tanzanian cuisine with fresh ingredients and traditional recipes passed down through generations. We specialize in local dishes like ugali, nyama choma, and pilau.",
    	"logoUrl": "https://example.com/images/mama-juma-logo.jpg",
    	"categoryId": "fec6a097-612c-470c-af4f-4807e24bef9a",
    	"phoneNumber": "+255712345678",
    	"city": "Dar es Salaam",
    	"region": "Dar es Salaam",
    	"tagline": "Taste of Home",
    	"shopImages": [
    		"https://example.com/images/shop-front.jpg",
    		"https://example.com/images/kitchen.jpg"
    	],
    	"bannerUrl": "https://example.com/images/banner.jpg",
    	"shopType": "ONLINE",
    	"email": "info@mamajuma.co.tz",
    	"websiteUrl": "https://mamajuma.co.tz",
    	"socialMediaLinks": [
    		"https://facebook.com/mamajuma",
    		"https://instagram.com/mamajuma"
    	],
    	"address": "123 Msimbazi Street, Kariakoo",
    	"postalCode": "11101",
    	"businessRegistrationNumber": "VRI19939",
    	"taxNumber": "TAX9482",
    	"countryCode": "TZ",
    	"latitude": -6.8160,
    	"longitude": 39.2803,
    	"locationNotes": "Near Kariakoo Market, opposite the blue building",
    	"promotionText": "Free delivery within 5km for orders above 20,000 TSH"
    }
    

    Request Body Parameters:updated:

    Parameter TypeRequiredDescription Validation
    shopName string NoUpdated shop nameMin: 2, Max: 100 characterschars
    shopDescription string NoUpdated descriptionMax: 1000 characters
    taglinestringNoUpdated taglineMax: 50 characterschars
    logoUrl string NoUpdated logo URLMust be validValid URL
    bannerUrl string NoUpdated banner URLMust be validValid URL
    shopImages array NoUpdated shop imagesArray of validValid URLs
    categoryIdUUIDNoUpdated categoryMust be valid category ID
    shopTypestringNoUpdated shop typeenum: PHYSICAL, ONLINE, HYBRID
    phoneNumber string NoUpdated phone numberPattern: ^\+?[0-9]{10,15}$
    email string NoUpdated emailMust be validValid email
    websiteUrlstreetAddress string NoUpdated website URLMust be valid URL
    socialMediaLinksarrayNoUpdated social media linksArray of valid URLs
    addressstringNoUpdated addressMax: 200255 characterschars
    city string NoUpdated cityMin: 2, Max: 50 characterschars
    region string NoUpdated regionMin: 2, Max: 50 characters
    postalCodestringNoUpdated postal codeMax: 10 characterschars
    countryCode string NoUpdated country codeMax: 3 characterschars
    latitude decimal NoUpdated latitudeRange: -90.0 to 90.0
    longitude decimal NoUpdated longitudeRange: -180.0 to 180.0
    locationNoteslandmark string NoUpdated location notesMax: 300 characters
    promotionTextstringNoUpdated promotion textMax: 200 characterschars

    SuccessResponse: ResponseFull JSONShopResponse Sample(same shape as Create response)

    Error Responses:

    • { "success"400: true,Not "httpStatus"the shop owner, or shop is deleted
    • 401: "OK",Authentication "message"required
    • 404: "Shop updatednot successfully",found
    • "action_time": "2025-09-23T10:30:45", "data": { "shopId": "123e4567-e89b-12d3-a456-426614174000", "shopName": "Mama Lucy's Premium Restaurant", "shopSlug": "mama-lucys-premium-restaurant", "updatedAt": "2025-09-23T10:30:45" } }

    5. Get Shop by ID (Summary)

    Purpose: Retrieves basic shop information by shop ID

    Endpoint: GET {base_url}/api/v1/e-commerce/shops/{shopId}

    Access Level: 🌐 Public (No authentication required)

    Authentication:Returns None

    ShopSummaryListResponse

    Path Parameters:

    public-facing fieldsincludingtop
    ParameterTypeRequiredDescriptionValidation
    shopIdUUIDYesUnique identifier of the shopMust be valid UUID

    Success Response JSON Sample:

    {
      "success": true,
      "httpStatus": "OK",
      "message": "Shop retrieved successfully",
      "action_time": "2025-09-23T10:30:45",
      "data": {
        "shopId": "123e4567-e89b-12d3-a456-426614174000",
        "shopName": "Mama Lucy's Restaurant",
        "shopSlug": "mama-lucys-restaurant",
        "shopDescription": "Authentic Tanzanian cuisine",
        "logoUrl": "https://example.com/logo.jpg",
        "averageRating": 4.5,
        "totalRatings": 25,
        "totalActiveReviews": 12,
        "city": "Dar es Salaam",
        "region": "Dar es Salaam",
        "isVerified": false,
        "trustScore": 8.5 }reviews }and 
    rating.


    6. Get Shop by ID (Detailed)

    Purpose: Retrieves complete shop information including sensitive business details (owner/admin access only)

    Endpoint: GET {base_url}/api/v1/e-commerce/shops/{shopId}/detailed

    Access Level: 🔒 Protected (Shop Owner or Admin Only)Admin)

    Authentication:Returns Bearerfull TokenShopResponse including all reviews and management fields.

    Path Parameters:

    ParameterTypeRequiredDescriptionValidation
    shopIdUUIDYesUnique identifier of the shopMust be valid UUID

    Request Headers:

    HeaderTypeRequiredDescription
    AuthorizationstringYesBearer token for authenticated user

    Success Response JSON Sample:

    {
      "success": true,
      "httpStatus": "OK",
      "message": "Shop retrieved successfully",
      "action_time": "2025-09-23T10:30:45",
      "data": {
        "shopId": "123e4567-e89b-12d3-a456-426614174000",
        "shopName": "Mama Lucy's Restaurant",
        "businessRegistrationNumber": "REG123456",
        "taxNumber": "TAX789012",
        "licenseNumber": "LIC345678",
        "averageRating": 4.5,
        "totalRatings": 25,
        "reviews": [
          {
            "reviewId": "rev-123",
            "userName": "John Doe",
            "reviewText": "Amazing food!",
            "status": "ACTIVE",
            "createdAt": "2025-09-22T14:30:00"
          }
        ]
      }
    }
    

    7. Get My Shops

    Purpose: Retrieves all shops owned by the authenticated user

    Endpoint: GET {base_url}/api/v1/e-commerce/shops/my-shops

    Access Level: 🔒 Protected (Authenticated User Only)

    Authentication:Returns Bearerall Token

    shops

    Requestowned Headers:

    by (ShopSummaryListResponse
    HeaderTypeRequiredDescription
    AuthorizationstringYesBearer token forthe authenticated user

    Success Response JSON Sample:list).

    {
      "success": true,
      "httpStatus": "OK",
      "message": "My shops retrieved successfully",
      "action_time": "2025-09-23T10:30:45",
      "data": [
        {
          "shopId": "123e4567-e89b-12d3-a456-426614174000",
          "shopName": "Mama Lucy's Restaurant",
          "status": "ACTIVE",
          "isApproved": true,
          "averageRating": 4.5,
          "totalRatings": 25,
          "createdAt": "2025-09-20T10:30:45"
        }
      ]
    }
    

    8. Get My Shops (Paginated)

    Purpose: Retrieves user's shops with pagination support

    Endpoint: GET {base_url}/api/v1/e-commerce/shops/my-shops-paged

    Access Level: 🔒 Protected (Authenticated User Only)

    AuthenticationQuery Parameters:

    ParameterDefaultDescription
    page1Page number (1-based)
    size10Items per page (max: 100)

    9. Approve / Reject Shop

    Endpoint: BearerPATCH Tokenapi/v1/e-commerce/shops/{shopId}/approve-shop

    Access Level: 🔒 Protected (ROLE_SUPER_ADMIN or ROLE_STAFF_ADMIN)

    Query Parameters:

    Parameter Type Required Description ValidationDefault
    pageintegerNoPage number (1-based)Min: 11
    sizeintegerNoNumber of items per pageMin: 1, Max: 10010

    Request Headers:

    HeaderTypeRequiredDescription
    AuthorizationstringYesBearer token for authenticated user

    9. Approve Shop

    Purpose: Approve or reject a shop (admin operation)

    Endpoint: PATCH {base_url}/shops/{shopId}/approve-shop

    Access Level: 🔒 Protected (Super Admin or Staff Admin Only)

    Authentication: Bearer Token

    Path Parameters:

    ParameterTypeRequiredDescriptionValidation
    shopIdUUIDYesUnique identifier of the shopMust be valid UUID

    Query Parameters:

    ParameterTypeRequiredDescriptionValidationDefault
    approve boolean Yes Whethertrue to approveapprove, (true)false orto reject (false)Must be boolean-

    Request Headers:

    HeaderTypeRequiredDescription
    AuthorizationstringYesBearer token for admin user

    Success Response JSON Sample:

    {
      "success": true,
      "httpStatus": "OK",
      "message": "Shop approval status changed successfully",
      "action_time": "2025-09-23T10:2026-05-19T10:30:45",
      "data": {
        "shopId": "123e4567-e89b-12d3-a456-426614174000",
        "shopName": "Mama Lucy's Restaurant",
        "isApproved": true,
        "approvedAt": "2025-09-23T10:2026-05-19T10:30:45"
      }
    }
    

    Purpose: Retrieves all shops in a specific category

    Endpoint: GET {base_url}/api/v1/e-commerce/shops/category/{categoryId}featured

    Access Level: 🌐 Public

    Returns up to 20 randomly selected featured shops (NoShopSummaryListResponse authenticationlist).

    required)

    Endpoint: GET api/v1/e-commerce/shops/featured-paged

    AuthenticationAccess Level: None🌐 Public

    PathQuery Parameters:

    ParameterDefaultDescription
    page1Page number
    size10Items per page (max: 100)

    12. Search Shops

    Endpoint: GET api/v1/e-commerce/shops/search

    Access Level: 🌐 Public

    Query Parameters:

    validUUID
    Parameter Type Required DescriptionDefault ValidationDescription
    categoryIdq UUIDstring YesNo Unique identifier of the shop category MustSearch bequery
    pageintegerNo1Page number
    sizeintegerNo10Items per page

    Success Response JSON Sample:

    {
      "success": true,
      "httpStatus": "OK",
      "message": "Shops by category retrieved successfully",
      "action_time": "2025-09-23T10:2026-05-19T10:30:45",
      "data": [
        {
        "shopId": "123e4567-e89b-12d3-a456-426614174000",
          "shopName": "Mama Lucy's Restaurant",
          "categoryName": "Restaurant & Food",
          "averageRating": 4.5,
          "city": "Dar es Salaam"
        }
      ]
    }
    

    11. Get Shops by Category (Paginated)

    Purpose: Retrieves shops in a category with pagination

    Endpoint: GET {base_url}/shops/category/{categoryId}/paged

    Access Level: 🌐 Public (No authentication required)

    Authentication: None

    Path Parameters:

    ParameterTypeRequiredDescriptionValidation
    categoryIdUUIDYesUnique identifier of the shop categoryMust be valid UUID

    Query Parameters:

    ParameterTypeRequiredDescriptionValidationDefault
    pageintegerNoPage number (1-based)Min: 11
    sizeintegerNoNumber of items per pageMin: 1, Max: 10010

    Purpose: Retrieves randomly selected featured shops (up to 20 shops)

    Endpoint: GET {base_url}/shops/featured

    Access Level: 🌐 Public (No authentication required)

    Authentication: None

    Success Response JSON Sample:

    {
      "success": true,
      "httpStatus": "OK",
      "message": "Featured shops retrieved successfully",
      "action_time": "2025-09-23T10:30:45",
      "data"content": [ { "shopId":...ShopSearchResponse fields..."123e4567-e89b-12d3-a456-426614174000",
          "shopName": "Mama Lucy's Restaurant",
          "averageRating": 4.5,
          "totalRatings": 25,
          "city": "Dar es Salaam",
          "isVerified": true } ],
        "totalElements": 8,
        "totalPages": 1,
        "currentPage": 1,
        "pageSize": 10,
        "hasNext": false,
        "hasPrevious": false
      }
    }
    

    13. Get FeaturedShop ShopsSummary (Paginated)Stats

    Purpose: Retrieves featured shops with pagination (randomized on each request)

    Endpoint: GET {base_url}/shops/featured-paged

    Access Level: 🌐 Public (No authentication required)

    Authentication: None

    Query Parameters:

    ParameterTypeRequiredDescriptionValidationDefault
    pageintegerNoPage number (1-based)Min: 11
    sizeintegerNoNumber of items per pageMin: 1, Max: 10010

    14. Get Shop Summary Statistics

    Purpose: Retrieves comprehensive statistics including ratings, reviews, and user activities for a shop

    Endpoint: GET {base_url}/api/v1/e-commerce/shops/{shopId}/summary-stats

    Access Level: 🌐 Public

    (No

    Returns authenticationaggregated required)review and rating statistics for a shop, including per-user activity.

    Authentication: None

    Path Parameters:

    ParameterTypeRequiredDescriptionValidation
    shopIdUUIDYesUnique identifier of the shopMust be valid UUID

    Success Response JSON Sample:

    {
      "success": true,
      "httpStatus": "OK",
      "message": "Shop summary stats retrieved successfully",
      "action_time": "2025-09-23T10:30:45",
      "data": {
        "shopId": "123e4567-e89b-12d3-a456-426614174000",
        "shopName": "Mama Lucy's Restaurant",
        "averageRating": 4.5,
        "totalRatings": 25,
        "ratingDistribution": { "1": 1, "2": 2, "3": 5, "4": 7, "5": 10 },
        "totalReviews": 15,
        "activeReviews": 12,
        "hiddenReviews": 2,
        "flaggedReviews": 1,
        "userActivities": [
          {
            "userId": "user-123",
            "userName": "John Doe",
            "reviewId"feedbackId": "rev-123",
            "reviewText": "Amazing food and service!",
            "reviewStatus": "ACTIVE",
            "reviewDate": "2025-09-22T14:30:00",
            "ratingId": "rat-123",
            "ratingValue": 5,
            "ratingDate"date": "2025-09-22T14:35:2026-05-19T14:30:00",
            "hasReview": true,
            "hasRating": true
          }
        ]
      }
    }
    

    14. WABA (WhatsApp Business) Integration

    WABA allows shops to receive and respond to WhatsApp customer messages via an AI-powered chatbot. The flow is: shop registers a WABA → admin approves with Meta credentials → shop toggles AI on/off and monitors conversation history.

    SuccessBase Responsepath Fieldsfor all WABA endpoints: api/v1/e-commerce/shops/{shopId}/waba

    Shared Path Parameter:

    identifier
    FieldParameterType Description
    shopId UniqueUUID ID of the shop

    14a. Register WABA

    Purpose: Shop owner submits a WhatsApp number and display name to begin WABA registration.

    Endpoint: POST api/v1/e-commerce/shops/{shopId}/waba/register

    Access Level: 🔒 Protected (Shop Owner)

    Request Body:

    ofthe
    ParameterTypeRequiredValidation
    shopNamephoneNumber Namestring Yes Max: shop20 chars
    averageRatingdisplayName Average rating score (1-5)
    totalRatingsstring Total number of ratings received
    ratingDistributionYes CountMax: of100 ratings by star value (1-5)
    totalReviewsTotal number of reviews (all statuses)
    activeReviewsNumber of active/visible reviews
    hiddenReviewsNumber of hidden reviews
    flaggedReviewsNumber of flagged reviews
    userActivitiesArray of combined user review and rating activities
    userActivities.hasReviewWhether user has written a review
    userActivities.hasRatingWhether user has given a ratingchars

    Standard Error Types and Responses

    Application-Level Exceptions (400-499)

    • 400 BAD_REQUEST: General invalid request data, random exceptions, or item already exists
    • 401 UNAUTHORIZED: Authentication issues (empty, invalid, expired, or malformed tokens)
    • 403 FORBIDDEN: Access denied, permission issues, verification failures, expired invitations
    • 404 NOT_FOUND: Requested resource does not exist
    • 422 UNPROCESSABLE_ENTITY: Validation errors with detailed field information
    • 429 TOO_MANY_REQUESTS: Rate limit exceeded

    Server-Level Exceptions (500+)

    • 500 INTERNAL_SERVER_ERROR: Unexpected server errors

    ErrorRequest ResponseJSON ExamplesSample:

    {
      "phoneNumber": "+255712345678",
      "displayName": "Mama Lucy's Restaurant"
    }
    

    14b. Approve WABA

    Purpose: Admin approves a pending WABA registration by supplying Meta WABA credentials.

    Endpoint: PATCH api/v1/e-commerce/shops/{shopId}/waba/approve

    Access Level: 🔒 Protected (ROLE_SUPER_ADMIN or ROLE_STAFF_ADMIN)

    Request Body:

    ParameterTypeRequiredValidation
    wabaIdstringYesMax: 64 chars (Meta WABA ID)
    phoneNumberIdstringYesMax: 64 chars (Meta Phone Number ID)
    phoneNumberstringYesMax: 20 chars

    14c. Resubmit WABA

    Purpose: Shop Alreadyowner Existsresubmits a rejected or pending WABA with corrected info.

    Endpoint: PATCH api/v1/e-commerce/shops/{shopId}/waba/resubmit

    Access Level: 🔒 Protected (400)Shop Owner)

    Request Body:

    ParameterTypeValidation
    phoneNumberstringMax: 20 chars
    displayNamestringMax: 100 chars

    14d. Admin Update WABA

    Purpose: Admin updates Meta credentials on an existing WABA account.

    Endpoint: PATCH api/v1/e-commerce/shops/{shopId}/waba/admin-update

    Access Level: 🔒 Protected (ROLE_SUPER_ADMIN or ROLE_STAFF_ADMIN)

    Same request body as Resubmit WABA.


    14e. Update WABA Status

    Purpose: Admin changes the status of a WABA account (e.g., suspend or reactivate).

    Endpoint: PATCH api/v1/e-commerce/shops/{shopId}/waba/status

    Access Level: 🔒 Protected (ROLE_SUPER_ADMIN or ROLE_STAFF_ADMIN)

    Query Parameters:

    ParameterTypeRequiredDescription
    statusShopWabaStatusYesPENDING, ACTIVE, SUSPENDED, REJECTED

    14f. Toggle AI Chatbot

    Purpose: Shop owner enables or disables the AI chatbot for their WABA.

    Endpoint: PATCH api/v1/e-commerce/shops/{shopId}/waba/toggle-ai

    Access Level: 🔒 Protected (Shop Owner)

    Query Parameters:

    ParameterTypeRequiredDescription
    enabledbooleanYestrue to enable, false to disable

    Response JSON Sample:

    {
      "success": false,
      "httpStatus": "BAD_REQUEST",true,
      "message": "ShopAI withenabled this name already exists",
      "action_time": "2025-09-23T10:30:45"successfully",
      "data": {
        "ShopshopId": with"...",
        this"aiEnabled": nametrue,
        already"updatedAt": exists""2026-05-19T11:00:00"
      }
    }
    

    14g. Get WABA Conversations

    UnauthorizedPurpose: -Retrieves Tokenpaginated IssuesWhatsApp conversation sessions for the shop.

    Endpoint: GET api/v1/e-commerce/shops/{shopId}/waba/conversations

    Access Level: 🔒 Protected (401)Shop Owner or Admin)

    Query Parameters:

    ParameterDefaultDescription
    page1Page number
    size10Items per page

    Response JSON Sample:

    {
      "success": false,
      "httpStatus": "UNAUTHORIZED",true,
      "message": "TokenConversations has expired",
      "action_time": "2025-09-23T10:30:45"retrieved",
      "data": {
        "Tokencontent": has[ expired"{ "...WabaSessionResponse fields..." } ],
        "currentPage": 1,
        "pageSize": 10,
        "totalElements": 42,
        "totalPages": 5,
        "hasNext": true,
        "hasPrevious": false
      }
    }
    

    14h. Get Session Messages

    Purpose: Retrieves paginated messages within a specific conversation session.

    Endpoint: GET api/v1/e-commerce/shops/{shopId}/waba/conversations/{sessionId}/messages

    Access DeniedLevel: -🔒 Protected (Shop Owner or Admin)

    Additional Path Parameter:

    ParameterTypeDescription
    sessionIdUUIDID of the conversation session

    Query Parameters:

    ParameterDefaultDescription
    page1Page number
    size20Items per page

    14i. Get Session Messages by Date Range

    Purpose: Retrieves messages in a session filtered by date range.

    Endpoint: GET api/v1/e-commerce/shops/{shopId}/waba/conversations/{sessionId}/messages/by-date

    Access Level: 🔒 Protected (Shop Owner or Admin)

    Additional Path Parameter:

    ParameterTypeDescription
    sessionIdUUIDID of the conversation session

    Query Parameters:

    ParameterTypeRequiredDescription
    fromLocalDateTimeYesStart datetime (ISO 8601)
    toLocalDateTimeYesEnd datetime (ISO 8601)
    pageintegerNoDefault: 1
    sizeintegerNoDefault: 20

    Quick Reference

    Enums

    ShopStatus: PENDING, ACTIVE, SUSPENDED, CLOSED, UNDER_REVIEW

    ShopType: PHYSICAL, ONLINE, HYBRID

    VerificationBadge: BRONZE, SILVER, GOLD, PREMIUM

    ShopWabaStatus: PENDING, ACTIVE, SUSPENDED, REJECTED

    Error Response Codes

    (403):

    
    "success": false,
      "httpStatus": "FORBIDDEN",
      "message": "Access denied: Insufficient permissions",
      "action_time": "2025-09-23T10:30:45",
      "data": "Access denied: Insufficient permissions"
    }
    
    

    Shop Not Found (404):

    {
      "success": false,
      "httpStatus": "NOT_FOUND",
      "message": "Shop
    "action_time":"2025-09-23T10:30:45","data":"Shop}
    CodeMeaning
    400Business logic violation or item already exists
    401Authentication required or token invalid/expired
    403Insufficient Permissionspermissions
    {404 Resource not found",found
    422 Field-level notvalidation found"errors

    Category Not Found (404):

    {
      "success": false,
      "httpStatus": "NOT_FOUND",
      "message": "Shop category not found",
      "action_time": "2025-09-23T10:30:45",
      "data": "Shop category not found"
    }
    

    User Not Authenticated (404):

    {
      "success": false,
      "httpStatus": "NOT_FOUND",
      "message": "User not authenticated",
      "action_time": "2025-09-23T10:30:45",
      "data": "User not authenticated"
    }
    

    Validation Error (422):

    {
      "success": false,
      "httpStatus": "UNPROCESSABLE_ENTITY",
      "message": "Validation failed",
      "action_time": "2025-09-23T10:30:45",
      "data": {
        "shopName": "Shop name must be between 2 and 100 characters",
        "phoneNumber": "Phone number must be between 10-15 digits and may start with +",
        "email": "Email must be valid"
      }
    }
    

    Random

    Access BusinessControl Logic Error (400):

    {
      "success": false,
      "httpStatus": "BAD_REQUEST",
      "message": "Only shop owners can update their shops",
      "action_time": "2025-09-23T10:30:45",
      "data": "Only shop owners can update their shops"
    }
    

    Cannot Update Deleted Shop (400):

    {
      "success": false,
      "httpStatus": "BAD_REQUEST",
      "message": "Cannot update a deleted shop",
      "action_time": "2025-09-23T10:30:45",
      "data": "Cannot update a deleted shop"
    }
    

    Data Models and Enums

    Shop Status EnumSummary

    approve/rejectshops,approve/update/status
    ValueRole DescriptionCapabilities
    PENDINGPublic AwaitingRead adminshops, approvalsearch, featured, summary stats
    Authenticated userAll public + create shop, view own shops
    Shop OwnerAll authenticated + update own shop, WABA management, view conversations
    ACTIVEROLE_SUPER_ADMIN / ROLE_STAFF_ADMIN ActiveAll and+ operational
    SUSPENDEDTemporarily suspended by admin
    CLOSEDPermanently closed/inactive
    UNDER_REVIEWUnder admin review for policy violationsWABA

    ShopWABA TypeRegistration EnumFlow

    1. 
    POST /{shopId}/waba/register shop owner submits
    ValueDescription
    PHYSICALPhysical store only (brick-and-mortar)
    ONLINEOnline store only (e-commerce)
    HYBRIDBoth physical and online presence

    Verification Badge Enum

    displayname2.PATCHPATCH/{shopId}/waba/toggle-ai
    ValueDescription
    BRONZEBasic verification (documents verified)
    SILVEREnhanced verification (business registrationphone + documents)
    GOLD Premium/{shopId}/waba/approve verification (fulladmin compliancesupplies Meta wabaId + goodphoneNumberId track3. record)
    PREMIUMHighest level (partner status + excellent performance)

    Review Status Enum (from related services)

    ValueDescription
    ACTIVEReview is visible and active
    HIDDENReview is hidden from public view
    FLAGGEDReview has been flagged for review
    DELETEDReview has been deleted

    Business Rules and Logic

    Shop Creation Rules

    • Shop name must be unique across all active shops
    • Shop slug is automatically generated from shop nameowner andenables mustAI bechatbot unique
    • 4.
    • NewGET shops/{shopId}/waba/conversations are automatically set to PENDING status
    • Shopshop owner ismonitors automaticallycustomer set to the authenticated user
    • Shop approval is automatically set to true in current implementation
    • Default country code is "TZ" (Tanzania)
    • Default shop type is "HYBRID"

    Shop Update Rules

    • Only shop owners can update their own shops
    • Shop name changes trigger automatic slug regeneration
    • Deleted shops cannot be updated
    • Category ID must exist and be valid
    • Phone number and email validation applies on updates

    Shop Approval Rules

    • Only users with ROLE_SUPER_ADMIN or ROLE_STAFF_ADMIN can approve shops
    • Approval status change is tracked with timestamp and admin user
    • Approved shops can be featured in search results

    Access Control Rules

    • Public endpoints: Shop listings, shop details (summary), categories, featured shops
    • Authenticated user: Create shop, update own shop, view own shops
    • Admin only: Approve/reject shops, view detailed shop information for all shops
    • Owner/Admin only: View detailed shop information with business details

    Rating and Review Integration

    • Shop responses automatically include rating summaries (average, total count)
    • Shop responses include review summaries (total active reviews, top reviews)
    • Summary statistics combine ratings and reviews from related services
    • User activities show combined review and rating history per user

    Pagination Rules

    • Page numbers are 1-based (first page is page=1)
    • Default page size is 10 items
    • Maximum page size is 100 items
    • Invalid page numbers default to page 1
    • Invalid page sizes default to 10

    Authentication and Authorization

    Bearer Token Authentication

    Include the Bearer token in the Authorization header for protected endpoints:

    Authorization: Bearer your_jwt_token_herechats
    

    Required Roles for Admin Operations

    • Shop Approval: Requires ROLE_SUPER_ADMIN or ROLE_STAFF_ADMIN
    • Detailed Shop Access: Shop owner or admin roles
    • Shop Updates: Shop owner only

    Token Validation

    • Tokens are validated on each request to protected endpoints
    • Expired tokens return 401 Unauthorized
    • Invalid or malformed tokens return 401 Unauthorized
    • Missing tokens on protected endpoints return 401 Unauthorized