{
  "openapi": "3.0.3",
  "info": {
    "title": "MarketKit — API publique",
    "version": "1.172.0",
    "description": "Sous-ensemble public de l’API MarketKit: API vitrine (catalogue, panier, commande, compte client), API stock vendeur (`/vendor-api/*`, clé `vk_…`) et API agents (`/agent/*`, clé `mk_live_…`).\n\nRéponses: `{ \"ok\": true, \"data\": … }` en cas de succès, `{ \"ok\": false, \"error\": … }` en cas d’échec. L’URL de base de votre API vous est communiquée à l’ouverture de votre compte.",
    "contact": {
      "name": "MarketKit",
      "url": "https://marketkit.ai",
      "email": "contact@marketkit.ai"
    },
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://{apiHost}/api/v2",
      "description": "Votre API MarketKit",
      "variables": {
        "apiHost": {
          "default": "api.example.com",
          "description": "Hôte communiqué à l’ouverture de votre compte"
        }
      }
    }
  ],
  "tags": [
    {
      "name": "Agents",
      "description": "API en lecture et serveur MCP pour les agents IA, authentifiés par une clé `mk_live_…`."
    },
    {
      "name": "Bundles"
    },
    {
      "name": "Analytics"
    },
    {
      "name": "Attributes"
    },
    {
      "name": "Auth"
    },
    {
      "name": "Brands"
    },
    {
      "name": "Cart"
    },
    {
      "name": "Categories"
    },
    {
      "name": "Checkout"
    },
    {
      "name": "Store Reservations"
    },
    {
      "name": "Storefront Reviews"
    },
    {
      "name": "Coupons"
    },
    {
      "name": "Customers"
    },
    {
      "name": "ERP Stock by Warehouse"
    },
    {
      "name": "GDPR"
    },
    {
      "name": "Orders"
    },
    {
      "name": "Products"
    },
    {
      "name": "Public Tenant"
    },
    {
      "name": "Storefront Banners"
    },
    {
      "name": "Store Events"
    },
    {
      "name": "Category Alerts"
    },
    {
      "name": "Search"
    },
    {
      "name": "Stores"
    },
    {
      "name": "Vendor API",
      "description": "API stock du vendeur, authentifiée par une clé `vk_…` de portée `stock`."
    },
    {
      "name": "Vendors"
    },
    {
      "name": "Variant Availability"
    }
  ],
  "paths": {
    "/auth/register": {
      "post": {
        "operationId": "authRegister",
        "summary": "Register a new storefront customer",
        "description": "Creates a storefront customer for the resolved tenant (account) and signs them in, returning a 7-day customer JWT plus a rotating `refreshToken` (see `POST /auth/refresh`) and `expiresIn` (access token lifetime, seconds).\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "description": "min 8 chars"
                  },
                  "firstName": {
                    "type": "string",
                    "description": "min 1 char"
                  },
                  "lastName": {
                    "type": "string",
                    "description": "min 1 char"
                  },
                  "phone": {
                    "type": "string",
                    "description": "min 1 char"
                  }
                },
                "required": [
                  "email",
                  "password"
                ]
              },
              "example": {
                "email": "client@example.com",
                "password": "hunter2hunter",
                "firstName": "Amira",
                "lastName": "Ben Salah",
                "phone": "+21620123456"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Customer created and signed in",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AuthResponse"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "token": "<jeton-jwt>",
                    "refreshToken": "q3Jx0n8yKc1Zb5Wm7Tg2Hs4Lp6Vd9Fa0Ue3Ri5Ok7Yw",
                    "expiresIn": 604800,
                    "customer": {
                      "customerId": "8f2c1e4a-1b2c-4d3e-9f10-abcdef012345",
                      "email": "client@example.com",
                      "firstName": "Amira",
                      "lastName": "Ben Salah",
                      "phone": "+21620123456",
                      "emailVerified": false,
                      "createdAt": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Email already registered for this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Conflict"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/auth/login": {
      "post": {
        "operationId": "authLogin",
        "summary": "Log in a storefront customer",
        "description": "Authenticates a customer against the resolved tenant by email/password and returns a 7-day customer JWT plus a rotating `refreshToken` (90 days sliding, 365 days max per sign-in; see `POST /auth/refresh`) and `expiresIn` (access token lifetime, seconds). Each login opens a new token family (one per device).\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "description": "min 1 char"
                  }
                },
                "required": [
                  "email",
                  "password"
                ]
              },
              "example": {
                "email": "client@example.com",
                "password": "hunter2hunter"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Authenticated; returns token + customer profile",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AuthResponse"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "token": "<jeton-jwt>",
                    "refreshToken": "q3Jx0n8yKc1Zb5Wm7Tg2Hs4Lp6Vd9Fa0Ue3Ri5Ok7Yw",
                    "expiresIn": 604800,
                    "customer": {
                      "customerId": "8f2c1e4a-1b2c-4d3e-9f10-abcdef012345",
                      "email": "client@example.com",
                      "firstName": "Amira",
                      "lastName": "Ben Salah",
                      "phone": "+21620123456",
                      "emailVerified": true,
                      "createdAt": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/auth/logout": {
      "post": {
        "operationId": "authLogout",
        "summary": "Log out a customer device (revoke its refresh token)",
        "description": "Revokes the family of the given customer `refreshToken` (this device's sign-in), so it can no longer be refreshed. Idempotent: an unknown or already revoked token answers `revoked: false`. No bearer needed (an app whose access token has expired can still sign out). Without a body it is a no-op, as before. The 7-day access token is stateless and stays valid until it expires — the client drops it.\n\n**Auth:** Public (no authentication); the refresh token is the credential.",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "refreshToken": {
                    "type": "string",
                    "description": "1..512 chars"
                  }
                }
              },
              "example": {
                "refreshToken": "q3Jx0n8yKc1Zb5Wm7Tg2Hs4Lp6Vd9Fa0Ue3Ri5Ok7Yw"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Logged out",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "revoked"
                      ],
                      "properties": {
                        "revoked": {
                          "type": "boolean",
                          "description": "true when this call revoked a live token family."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "message": "Logged out",
                  "data": {
                    "revoked": true
                  }
                }
              }
            }
          },
          "422": {
            "description": "Validation failed (`error` = `VALIDATION`, zod `details`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "VALIDATION",
                  "message": "Jeton de rafraîchissement invalide."
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/auth/me": {
      "get": {
        "operationId": "authMe",
        "summary": "Get the current customer's profile",
        "description": "Returns the profile of the authenticated customer, scoped to the token's customerId and the resolved tenant account.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Auth"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Current customer profile",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/CustomerProfile"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "customerId": "8f2c1e4a-1b2c-4d3e-9f10-abcdef012345",
                    "email": "client@example.com",
                    "firstName": "Amira",
                    "lastName": "Ben Salah",
                    "phone": "+21620123456",
                    "emailVerified": true,
                    "createdAt": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — authenticated principal's realm is not permitted for this route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "authUpdateMe",
        "summary": "Update the current customer's profile",
        "description": "Updates firstName, lastName and/or phone for the authenticated customer. Scoped strictly to the caller's own customerId (no client-supplied id). At least one field must be present.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Auth"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "firstName": {
                    "type": "string",
                    "description": "min 1 char"
                  },
                  "lastName": {
                    "type": "string",
                    "description": "min 1 char"
                  },
                  "phone": {
                    "type": "string",
                    "description": "min 1 char"
                  }
                }
              },
              "example": {
                "firstName": "Amira",
                "phone": "+21629876543"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated customer profile",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/CustomerProfile"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "customerId": "8f2c1e4a-1b2c-4d3e-9f10-abcdef012345",
                    "email": "client@example.com",
                    "firstName": "Amira",
                    "lastName": "Ben Salah",
                    "phone": "+21629876543",
                    "emailVerified": true,
                    "createdAt": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — authenticated principal's realm is not permitted for this route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "authDeleteMe",
        "summary": "Delete the current customer's account",
        "description": "Self-service account deletion (Apple / Google requirement). Scoped strictly to the token's customerId; the password confirms the action.\n\nThe account is anonymised, not removed: name, email, phone and saved addresses are erased, sign-in is disabled, every refresh token is deleted, and every existing access token is refused afterwards (401 on protected routes, treated as a guest on guest-friendly ones). The email is released, so a later signup with it creates a new, unrelated account. Orders and invoices are kept in anonymised form for accounting.\n\nDeletion is refused with 409 `ACTIVE_ORDERS` while an order is `confirmed`, `processing`, `in_fulfillment` or `shipped`, or `pending` and placed less than 30 days ago.\n\nA wrong password is 403, never 401: clients treat 401 as an expired session. An account with no password (legacy customers) gets 403 `WRONG_PASSWORD` with a message asking to reset the password first.\n\nAll `error.message` values are French and meant to be shown to the customer.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Auth"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "password"
                ],
                "properties": {
                  "password": {
                    "type": "string",
                    "minLength": 1,
                    "description": "The customer's current password."
                  }
                }
              },
              "example": {
                "password": "correct-horse-battery"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Account anonymised.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AccountDeleted"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "deleted": true,
                    "deletedAt": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "The password is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountDeletionError"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "code": "PASSWORD_REQUIRED",
                    "message": "Saisissez votre mot de passe pour confirmer la suppression de votre compte."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token, or the account is already deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Wrong password (`WRONG_PASSWORD`), an account with no password, or a realm other than customer.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/AccountDeletionError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                },
                "example": {
                  "ok": false,
                  "error": {
                    "code": "WRONG_PASSWORD",
                    "message": "Mot de passe incorrect. Votre compte n'a pas été supprimé."
                  }
                }
              }
            }
          },
          "409": {
            "description": "An order is still in progress (`ACTIVE_ORDERS`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountDeletionError"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "code": "ACTIVE_ORDERS",
                    "message": "Une commande est en cours de traitement ou de livraison. Vous pourrez supprimer votre compte une fois qu'elle sera livrée ou annulée."
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountDeletionError"
                }
              }
            }
          },
          "503": {
            "description": "The account state could not be checked. Retry; this does not mean the session expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Service Unavailable"
                }
              }
            }
          }
        }
      }
    },
    "/auth/change-password": {
      "post": {
        "operationId": "authChangePassword",
        "summary": "Change the current customer's password",
        "description": "Verifies the customer's current password and sets a new one. A wrong current password is 403 `WRONG_PASSWORD`, never 401: clients treat 401 as an expired session. An account with no password (legacy customers) gets 403 `NO_PASSWORD` and must use the reset flow. Revokes every refresh token of the customer (all devices) and refuses, with 401, every access token issued before the change; returns a fresh session for the caller in `data` (same shape as login), so this device stays signed in.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Auth"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "currentPassword": {
                    "type": "string",
                    "description": "min 1 char"
                  },
                  "newPassword": {
                    "type": "string",
                    "description": "min 8 chars"
                  }
                },
                "required": [
                  "currentPassword",
                  "newPassword"
                ]
              },
              "example": {
                "currentPassword": "hunter2hunter",
                "newPassword": "newpass9newpass9"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Password changed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/AuthResponse"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "message": "Password changed"
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Wrong current password (`WRONG_PASSWORD`), an account with no password (`NO_PASSWORD`), or a realm other than customer.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/PasswordChangeError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorResponse"
                    }
                  ]
                },
                "example": {
                  "ok": false,
                  "error": {
                    "code": "WRONG_PASSWORD",
                    "message": "Mot de passe actuel incorrect. Votre mot de passe n'a pas été modifié."
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/auth/forgot-password": {
      "post": {
        "operationId": "authForgotPassword",
        "summary": "Request a customer password-reset email",
        "description": "Public, tenant-resolved (falls back to default account). Sends a reset link if the email matches an active customer. Always returns 200 with a fixed message and never reveals whether the email exists.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                },
                "required": [
                  "email"
                ]
              },
              "example": {
                "email": "client@example.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generic acknowledgement (no account-existence leak)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "message": "Operation completed"
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/auth/reset-password": {
      "post": {
        "operationId": "authResetPassword",
        "summary": "Reset a customer password with a token",
        "description": "Public. Consumes a single-use reset token (validated for existence, unexpired, unused) and sets a new password. Returns 400 on an invalid, expired or already-used token. Revokes every refresh token of the customer (all devices) and refuses, with 401, every access token issued before the reset.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "description": "min 1 char; raw reset token from the email link"
                  },
                  "newPassword": {
                    "type": "string",
                    "description": "min 8 chars"
                  }
                },
                "required": [
                  "token",
                  "newPassword"
                ]
              },
              "example": {
                "token": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
                "newPassword": "newpass9newpass9"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Password has been reset",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "message": "Operation completed"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or expired token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/auth/verify-email": {
      "post": {
        "operationId": "authVerifyEmail",
        "summary": "Verify a customer email with a token",
        "description": "Public, tenant-resolved (falls back to default account). Consumes a single-use verification token (validated for existence, unexpired, unused), sets the customer's email as verified, links any prior guest orders placed with that email, and returns a fresh 7-day customer JWT so the storefront can sign the user straight in. Returns 400 on an invalid, expired or already-used token.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "token": {
                    "type": "string",
                    "description": "min 1 char; raw verification token from the email link"
                  }
                },
                "required": [
                  "token"
                ]
              },
              "example": {
                "token": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Email verified and customer signed in",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AuthResponse"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "token": "<jeton-jwt>",
                    "refreshToken": "q3Jx0n8yKc1Zb5Wm7Tg2Hs4Lp6Vd9Fa0Ue3Ri5Ok7Yw",
                    "expiresIn": 604800,
                    "customer": {
                      "customerId": "8f2c1e4a-1b2c-4d3e-9f10-abcdef012345",
                      "email": "client@example.com",
                      "firstName": "Amira",
                      "lastName": "Ben Salah",
                      "phone": "+21620123456",
                      "emailVerified": true,
                      "createdAt": {}
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid or expired token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Invalid or expired token"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/auth/resend-verification": {
      "post": {
        "operationId": "authResendVerification",
        "summary": "Resend a customer email-verification link",
        "description": "Public, tenant-resolved (falls back to default account), rate-limited per IP. Sends a fresh verification link if the email matches an active, not-yet-verified customer. Always returns 200 with a fixed message and never reveals whether the email exists or is already verified.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                },
                "required": [
                  "email"
                ]
              },
              "example": {
                "email": "client@example.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generic acknowledgement (no account existence/state leak)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "message": "If an unverified account exists for that email, a verification link has been sent."
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/auth/refresh": {
      "post": {
        "operationId": "authRefresh",
        "summary": "Rotate a customer refresh token",
        "description": "Rotates a customer refresh token obtained from `POST /auth/login` or `POST /auth/register` (body `{ refreshToken }`). Answers the same `AuthResponse` as login (`token`, `refreshToken`, `expiresIn`, `customer`).\n\nThe presented token is consumed; the new one belongs to the same sign-in and gets a fresh 90 days, never past 365 days from the sign-in. Presenting an already-rotated token again revokes the whole sign-in (reuse detection), except within a few seconds of its rotation (a retried request), where it is only refused.\n\nUnknown, expired, revoked or reused tokens, and a deleted or suspended customer, answer `401 { ok:false, error:'INVALID_REFRESH_TOKEN', message }`. A bad body is `422`. Password change, password reset and account deletion revoke every refresh token of the customer.\n\n**Auth:** Public (no authentication); the refresh token is the credential.",
        "tags": [
          "Auth"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "title": "CustomerRefreshRequest",
                "required": [
                  "refreshToken"
                ],
                "properties": {
                  "refreshToken": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "The refresh token returned by login, register or the previous refresh."
                  }
                }
              },
              "example": {
                "refreshToken": "q3Jx0n8yKc1Zb5Wm7Tg2Hs4Lp6Vd9Fa0Ue3Ri5Ok7Yw"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "New access token + rotated refresh token (same shape as login).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AuthResponse"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "token": "<jeton-jwt>",
                    "refreshToken": "Zr8Tq1Lm4Xc7Vb0Ny3Hk6Ds9Pa2We5Jf8Gu1Oi4Ql7E",
                    "expiresIn": 604800,
                    "customer": {
                      "customerId": "8f2c1e4a-1b2c-4d3e-9f10-abcdef012345",
                      "email": "client@example.com",
                      "firstName": "Amira",
                      "lastName": "Ben Salah",
                      "phone": "+21620123456",
                      "emailVerified": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unknown, expired, revoked or reused refresh token, or a deleted / suspended customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "INVALID_REFRESH_TOKEN",
                  "message": "Votre session a expiré. Veuillez vous reconnecter."
                }
              }
            }
          },
          "422": {
            "description": "Invalid body (`error` = `VALIDATION`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "VALIDATION",
                  "message": "Jeton de rafraîchissement invalide."
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/products": {
      "get": {
        "operationId": "listProducts",
        "deprecated": true,
        "summary": "List storefront products",
        "description": "Returns a paginated list of published products with an active marketplace listing for the resolved tenant (storefront invariant. Whatever the sort, products a shopper can act on come first and « dead ends » (`acceptsOnlineOrders: false` and `vendorWhatsapp: null`) come last, each group in the sort's own order. Supports filtering by category, vendor, brand(s), price range, on-sale, stock status, free-text search and variant attributes. Tenant is resolved from request context, falling back to the default account.\n\n**Multi-select:** `brandId=a,b` lists products of brand a OR b; `attr[color]=noir,blanc&attr[size]=M` lists products carrying (noir OR blanc) AND M — OR inside one attribute, AND across attributes. Attribute keys accept the PIM code or a legacy name (`attr[Couleur]` = `attr[color]`). At most 20 values per parameter and 6 attributes; beyond that the request is a 400 (never silently truncated).\n\n**Attribute values are matched on their normalised slug** — case, accents and separators are folded, so `Noir` = `noir` = `NOIR` and `Bleu Marine` = `bleu-marine`. The legacy `attributeName` + `attributeValue` pair keeps working (one more single-value attribute; its value is never split on commas). Stored product data is not rewritten.\n\nThe filter sidebar for the same query is `GET /products/facets`.\n\nProducts of a vendor with « masquer les produits en rupture » switched on are left out while they have no sellable stock (no `instock`/`onbackorder` on the product nor on any live variation) — resolved at read time, before pagination, so `total` stays right; this covers listings, the home page, related products and the sitemap feed (`indexable=true`).\n\n**Auth:** Public (no authentication).\n\nUse /public/products; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Products"
        ],
        "parameters": [
          {
            "name": "X-Channel",
            "in": "header",
            "required": false,
            "description": "Distribution channel selecting per-channel storefront display config (independent toggles per marketplace tenant). Display config, not authentication. Absent header defaults to `web`.",
            "schema": {
              "type": "string",
              "enum": [
                "web",
                "mobile"
              ],
              "default": "web"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page (min 1)",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size (1-100)",
            "schema": {
              "type": "integer",
              "default": 24
            }
          },
          {
            "name": "madeInTunisia",
            "in": "query",
            "required": false,
            "description": "`1` / `true` keeps only « made in Tunisia » products (product override ?? vendor default ?? false). `0` / `false` / absent = no filter (it never selects the non-Tunisian products).",
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "0",
                "true",
                "false"
              ]
            }
          },
          {
            "name": "stockFirst",
            "in": "query",
            "required": false,
            "description": "`1` / `true`: products in stock first, then the rest, each group in the sort's own order (after the buyable-first rule). Totals unchanged. Absent = unchanged order. Used by storefront brand pages.",
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "0",
                "true",
                "false"
              ]
            }
          },
          {
            "name": "indexable",
            "in": "query",
            "required": false,
            "description": "Sitemap feed flag. When `true`, products flagged `noindex` (via the per-product SEO panel) are excluded so the storefront sitemap only emits indexable URLs. Default (unset) keeps the normal browse behaviour — noindex products still appear on category pages.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category filter — a master-tree category **id or slug** (id tried first); lists the whole subtree. `categoryId` and `categorySlug` are explicit aliases. An unknown category is a 400 `UNKNOWN_CATEGORY` (never the whole catalogue); several category parameters naming different categories are a 400 `CONFLICTING_CATEGORY_FILTERS`. A blank value is ignored.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categoryId",
            "in": "query",
            "required": false,
            "description": "Alias of `category` taking a category **id** only (mobile app).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categorySlug",
            "in": "query",
            "required": false,
            "description": "Alias of `category` taking a category **slug** only.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "vendor_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Free-text title match",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "- `newest` (default) — most recently created first.\n- `price_asc` / `price_desc` — by the card's resolved `price` (the cheapest variant's selling price for a product with variants), not the raw product column.\n- `name` — title A→Z.\n- `bestselling` — units sold over the last 90 days (orders not cancelled / refunded / failed, the vendor source row's sales credited to the storefront copy, a product group's sales shared by its members); ties and unsold products follow, newest first. Ranking recomputed at most every 10 minutes.\n- `relevance` — with `q`: exact title > title starts with `q` > every word of `q` in the title > title contains `q`, brand / description matches as a bonus; ties newest first. **Without `q` it is `newest`.**",
            "schema": {
              "type": "string",
              "enum": [
                "newest",
                "price_asc",
                "price_desc",
                "name",
                "bestselling",
                "relevance"
              ],
              "default": "newest"
            }
          },
          {
            "name": "brandId",
            "in": "query",
            "required": false,
            "description": "Brand id, or a comma-separated list of brand ids (OR). At most 20.",
            "schema": {
              "type": "string"
            },
            "example": "brd_a,brd_b"
          },
          {
            "name": "minPrice",
            "in": "query",
            "required": false,
            "description": "Lower bound on the card's resolved `price` (cheapest variant for a product with variants).",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "maxPrice",
            "in": "query",
            "required": false,
            "description": "Upper bound on the card's resolved `price` (cheapest variant for a product with variants).",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "onSale",
            "in": "query",
            "required": false,
            "description": "true = only products whose card is on sale — the resolved `onSale` (for a product with variants, its cheapest variant's promotion, even when the product row carries none).",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "stockStatus",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "instock",
                "outofstock",
                "onbackorder"
              ]
            }
          },
          {
            "name": "attributeName",
            "in": "query",
            "required": false,
            "description": "Variant attribute name (PIM code or legacy name); must be paired with attributeValue. Legacy single-value form of `attr[...]`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "attributeValue",
            "in": "query",
            "required": false,
            "description": "Variant attribute value, matched case/accent-insensitively on its normalised slug (`Noir` = `noir`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "attr",
            "in": "query",
            "required": false,
            "description": "Attribute filters, one key per attribute: `attr[color]=noir,blanc&attr[size]=M`. Comma-separated values are OR'ed, attributes are AND'ed. Values are matched on their normalised slug (case/accent-insensitive). At most 6 attributes, 20 values each. A stored value that itself holds a comma (`24/16H/6,5CM`) can be sent as its `slug` (`24-16h-6-5cm`) or as is: comma pieces that match no value on their own are re-joined when the join is a known value, while pieces that are values stay separate (`Blanc,Noir` = blanc OR noir). Prefer the `slug`.",
            "style": "deepObject",
            "explode": true,
            "schema": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "example": {
              "color": "noir,blanc",
              "size": "M"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated product list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/ProductListPage"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "prd_123",
                        "slug": "casque-audio-bluetooth",
                        "name": "Casque Bluetooth",
                        "price": 89.9,
                        "compareAtPrice": 129,
                        "imageUrl": "https://cdn.example.com/p/123.jpg",
                        "vendorId": "ven_42",
                        "vendorName": "TechStore Tunis",
                        "inStock": true,
                        "createdAt": {}
                      }
                    ],
                    "total": 1,
                    "page": 1,
                    "limit": 24
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — a query parameter failed validation (zod field errors), or the category filter names no category of the master tree (`error.code = UNKNOWN_CATEGORY`) or several different ones (`error.code = CONFLICTING_CATEGORY_FILTERS`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "validation": {
                    "value": {
                      "ok": false,
                      "error": {
                        "formErrors": [],
                        "fieldErrors": {
                          "field": [
                            "Invalid input"
                          ]
                        }
                      }
                    }
                  },
                  "unknownCategory": {
                    "value": {
                      "ok": false,
                      "error": {
                        "code": "UNKNOWN_CATEGORY",
                        "message": "categoryId: unknown category \"cat_nope\""
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/products": {
      "get": {
        "operationId": "listProductsPublic",
        "summary": "List storefront products",
        "description": "Returns a paginated list of published products with an active marketplace listing for the resolved tenant (storefront invariant. Whatever the sort, products a shopper can act on come first and « dead ends » (`acceptsOnlineOrders: false` and `vendorWhatsapp: null`) come last, each group in the sort's own order. Supports filtering by category, vendor, brand(s), price range, on-sale, stock status, free-text search and variant attributes. Tenant is resolved from request context, falling back to the default account.\n\n**Multi-select:** `brandId=a,b` lists products of brand a OR b; `attr[color]=noir,blanc&attr[size]=M` lists products carrying (noir OR blanc) AND M — OR inside one attribute, AND across attributes. Attribute keys accept the PIM code or a legacy name (`attr[Couleur]` = `attr[color]`). At most 20 values per parameter and 6 attributes; beyond that the request is a 400 (never silently truncated).\n\n**Attribute values are matched on their normalised slug** — case, accents and separators are folded, so `Noir` = `noir` = `NOIR` and `Bleu Marine` = `bleu-marine`. The legacy `attributeName` + `attributeValue` pair keeps working (one more single-value attribute; its value is never split on commas). Stored product data is not rewritten.\n\nThe filter sidebar for the same query is `GET /products/facets`.\n\nProducts of a vendor with « masquer les produits en rupture » switched on are left out while they have no sellable stock (no `instock`/`onbackorder` on the product nor on any live variation) — resolved at read time, before pagination, so `total` stays right; this covers listings, the home page, related products and the sitemap feed (`indexable=true`).\n\n**Auth:** Public (no authentication).\n\nSame route as `GET /products` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Products"
        ],
        "parameters": [
          {
            "name": "X-Channel",
            "in": "header",
            "required": false,
            "description": "Distribution channel selecting per-channel storefront display config (independent toggles per marketplace tenant). Display config, not authentication. Absent header defaults to `web`.",
            "schema": {
              "type": "string",
              "enum": [
                "web",
                "mobile"
              ],
              "default": "web"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page (min 1)",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size (1-100)",
            "schema": {
              "type": "integer",
              "default": 24
            }
          },
          {
            "name": "madeInTunisia",
            "in": "query",
            "required": false,
            "description": "`1` / `true` keeps only « made in Tunisia » products (product override ?? vendor default ?? false). `0` / `false` / absent = no filter (it never selects the non-Tunisian products).",
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "0",
                "true",
                "false"
              ]
            }
          },
          {
            "name": "stockFirst",
            "in": "query",
            "required": false,
            "description": "`1` / `true`: products in stock first, then the rest, each group in the sort's own order (after the buyable-first rule). Totals unchanged. Absent = unchanged order. Used by storefront brand pages.",
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "0",
                "true",
                "false"
              ]
            }
          },
          {
            "name": "indexable",
            "in": "query",
            "required": false,
            "description": "Sitemap feed flag. When `true`, products flagged `noindex` (via the per-product SEO panel) are excluded so the storefront sitemap only emits indexable URLs. Default (unset) keeps the normal browse behaviour — noindex products still appear on category pages.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category filter — a master-tree category **id or slug** (id tried first); lists the whole subtree. `categoryId` and `categorySlug` are explicit aliases. An unknown category is a 400 `UNKNOWN_CATEGORY` (never the whole catalogue); several category parameters naming different categories are a 400 `CONFLICTING_CATEGORY_FILTERS`. A blank value is ignored.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categoryId",
            "in": "query",
            "required": false,
            "description": "Alias of `category` taking a category **id** only (mobile app).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categorySlug",
            "in": "query",
            "required": false,
            "description": "Alias of `category` taking a category **slug** only.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "vendor_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Free-text title match",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "- `newest` (default) — most recently created first.\n- `price_asc` / `price_desc` — by the card's resolved `price` (the cheapest variant's selling price for a product with variants), not the raw product column.\n- `name` — title A→Z.\n- `bestselling` — units sold over the last 90 days (orders not cancelled / refunded / failed, the vendor source row's sales credited to the storefront copy, a product group's sales shared by its members); ties and unsold products follow, newest first. Ranking recomputed at most every 10 minutes.\n- `relevance` — with `q`: exact title > title starts with `q` > every word of `q` in the title > title contains `q`, brand / description matches as a bonus; ties newest first. **Without `q` it is `newest`.**",
            "schema": {
              "type": "string",
              "enum": [
                "newest",
                "price_asc",
                "price_desc",
                "name",
                "bestselling",
                "relevance"
              ],
              "default": "newest"
            }
          },
          {
            "name": "brandId",
            "in": "query",
            "required": false,
            "description": "Brand id, or a comma-separated list of brand ids (OR). At most 20.",
            "schema": {
              "type": "string"
            },
            "example": "brd_a,brd_b"
          },
          {
            "name": "minPrice",
            "in": "query",
            "required": false,
            "description": "Lower bound on the card's resolved `price` (cheapest variant for a product with variants).",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "maxPrice",
            "in": "query",
            "required": false,
            "description": "Upper bound on the card's resolved `price` (cheapest variant for a product with variants).",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "onSale",
            "in": "query",
            "required": false,
            "description": "true = only products whose card is on sale — the resolved `onSale` (for a product with variants, its cheapest variant's promotion, even when the product row carries none).",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "stockStatus",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "instock",
                "outofstock",
                "onbackorder"
              ]
            }
          },
          {
            "name": "attributeName",
            "in": "query",
            "required": false,
            "description": "Variant attribute name (PIM code or legacy name); must be paired with attributeValue. Legacy single-value form of `attr[...]`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "attributeValue",
            "in": "query",
            "required": false,
            "description": "Variant attribute value, matched case/accent-insensitively on its normalised slug (`Noir` = `noir`).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "attr",
            "in": "query",
            "required": false,
            "description": "Attribute filters, one key per attribute: `attr[color]=noir,blanc&attr[size]=M`. Comma-separated values are OR'ed, attributes are AND'ed. Values are matched on their normalised slug (case/accent-insensitive). At most 6 attributes, 20 values each. A stored value that itself holds a comma (`24/16H/6,5CM`) can be sent as its `slug` (`24-16h-6-5cm`) or as is: comma pieces that match no value on their own are re-joined when the join is a known value, while pieces that are values stay separate (`Blanc,Noir` = blanc OR noir). Prefer the `slug`.",
            "style": "deepObject",
            "explode": true,
            "schema": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "example": {
              "color": "noir,blanc",
              "size": "M"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated product list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/ProductListPage"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "prd_123",
                        "slug": "casque-audio-bluetooth",
                        "name": "Casque Bluetooth",
                        "price": 89.9,
                        "compareAtPrice": 129,
                        "imageUrl": "https://cdn.example.com/p/123.jpg",
                        "vendorId": "ven_42",
                        "vendorName": "TechStore Tunis",
                        "inStock": true,
                        "createdAt": {}
                      }
                    ],
                    "total": 1,
                    "page": 1,
                    "limit": 24
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — a query parameter failed validation (zod field errors), or the category filter names no category of the master tree (`error.code = UNKNOWN_CATEGORY`) or several different ones (`error.code = CONFLICTING_CATEGORY_FILTERS`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "validation": {
                    "value": {
                      "ok": false,
                      "error": {
                        "formErrors": [],
                        "fieldErrors": {
                          "field": [
                            "Invalid input"
                          ]
                        }
                      }
                    }
                  },
                  "unknownCategory": {
                    "value": {
                      "ok": false,
                      "error": {
                        "code": "UNKNOWN_CATEGORY",
                        "message": "categoryId: unknown category \"cat_nope\""
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/products/facets": {
      "get": {
        "operationId": "getProductFacets",
        "deprecated": true,
        "summary": "Facet counts of a storefront product listing",
        "description": "The filter sidebar of a listing: accepts EXACTLY the filters of `GET /products` (`category` / `categoryId` / `categorySlug` — an unknown or conflicting category is the same 400, `vendor_id`, `q`, `indexable`, `brandId`, `attr[...]`, `attributeName`/`attributeValue`, `minPrice`/`maxPrice`, `onSale`, `stockStatus`; `page`/`limit`/`sort` are accepted and ignored) and counts on exactly the set `GET /products` lists for them — same visibility rules (active listing, hidden group offers, hidden out-of-stock products, `X-Channel` display mode). `total` equals the `/products` `total`.\n\nStandard facet semantics: a group's counts ignore that group's OWN selection and apply every other one — with `brandId=nike` the other brands keep their counts so a second brand can be added; with `attr[color]=noir` the other colours keep theirs. `price` ignores `minPrice`/`maxPrice`, `stockStatus`/`inStock` ignore `stockStatus`, `onSale` ignores `onSale`.\n\nAttribute values are grouped by normalised slug (`Noir` / `noir` / `NOIR` = one value `noir`, labelled with its most frequent spelling); the `brand` axis, metadata axes and empty values are left out. At most 100 values per attribute (most frequent first, selected values always kept).\n\nCacheable: `Cache-Control: public, max-age=300`, `Vary: X-Channel`.\n\n**Auth:** Public (no authentication).\n\nUse /public/products/facets; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Products"
        ],
        "parameters": [
          {
            "name": "X-Channel",
            "in": "header",
            "required": false,
            "description": "Distribution channel (display config). Absent header defaults to `web`.",
            "schema": {
              "type": "string",
              "enum": [
                "web",
                "mobile"
              ],
              "default": "web"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category id or slug (its whole subtree). Same resolution and 400s as `GET /products`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categoryId",
            "in": "query",
            "required": false,
            "description": "Alias of `category` taking an id only.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categorySlug",
            "in": "query",
            "required": false,
            "description": "Alias of `category` taking a slug only.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "vendor_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Free-text title match",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "madeInTunisia",
            "in": "query",
            "required": false,
            "description": "`1` / `true` keeps only « made in Tunisia » products (product override ?? vendor default ?? false). `0` / `false` / absent = no filter (it never selects the non-Tunisian products).",
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "0",
                "true",
                "false"
              ]
            }
          },
          {
            "name": "indexable",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "brandId",
            "in": "query",
            "required": false,
            "description": "Brand id or comma-separated ids (OR). At most 20.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "attr",
            "in": "query",
            "required": false,
            "description": "Attribute filters `attr[color]=noir,blanc&attr[size]=M` (OR inside, AND across; normalised values).",
            "style": "deepObject",
            "explode": true,
            "schema": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            }
          },
          {
            "name": "attributeName",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "attributeValue",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "minPrice",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "maxPrice",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "onSale",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "stockStatus",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "instock",
                "outofstock",
                "onbackorder"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Facet counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/ProductFacets"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "total": 712,
                    "brands": [
                      {
                        "id": "brd_a",
                        "name": "Marque Exemple",
                        "slug": "lee-cooper",
                        "count": 120,
                        "selected": false
                      }
                    ],
                    "attributes": [
                      {
                        "code": "color",
                        "name": "Couleur",
                        "values": [
                          {
                            "slug": "noir",
                            "value": "noir",
                            "count": 712,
                            "selected": true
                          },
                          {
                            "slug": "blanc",
                            "value": "blanc",
                            "count": 260,
                            "selected": false
                          }
                        ]
                      }
                    ],
                    "price": {
                      "min": 9.9,
                      "max": 899
                    },
                    "inStock": 650,
                    "stockStatus": {
                      "instock": 650,
                      "outofstock": 62,
                      "onbackorder": 0
                    },
                    "onSale": 41,
                    "madeInTunisia": 128,
                    "vendors": [
                      {
                        "id": "vnd_exemple",
                        "name": "Boutique Exemple",
                        "count": 248,
                        "inStock": 176
                      }
                    ],
                    "inStockPrice": {
                      "min": 12,
                      "max": 749,
                      "median": 199
                    },
                    "inStockOnSale": 186
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — a parameter failed validation (or too many values / attributes).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "brandId: at most 20 values"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/products/facets": {
      "get": {
        "operationId": "getProductFacetsPublic",
        "summary": "Facet counts of a storefront product listing",
        "description": "The filter sidebar of a listing: accepts EXACTLY the filters of `GET /products` (`category` / `categoryId` / `categorySlug` — an unknown or conflicting category is the same 400, `vendor_id`, `q`, `indexable`, `brandId`, `attr[...]`, `attributeName`/`attributeValue`, `minPrice`/`maxPrice`, `onSale`, `stockStatus`; `page`/`limit`/`sort` are accepted and ignored) and counts on exactly the set `GET /products` lists for them — same visibility rules (active listing, hidden group offers, hidden out-of-stock products, `X-Channel` display mode). `total` equals the `/products` `total`.\n\nStandard facet semantics: a group's counts ignore that group's OWN selection and apply every other one — with `brandId=nike` the other brands keep their counts so a second brand can be added; with `attr[color]=noir` the other colours keep theirs. `price` ignores `minPrice`/`maxPrice`, `stockStatus`/`inStock` ignore `stockStatus`, `onSale` ignores `onSale`.\n\nAttribute values are grouped by normalised slug (`Noir` / `noir` / `NOIR` = one value `noir`, labelled with its most frequent spelling); the `brand` axis, metadata axes and empty values are left out. At most 100 values per attribute (most frequent first, selected values always kept).\n\nCacheable: `Cache-Control: public, max-age=300`, `Vary: X-Channel`.\n\n**Auth:** Public (no authentication).\n\nSame route as `GET /products/facets` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Products"
        ],
        "parameters": [
          {
            "name": "X-Channel",
            "in": "header",
            "required": false,
            "description": "Distribution channel (display config). Absent header defaults to `web`.",
            "schema": {
              "type": "string",
              "enum": [
                "web",
                "mobile"
              ],
              "default": "web"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Category id or slug (its whole subtree). Same resolution and 400s as `GET /products`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categoryId",
            "in": "query",
            "required": false,
            "description": "Alias of `category` taking an id only.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "categorySlug",
            "in": "query",
            "required": false,
            "description": "Alias of `category` taking a slug only.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "vendor_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Free-text title match",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "madeInTunisia",
            "in": "query",
            "required": false,
            "description": "`1` / `true` keeps only « made in Tunisia » products (product override ?? vendor default ?? false). `0` / `false` / absent = no filter (it never selects the non-Tunisian products).",
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "0",
                "true",
                "false"
              ]
            }
          },
          {
            "name": "indexable",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "brandId",
            "in": "query",
            "required": false,
            "description": "Brand id or comma-separated ids (OR). At most 20.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "attr",
            "in": "query",
            "required": false,
            "description": "Attribute filters `attr[color]=noir,blanc&attr[size]=M` (OR inside, AND across; normalised values).",
            "style": "deepObject",
            "explode": true,
            "schema": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            }
          },
          {
            "name": "attributeName",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "attributeValue",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "minPrice",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "maxPrice",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "onSale",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "stockStatus",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "instock",
                "outofstock",
                "onbackorder"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Facet counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/ProductFacets"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "total": 712,
                    "brands": [
                      {
                        "id": "brd_a",
                        "name": "Marque Exemple",
                        "slug": "lee-cooper",
                        "count": 120,
                        "selected": false
                      }
                    ],
                    "attributes": [
                      {
                        "code": "color",
                        "name": "Couleur",
                        "values": [
                          {
                            "slug": "noir",
                            "value": "noir",
                            "count": 712,
                            "selected": true
                          },
                          {
                            "slug": "blanc",
                            "value": "blanc",
                            "count": 260,
                            "selected": false
                          }
                        ]
                      }
                    ],
                    "price": {
                      "min": 9.9,
                      "max": 899
                    },
                    "inStock": 650,
                    "stockStatus": {
                      "instock": 650,
                      "outofstock": 62,
                      "onbackorder": 0
                    },
                    "onSale": 41,
                    "madeInTunisia": 128,
                    "vendors": [
                      {
                        "id": "vnd_exemple",
                        "name": "Boutique Exemple",
                        "count": 248,
                        "inStock": 176
                      }
                    ],
                    "inStockPrice": {
                      "min": 12,
                      "max": 749,
                      "median": 199
                    },
                    "inStockOnSale": 186
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — a parameter failed validation (or too many values / attributes).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "brandId: at most 20 values"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/products/{slug}": {
      "get": {
        "operationId": "getProductBySlug",
        "deprecated": true,
        "summary": "Get a product by slug",
        "description": "Returns the full product detail (variants, option axes, images, and same-EAN seller offers) for a published product with an active marketplace listing for the resolved tenant. Sets a public Cache-Control header.\n\n« Masquer les produits en rupture »: an out-of-stock offer of a vendor with the setting on is removed from `offers[]`; when the page's own product is that offer and no other seller is left, the response is 404 (the storefront renders its not-found page, noindex).\n\n**Merged fiche (301):** when no live product owns the slug but it is the URL of a duplicate fiche merged into another one (or the previous URL of a fiche that inherited an older one), the response is **301** with `Location` = the same path ending in the kept fiche's CURRENT slug, and the body names it (`code: PRODUCT_MOVED`, `redirect.slug`). A client that follows redirects receives the kept product directly; the storefront compares `data.slug` with the requested slug and issues its own permanent redirect. A target that is not published or not actively listed gives the usual 404.\n\n**Auth:** Public (no authentication).\n\nUse /public/products/{slug}; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Products"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Product slug (min 1 char)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Product detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/ProductDetail"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "prd_123",
                    "slug": "casque-audio-bluetooth",
                    "name": "Casque Bluetooth",
                    "price": 89.9,
                    "compareAtPrice": 129,
                    "imageUrl": "https://cdn.example.com/p/123.jpg",
                    "vendorId": "ven_42",
                    "vendorName": "TechStore Tunis",
                    "inStock": true,
                    "createdAt": {},
                    "description": "Casque sans fil...",
                    "ean": "0123456789012",
                    "commissionType": "percent",
                    "commissionRate": 12.5,
                    "variants": [
                      {
                        "id": "var_1",
                        "sku": "CSQ-BLK",
                        "name": "Noir",
                        "price": 89.9,
                        "stock": 5,
                        "inStock": true,
                        "attributes": [
                          {
                            "name": "Couleur",
                            "value": "Noir"
                          }
                        ],
                        "imageUrl": null
                      }
                    ],
                    "options": [
                      {
                        "name": "Couleur",
                        "values": [
                          "Noir",
                          "Blanc"
                        ]
                      }
                    ],
                    "images": [
                      {
                        "id": "0",
                        "url": "https://cdn.example.com/p/123.jpg",
                        "alt": null,
                        "position": 0
                      }
                    ],
                    "offers": [
                      {
                        "productId": "prd_123",
                        "vendorId": "ven_42",
                        "vendorName": "TechStore Tunis",
                        "vendorWhatsapp": "21620000000",
                        "price": 89.9,
                        "inStock": true,
                        "isCanonical": true
                      }
                    ]
                  }
                }
              }
            }
          },
          "301": {
            "description": "Moved — the slug belongs to a merged duplicate fiche; `Location` points to the kept fiche.",
            "headers": {
              "Location": {
                "description": "Same request path ending in the kept fiche's current slug (query string kept).",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductMovedResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Product moved",
                  "code": "PRODUCT_MOVED",
                  "redirect": {
                    "slug": "chaussures-honfleur-lea-metallic-le-coq-sportif",
                    "productId": "fc4ee543-9213-4073-a04c-9e62772e1a70"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/products/{slug}": {
      "get": {
        "operationId": "getProductBySlugPublic",
        "summary": "Get a product by slug",
        "description": "Returns the full product detail (variants, option axes, images, and same-EAN seller offers) for a published product with an active marketplace listing for the resolved tenant. Sets a public Cache-Control header.\n\n« Masquer les produits en rupture »: an out-of-stock offer of a vendor with the setting on is removed from `offers[]`; when the page's own product is that offer and no other seller is left, the response is 404 (the storefront renders its not-found page, noindex).\n\n**Merged fiche (301):** when no live product owns the slug but it is the URL of a duplicate fiche merged into another one (or the previous URL of a fiche that inherited an older one), the response is **301** with `Location` = the same path ending in the kept fiche's CURRENT slug, and the body names it (`code: PRODUCT_MOVED`, `redirect.slug`). A client that follows redirects receives the kept product directly; the storefront compares `data.slug` with the requested slug and issues its own permanent redirect. A target that is not published or not actively listed gives the usual 404.\n\n**Auth:** Public (no authentication).\n\nSame route as `GET /products/{slug}` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Products"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Product slug (min 1 char)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Product detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/ProductDetail"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "prd_123",
                    "slug": "casque-audio-bluetooth",
                    "name": "Casque Bluetooth",
                    "price": 89.9,
                    "compareAtPrice": 129,
                    "imageUrl": "https://cdn.example.com/p/123.jpg",
                    "vendorId": "ven_42",
                    "vendorName": "TechStore Tunis",
                    "inStock": true,
                    "createdAt": {},
                    "description": "Casque sans fil...",
                    "ean": "0123456789012",
                    "commissionType": "percent",
                    "commissionRate": 12.5,
                    "variants": [
                      {
                        "id": "var_1",
                        "sku": "CSQ-BLK",
                        "name": "Noir",
                        "price": 89.9,
                        "stock": 5,
                        "inStock": true,
                        "attributes": [
                          {
                            "name": "Couleur",
                            "value": "Noir"
                          }
                        ],
                        "imageUrl": null
                      }
                    ],
                    "options": [
                      {
                        "name": "Couleur",
                        "values": [
                          "Noir",
                          "Blanc"
                        ]
                      }
                    ],
                    "images": [
                      {
                        "id": "0",
                        "url": "https://cdn.example.com/p/123.jpg",
                        "alt": null,
                        "position": 0
                      }
                    ],
                    "offers": [
                      {
                        "productId": "prd_123",
                        "vendorId": "ven_42",
                        "vendorName": "TechStore Tunis",
                        "vendorWhatsapp": "21620000000",
                        "price": 89.9,
                        "inStock": true,
                        "isCanonical": true
                      }
                    ]
                  }
                }
              }
            }
          },
          "301": {
            "description": "Moved — the slug belongs to a merged duplicate fiche; `Location` points to the kept fiche.",
            "headers": {
              "Location": {
                "description": "Same request path ending in the kept fiche's current slug (query string kept).",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductMovedResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Product moved",
                  "code": "PRODUCT_MOVED",
                  "redirect": {
                    "slug": "chaussures-honfleur-lea-metallic-le-coq-sportif",
                    "productId": "fc4ee543-9213-4073-a04c-9e62772e1a70"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/categories": {
      "get": {
        "operationId": "listCategories",
        "deprecated": true,
        "summary": "List categories",
        "description": "Returns active categories for the resolved tenant, optionally scoped to a parent category. By default empty categories (productCount 0) are excluded unless include_empty is true. Each item carries product and child counts. `productCount` = DISTINCT products a shopper sees in the category's subtree — the same set `GET /products?category=<id>` lists (published, actively listed, not a hidden group offer, not hidden by « Masquer les produits en rupture »); a product filed on several levels counts once.\n\n**Auth:** Public (no authentication).\n\nUse /public/categories; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Categories"
        ],
        "parameters": [
          {
            "name": "parent",
            "in": "query",
            "required": false,
            "description": "Parent category id; omit for root-level categories",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_empty",
            "in": "query",
            "required": false,
            "description": "Include categories with no products",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "includeHidden",
            "in": "query",
            "required": false,
            "description": "Opt-in. Also return the categories hidden in the back office (switch « Active » off), flagged `visible: false`, so a storefront can show them as « Bientôt ». A hidden category always reports `productCount: 0`. Parsed strictly: `true`/`1` = on, `false`/`0`/absent = off. Part of the URL, so Cache-Control and `Vary: X-Channel` are unchanged.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Category list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CategoryItem"
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": [
                    {
                      "id": "cat_1",
                      "slug": "electronique",
                      "name": "Électronique",
                      "description": null,
                      "imageUrl": null,
                      "parentId": null,
                      "sortOrder": 0,
                      "productCount": 120,
                      "childCount": 4
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/categories": {
      "get": {
        "operationId": "listCategoriesPublic",
        "summary": "List categories",
        "description": "Returns active categories for the resolved tenant, optionally scoped to a parent category. By default empty categories (productCount 0) are excluded unless include_empty is true. Each item carries product and child counts. `productCount` = DISTINCT products a shopper sees in the category's subtree — the same set `GET /products?category=<id>` lists (published, actively listed, not a hidden group offer, not hidden by « Masquer les produits en rupture »); a product filed on several levels counts once.\n\n**Auth:** Public (no authentication).\n\nSame route as `GET /categories` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Categories"
        ],
        "parameters": [
          {
            "name": "parent",
            "in": "query",
            "required": false,
            "description": "Parent category id; omit for root-level categories",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_empty",
            "in": "query",
            "required": false,
            "description": "Include categories with no products",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "includeHidden",
            "in": "query",
            "required": false,
            "description": "Opt-in. Also return the categories hidden in the back office (switch « Active » off), flagged `visible: false`, so a storefront can show them as « Bientôt ». A hidden category always reports `productCount: 0`. Parsed strictly: `true`/`1` = on, `false`/`0`/absent = off. Part of the URL, so Cache-Control and `Vary: X-Channel` are unchanged.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Category list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CategoryItem"
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": [
                    {
                      "id": "cat_1",
                      "slug": "electronique",
                      "name": "Électronique",
                      "description": null,
                      "imageUrl": null,
                      "parentId": null,
                      "sortOrder": 0,
                      "productCount": 120,
                      "childCount": 4
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/categories/tree": {
      "get": {
        "operationId": "getCategoryTree",
        "deprecated": true,
        "summary": "Get full category tree",
        "description": "Returns the complete active category hierarchy for the resolved tenant as a nested tree of root categories with recursive children. Cached publicly.\n\n**Auth:** Public (no authentication).\n\nUse /public/categories/tree; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Categories"
        ],
        "parameters": [
          {
            "name": "includeHidden",
            "in": "query",
            "required": false,
            "description": "Opt-in. Also return the categories hidden in the back office (switch « Active » off), flagged `visible: false`, so a storefront can show them as « Bientôt ». A hidden category always reports `productCount: 0`. Parsed strictly: `true`/`1` = on, `false`/`0`/absent = off. Part of the URL, so Cache-Control and `Vary: X-Channel` are unchanged.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Nested category tree",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CategoryTree"
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": [
                    {
                      "id": "cat_1",
                      "slug": "electronique",
                      "name": "Électronique",
                      "description": null,
                      "imageUrl": null,
                      "parentId": null,
                      "sortOrder": 0,
                      "productCount": 120,
                      "childCount": 1,
                      "children": [
                        {
                          "id": "cat_2",
                          "slug": "audio",
                          "name": "Audio",
                          "description": null,
                          "imageUrl": null,
                          "parentId": "cat_1",
                          "sortOrder": 0,
                          "productCount": 30,
                          "childCount": 0,
                          "children": []
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/categories/tree": {
      "get": {
        "operationId": "getCategoryTreePublic",
        "summary": "Get full category tree",
        "description": "Returns the complete active category hierarchy for the resolved tenant as a nested tree of root categories with recursive children. Cached publicly.\n\n**Auth:** Public (no authentication).\n\nSame route as `GET /categories/tree` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Categories"
        ],
        "parameters": [
          {
            "name": "includeHidden",
            "in": "query",
            "required": false,
            "description": "Opt-in. Also return the categories hidden in the back office (switch « Active » off), flagged `visible: false`, so a storefront can show them as « Bientôt ». A hidden category always reports `productCount: 0`. Parsed strictly: `true`/`1` = on, `false`/`0`/absent = off. Part of the URL, so Cache-Control and `Vary: X-Channel` are unchanged.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Nested category tree",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CategoryTree"
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": [
                    {
                      "id": "cat_1",
                      "slug": "electronique",
                      "name": "Électronique",
                      "description": null,
                      "imageUrl": null,
                      "parentId": null,
                      "sortOrder": 0,
                      "productCount": 120,
                      "childCount": 1,
                      "children": [
                        {
                          "id": "cat_2",
                          "slug": "audio",
                          "name": "Audio",
                          "description": null,
                          "imageUrl": null,
                          "parentId": "cat_1",
                          "sortOrder": 0,
                          "productCount": 30,
                          "childCount": 0,
                          "children": []
                        }
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/categories/{slug}": {
      "get": {
        "operationId": "getCategoryBySlug",
        "deprecated": true,
        "summary": "Get a category by slug",
        "description": "Returns a single active category (with child count) by slug for the resolved tenant. Cached publicly.\n\n**Auth:** Public (no authentication).\n\nUse /public/categories/{slug}; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Categories"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeHidden",
            "in": "query",
            "required": false,
            "description": "Opt-in. Also return the categories hidden in the back office (switch « Active » off), flagged `visible: false`, so a storefront can show them as « Bientôt ». A hidden category always reports `productCount: 0`. Parsed strictly: `true`/`1` = on, `false`/`0`/absent = off. Part of the URL, so Cache-Control and `Vary: X-Channel` are unchanged.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Category detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/CategoryItem"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "cat_2",
                    "slug": "audio",
                    "name": "Audio",
                    "description": null,
                    "imageUrl": null,
                    "parentId": "cat_1",
                    "sortOrder": 0,
                    "productCount": 30,
                    "childCount": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/categories/{slug}": {
      "get": {
        "operationId": "getCategoryBySlugPublic",
        "summary": "Get a category by slug",
        "description": "Returns a single active category (with child count) by slug for the resolved tenant. Cached publicly.\n\n**Auth:** Public (no authentication).\n\nSame route as `GET /categories/{slug}` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Categories"
        ],
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeHidden",
            "in": "query",
            "required": false,
            "description": "Opt-in. Also return the categories hidden in the back office (switch « Active » off), flagged `visible: false`, so a storefront can show them as « Bientôt ». A hidden category always reports `productCount: 0`. Parsed strictly: `true`/`1` = on, `false`/`0`/absent = off. Part of the URL, so Cache-Control and `Vary: X-Channel` are unchanged.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Category detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/CategoryItem"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "cat_2",
                    "slug": "audio",
                    "name": "Audio",
                    "description": null,
                    "imageUrl": null,
                    "parentId": "cat_1",
                    "sortOrder": 0,
                    "productCount": 30,
                    "childCount": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/brands": {
      "get": {
        "operationId": "listBrands",
        "deprecated": true,
        "summary": "List brands",
        "description": "Returns active brands for the resolved tenant with per-brand counts of the products a shopper sees (the same visibility rule as `GET /products`: published, actively listed, not a hidden group offer, not hidden by « Masquer les produits en rupture »). When categoryId is supplied, only brands having at least one such product in that category's subtree are returned.\n\n**Auth:** Public (no authentication).\n\nUse /public/brands; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Brands"
        ],
        "parameters": [
          {
            "name": "categoryId",
            "in": "query",
            "required": false,
            "description": "Restrict to brands with published products in this category",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Brand list with counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/BrandList"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "brd_1",
                        "name": "Samsung",
                        "slug": "samsung",
                        "logoUrl": "https://cdn.example.com/b/samsung.png",
                        "productCount": 42
                      }
                    ],
                    "total": 1
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/brands": {
      "get": {
        "operationId": "listBrandsPublic",
        "summary": "List brands",
        "description": "Returns active brands for the resolved tenant with per-brand counts of the products a shopper sees (the same visibility rule as `GET /products`: published, actively listed, not a hidden group offer, not hidden by « Masquer les produits en rupture »). When categoryId is supplied, only brands having at least one such product in that category's subtree are returned.\n\n**Auth:** Public (no authentication).\n\nSame route as `GET /brands` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Brands"
        ],
        "parameters": [
          {
            "name": "categoryId",
            "in": "query",
            "required": false,
            "description": "Restrict to brands with published products in this category",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Brand list with counts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/BrandList"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "brd_1",
                        "name": "Samsung",
                        "slug": "samsung",
                        "logoUrl": "https://cdn.example.com/b/samsung.png",
                        "productCount": 42
                      }
                    ],
                    "total": 1
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/attributes": {
      "get": {
        "operationId": "listAttributes",
        "deprecated": true,
        "summary": "List product attributes",
        "description": "Without categoryId, returns all defined attributes (e.g. Couleur, Taille) with their values for the resolved tenant. With categoryId, derives the attribute values from variants of the products the storefront LISTS in that category (its whole subtree — same visibility as `GET /products`: published, active listing, not hidden, `X-Channel` display mode), merging with canonical attribute metadata where available. A value carried only by unlisted products is not offered.\n\nValues are ONE entry per normalised value — `Noir` / `noir` / `NOIR` are one entry (slug `noir`, labelled with the most frequent spelling); the `slug` is what `GET /products` `attr[code]=` / `attributeValue` match (in both forms of this endpoint, it is the normalised value — never a stored value slug). The `brand` attribute (the brand has its own filter), metadata axes and empty values are left out.\n\n**Auth:** Public (no authentication).\n\nUse /public/attributes; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Attributes"
        ],
        "parameters": [
          {
            "name": "categoryId",
            "in": "query",
            "required": false,
            "description": "Derive attributes from products in this category",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Attribute list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AttributeList"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "attr_1",
                        "name": "Couleur",
                        "slug": "couleur",
                        "type": "select",
                        "values": [
                          {
                            "id": "val_1",
                            "value": "Noir",
                            "slug": "noir",
                            "sortOrder": 0
                          }
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/attributes": {
      "get": {
        "operationId": "listAttributesPublic",
        "summary": "List product attributes",
        "description": "Without categoryId, returns all defined attributes (e.g. Couleur, Taille) with their values for the resolved tenant. With categoryId, derives the attribute values from variants of the products the storefront LISTS in that category (its whole subtree — same visibility as `GET /products`: published, active listing, not hidden, `X-Channel` display mode), merging with canonical attribute metadata where available. A value carried only by unlisted products is not offered.\n\nValues are ONE entry per normalised value — `Noir` / `noir` / `NOIR` are one entry (slug `noir`, labelled with the most frequent spelling); the `slug` is what `GET /products` `attr[code]=` / `attributeValue` match (in both forms of this endpoint, it is the normalised value — never a stored value slug). The `brand` attribute (the brand has its own filter), metadata axes and empty values are left out.\n\n**Auth:** Public (no authentication).\n\nSame route as `GET /attributes` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Attributes"
        ],
        "parameters": [
          {
            "name": "categoryId",
            "in": "query",
            "required": false,
            "description": "Derive attributes from products in this category",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Attribute list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AttributeList"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "attr_1",
                        "name": "Couleur",
                        "slug": "couleur",
                        "type": "select",
                        "values": [
                          {
                            "id": "val_1",
                            "value": "Noir",
                            "slug": "noir",
                            "sortOrder": 0
                          }
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/search": {
      "get": {
        "operationId": "searchProducts",
        "deprecated": true,
        "summary": "Search products",
        "description": "Full-text product search scoped to the resolved marketplace. Supports filtering by brand, category, vendor, price range, in-stock and on-sale, plus sorting and facet distribution.\n\nOut-of-stock products of vendors that hide them (« masquer les produits en rupture ») are excluded before pagination, so `total` and facets match the results.\n\nUse /public/search; this path stays until the storefront and the mobile app have moved.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Search"
        ],
        "parameters": [
          {
            "name": "X-Channel",
            "in": "header",
            "required": false,
            "description": "Distribution channel selecting per-channel storefront display config (independent toggles per marketplace tenant). Display config, not authentication. Absent header defaults to `web`.",
            "schema": {
              "type": "string",
              "enum": [
                "web",
                "mobile"
              ],
              "default": "web"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search query (max 200 chars)",
            "schema": {
              "type": "string",
              "default": ""
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100",
            "schema": {
              "type": "integer",
              "default": 10
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "min 0",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "brand_id",
            "in": "query",
            "required": false,
            "description": "Exact brand id. An id only (letters, digits, `_`, `-`, `.`, `:`); anything else, including filter syntax, is refused with a 400. Empty = no filter.",
            "schema": {
              "type": "string",
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
            }
          },
          {
            "name": "category_id",
            "in": "query",
            "required": false,
            "description": "Exact category id. An id only (letters, digits, `_`, `-`, `.`, `:`); anything else, including filter syntax, is refused with a 400. Empty = no filter.",
            "schema": {
              "type": "string",
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
            }
          },
          {
            "name": "vendor_id",
            "in": "query",
            "required": false,
            "description": "Exact vendor id. An id only (letters, digits, `_`, `-`, `.`, `:`); anything else, including filter syntax, is refused with a 400. Empty = no filter.",
            "schema": {
              "type": "string",
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
            }
          },
          {
            "name": "min_price",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "max_price",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "in_stock",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "on_sale",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "price:asc",
                "price:desc",
                "title:asc",
                "newest"
              ],
              "default": "newest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results with facet distribution",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/SearchResponse"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "query": "casque",
                    "results": [
                      {
                        "id": "prd_123",
                        "type": "product",
                        "title": "Casque Bluetooth",
                        "slug": "casque-audio-bluetooth",
                        "price": 89.9,
                        "salePrice": 89.9,
                        "onSale": true,
                        "imageUrl": "https://cdn.example.com/p/123.jpg",
                        "inStock": true,
                        "vendorId": "ven_42",
                        "vendorName": "TechStore Tunis",
                        "brandId": "brd_3",
                        "categoryIds": [
                          "cat_2"
                        ]
                      }
                    ],
                    "total": 1,
                    "facetDistribution": {
                      "brandId": {
                        "brd_3": 1
                      },
                      "inStock": {
                        "true": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/search": {
      "get": {
        "operationId": "searchProductsPublic",
        "summary": "Search products",
        "description": "Full-text product search scoped to the resolved marketplace. Supports filtering by brand, category, vendor, price range, in-stock and on-sale, plus sorting and facet distribution.\n\nOut-of-stock products of vendors that hide them (« masquer les produits en rupture ») are excluded before pagination, so `total` and facets match the results.\n\nSame route as `GET /search`; prefer this path.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Search"
        ],
        "parameters": [
          {
            "name": "X-Channel",
            "in": "header",
            "required": false,
            "description": "Distribution channel selecting per-channel storefront display config (independent toggles per marketplace tenant). Display config, not authentication. Absent header defaults to `web`.",
            "schema": {
              "type": "string",
              "enum": [
                "web",
                "mobile"
              ],
              "default": "web"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search query (max 200 chars)",
            "schema": {
              "type": "string",
              "default": ""
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100",
            "schema": {
              "type": "integer",
              "default": 10
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "min 0",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "brand_id",
            "in": "query",
            "required": false,
            "description": "Exact brand id. An id only (letters, digits, `_`, `-`, `.`, `:`); anything else, including filter syntax, is refused with a 400. Empty = no filter.",
            "schema": {
              "type": "string",
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
            }
          },
          {
            "name": "category_id",
            "in": "query",
            "required": false,
            "description": "Exact category id. An id only (letters, digits, `_`, `-`, `.`, `:`); anything else, including filter syntax, is refused with a 400. Empty = no filter.",
            "schema": {
              "type": "string",
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
            }
          },
          {
            "name": "vendor_id",
            "in": "query",
            "required": false,
            "description": "Exact vendor id. An id only (letters, digits, `_`, `-`, `.`, `:`); anything else, including filter syntax, is refused with a 400. Empty = no filter.",
            "schema": {
              "type": "string",
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
            }
          },
          {
            "name": "min_price",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "max_price",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "in_stock",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "on_sale",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "price:asc",
                "price:desc",
                "title:asc",
                "newest"
              ],
              "default": "newest"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Search results with facet distribution",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/SearchResponse"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "query": "casque",
                    "results": [
                      {
                        "id": "prd_123",
                        "type": "product",
                        "title": "Casque Bluetooth",
                        "slug": "casque-audio-bluetooth",
                        "price": 89.9,
                        "salePrice": 89.9,
                        "onSale": true,
                        "imageUrl": "https://cdn.example.com/p/123.jpg",
                        "inStock": true,
                        "vendorId": "ven_42",
                        "vendorName": "TechStore Tunis",
                        "brandId": "brd_3",
                        "categoryIds": [
                          "cat_2"
                        ]
                      }
                    ],
                    "total": 1,
                    "facetDistribution": {
                      "brandId": {
                        "brd_3": 1
                      },
                      "inStock": {
                        "true": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/cart/{cartId}": {
      "get": {
        "operationId": "getCart",
        "summary": "Get a cart",
        "description": "Returns a cart (with items and computed subtotal) for the account resolved from tenant context or the x-account-id header. Auth is soft: a customer token is decoded if present but not required.\n\n**Auth:** Bearer JWT optional (guest-friendly).",
        "tags": [
          "Cart"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "cartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-account-id",
            "in": "header",
            "required": false,
            "description": "Account id fallback when tenant context is not resolved",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cart with items and subtotal",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Cart"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "cartId": "8f1c...",
                    "accountId": "acc_exemple",
                    "customerId": null,
                    "sessionId": "sess_1",
                    "currency": "TND",
                    "notes": null,
                    "expiresAt": {},
                    "createdAt": {},
                    "updatedAt": {},
                    "items": [
                      {
                        "itemId": "itm_1",
                        "productId": "prd_123",
                        "variantId": null,
                        "quantity": 2,
                        "unitPrice": 89.9,
                        "addedAt": {}
                      }
                    ],
                    "subtotal": 179.8
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing account context (no tenant context and no x-account-id header)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteCart",
        "summary": "Delete (abandon) a cart",
        "description": "Deletes the entire cart and invalidates its cache. Returns 204 No Content. Soft auth.\n\n**Auth:** Bearer JWT optional (guest-friendly).",
        "tags": [
          "Cart"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "cartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-account-id",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Cart deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "message": "Operation completed"
                }
              }
            }
          },
          "400": {
            "description": "Missing account context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/cart": {
      "post": {
        "operationId": "createCart",
        "summary": "Create a cart",
        "description": "Creates a new empty cart for the resolved account, defaulting currency to TND and expiry to 7 days. Optionally links a customerId/sessionId. Soft auth.\n\n**Auth:** Bearer JWT optional (guest-friendly).",
        "tags": [
          "Cart"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "x-account-id",
            "in": "header",
            "required": false,
            "description": "Account id fallback when tenant context is not resolved",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customerId": {
                    "type": "string"
                  },
                  "sessionId": {
                    "type": "string"
                  },
                  "currency": {
                    "type": "string",
                    "default": "TND"
                  }
                }
              },
              "example": {
                "sessionId": "sess_1",
                "currency": "TND"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Cart created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Cart"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "cartId": "8f1c...",
                    "accountId": "acc_exemple",
                    "customerId": null,
                    "sessionId": "sess_1",
                    "currency": "TND",
                    "notes": null,
                    "expiresAt": {},
                    "createdAt": {},
                    "updatedAt": {},
                    "items": [],
                    "subtotal": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing account context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/cart/{cartId}/items": {
      "post": {
        "operationId": "addCartItem",
        "summary": "Add an item to a cart",
        "description": "Adds a product (optionally a variant) to the cart. The unit price is resolved SERVER-SIDE (THE RULE: the variant's regular/sale pair, else the product pair, with the vendor price rule and any listing override — the same pricer checkout charges with); a client `unitPrice` is only a fallback for a line the server cannot price, and a line that cannot be priced at all is refused with 422. If the same product+variant already exists, its quantity is incremented and its price refreshed. Returns the updated cart. Soft auth.\n\n**Auth:** Bearer JWT optional (guest-friendly).",
        "tags": [
          "Cart"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "cartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-account-id",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "productId": {
                    "type": "string",
                    "description": "min 1 char"
                  },
                  "variantId": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": "integer",
                    "description": "positive integer",
                    "default": 1
                  },
                  "unitPrice": {
                    "type": "number",
                    "description": "DEPRECATED — positive; ignored whenever the server can price the line",
                    "deprecated": true
                  }
                },
                "required": [
                  "productId"
                ]
              },
              "example": {
                "productId": "prd_123",
                "quantity": 2,
                "unitPrice": 89.9
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Updated cart",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Cart"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "cartId": "8f1c...",
                    "accountId": "acc_exemple",
                    "customerId": null,
                    "sessionId": null,
                    "currency": "TND",
                    "notes": null,
                    "expiresAt": {},
                    "createdAt": {},
                    "updatedAt": {},
                    "items": [
                      {
                        "itemId": "itm_1",
                        "productId": "prd_123",
                        "variantId": null,
                        "quantity": 2,
                        "unitPrice": 89.9,
                        "addedAt": {}
                      }
                    ],
                    "subtotal": 179.8
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing account context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/cart/{cartId}/items/{itemId}": {
      "patch": {
        "operationId": "updateCartItem",
        "summary": "Update a cart item quantity",
        "description": "Sets the quantity of a cart line item. A quantity of 0 removes the item. Returns the updated cart. Soft auth.\n\n**Auth:** Bearer JWT optional (guest-friendly).",
        "tags": [
          "Cart"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "cartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-account-id",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quantity": {
                    "type": "integer",
                    "description": "min 0; 0 removes the item"
                  }
                },
                "required": [
                  "quantity"
                ]
              },
              "example": {
                "quantity": 3
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated cart",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Cart"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "cartId": "8f1c...",
                    "accountId": "acc_exemple",
                    "customerId": null,
                    "sessionId": null,
                    "currency": "TND",
                    "notes": null,
                    "expiresAt": {},
                    "createdAt": {},
                    "updatedAt": {},
                    "items": [
                      {
                        "itemId": "itm_1",
                        "productId": "prd_123",
                        "variantId": null,
                        "quantity": 3,
                        "unitPrice": 89.9,
                        "addedAt": {}
                      }
                    ],
                    "subtotal": 269.7
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing account context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteCartItem",
        "summary": "Remove a cart item",
        "description": "Deletes a single line item from the cart and invalidates the cart cache. Returns 204 No Content. Soft auth.\n\n**Auth:** Bearer JWT optional (guest-friendly).",
        "tags": [
          "Cart"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "cartId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-account-id",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Item removed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "message": "Operation completed"
                }
              }
            }
          },
          "400": {
            "description": "Missing account context",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/products/{productId}/reviews": {
      "get": {
        "operationId": "listPublicProductReviews",
        "summary": "Published reviews of a product (« Avis vérifiés »)",
        "description": "Published reviews only, newest first, with the rating summary of the same set. Marketplace = the request's tenant (default marketplace when unresolved). `productId` is the id the storefront holds (`GET /products/{slug}` → `id`); a vendor SOURCE product id is mapped to its copy in the marketplace.\n\n`authorDisplay` is « Prénom + initiale » (e.g. `Hedii T.`) — never an e-mail or phone (falls back to `Client`). `verifiedPurchase` = the stored `is_verified` flag: always true for a review posted through `POST` (it requires a delivered order). `variantLabel` = the variation bought (reviews linked to an order), else null. `sellerName` = the seller of the line reviewed. `sellerReply` = the latest published reply (vendor or marketplace), else null.\n\nCacheable: `Cache-Control: public, max-age=60, s-maxage=300, stale-while-revalidate=600`.\n\nErrors: `{ ok:false, error:{ code, message }, message }`.\n\n**Auth:** None (public).",
        "tags": [
          "Storefront Reviews"
        ],
        "security": [],
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of published reviews + the summary.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/PublicReviewsPage"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "summary": {
                      "average": 4.67,
                      "count": 3,
                      "distribution": {
                        "1": 0,
                        "2": 0,
                        "3": 0,
                        "4": 1,
                        "5": 2
                      }
                    },
                    "items": [
                      {
                        "id": "rev_woo_139508",
                        "rating": 5,
                        "title": null,
                        "body": "Je recommande vivement ce produit",
                        "authorDisplay": "Hedii T.",
                        "verifiedPurchase": true,
                        "variantLabel": null,
                        "sellerName": "Boutique Exemple",
                        "createdAt": "2023-01-13T16:47:11.000Z",
                        "sellerReply": {
                          "body": "Merci pour votre retour !",
                          "createdAt": "2023-01-14T09:00:00.000Z"
                        }
                      }
                    ],
                    "pagination": {
                      "page": 1,
                      "limit": 10,
                      "total": 3
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`NOT_FOUND` — no such product in this marketplace",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          },
          "422": {
            "description": "`VALIDATION` — bad page/limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "submitProductReview",
        "summary": "A customer reviews a product they received",
        "description": "Refused (403 `NOT_ELIGIBLE`) unless the customer has an order with status `delivered` (not a grouping parent) containing this product or another seller's offer of it (same product group). `orderId` optionally picks which of those orders; one that is not eligible is refused the same way. One review per customer × product: a second one is 409 `ALREADY_REVIEWED` (the review id is deterministic, so concurrent submissions collide too).\n\nThe review lands `pending` (verified) and goes online when the marketplace publishes it from the moderation queue, which also recomputes the product's `rating`. Title/body are stored as plain text (tags stripped).\n\nThe customer id comes from the token, never the body.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Storefront Reviews"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitProductReviewInput"
              },
              "example": {
                "rating": 5,
                "title": "Très confortable",
                "body": "Taille normale, livraison rapide."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Review received, awaiting moderation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/SubmittedProductReview"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`NOT_ELIGIBLE` — no delivered order of this product; `FORBIDDEN` — not a customer session",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          },
          "404": {
            "description": "`NOT_FOUND`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          },
          "409": {
            "description": "`ALREADY_REVIEWED`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          },
          "422": {
            "description": "`VALIDATION` — rating outside 1..5, title > 255, body > 4000",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          }
        }
      }
    },
    "/public/products/{productId}/questions": {
      "get": {
        "operationId": "listPublicProductQuestions",
        "summary": "Answered questions of a product (« Questions-réponses »)",
        "description": "Answered questions only (`status = answered`), newest answer first, at most 50. `answer.sellerName` = the product's vendor, or the marketplace name when its staff answered. The asker's e-mail is never returned. The same pairs also feed `faqs` on `GET /products/{slug}` (after the editorial FAQ, at most 20, answer HTML-escaped).\n\nCacheable like the reviews list.\n\n**Auth:** None (public).",
        "tags": [
          "Storefront Reviews"
        ],
        "security": [],
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Answered questions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "items"
                      ],
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/PublicProductQuestion"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`NOT_FOUND`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "askProductQuestion",
        "summary": "Ask the seller a question about a product",
        "description": "Guest-friendly (a customer token, when present, only links the customer id). The question lands `pending`; the product's vendor is notified in the back office (`product_question_asked`, in-app; e-mail only if the vendor opted in). Nothing is e-mailed to the asker. The answer appears on the product page once given.\n\nThe same question from the same e-mail on the same product within 24 h is acknowledged (202) but not stored twice. The product must be published.\n\n**Auth:** Bearer JWT optional (guest-friendly).",
        "tags": [
          "Storefront Reviews"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AskProductQuestionInput"
              },
              "example": {
                "question": "Est-ce que cette chaussure taille grand ?",
                "email": "client@example.tn"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Question received.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "status",
                        "message"
                      ],
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "French, displayable."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`NOT_FOUND` — unknown or unpublished product",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          },
          "422": {
            "description": "`VALIDATION` — question under 10 or over 1000 characters, invalid e-mail",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          }
        }
      }
    },
    "/store-reservations": {
      "get": {
        "operationId": "listMyStoreReservations",
        "summary": "My store reservations (customer)",
        "description": "The authenticated customer's own reservations, newest first. Each item carries its `accessToken`.\n\n**Auth:** Bearer JWT required (realm: customer).",
        "tags": [
          "Store Reservations"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated reservations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/StoreReservationPage"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid token"
          }
        }
      },
      "post": {
        "operationId": "createStoreReservation",
        "summary": "Reserve a variant in a physical store (« Réservation en boutique »)",
        "description": "Reserves ONE variant (e.g. a shoe size) in ONE store of ONE vendor; the shopper collects and pays in the store. No online payment, no stock decrement (ERP stock is read-only).\n\nThe server re-checks what the product page showed, via the same resolution as `GET /public/variant-availability`: the vendor offers the variant, the vendor shows store stock (`showsStoreStock` = per-depot feed AND the `store_stock` offer capability), the store is listed for that variant with a status other than `out_of_stock`, and the warehouse is active and belongs to the vendor. Otherwise 409 `STORE_UNAVAILABLE`. The seller's product must also be ACTIVELY listed on this marketplace (not paused, rejected or retired, vendor not suspended or terminated), otherwise 404 `NOT_FOUND`.\n\n`productId` / `variantId` may be the seller's own pair (`vendors[].productId` / `vendors[].variantId` from variant-availability) or the page's canonical pair; the reservation always stores the seller's own variant. `unitPrice` is a snapshot of the seller's selling price (same pricer as checkout, never the raw `price` column).\n\nHolds 48 h from creation; when the store marks it `ready`, 48 h from then. Overdue pending/confirmed/ready reservations become `expired` (15-minute sweep). At most 3 active reservations per phone number per vendor (429 `RESERVATION_LIMIT`). Phone: Tunisian, 8 digits; `+216` / `00216` / `216` prefixes, spaces, dots and dashes accepted; stored as `+216XXXXXXXX`.\n\nGuest-friendly: a customer Bearer links the reservation to that customer (never a body field). Per-IP rate limit. Optional `Idempotency-Key` header: a repeat returns the existing reservation with 200.\n\nNotifies the vendor (bell + email, `store_reservation_created`) and emails the shopper when `email` is given.\n\nErrors: `{ ok:false, error:{ code, message }, message }`.\n\n**Auth:** Bearer JWT optional (guest-friendly).",
        "tags": [
          "Store Reservations"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Replays the reservation already created for this marketplace/key (200) instead of creating a duplicate.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateStoreReservationInput"
              },
              "example": {
                "vendorId": "vnd_exemple",
                "productId": "prd_123",
                "variantId": "var_456",
                "storeId": "3f2a9c1e-0000-4000-8000-000000000001",
                "quantity": 1,
                "firstName": "Amine",
                "lastName": "Ben Ali",
                "phone": "22 123 456",
                "email": "amine@example.tn",
                "note": "Je passe vers 18h"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay — the reservation already existed for this Idempotency-Key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/StoreReservation"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Reservation created (status `pending`)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/StoreReservation"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`CUSTOMER_BLOCKED` — the customer (phone / e-mail / account) is blocked on this marketplace. Neutral French message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          },
          "404": {
            "description": "`NOT_FOUND` — product not published, variant not in the product, the vendor does not offer it, or the seller's product is no longer actively listed on this marketplace (listing paused, rejected or retired, vendor suspended or terminated)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          },
          "409": {
            "description": "`STORE_UNAVAILABLE` — store not listed / out of stock for the variant, store stock not shown by the vendor, or warehouse inactive",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          },
          "422": {
            "description": "`VALIDATION` — invalid body or phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          }
        }
      }
    },
    "/store-reservations/{reservationNumber}": {
      "get": {
        "operationId": "getStoreReservation",
        "summary": "Read one store reservation (owner customer or access token)",
        "description": "Returns the reservation when the Bearer is the owner customer's OR `?token=` matches its `accessToken` (constant-time compare). Anything else is 404 `NOT_FOUND` (never 403, so numbers cannot be probed). `Cache-Control: private, no-store`.\n\nThe shopper emails link to the storefront page `https://boutique.example.com/reservation/{reservationNumber}?token={accessToken}`, which calls this endpoint.\n\n**Auth:** Bearer JWT optional; token-gated.",
        "tags": [
          "Store Reservations"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "reservationNumber",
            "in": "path",
            "required": true,
            "description": "Human reservation number, e.g. `R-7KQ2MX`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "token",
            "in": "query",
            "required": false,
            "description": "The reservation's `accessToken` (32 hex). Required unless the Bearer is the owner customer's.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The reservation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/StoreReservation"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`NOT_FOUND`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          }
        }
      }
    },
    "/store-reservations/{reservationNumber}/cancel": {
      "post": {
        "operationId": "cancelStoreReservation",
        "summary": "Cancel a store reservation (shopper)",
        "description": "Cancels a `pending`, `confirmed` or `ready` reservation (`cancelledBy = customer`) and notifies the vendor's bell. Same gating as the GET (owner customer OR `?token=`). Returns the updated reservation. 409 `INVALID_TRANSITION` when it is already collected / cancelled / expired, or changed concurrently.\n\n**Auth:** Bearer JWT optional; token-gated.",
        "tags": [
          "Store Reservations"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "reservationNumber",
            "in": "path",
            "required": true,
            "description": "Human reservation number, e.g. `R-7KQ2MX`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "token",
            "in": "query",
            "required": false,
            "description": "The reservation's `accessToken` (32 hex). Required unless the Bearer is the owner customer's.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 500,
                    "nullable": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The cancelled reservation",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/StoreReservation"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`NOT_FOUND`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          },
          "409": {
            "description": "`INVALID_TRANSITION`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          },
          "422": {
            "description": "`VALIDATION`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StoreReservationError"
                }
              }
            }
          }
        }
      }
    },
    "/checkout": {
      "post": {
        "operationId": "createCheckout",
        "summary": "Place an order (checkout)",
        "description": "Creates an order from supplied line items and addresses for the resolved tenant. Guest-friendly: a customer token is decoded if present so the order links to that customer, otherwise it is a guest COD order. The order's customer is always the authenticated customer, never a body field. Supports an optional Idempotency-Key header that replays an existing order (returns 200) instead of creating a duplicate. Validates stock with a race-safe decrement and emits an order.created analytics event.\n\nEvery line must be a product ACTIVELY listed on this marketplace (the rule the storefront applies before showing it): a product whose listing is paused, rejected or retired, or whose vendor is suspended or terminated, is refused with 422 `Product <id> not available — no longer sold on this marketplace` and no order is created, even from a saved cart or a direct call.\n\nShipping is computed server-side per vendor (each vendor's flat fee, waived above their free-shipping threshold); a client-supplied `shippingAmount` is ignored. `paymentMethod` is `cod` (default) or `clictopay` (case-insensitive). Use `POST /shipping-quote` to preview the shipping total before checkout.\n\nWhen on, the order is placed as usual (stock reserved, `status: pending`, `paymentStatus: pending`), registered at ClicToPay (amount in millimes, `orderNumber` = our `orderId` UUID **without its hyphens**, 32 hex characters — the gateway caps that field at 32) and returned with `payment: { provider: clictopay, status: pending, formUrl }` — send the buyer to `formUrl`. Card orders are charged in TND only (another `currency` → 422 `PAYMENT_CURRENCY_UNSUPPORTED`) and must have something to pay (a zero total → 422 `PAYMENT_AMOUNT_INVALID`). Vendor fulfilment tasks, vendor e-mails and the customer confirmation wait for the payment to be proven (`GET /payments/clictopay/status`). A replay with the same Idempotency-Key reuses the registration (never registers twice); `409 PAYMENT_REGISTRATION_IN_PROGRESS` = a concurrent request is registering, retry; `409 PAYMENT_NOT_RESUMABLE` = the gateway holds the order but its payment page was lost (the gateway answer never reached us) — place a new order; `502 PAYMENT_GATEWAY_UNAVAILABLE` = the order is placed but the gateway did not answer — retry with the same Idempotency-Key.\n\nMulti-vendor packs: lines carrying a `bundleId` must form that pack exactly — every pack item covered once (an item with a variant by that variant, an \"any variant\" item by any variant of its product), no extra line carrying the id, quantities = pack quantities × the same whole number k. The pack total (`price × k`) is split across its lines in proportion to their catalogue totals (millime-rounded, remainder on the last line); each line keeps its vendor, so commission, the vendor's free-shipping threshold and payouts use that share. The line `discountAmount` records catalogue − share; the order `discountAmount` stays 0 (the subtotal is already the sum of the shares). An unknown / inactive / out-of-dates pack, a currency mismatch or lines that do not form the pack → 422 `Bundle … not available — <reason>`. `POST /shipping-quote` applies the same pack pricing.\n\n**Auth:** Bearer JWT optional (guest-friendly).",
        "tags": [
          "Checkout"
        ],
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Replays an already-created order for the same account/key instead of placing a duplicate",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "type": "array",
                    "items": {},
                    "description": "Line items: [{ productId, quantity (1-99), variantId?, bundleId? }] (min 1). `bundleId` marks the lines of a multi-vendor pack (GET /public/products/{productId}/bundles): the server checks they form the pack and prices them at the pack price."
                  },
                  "shippingAddress": {
                    "$ref": "#/components/schemas/AddressInput"
                  },
                  "billingAddress": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/AddressInput"
                      }
                    ],
                    "description": "Defaults to shippingAddress when omitted"
                  },
                  "paymentMethod": {
                    "type": "string",
                    "enum": [
                      "cod",
                      "clictopay"
                    ],
                    "default": "cod",
                    "description": "`cod` (cash on delivery) or `clictopay` (online card, 422 PAYMENT_METHOD_UNAVAILABLE while the server switch is off). Case-insensitive; defaults to 'cod'. A free-form/unknown value is rejected."
                  },
                  "customerNote": {
                    "type": "string"
                  },
                  "customerId": {
                    "type": "string",
                    "description": "Accepted by schema but ignored for security; the authenticated customer is used"
                  },
                  "shippingAmount": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Optional and IGNORED — shipping is computed server-side per vendor; the response shippingAmount/total reflect the server-computed value, not this field."
                  },
                  "currency": {
                    "type": "string",
                    "default": "TND"
                  },
                  "couponCode": {
                    "type": "string",
                    "description": "Optional promo code (2-64 chars). Only the CODE is trusted — the discount is recomputed server-side on the priced lines (same engine as POST /public/coupons/validate) and the use is consumed atomically with the order. An unusable code → 422 with `error.code` (no order is created). total = subtotal − discountAmount + shippingAmount."
                  },
                  "loyaltyPoints": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10000000,
                    "description": "Loyalty points to spend. **IGNORED unless the marketplace has switched this feature on.** Only the NUMBER is trusted: 100 points = 1 TND, at most 20 % of the goods total (subtotal, shipping excluded) and at most the balance; the discount is split per line (platform-funded, `discount_funded_by = platform`) and the points are debited atomically with the order. Signed-in customer with a linked loyalty account only; not combinable with `couponCode`. Refused → 422 with `error.code`: `loyalty_exceeds_max` (+ `details.maxPoints`), `loyalty_insufficient_points` (balance spent by a concurrent order), `loyalty_signin_required`, `loyalty_no_account`, `loyalty_with_coupon`, `loyalty_currency` (TND only). Points are given back when the order is cancelled (any path); delivered orders earn ⌊paid goods TND⌋ points."
                  }
                },
                "required": [
                  "items",
                  "shippingAddress",
                  "paymentMethod"
                ]
              },
              "example": {
                "items": [
                  {
                    "productId": "prd_123",
                    "quantity": 2
                  }
                ],
                "shippingAddress": {
                  "firstName": "Sami",
                  "lastName": "Ben Ali",
                  "address1": "12 Rue de Carthage",
                  "city": "Tunis",
                  "countryCode": "TN",
                  "phone": "+21620000000"
                },
                "paymentMethod": "cod",
                "currency": "TND"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Idempotent replay — the order already existed for this Idempotency-Key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/OrderSummary"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "orderId": "b3c1...",
                    "orderNumber": "ORD-LWZ3KP",
                    "status": "pending",
                    "currency": "TND",
                    "subtotal": 179.8,
                    "shippingAmount": 7,
                    "total": 186.8,
                    "paymentMethod": "cod",
                    "paymentStatus": "pending",
                    "placedAt": {},
                    "items": [
                      {
                        "itemId": "itm_1",
                        "productId": "prd_123",
                        "title": "Casque Bluetooth",
                        "quantity": 2,
                        "unitPrice": 89.9,
                        "lineTotal": 179.8
                      }
                    ]
                  }
                }
              }
            }
          },
          "201": {
            "description": "Order created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/OrderSummary"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "orderId": "b3c1...",
                    "orderNumber": "ORD-LWZ3KP",
                    "status": "pending",
                    "currency": "TND",
                    "subtotal": 179.8,
                    "shippingAmount": 7,
                    "total": 186.8,
                    "paymentMethod": "cod",
                    "paymentStatus": "pending",
                    "placedAt": {},
                    "items": [
                      {
                        "itemId": "itm_1",
                        "productId": "prd_123",
                        "title": "Casque Bluetooth",
                        "quantity": 2,
                        "unitPrice": 89.9,
                        "lineTotal": 179.8
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "`CUSTOMER_BLOCKED` — the marketplace blocked this customer (« Clients bloqués »: normalised phone, e-mail or customer account; checked on the shipping + billing phone / e-mail, the authenticated customer id and that customer's profile). Neutral, displayable French message; no order is created. Server-side only — every client (web, mobile) and every payment method lands here.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerBlockedError"
                }
              }
            }
          },
          "409": {
            "description": "Retry with the same Idempotency-Key. The unpaid order is cancelled by the server job. `data` carries `orderId` + `orderNumber`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "A product or variant is not available / out of stock / lost the stock race / no longer actively listed on this marketplace (`… not available — no longer sold on this marketplace`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          },
          "502": {
            "description": "Retry with the same Idempotency-Key. `data` carries `orderId` + `orderNumber`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/shipping-quote": {
      "post": {
        "operationId": "createShippingQuote",
        "deprecated": true,
        "summary": "Estimate cart shipping (per vendor)",
        "description": "Returns the exact per-vendor shipping checkout will charge for the supplied cart — each vendor's flat delivery fee, waived above that vendor's optional free-shipping threshold — summed into an order-level total. No order is created. Lets the cart/checkout UI show an accurate total (including multi-vendor carts). Prices and vendors are resolved from the catalog the same way checkout does. Guest-friendly.\n\n**Auth:** Public (no authentication).\n\nUse /public/shipping-quote; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Checkout"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "type": "array",
                    "items": {},
                    "description": "Line items: [{ productId, quantity (1-99), variantId?, bundleId? }] (min 1). `bundleId` marks the lines of a multi-vendor pack (GET /public/products/{productId}/bundles): the server checks they form the pack and prices them at the pack price."
                  },
                  "currency": {
                    "type": "string",
                    "default": "TND"
                  }
                },
                "required": [
                  "items"
                ]
              },
              "example": {
                "items": [
                  {
                    "productId": "prd_123",
                    "quantity": 2
                  },
                  {
                    "productId": "prd_456",
                    "quantity": 1
                  }
                ],
                "currency": "TND"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-vendor shipping estimate",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/ShippingQuote"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "shippingAmount": 8,
                    "perVendor": [
                      {
                        "vendorId": "vnd_1",
                        "shippingAmount": 0
                      },
                      {
                        "vendorId": "vnd_2",
                        "shippingAmount": 8
                      }
                    ],
                    "currency": "TND"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/shipping-quote": {
      "post": {
        "operationId": "createShippingQuotePublic",
        "summary": "Estimate cart shipping (per vendor)",
        "description": "Returns the exact per-vendor shipping checkout will charge for the supplied cart — each vendor's flat delivery fee, waived above that vendor's optional free-shipping threshold — summed into an order-level total. No order is created. Lets the cart/checkout UI show an accurate total (including multi-vendor carts). Prices and vendors are resolved from the catalog the same way checkout does. Guest-friendly.\n\n**Auth:** Public (no authentication).\n\nSame route as `POST /shipping-quote` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Checkout"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "type": "array",
                    "items": {},
                    "description": "Line items: [{ productId, quantity (1-99), variantId?, bundleId? }] (min 1). `bundleId` marks the lines of a multi-vendor pack (GET /public/products/{productId}/bundles): the server checks they form the pack and prices them at the pack price."
                  },
                  "currency": {
                    "type": "string",
                    "default": "TND"
                  }
                },
                "required": [
                  "items"
                ]
              },
              "example": {
                "items": [
                  {
                    "productId": "prd_123",
                    "quantity": 2
                  },
                  {
                    "productId": "prd_456",
                    "quantity": 1
                  }
                ],
                "currency": "TND"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-vendor shipping estimate",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/ShippingQuote"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "shippingAmount": 8,
                    "perVendor": [
                      {
                        "vendorId": "vnd_1",
                        "shippingAmount": 0
                      },
                      {
                        "vendorId": "vnd_2",
                        "shippingAmount": 8
                      }
                    ],
                    "currency": "TND"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/orders": {
      "get": {
        "operationId": "listMyOrders",
        "summary": "List my orders",
        "description": "Returns a paginated list of the authenticated customer's own orders. Hard-scoped to the customer from the token; any client-supplied customer id is ignored.\n\nA purchase from several vendors is listed as one order per vendor (each one is prepared, shipped and tracked on its own); no grouping order is returned on top of them, so the same purchase never appears twice.\n\n`status` filters on an exact status value (`pending`, `confirmed`, `processing`, `shipped`, `delivered`, `cancelled`…); an unknown value returns an empty list.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "min 1",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-50",
            "schema": {
              "type": "integer",
              "default": 20
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Exact order status (`pending`, `confirmed`, `processing`, `shipped`, `delivered`, `cancelled`, `refunded`). The terminal status of a completed order is `delivered`. An unknown value is not an error: it returns `200` with an empty list.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "description": "Ignored — orders are hard-scoped to the authenticated customer",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated order list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/OrderListPage"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "orderId": "b3c1...",
                        "orderNumber": "ORD-LWZ3KP",
                        "status": "pending",
                        "currency": "TND",
                        "total": 186.8,
                        "paymentMethod": "cod",
                        "paymentStatus": "pending",
                        "itemCount": 1,
                        "placedAt": {}
                      }
                    ],
                    "total": 1,
                    "page": 1,
                    "limit": 20
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — authenticated principal's realm is not permitted for this route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/orders/{orderId}": {
      "get": {
        "operationId": "getMyOrder",
        "summary": "Get one of my orders",
        "description": "Returns full detail (items and status event timeline) for one of the authenticated customer's orders. Returns 404 if the order does not belong to the customer. Requires the customer realm.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/OrderDetail"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "orderId": "b3c1...",
                    "orderNumber": "ORD-LWZ3KP",
                    "status": "pending",
                    "currency": "TND",
                    "total": 186.8,
                    "paymentMethod": "cod",
                    "paymentStatus": "pending",
                    "itemCount": 1,
                    "placedAt": {},
                    "subtotal": 179.8,
                    "discountAmount": 0,
                    "shippingAmount": 7,
                    "customerNote": null,
                    "items": [
                      {
                        "itemId": "itm_1",
                        "productId": "prd_123",
                        "vendorId": "ven_42",
                        "title": "Casque Bluetooth",
                        "quantity": 2,
                        "unitPrice": 89.9,
                        "lineTotal": 179.8
                      }
                    ],
                    "events": [
                      {
                        "eventId": "ev_1",
                        "eventType": "order.placed",
                        "fromStatus": null,
                        "toStatus": "pending",
                        "note": null,
                        "occurredAt": {}
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — authenticated principal's realm is not permitted for this route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/orders/{orderId}/cancel": {
      "post": {
        "operationId": "cancelMyOrder",
        "summary": "Cancel one of my orders before it ships",
        "description": "The authenticated customer cancels their OWN order (same ownership rule as `GET /orders/{orderId}`: another customer's order is a 404). The order becomes `cancelled` with the chosen reason, a « Client » event is added to its timeline, the customer receives the cancellation e-mail, reserved stock is released and every vendor on the order is notified.\n\nAllowed only from `pending`, `confirmed` or `processing` AND while no vendor's part has shipped — otherwise 409 `ORDER_NOT_CANCELLABLE` with the current `status`. An order with any recorded payment or refund is refused with 409 `ORDER_PAID_CONTACT_SUPPORT` (money is handled by the marketplace). Already cancelled → 200 with the current order (idempotent).\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Orders"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerOrderCancelRequest"
              },
              "example": {
                "reasonCode": "customer_request"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Order cancelled (or already cancelled) — the current order detail.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/OrderDetail"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — unknown / non-customer reason code, `other` without a note, note over 500 characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — authenticated principal's realm is not permitted for this route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not found — no such order for this customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Order not found"
                }
              }
            }
          },
          "409": {
            "description": "The order can no longer be cancelled by the customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerOrderCancelError"
                },
                "examples": {
                  "notCancellable": {
                    "value": {
                      "ok": false,
                      "error": "ORDER_NOT_CANCELLABLE",
                      "message": "Cette commande ne peut plus être annulée.",
                      "data": {
                        "status": "shipped"
                      }
                    }
                  },
                  "paid": {
                    "value": {
                      "ok": false,
                      "error": "ORDER_PAID_CONTACT_SUPPORT",
                      "message": "Un paiement est enregistré sur cette commande : contactez le service client pour l’annuler.",
                      "data": {
                        "status": "confirmed"
                      }
                    }
                  },
                  "confirmedByVendor": {
                    "value": {
                      "ok": false,
                      "error": "ORDER_CONFIRMED_BY_VENDOR",
                      "message": "La commande a été confirmée par le vendeur ; contactez-le pour l’annuler.",
                      "data": {
                        "status": "confirmed"
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "The vendor's order mode could not be read for an order past `pending` (settings unavailable or corrupt) — the cancel is refused (fail closed), retry in a few minutes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerOrderCancelError"
                },
                "example": {
                  "ok": false,
                  "error": "ORDER_MODE_UNAVAILABLE",
                  "message": "Nous ne pouvons pas vérifier cette commande pour le moment : réessayez dans quelques minutes.",
                  "data": {
                    "status": "confirmed"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/orders/track": {
      "get": {
        "operationId": "trackOrder",
        "summary": "Public order tracking by number + email",
        "description": "Public, unauthenticated order lookup against the default account. Security requires BOTH the order number and the customer email to match (registered customer or guest address email); a mismatch returns 404 without distinguishing wrong-email from not-found. Invalid query parameters return 422.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "name": "order_id",
            "in": "query",
            "required": true,
            "description": "Human-readable order number (min 1)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "email"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order tracking summary",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/TrackingResponse"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "orderId": "ORD-LWZ3KP",
                    "status": "shipped",
                    "createdAt": {},
                    "total": 186.8,
                    "items": [
                      {
                        "name": "Casque Bluetooth",
                        "quantity": 2,
                        "price": 89.9
                      }
                    ],
                    "shippingAddress": {
                      "name": "Sami Ben Ali",
                      "address": "12 Rue de Carthage",
                      "city": "Tunis",
                      "phone": "+21620000000"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Missing or invalid query parameters (order_id / email)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/orders/track/{token}": {
      "get": {
        "operationId": "getPublicOrderTracking",
        "summary": "Public order tracking by token",
        "description": "Public, unauthenticated tracking using an unguessable trk_ token issued at order creation (or backfilled for legacy orders). Returns a deliberately narrow shape excluding email/phone, internal IDs and commission data. Any invalid/unknown token returns a generic 404 ('Lien invalide ou expiré').\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "description": "Tracking token matching /^trk_[a-zA-Z0-9]{16,40}$/",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Narrow public tracking view",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/PublicTrackingResponse"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "orderNumber": "ORD-LWZ3KP",
                    "customerFirstName": "Sami",
                    "status": "shipped",
                    "statusLabel": "Expédiée",
                    "paymentMethod": "cod",
                    "paymentStatus": "pending",
                    "currency": "TND",
                    "items": [
                      {
                        "title": "Casque Bluetooth",
                        "imageUrl": "https://cdn.example.com/p/123.jpg",
                        "quantity": 2,
                        "unitPrice": 89.9,
                        "lineTotal": 179.8
                      }
                    ],
                    "totals": {
                      "subtotal": 179.8,
                      "discount": 0,
                      "shipping": 7,
                      "tax": 0,
                      "total": 186.8
                    },
                    "shipping": {
                      "address1": "12 Rue de Carthage",
                      "city": "Tunis",
                      "country": "TN"
                    },
                    "carrier": {
                      "name": "Mylerz",
                      "awb": "MYL123456",
                      "trackingUrl": "https://mylerz.net/track/MYL123456"
                    },
                    "timeline": [
                      {
                        "status": "pending",
                        "statusLabel": "En attente",
                        "occurredAt": {}
                      }
                    ],
                    "placedAt": {},
                    "canRequestReturn": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/orders/track/{token}/return-request": {
      "post": {
        "operationId": "createPublicReturnRequest",
        "summary": "Request a return via tracking token",
        "description": "Public RMA entry point. Validates the trk_ token (invalid/unknown → 404), then creates a return in 'requested' status with the supplied line items for the resolved order. Invalid body returns 422.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Orders"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "description": "Tracking token matching /^trk_[a-zA-Z0-9]{16,40}$/",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "description": "5-500 chars"
                  },
                  "customerNotes": {
                    "type": "string",
                    "description": "max 2000 chars"
                  },
                  "lines": {
                    "type": "array",
                    "items": {},
                    "description": "[{ orderItemId, quantity (>=1) }] (min 1)"
                  }
                },
                "required": [
                  "reason",
                  "lines"
                ]
              },
              "example": {
                "reason": "Produit défectueux à la réception",
                "customerNotes": "Boîte endommagée",
                "lines": [
                  {
                    "orderItemId": "itm_1",
                    "quantity": 1
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Return request created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "returnId": {
                          "type": "string",
                          "format": "uuid"
                        }
                      },
                      "required": [
                        "returnId"
                      ]
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "returnId": "9d2e1a00-0000-4000-8000-000000000000"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "422": {
            "description": "Invalid return-request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/customers/me/addresses": {
      "get": {
        "operationId": "listMyAddresses",
        "summary": "List my saved addresses",
        "description": "Returns the authenticated customer's saved addresses for the resolved account, oldest first.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Customers"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Address list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AddressView"
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": [
                    {
                      "addressId": "adr_1",
                      "customerId": "cus_1",
                      "accountId": "acc_exemple",
                      "firstName": "Sami",
                      "lastName": "Ben Ali",
                      "address1": "12 Rue de Carthage",
                      "address2": null,
                      "city": "Tunis",
                      "state": null,
                      "postcode": "1000",
                      "countryCode": "TN",
                      "phone": "+21620000000",
                      "isDefaultBilling": true,
                      "isDefaultShipping": true,
                      "createdAt": {}
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — authenticated principal's realm is not permitted for this route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createMyAddress",
        "summary": "Create a saved address",
        "description": "Creates a saved address for the authenticated customer. Setting it as the default billing or shipping address clears that flag on the customer's other addresses. The `label` field is not stored: it is always returned as `null`.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Customers"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "firstName": {
                    "type": "string",
                    "description": "min 1"
                  },
                  "lastName": {
                    "type": "string",
                    "description": "min 1"
                  },
                  "address1": {
                    "type": "string",
                    "description": "min 1"
                  },
                  "address2": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string",
                    "description": "min 1"
                  },
                  "state": {
                    "type": "string"
                  },
                  "postcode": {
                    "type": "string"
                  },
                  "countryCode": {
                    "type": "string",
                    "description": "exactly 2 chars",
                    "default": "TN"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "isDefaultBilling": {
                    "type": "boolean",
                    "default": false
                  },
                  "isDefaultShipping": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "firstName",
                  "lastName",
                  "address1",
                  "city"
                ]
              },
              "example": {
                "firstName": "Sami",
                "lastName": "Ben Ali",
                "address1": "12 Rue de Carthage",
                "city": "Tunis",
                "countryCode": "TN",
                "phone": "+21620000000",
                "isDefaultShipping": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Address created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AddressView"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "addressId": "adr_1",
                    "customerId": "cus_1",
                    "accountId": "acc_exemple",
                    "firstName": "Sami",
                    "lastName": "Ben Ali",
                    "address1": "12 Rue de Carthage",
                    "address2": null,
                    "city": "Tunis",
                    "state": null,
                    "postcode": null,
                    "countryCode": "TN",
                    "phone": "+21620000000",
                    "isDefaultBilling": false,
                    "isDefaultShipping": true,
                    "createdAt": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — authenticated principal's realm is not permitted for this route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/customers/me/addresses/{addressId}": {
      "patch": {
        "operationId": "updateMyAddress",
        "summary": "Update a saved address",
        "description": "Updates one of the authenticated customer's saved addresses; default-billing/shipping flags clear the flag on the customer's other addresses (in a transaction). Returns 404 if the address does not belong to the customer. Guarded by the 'customer' realm.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Customers"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "addressId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "firstName": {
                    "type": "string",
                    "description": "min 1"
                  },
                  "lastName": {
                    "type": "string",
                    "description": "min 1"
                  },
                  "address1": {
                    "type": "string",
                    "description": "min 1"
                  },
                  "address2": {
                    "type": "string"
                  },
                  "city": {
                    "type": "string",
                    "description": "min 1"
                  },
                  "state": {
                    "type": "string"
                  },
                  "postcode": {
                    "type": "string"
                  },
                  "countryCode": {
                    "type": "string",
                    "description": "exactly 2 chars",
                    "default": "TN"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "isDefaultBilling": {
                    "type": "boolean",
                    "default": false
                  },
                  "isDefaultShipping": {
                    "type": "boolean",
                    "default": false
                  }
                },
                "required": [
                  "firstName",
                  "lastName",
                  "address1",
                  "city"
                ]
              },
              "example": {
                "firstName": "Sami",
                "lastName": "Ben Ali",
                "address1": "15 Avenue Habib Bourguiba",
                "city": "Tunis",
                "countryCode": "TN",
                "isDefaultShipping": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated address",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/AddressView"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "addressId": "adr_1",
                    "customerId": "cus_1",
                    "accountId": "acc_exemple",
                    "firstName": "Sami",
                    "lastName": "Ben Ali",
                    "address1": "15 Avenue Habib Bourguiba",
                    "address2": null,
                    "city": "Tunis",
                    "state": null,
                    "postcode": null,
                    "countryCode": "TN",
                    "phone": "+21620000000",
                    "isDefaultBilling": false,
                    "isDefaultShipping": true,
                    "createdAt": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — authenticated principal's realm is not permitted for this route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteMyAddress",
        "summary": "Delete a saved address",
        "description": "Deletes one of the authenticated customer's saved addresses. Returns 204 No Content on success, 404 if not found. Guarded by the 'customer' realm.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Customers"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "addressId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Address deleted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "message"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "message": "Operation completed"
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — authenticated principal's realm is not permitted for this route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/customers/me/wishlist": {
      "get": {
        "operationId": "listMyWishlist",
        "summary": "List the customer's wishlist (« Favoris »)",
        "description": "The authenticated customer's wishlist as storefront product CARDS — the same shape `GET /products` returns (`ProductListItem`), plus `addedAt` — newest saved first. Shared by the mobile app and web.\n\nFiltered at READ time by the storefront visibility rule (published, actively listed, not a hidden group offer, not a hidden out-of-stock product), so `total` counts visible items only. A product that goes offline stays saved and reappears when it comes back. Honours `X-Channel` (group display mode) like `/products`. Response is `Cache-Control: private, no-store`.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Customers"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "X-Channel",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "web",
                "mobile"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of visible wishlist products.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/WishlistPage"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — query, body or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "productId": [
                        "Required"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — the token's realm is not `customer`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "addToMyWishlist",
        "summary": "Add a product to the customer's wishlist",
        "description": "Idempotent: `201` + `added: true` when saved, `200` + `added: false` when it was already there. The product must be visible on the storefront, else `404 PRODUCT_NOT_FOUND`. A vendor SOURCE product id is accepted and resolved to the marketplace copy the storefront lists — the stored (and returned) `productId` is always the listed one. At most 500 items per customer: beyond that `409 WISHLIST_FULL` (re-adding an existing item still answers 200). The customer is the token's; any other body field is rejected (400).\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Customers"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "productId"
                ],
                "properties": {
                  "productId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64
                  }
                }
              },
              "example": {
                "productId": "prd_123"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already in the wishlist (idempotent replay).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WishlistAddResponse"
                },
                "example": {
                  "ok": true,
                  "data": {
                    "productId": "prd_123",
                    "added": false,
                    "count": 4
                  }
                }
              }
            }
          },
          "201": {
            "description": "Saved.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WishlistAddResponse"
                },
                "example": {
                  "ok": true,
                  "data": {
                    "productId": "prd_123",
                    "added": true,
                    "count": 4
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — query, body or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "productId": [
                        "Required"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — the token's realm is not `customer`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "404": {
            "description": "Unknown product, or not visible on the storefront.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Product not found",
                  "code": "PRODUCT_NOT_FOUND"
                }
              }
            }
          },
          "409": {
            "description": "The wishlist already holds 500 items.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Wishlist is full (500 items max)",
                  "code": "WISHLIST_FULL"
                }
              }
            }
          }
        }
      }
    },
    "/customers/me/wishlist/ids": {
      "get": {
        "operationId": "listMyWishlistIds",
        "summary": "Wishlist product ids (heart icons)",
        "description": "Every saved product id, newest first, NOT filtered by visibility (a hidden product has no card to decorate). Cheap — one indexed read — for the heart icon on cards and product pages. Response is `Cache-Control: private, no-store`.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Customers"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Saved product ids.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "productIds"
                      ],
                      "properties": {
                        "productIds": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "productIds": [
                      "prd_123",
                      "prd_456"
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — the token's realm is not `customer`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          }
        }
      }
    },
    "/customers/me/wishlist/{productId}": {
      "delete": {
        "operationId": "removeFromMyWishlist",
        "summary": "Remove a product from the customer's wishlist",
        "description": "Idempotent — `204` whether or not the product was saved. Accepts the listed id or a vendor source id (its marketplace copy is removed).\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Customers"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Removed (or was not saved)."
          },
          "400": {
            "description": "Bad request — query, body or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "productId": [
                        "Required"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — the token's realm is not `customer`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          }
        }
      }
    },
    "/customers/me/devices": {
      "post": {
        "operationId": "registerMyDevice",
        "summary": "Register the app's push token (FCM) for the signed-in customer",
        "description": "mobile app push notifications. Upsert by `token`: a new token creates a device, a known one refreshes `lastSeenAt` — and a token registered under ANOTHER customer (shared phone, new sign-in) is reassigned to the caller. At most 10 devices per customer: the least recently seen one is dropped. Always `200`. The customer is the token's; unknown body fields are ignored. Pushes sent to these devices (order confirmed / shipped / delivered / cancelled by the shop, store reservation ready / cancelled by the shop) carry `data` strings `{ type: order_status | reservation, orderId?, orderNumber?, status, reservationNumber?, path }` with `path` = `/commande/<orderId>` or `/reservation/<reservationNumber>`; Android channel `orders`. Sending is off until the marketplace switches it on.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Customers"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "token",
                  "platform"
                ],
                "properties": {
                  "token": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4096,
                    "description": "FCM registration token (no whitespace)."
                  },
                  "platform": {
                    "type": "string",
                    "enum": [
                      "android",
                      "ios"
                    ]
                  },
                  "appVersion": {
                    "type": "string",
                    "maxLength": 64,
                    "nullable": true
                  },
                  "locale": {
                    "type": "string",
                    "maxLength": 35,
                    "nullable": true
                  }
                }
              },
              "example": {
                "token": "fGx1abc:APA91bExample",
                "platform": "android",
                "appVersion": "2.0.0",
                "locale": "fr"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Registered (created, refreshed or reassigned).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "$ref": "#/components/schemas/CustomerDevice"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "deviceId": "dev_3f1c9a0e5b7d4c2a9e8f1b2c3d4e5f60",
                    "platform": "android",
                    "createdAt": "2026-11-26T09:00:00.000Z",
                    "lastSeenAt": "2026-11-26T09:00:00.000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — the token's realm is not `customer`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed (`error` = `VALIDATION`, zod `details`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "VALIDATION",
                  "message": "Appareil invalide."
                }
              }
            }
          }
        }
      }
    },
    "/customers/me/devices/{token}": {
      "delete": {
        "operationId": "unregisterMyDevice",
        "summary": "Forget a push token (sign-out, notifications turned off)",
        "description": "Idempotent — `200` with `deleted: true` when the caller's device was removed, `false` when there was none. Only ever deletes the caller's own device; another customer's token answers `deleted: false`. Percent-encode the token in the path.\n\n**Auth:** Bearer JWT required; allowed realms: customer.",
        "tags": [
          "Customers"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 4096
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Done (idempotent).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "deleted"
                      ],
                      "properties": {
                        "deleted": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "deleted": true
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized — missing, invalid, or expired bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Unauthorized"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden — the token's realm is not `customer`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Forbidden"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed (`error` = `VALIDATION`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "VALIDATION",
                  "message": "Jeton invalide."
                }
              }
            }
          }
        }
      }
    },
    "/vendors": {
      "get": {
        "operationId": "listVendors",
        "deprecated": true,
        "summary": "List storefront vendors",
        "description": "Public storefront listing of vendors for the resolved tenant (falls back to the default account when no tenant context). Supports search, status filter and pagination.\n\n**Auth:** Public (no authentication).\n\nUse /public/vendors; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Vendors"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page (min 1)",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size (1..100)",
            "schema": {
              "type": "integer",
              "default": 20
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Case-insensitive name search",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by vendor status",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive"
              ],
              "default": "active"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated vendor list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/VendorListItem"
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "page": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "items",
                        "total",
                        "page",
                        "limit"
                      ]
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "ven_01",
                        "name": "Boutique Carthage",
                        "email": "client@example.com",
                        "phone": "+21671000111",
                        "avatarUrl": "https://cdn.marketkit.tn/v/ven_01.png",
                        "status": "active",
                        "commissionType": "percentage",
                        "commissionRate": 12.5,
                        "productCount": 0,
                        "createdAt": {}
                      }
                    ],
                    "total": 1,
                    "page": 1,
                    "limit": 20
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/vendors": {
      "get": {
        "operationId": "listVendorsPublic",
        "summary": "List storefront vendors",
        "description": "Public storefront listing of vendors for the resolved tenant (falls back to the default account when no tenant context). Supports search, status filter and pagination.\n\n**Auth:** Public (no authentication).\n\nSame route as `GET /vendors` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Vendors"
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "1-based page (min 1)",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size (1..100)",
            "schema": {
              "type": "integer",
              "default": 20
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Case-insensitive name search",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by vendor status",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive"
              ],
              "default": "active"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated vendor list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/VendorListItem"
                          }
                        },
                        "total": {
                          "type": "integer"
                        },
                        "page": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "items",
                        "total",
                        "page",
                        "limit"
                      ]
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "id": "ven_01",
                        "name": "Boutique Carthage",
                        "email": "client@example.com",
                        "phone": "+21671000111",
                        "avatarUrl": "https://cdn.marketkit.tn/v/ven_01.png",
                        "status": "active",
                        "commissionType": "percentage",
                        "commissionRate": 12.5,
                        "productCount": 0,
                        "createdAt": {}
                      }
                    ],
                    "total": 1,
                    "page": 1,
                    "limit": 20
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/vendors/{vendorId}": {
      "get": {
        "operationId": "getVendorById",
        "deprecated": true,
        "summary": "Get a storefront vendor",
        "description": "Public storefront fetch of a single vendor (with banner) scoped to the resolved tenant. Returns 404 when the vendor is not found for the tenant.\n\n**Auth:** Public (no authentication).\n\nUse /public/vendors/{vendorId}; this path stays until the storefront and the mobile app have moved.",
        "tags": [
          "Vendors"
        ],
        "parameters": [
          {
            "name": "vendorId",
            "in": "path",
            "required": true,
            "description": "Vendor id",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Vendor detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/VendorDetail"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "ven_01",
                    "name": "Boutique Carthage",
                    "email": "client@example.com",
                    "phone": "+21671000111",
                    "avatarUrl": "https://cdn.marketkit.tn/v/ven_01.png",
                    "bannerUrl": "https://cdn.marketkit.tn/v/ven_01_banner.png",
                    "status": "active",
                    "commissionType": "percentage",
                    "commissionRate": 12.5,
                    "productCount": 0,
                    "createdAt": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/vendors/{vendorId}": {
      "get": {
        "operationId": "getVendorByIdPublic",
        "summary": "Get a storefront vendor",
        "description": "Public storefront fetch of a single vendor (with banner) scoped to the resolved tenant. Returns 404 when the vendor is not found for the tenant.\n\n**Auth:** Public (no authentication).\n\nSame route as `GET /vendors/{vendorId}` under the explicit `/public` namespace: same handler, parameters, cache headers and `X-Channel` handling. Prefer this path.",
        "tags": [
          "Vendors"
        ],
        "parameters": [
          {
            "name": "vendorId",
            "in": "path",
            "required": true,
            "description": "Vendor id",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Vendor detail",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/VendorDetail"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "id": "ven_01",
                    "name": "Boutique Carthage",
                    "email": "client@example.com",
                    "phone": "+21671000111",
                    "avatarUrl": "https://cdn.marketkit.tn/v/ven_01.png",
                    "bannerUrl": "https://cdn.marketkit.tn/v/ven_01_banner.png",
                    "status": "active",
                    "commissionType": "percentage",
                    "commissionRate": 12.5,
                    "productCount": 0,
                    "createdAt": {}
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/coupons/validate": {
      "post": {
        "operationId": "quoteCouponPublic",
        "summary": "Validate a coupon against a basket, per line (public)",
        "description": "Storefront cart entry. Every line is RE-PRICED server-side with the same rule as checkout — the client never sends a price — then the coupon is evaluated: scope (all / vendor / category incl. sub-categories / brand), minimum on the in-scope subtotal, percent with optional cap or fixed amount, global and per-shopper uses, channel pin, phone reservation. The discount is split per line in millimes. Nothing is reserved: `POST /checkout` with `couponCode` re-evaluates and consumes the use atomically.\n\nErrors are HTTP 422 with a readable `error.code`: `not_found` (unknown, disabled, or reserved to another phone — no existence leak), `expired`, `min_not_reached`, `not_applicable` (out of scope, not yet active, other channel), `already_used` (global or per-shopper cap), `phone_required` (a once-per-shopper code with neither a customer token nor a phone), `line_unavailable`. The channel is resolved server-side like checkout (`wildkard` on the default marketplace), never from the body.\n\nThe marketplace is resolved from the host, never the body. A customer token (optional) counts the per-customer cap on that customer.\n\n**Auth:** Public (customer Bearer JWT optional).",
        "tags": [
          "Coupons"
        ],
        "security": [
          {},
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CouponQuoteRequest"
              },
              "example": {
                "code": "WELCOME10",
                "lines": [
                  {
                    "productId": "prd_123",
                    "variantId": "var_42",
                    "quantity": 2
                  }
                ],
                "phone": "+216 98 123 456"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The code applies — per-line quote",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/CouponQuote"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "valid": true,
                    "code": "WELCOME10",
                    "type": "percent",
                    "fundedBy": "platform",
                    "freeShipping": false,
                    "subtotal": 179.8,
                    "eligibleSubtotal": 179.8,
                    "discountAmount": 17.98,
                    "lines": [
                      {
                        "productId": "prd_123",
                        "variantId": "var_42",
                        "vendorId": "ven_1",
                        "quantity": 2,
                        "unitPrice": 89.9,
                        "lineTotal": 179.8,
                        "eligible": true,
                        "discountAmount": 17.98
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — the body failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CouponErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "The code does not apply (readable code)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CouponErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "code": "min_not_reached",
                    "message": "Le montant minimum de commande pour ce code n’est pas atteint."
                  },
                  "message": "Le montant minimum de commande pour ce code n’est pas atteint."
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CouponErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/public/erp-stock-by-warehouse": {
      "get": {
        "operationId": "getPublicErpStockByWarehouse",
        "summary": "Storefront-safe per-warehouse stock status",
        "description": "Public storefront read of the per-store stock status of a product for one vendor. Only active stores linked to the vendor are listed; each one carries a low-stock-aware status, never a raw quantity, and no internal id. `vendor_id` is required. The marketplace is resolved from the product itself.\n\n`Cache-Control: public, max-age=60`.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "ERP Stock by Warehouse"
        ],
        "parameters": [
          {
            "name": "X-Channel",
            "in": "header",
            "required": false,
            "description": "Distribution channel selecting per-channel storefront display config (independent toggles per marketplace tenant). Display config, not authentication. Absent header defaults to `web`.",
            "schema": {
              "type": "string",
              "enum": [
                "web",
                "mobile"
              ],
              "default": "web"
            }
          },
          {
            "name": "mk_product_id",
            "in": "query",
            "required": true,
            "description": "1..64",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "vendor_id",
            "in": "query",
            "required": true,
            "description": "1..64",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mk_variant_id",
            "in": "query",
            "required": false,
            "description": "Scope to the exact variation (size/colour) the customer selected; falls back to whole-product when the product has no per-variant mappings. 1..64",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Storefront-safe warehouse list (sets Cache-Control: public, max-age=60)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PublicWarehouseStock"
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": [
                    {
                      "storeId": "wh_1",
                      "name": "Entrepôt Tunis",
                      "city": "Tunis",
                      "lat": 36.8065,
                      "lng": 10.1815,
                      "status": "in_stock"
                    },
                    {
                      "storeId": "wh_2",
                      "name": "Sousse",
                      "city": "Sousse",
                      "lat": null,
                      "lng": null,
                      "status": "out_of_stock"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Product not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/stores": {
      "get": {
        "operationId": "getPublicStores",
        "summary": "Physical stores of the marketplace's vendors (store directory)",
        "description": "Every public store of every vendor with an ACTIVE relation to the storefront's marketplace (tenant resolved from the host like `GET /products`, default marketplace otherwise). `storeId` is the SAME id as `stores[].storeId` in GET /public/erp-stock-by-warehouse and GET /public/variant-availability, and the store a store reservation targets.\n\nPublic = active, physical, owned by a vendor, and either shown explicitly by the vendor or (automatic) linked to an ERP depot. Fields the vendor has not filled are null / `[]` — the storefront emits LocalBusiness markup only for stores with a street and a city.\n\nAlways 200 (an empty `items` when there is no store). Cache-Control: public, max-age=300.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Stores"
        ],
        "responses": {
          "200": {
            "description": "Store directory (Cache-Control: public, max-age=300)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "items"
                      ],
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/PublicStore"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "storeId": "wh_dep_2f81d3c2dbf4d0df132a061f",
                        "name": "La Marsa",
                        "vendorId": "vnd_exemple",
                        "vendorName": "Boutique Exemple",
                        "address": {
                          "street": "12 av. Habib Bourguiba",
                          "city": "La Marsa",
                          "postalCode": "2070",
                          "region": "Tunis"
                        },
                        "phone": "+216 20 123 456",
                        "geo": {
                          "lat": 36.8782,
                          "lng": 10.3247
                        },
                        "openingHours": [
                          {
                            "days": [
                              "Monday",
                              "Tuesday",
                              "Wednesday",
                              "Thursday",
                              "Friday",
                              "Saturday"
                            ],
                            "opens": "10:00",
                            "closes": "20:00"
                          }
                        ],
                        "imageUrl": null
                      }
                    ]
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/public/variant-availability": {
      "get": {
        "operationId": "getPublicVariantAvailability",
        "summary": "Per-vendor online + in-store availability for a selected variation",
        "description": "Storefront-facing, public. For the selected variation, returns — for every vendor offering the product's EAN group — the online availability of that variation AND its per-store (in-store) availability. Quantities are hidden (low-stock-aware status only). Cross-vendor variant matching keys off the variant EAN, falling back to a normalized selectable-axis signature (color+size…). Account is resolved from the product. Cache-Control: public, max-age=60.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Variant Availability"
        ],
        "parameters": [
          {
            "name": "X-Channel",
            "in": "header",
            "required": false,
            "description": "Distribution channel selecting per-channel storefront display config (independent toggles per marketplace tenant). Display config, not authentication. Absent header defaults to `web`.",
            "schema": {
              "type": "string",
              "enum": [
                "web",
                "mobile"
              ],
              "default": "web"
            }
          },
          {
            "name": "mk_product_id",
            "in": "query",
            "required": true,
            "description": "1..64",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "mk_variant_id",
            "in": "query",
            "required": true,
            "description": "The variation the customer selected. 1..64",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Per-vendor availability for the selected variation (sets Cache-Control: public, max-age=60)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/VariantAvailability"
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "productId": "prod_123",
                    "variantId": "var_456",
                    "vendors": [
                      {
                        "vendorId": "vendor_a",
                        "vendorName": "Boutique Exemple",
                        "vendorWhatsapp": "21620000000",
                        "price": 199.9,
                        "online": {
                          "status": "in_stock"
                        },
                        "stores": [
                          {
                            "storeId": "wh_1",
                            "name": "Skanes",
                            "city": "Sfax",
                            "status": "low_stock"
                          }
                        ],
                        "stockScopedToVariant": true,
                        "productId": "prod_123",
                        "variantId": "var_456"
                      },
                      {
                        "vendorId": "vendor_b",
                        "vendorName": "Sport Exemple",
                        "vendorWhatsapp": null,
                        "price": 209,
                        "online": {
                          "status": "out_of_stock"
                        },
                        "stores": [],
                        "stockScopedToVariant": false,
                        "productId": "prod_789",
                        "variantId": null
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Product or variant not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/products/{productId}/bundles": {
      "get": {
        "operationId": "listProductBundles",
        "summary": "Eligible multi-vendor bundles containing a product (storefront)",
        "description": "Only packs a shopper can buy right now: active and inside their dates, every item's product published on the marketplace and not hidden on the storefront, every vendor taking online orders (offer capability `order`, product ?? vendor ?? marketplace — the same rule checkout enforces), every item in stock for its pack quantity (the variant when the item names one, else any variant / the product), and every item priced. One failing item drops the whole pack. `unitPrice` is the item's own catalogue price (same pricer as checkout); `price` is what the pack costs. Add the pack to the cart by sending each item as a checkout line with `bundleId` (an item with `variantId: null` takes the variant the shopper picks).\n\nCache: `public, max-age=60, s-maxage=60, stale-while-revalidate=300`, `Vary: X-Channel` (same window as the product page).\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Bundles"
        ],
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Eligible packs (possibly empty).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "items"
                      ],
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/PublicBundle"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "items": [
                      {
                        "bundleId": "bdl_3f1c2a9e0b7d4c6a8e5f1b2c",
                        "title": "Pack match",
                        "price": 189,
                        "compareAtPrice": 215,
                        "currency": "TND",
                        "items": [
                          {
                            "productId": "prd_shirt",
                            "variantId": null,
                            "vendorId": "ven_a",
                            "quantity": 1,
                            "title": "Maillot",
                            "slug": "maillot",
                            "imageUrl": null,
                            "unitPrice": 129
                          },
                          {
                            "productId": "prd_ball",
                            "variantId": "var_ball_5",
                            "vendorId": "ven_b",
                            "quantity": 1,
                            "title": "Ballon",
                            "slug": "ballon",
                            "imageUrl": null,
                            "unitPrice": 86
                          }
                        ]
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/public/whatsapp-clicks": {
      "post": {
        "operationId": "trackWhatsappClick",
        "summary": "Record a WhatsApp button click (public)",
        "description": "Storefront ingest for the \"Commander via WhatsApp\" button. Called by the web storefront and the mobile app, normally via `navigator.sendBeacon`, at the moment the shopper leaves for WhatsApp.\n\nThe distribution channel is taken from the `X-Channel` header (`web` | `mobile`), the marketplace tenant from the usual storefront resolution. A body naming a vendor that does not exist is rejected — no orphan rows.\n\n**Auth:** none (public).",
        "tags": [
          "Analytics"
        ],
        "parameters": [
          {
            "name": "X-Channel",
            "in": "header",
            "required": false,
            "description": "Distribution channel the click came from. Absent header defaults to `web`.",
            "schema": {
              "type": "string",
              "enum": [
                "web",
                "mobile"
              ],
              "default": "web"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WhatsappClickInput"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Click accepted (nothing to return — the caller has already navigated away).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body, or unknown vendor."
          },
          "429": {
            "description": "Too many requests. Retry later."
          }
        }
      }
    },
    "/public/gdpr/request": {
      "post": {
        "operationId": "createPublicGdprRequest",
        "summary": "Submit a GDPR request (public)",
        "description": "Public, customer-facing: submits an export or anonymize request by email. A verification email is sent if the address matches a customer; the response is identical whether or not a match exists to prevent account enumeration. Always responds 202.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "GDPR"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "description": "3-255 chars"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "export",
                      "anonymize"
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "description": "max 512 chars"
                  }
                },
                "required": [
                  "email",
                  "type"
                ]
              },
              "example": {
                "email": "sami@example.tn",
                "type": "export",
                "reason": "Je souhaite récupérer mes données"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Request accepted (neutral message, no account enumeration)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ]
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "message": "Si un compte correspond à cette adresse, un email de confirmation a été envoyé."
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/public/gdpr/verify/{token}": {
      "post": {
        "operationId": "verifyPublicGdprRequest",
        "summary": "Verify a GDPR request (public)",
        "description": "Public: confirms a GDPR request via the emailed token. For export requests it returns the export payload inline and marks the request fulfilled; for anonymize requests it marks the request verified only. Returns 404 for an invalid or used token.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "GDPR"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Verification result — export payload (export) or pending message (anonymize)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "export",
                            "anonymize"
                          ]
                        },
                        "request": {
                          "description": "{ requestId, status }"
                        },
                        "export": {
                          "allOf": [
                            {
                              "$ref": "#/components/schemas/CustomerExportPayload"
                            }
                          ],
                          "description": "Present only for export"
                        },
                        "message": {
                          "type": "string",
                          "description": "Present only for anonymize"
                        }
                      },
                      "required": [
                        "type",
                        "request"
                      ]
                    }
                  }
                },
                "example": {
                  "ok": true,
                  "data": {
                    "type": "anonymize",
                    "request": {
                      "requestId": "gdpr_001",
                      "status": "verified"
                    },
                    "message": "Votre demande a été reçue. Un administrateur la traitera sous 30 jours conformément à la Loi 2004-63."
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request — request body, query, or path parameter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": {
                    "formErrors": [],
                    "fieldErrors": {
                      "field": [
                        "Invalid input"
                      ]
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found — the referenced resource does not exist (or is not visible to this tenant).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Not found"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "ok": false,
                  "error": "Internal server error."
                }
              }
            }
          }
        }
      }
    },
    "/vendor-api/stock": {
      "get": {
        "operationId": "vendorApiListStock",
        "summary": "Vendor stock API — the calling vendor's articles (stock, price pair)",
        "description": "For a vendor's own software. Authenticated by a vendor API key with the `stock` scope (`Authorization: Bearer vk_…` or `X-Api-Key`), created by the vendor in its back office (« Mise à jour du stock » › API) or by the marketplace on its behalf; no login, no JWT. The key IS the vendor: only its own articles are read.\n\n`price` = regular selling price, `salePrice` = promotional price when a promotion runs.\n\nCalls are rate limited per key and per IP: a `429` means « try again later ».",
        "tags": [
          "Vendor API"
        ],
        "security": [
          {
            "vendorStockKey": []
          }
        ],
        "parameters": [
          {
            "name": "reference",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Product reference (its SKU)"
          },
          {
            "name": "sku",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Article SKU"
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Articles",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "items",
                        "pagination"
                      ],
                      "properties": {
                        "items": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/VendorStockRow"
                          }
                        },
                        "pagination": {
                          "type": "object",
                          "properties": {
                            "page": {
                              "type": "integer"
                            },
                            "pageSize": {
                              "type": "integer"
                            },
                            "total": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Unknown query parameter or invalid paging.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Key missing, malformed, wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Key without the `stock` scope (a full key), or vendor account not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "vendorApiPushStock",
        "summary": "Vendor stock API — update stock and/or prices of the calling vendor's articles",
        "description": "`dryRun` defaults to TRUE (JSON boolean): the answer lists what would change and nothing is written; send `\"dryRun\": false` to apply. ≤ 2,000 items per call, body ≤ 2 MB, one write at a time per vendor (409).\n\nEach item names ONE article of the vendor — `sku` (article SKU, or the product SKU of a product without sizes), else `ean`, else `reference` + `size` (+ `color`) — and carries `stock` and/or `price` (+ `salePrice`: below `price`; `null` ends the promotion; absent keeps a running promotion that is still below the new price). Unknown, ambiguous, duplicated or ERP-fed articles come back in `notFound` with their index — never guessed, never created (this API cannot create products, nor change designations / photos).\n\nSame write path as a file import (`stock_price`): Wildkard copies follow, connected stores get the stock, search is reindexed; price and stock need no Wildkard re-approval. A strict-ERP vendor's stock is never written (`stockBlockedBy: strict_erp`).",
        "tags": [
          "Vendor API"
        ],
        "security": [
          {
            "vendorStockKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "items"
                ],
                "properties": {
                  "dryRun": {
                    "type": "boolean",
                    "default": true
                  },
                  "items": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 2000,
                    "items": {
                      "$ref": "#/components/schemas/VendorStockItem"
                    }
                  }
                }
              },
              "example": {
                "dryRun": true,
                "items": [
                  {
                    "sku": "CHEMISE01-27",
                    "stock": 3
                  },
                  {
                    "reference": "CHEMISE01",
                    "size": "28",
                    "stock": 0
                  },
                  {
                    "sku": "JEAN02-26",
                    "price": 109,
                    "salePrice": 89
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "What changed (or would change)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "example": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/VendorStockPushResult"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid body (unknown key, no identifier, nothing to write, promo ≥ price, > 2000 items, dryRun not a boolean).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Key missing, malformed, wrong or revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Key without the `stock` scope, or vendor account not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "Another write for this vendor is running.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/public/tenant": {
      "get": {
        "operationId": "getPublicTenant",
        "summary": "Public tenant identity, copy and storefront feature flags",
        "description": "Storefront read of the marketplace's public settings: site name, tagline, default meta description, country, currency, locale, logos, contact, social links, payment methods shown in the footer, trust line, home FAQ, plus four feature flags.\n\nThe marketplace is resolved like every storefront read (`Host`, then the `/t/:tenantId/` path prefix, else the default marketplace). Values the marketplace has not set fall back to neutral defaults (its account name, empty lists, null contact).\n\nThe payload is built field by field from a whitelist — it never carries secrets. A malformed stored setting degrades to the defaults (never a 500).\n\n`paymentMethods` is the list the marketplace SHOWS (footer); checkout itself only accepts cash on delivery today.\n\n`Cache-Control: public, max-age=300, s-maxage=300` — an edit takes up to 5 minutes to show.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Public Tenant"
        ],
        "responses": {
          "200": {
            "description": "Effective public settings of the resolved tenant.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "public, max-age=300, s-maxage=300"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/PublicTenantSettings"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/public/banners": {
      "get": {
        "operationId": "getPublicBanners",
        "summary": "Live storefront banners (home hero, home promo, category header)",
        "description": "The banners the storefront (web + mobile) shows. Only LIVE banners are served: `active` and inside their optional `[startsAt, endsAt)` window — the schedule itself is never on the wire. Sorted by the back office's order.\n\nImages carry no baked-in text: `title` / `subtitle` / `ctaLabel` are drawn by the client. `imageUrl` is the wide image (≈ 21:9), `mobileImageUrl` the narrower one (≈ 3:2) — fall back to `imageUrl` when null.\n\nThe tenant is resolved like every storefront read. A malformed stored row reads as an empty list (never a 500).\n\n`Cache-Control: public, max-age=300, s-maxage=300`; a back-office save also purges the storefront tag `banners`.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Storefront Banners"
        ],
        "parameters": [
          {
            "name": "placement",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "home_hero",
                "home_promo",
                "category"
              ]
            }
          },
          {
            "name": "categoryId",
            "in": "query",
            "required": false,
            "description": "Only the banners of this category (placement `category`).",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Live banners.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "public, max-age=300, s-maxage=300"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PublicBanner"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid query (unknown placement).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/public/store-events": {
      "get": {
        "operationId": "getPublicStoreEvents",
        "summary": "Current and upcoming in-store promotions and events",
        "description": "« En ce moment en boutique »: what the marketplace's vendors announce IN their physical stores — a `promotion` or an `event`, each attached to one store of GET /public/stores. Only events that are `active` and not yet ended (`endsAt` in the future) are served, of stores the storefront shows, and never one another marketplace entered; sorted soonest first (by `startsAt`, then `endsAt`), at most 50.\n\n`allDay: true` means the dates matter, not the times (print « Du 5 au 14 décembre »); `startsAt` / `endsAt` always carry an offset. An event whose `startsAt` is past is running now.\n\nThe tenant is resolved like every storefront read. A malformed stored row reads as no events (never a 500).\n\n`Cache-Control: public, max-age=300, s-maxage=300`; a back-office write also purges the storefront tag `store-events`.\n\n**Auth:** Public (no authentication).",
        "tags": [
          "Store Events"
        ],
        "responses": {
          "200": {
            "description": "Current and upcoming events.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "public, max-age=300, s-maxage=300"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "items"
                      ],
                      "properties": {
                        "items": {
                          "type": "array",
                          "maxItems": 50,
                          "items": {
                            "$ref": "#/components/schemas/PublicStoreEvent"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/public/category-alerts": {
      "post": {
        "operationId": "createCategoryAlert",
        "summary": "Ask to be e-mailed when a « Bientôt » category gets its first products",
        "description": "Guest write (a customer token, when present, only links the customer id — read from the TOKEN, never the body). The category must belong to the marketplace's MASTER tree, any status — 404 `CATEGORY_NOT_FOUND` otherwise (unknown id or a vendor's own category).\n\nIdempotent per (marketplace, category, normalised e-mail — lower-cased, `+tag` dropped). The answer is the **same 202** whether the subscription is new, already pending, already notified or re-armed after an unsubscribe: the caller never learns whether an address was known.\n\nOne e-mail is sent per subscription, by an hourly job, once the category's subtree holds ≥ 1 product the storefront shows (same count as `GET /categories`). Sending is OFF until the marketplace switches it on; subscriptions are accepted either way.\n\n**Auth:** Public (no authentication); optional customer Bearer token.",
        "tags": [
          "Category Alerts"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "categoryId",
                  "email"
                ],
                "properties": {
                  "categoryId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64,
                    "description": "Category id (`cat_…`) of the marketplace's master tree."
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 191
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Subscription recorded (or already known — same answer).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "data"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean",
                      "enum": [
                        true
                      ]
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "status",
                        "message"
                      ],
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "subscribed"
                          ]
                        },
                        "message": {
                          "type": "string",
                          "description": "French, displayable."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "`CATEGORY_NOT_FOUND` — not a category of the marketplace's master tree.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          },
          "422": {
            "description": "`VALIDATION` — invalid e-mail or category id.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          }
        }
      }
    },
    "/public/category-alerts/unsubscribe": {
      "get": {
        "operationId": "unsubscribeCategoryAlertLink",
        "summary": "Unsubscribe from a category alert (link in the e-mail)",
        "description": "Target of the link in the alert e-mail. The token is random and re-minted at each send. Idempotent. With `Accept: text/html` (a browser) the answer is a small French HTML page (200, or 404 for an invalid link); otherwise JSON.\n\n**Auth:** Public (no authentication); the token is the credential.",
        "tags": [
          "Category Alerts"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Unsubscribed (or already was).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoryAlertUnsubscribed"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "`INVALID_TOKEN` — unknown or malformed token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "unsubscribeCategoryAlert",
        "summary": "Unsubscribe from a category alert (token in the body)",
        "description": "Same as the GET link, for an app that opened the link itself. Idempotent.\n\n**Auth:** Public (no authentication); the token is the credential.",
        "tags": [
          "Category Alerts"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "type": "string",
                    "maxLength": 128
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unsubscribed (or already was).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CategoryAlertUnsubscribed"
                }
              }
            }
          },
          "404": {
            "description": "`INVALID_TOKEN` — unknown or malformed token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          },
          "429": {
            "description": "Too many requests. Retry later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StorefrontCodedError"
                }
              }
            }
          }
        }
      }
    },
    "/agent/me": {
      "get": {
        "operationId": "agentWhoami",
        "summary": "Who this agent key is (name, account, scopes)",
        "description": "Call first: tells which scopes — hence which other endpoints / MCP tools — this key may use.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Identity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          }
        }
      }
    },
    "/agent/products": {
      "get": {
        "operationId": "agentSearchProducts",
        "summary": "Search the marketplace catalogue (catalog:read)",
        "description": "Matches `q` on title (contains), SKU / slug (prefix), EAN (exact). Status `publish` = online on the marketplace storefront. Prices are in the marketplace currency: `price` is the selling price, `compareAtPrice` the regular one when on sale. Newest update first; page with `meta.nextCursor`.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "publish",
                "private",
                "draft",
                "pending"
              ]
            }
          },
          {
            "name": "vendor_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "updated_since",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "$ref": "#/components/parameters/AgentLimit"
          },
          {
            "$ref": "#/components/parameters/AgentCursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Products",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AgentBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentForbidden"
          },
          "429": {
            "$ref": "#/components/responses/AgentRateLimited"
          }
        }
      }
    },
    "/agent/products/{id}": {
      "get": {
        "operationId": "agentGetProduct",
        "summary": "One product fiche with its variants (catalog:read)",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Product id or slug"
          }
        ],
        "responses": {
          "200": {
            "description": "Product",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AgentNotFound"
          }
        }
      }
    },
    "/agent/stock": {
      "get": {
        "operationId": "agentStockLevels",
        "summary": "Stock status + quantity per variant (stock:read)",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "sku",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "product_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "instock",
                "outofstock",
                "onbackorder"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/AgentLimit"
          },
          {
            "$ref": "#/components/parameters/AgentCursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Variants",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AgentBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentForbidden"
          }
        }
      }
    },
    "/agent/orders": {
      "get": {
        "operationId": "agentListOrders",
        "summary": "Marketplace orders, newest first (orders:read)",
        "description": "Status: pending, confirmed, processing, shipped, delivered, cancelled, refunded. Amounts in the marketplace currency. Customer shown as « Prénom I. » with masked e-mail / phone unless the key has customers:pii.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/AgentSince"
          },
          {
            "$ref": "#/components/parameters/AgentUntil"
          },
          {
            "$ref": "#/components/parameters/AgentLimit"
          },
          {
            "$ref": "#/components/parameters/AgentCursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Orders",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AgentBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentForbidden"
          }
        }
      }
    },
    "/agent/orders/{id}": {
      "get": {
        "operationId": "agentGetOrder",
        "summary": "One order with lines, shipping and addresses (orders:read)",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Order id or order number"
          }
        ],
        "responses": {
          "200": {
            "description": "Order",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AgentNotFound"
          }
        }
      }
    },
    "/agent/customers": {
      "get": {
        "operationId": "agentListCustomers",
        "summary": "Customers with order counts (customers:read; contact masked without customers:pii)",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Last-name prefix (and e-mail / phone with customers:pii)"
          },
          {
            "$ref": "#/components/parameters/AgentSince"
          },
          {
            "$ref": "#/components/parameters/AgentUntil"
          },
          {
            "$ref": "#/components/parameters/AgentLimit"
          },
          {
            "$ref": "#/components/parameters/AgentCursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Customers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AgentBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentForbidden"
          }
        }
      }
    },
    "/agent/vendors": {
      "get": {
        "operationId": "agentListVendors",
        "summary": "Vendors selling on the marketplace, with product counts (vendors:read)",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Vendors",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentForbidden"
          }
        }
      }
    },
    "/agent/analytics/sales": {
      "get": {
        "operationId": "agentSalesSummary",
        "summary": "Sales over a window by day, status or vendor (analytics:read)",
        "description": "Default window: last 30 days, max 366. Revenue in the marketplace currency (order totals incl. shipping; by vendor = line totals). Cancelled / refunded / failed orders excluded from revenue.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentSince"
          },
          {
            "$ref": "#/components/parameters/AgentUntil"
          },
          {
            "name": "group_by",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "day",
                "status",
                "vendor"
              ],
              "default": "day"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AgentBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentForbidden"
          }
        }
      }
    },
    "/agent/analytics/top-products": {
      "get": {
        "operationId": "agentTopProducts",
        "summary": "Best sellers by revenue over a window (analytics:read)",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentSince"
          },
          {
            "$ref": "#/components/parameters/AgentUntil"
          },
          {
            "$ref": "#/components/parameters/AgentLimit"
          }
        ],
        "responses": {
          "200": {
            "description": "Products",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/AgentBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentForbidden"
          }
        }
      }
    },
    "/agent/analytics/search-traffic": {
      "get": {
        "operationId": "agentSearchTraffic",
        "summary": "Google Search Console clicks / impressions / position per product (analytics:read)",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "product_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/AgentLimit"
          }
        ],
        "responses": {
          "200": {
            "description": "Traffic",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentOk"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentForbidden"
          }
        }
      }
    },
    "/agent/mcp": {
      "get": {
        "operationId": "agentMcpStream",
        "summary": "Not offered — stateless server (405)",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "responses": {
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          },
          "405": {
            "description": "Use POST"
          }
        }
      },
      "post": {
        "operationId": "agentMcp",
        "summary": "MCP server (Streamable HTTP, stateless) — the same tools as /agent/*",
        "description": "One JSON-RPC 2.0 message per POST, one JSON response. Methods: `initialize` (protocol versions +216 20 123 456, +216 20 123 456, +216 20 123 456), `ping`, `tools/list` (only the tools the key's scopes allow), `tools/call`. Notifications get 202 with no body. Batches are refused (400). Tools: whoami, search_products, get_product, stock_levels, list_orders, get_order, list_customers, list_vendors, sales_summary, top_products, search_traffic. A tool the key may not use returns `isError: true`.",
        "tags": [
          "Agents"
        ],
        "security": [
          {
            "agentKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "jsonrpc",
                  "method"
                ],
                "properties": {
                  "jsonrpc": {
                    "type": "string",
                    "enum": [
                      "2.0"
                    ]
                  },
                  "id": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "integer"
                      }
                    ]
                  },
                  "method": {
                    "type": "string",
                    "example": "tools/call"
                  },
                  "params": {
                    "type": "object"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "202": {
            "description": "Notification accepted"
          },
          "400": {
            "description": "Batch or non-object body"
          },
          "401": {
            "$ref": "#/components/responses/AgentUnauthorized"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "AgentCursor": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string"
        },
        "description": "`meta.nextCursor` of the previous page"
      },
      "AgentLimit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 25
        }
      },
      "AgentSince": {
        "name": "since",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "format": "date-time"
        },
        "description": "Inclusive lower bound (ISO 8601)"
      },
      "AgentUntil": {
        "name": "until",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string",
          "format": "date-time"
        },
        "description": "Exclusive upper bound (ISO 8601)"
      }
    },
    "responses": {
      "AgentBadRequest": {
        "description": "Unknown or invalid parameter, tampered cursor, window > 366 days (INVALID_INPUT).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentErrorResponse"
            }
          }
        }
      },
      "AgentForbidden": {
        "description": "The key lacks the scope this endpoint needs (SCOPE_REQUIRED).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentErrorResponse"
            }
          }
        }
      },
      "AgentNotFound": {
        "description": "Not on this key's account (NOT_FOUND).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentErrorResponse"
            }
          }
        }
      },
      "AgentRateLimited": {
        "description": "Too many requests. Retry later.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentErrorResponse"
            }
          }
        }
      },
      "AgentUnauthorized": {
        "description": "Agent key missing, malformed, unknown, revoked or expired.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentErrorResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "AccountDeleted": {
        "type": "object",
        "description": "Confirmation that the account was anonymised.",
        "required": [
          "deleted",
          "deletedAt"
        ],
        "properties": {
          "deleted": {
            "type": "boolean",
            "example": true
          },
          "deletedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AccountDeletionError": {
        "type": "object",
        "description": "Coded error of `DELETE /auth/me`. `message` is French and meant to be shown to the customer.",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "PASSWORD_REQUIRED",
                  "WRONG_PASSWORD",
                  "ACTIVE_ORDERS",
                  "RATE_LIMITED"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "AddressInput": {
        "type": "object",
        "properties": {
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "address1": {
            "type": "string"
          },
          "address2": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "postcode": {
            "type": "string"
          },
          "countryCode": {
            "type": "string",
            "default": "TN"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string"
          }
        },
        "required": [
          "firstName",
          "lastName",
          "address1",
          "city"
        ]
      },
      "AddressView": {
        "type": "object",
        "properties": {
          "addressId": {
            "type": "string",
            "format": "uuid"
          },
          "customerId": {
            "type": "string"
          },
          "accountId": {
            "type": "string"
          },
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "address1": {
            "type": "string"
          },
          "address2": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "nullable": true
          },
          "postcode": {
            "type": "string",
            "nullable": true
          },
          "countryCode": {
            "type": "string"
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "isDefaultBilling": {
            "type": "boolean"
          },
          "isDefaultShipping": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "addressId",
          "customerId",
          "accountId",
          "firstName",
          "lastName",
          "address1",
          "address2",
          "city",
          "state",
          "postcode",
          "countryCode",
          "phone",
          "isDefaultBilling",
          "isDefaultShipping",
          "createdAt"
        ]
      },
      "AgentErrorResponse": {
        "type": "object",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "UNAUTHORIZED",
                  "SCOPE_REQUIRED",
                  "INVALID_INPUT",
                  "NOT_FOUND",
                  "RATE_LIMITED",
                  "METHOD_NOT_ALLOWED"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "AgentOk": {
        "type": "object",
        "required": [
          "ok",
          "data",
          "meta"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "data": {
            "description": "Object or array, see the endpoint"
          },
          "meta": {
            "type": "object",
            "properties": {
              "nextCursor": {
                "type": "string",
                "nullable": true,
                "description": "Pass back as `cursor` for the next page; null at the end."
              }
            }
          }
        }
      },
      "AskProductQuestionInput": {
        "type": "object",
        "required": [
          "question",
          "email"
        ],
        "properties": {
          "question": {
            "type": "string",
            "minLength": 10,
            "maxLength": 1000
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 191,
            "description": "Private — never shown publicly nor to the vendor."
          }
        }
      },
      "AttributeList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AttributeView"
            }
          }
        },
        "required": [
          "items"
        ]
      },
      "AttributeValueView": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "sortOrder": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "value",
          "slug",
          "sortOrder"
        ]
      },
      "AttributeView": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "description": "Canonical PIM attribute code — the STABLE filter key. Send this back as `attributeName` to GET /products to filter (the storefront read path + the variant-attribute backfill both key axes off this code)."
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "description": "e.g. 'select'"
          },
          "values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AttributeValueView"
            }
          }
        },
        "required": [
          "id",
          "code",
          "name",
          "slug",
          "type",
          "values"
        ]
      },
      "AuthResponse": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "description": "Customer JWT (realm 'customer'), expires in 7d"
          },
          "refreshToken": {
            "type": "string",
            "description": "Opaque customer refresh token (32 random bytes, base64url). Single use - POST /auth/refresh consumes it and returns the next one. 90 days sliding, at most 365 days from the sign-in. Store it securely."
          },
          "expiresIn": {
            "type": "integer",
            "description": "Lifetime of `token` in seconds (604800 = 7 days).",
            "example": 604800
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerProfile"
          }
        },
        "required": [
          "token",
          "refreshToken",
          "expiresIn",
          "customer"
        ]
      },
      "BrandList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BrandView"
            }
          },
          "total": {
            "type": "integer"
          }
        },
        "required": [
          "items",
          "total"
        ]
      },
      "BrandView": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "logoUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "productCount": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "name",
          "slug",
          "logoUrl",
          "productCount"
        ]
      },
      "Cart": {
        "type": "object",
        "properties": {
          "cartId": {
            "type": "string",
            "format": "uuid"
          },
          "accountId": {
            "type": "string"
          },
          "customerId": {
            "type": "string",
            "nullable": true
          },
          "sessionId": {
            "type": "string",
            "nullable": true
          },
          "currency": {
            "type": "string"
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CartItem"
            }
          },
          "subtotal": {
            "type": "number",
            "description": "Sum of unitPrice*quantity, rounded to 2dp"
          }
        },
        "required": [
          "cartId",
          "accountId",
          "customerId",
          "sessionId",
          "currency",
          "notes",
          "expiresAt",
          "createdAt",
          "updatedAt",
          "items",
          "subtotal"
        ]
      },
      "CartItem": {
        "type": "object",
        "properties": {
          "itemId": {
            "type": "string"
          },
          "productId": {
            "type": "string"
          },
          "variantId": {
            "type": "string",
            "nullable": true
          },
          "quantity": {
            "type": "integer"
          },
          "unitPrice": {
            "type": "number",
            "description": "Server-resolved SELLING price at add time (THE RULE + vendor rule + listing override — the same pricer checkout charges with). A client-sent unitPrice is ignored whenever the server can price the line."
          },
          "addedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "itemId",
          "productId",
          "variantId",
          "quantity",
          "unitPrice",
          "addedAt"
        ]
      },
      "CategoryAlertUnsubscribed": {
        "type": "object",
        "required": [
          "ok",
          "data"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "data": {
            "type": "object",
            "required": [
              "status"
            ],
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "unsubscribed"
                ]
              }
            }
          }
        }
      },
      "CategoryItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "seoTitle": {
            "type": "string",
            "nullable": true,
            "maxLength": 70,
            "description": "Storefront `<title>` override set in the back office; null = use the storefront's own template."
          },
          "metaDescription": {
            "type": "string",
            "nullable": true,
            "maxLength": 320,
            "description": "Storefront meta description override set in the back office; null = use the storefront's own template."
          },
          "imageUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "parentId": {
            "type": "string",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer"
          },
          "productCount": {
            "type": "integer"
          },
          "childCount": {
            "type": "integer"
          },
          "visible": {
            "type": "boolean",
            "description": "false = hidden in the back office (only ever returned with `includeHidden=true`, and then with `productCount: 0`); true otherwise."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Last change of the category row."
          }
        },
        "required": [
          "id",
          "slug",
          "name",
          "description",
          "imageUrl",
          "parentId",
          "sortOrder",
          "productCount",
          "childCount",
          "seoTitle",
          "metaDescription",
          "visible",
          "updatedAt"
        ]
      },
      "CategoryTree": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "seoTitle": {
            "type": "string",
            "nullable": true,
            "maxLength": 70,
            "description": "Storefront `<title>` override set in the back office; null = use the storefront's own template."
          },
          "metaDescription": {
            "type": "string",
            "nullable": true,
            "maxLength": 320,
            "description": "Storefront meta description override set in the back office; null = use the storefront's own template."
          },
          "imageUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "parentId": {
            "type": "string",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer"
          },
          "productCount": {
            "type": "integer"
          },
          "childCount": {
            "type": "integer"
          },
          "visible": {
            "type": "boolean",
            "description": "false = hidden in the back office (only ever returned with `includeHidden=true`, and then with `productCount: 0`); true otherwise."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Last change of the category row."
          },
          "children": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CategoryTree"
            },
            "description": "Nested child categories"
          }
        },
        "required": [
          "id",
          "slug",
          "name",
          "description",
          "imageUrl",
          "parentId",
          "sortOrder",
          "productCount",
          "childCount",
          "seoTitle",
          "metaDescription",
          "visible",
          "updatedAt",
          "children"
        ]
      },
      "ConsumerOrderVendorPart": {
        "type": "object",
        "description": "Order mode of one vendor part of a consumer order.",
        "properties": {
          "vendorId": {
            "type": "string"
          },
          "vendorName": {
            "type": "string",
            "nullable": true
          },
          "fulfillmentMode": {
            "type": "string",
            "enum": [
              "full",
              "simple"
            ]
          },
          "deliveredBy": {
            "type": "string",
            "enum": [
              "marketplace",
              "vendor"
            ]
          },
          "paymentCollectedBy": {
            "type": "string",
            "enum": [
              "marketplace",
              "vendor"
            ],
            "description": "`vendor` only for cash on delivery (a card order is collected by the marketplace)."
          }
        },
        "required": [
          "vendorId",
          "vendorName",
          "fulfillmentMode",
          "deliveredBy",
          "paymentCollectedBy"
        ]
      },
      "CouponErrorResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "not_found",
                  "expired",
                  "min_not_reached",
                  "not_applicable",
                  "already_used",
                  "phone_required",
                  "line_unavailable"
                ]
              },
              "message": {
                "type": "string",
                "description": "French, ready to show"
              }
            },
            "required": [
              "code",
              "message"
            ]
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "ok",
          "error"
        ]
      },
      "CouponQuote": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "code": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "percent",
              "fixed_amount",
              "free_shipping"
            ]
          },
          "fundedBy": {
            "type": "string",
            "enum": [
              "platform",
              "vendor"
            ]
          },
          "freeShipping": {
            "type": "boolean",
            "description": "Shipping of the vendors with a line in scope is waived at checkout"
          },
          "subtotal": {
            "type": "number"
          },
          "eligibleSubtotal": {
            "type": "number",
            "description": "Subtotal of the lines in scope (the minimum is checked on it)"
          },
          "discountAmount": {
            "type": "number"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CouponQuoteLine"
            }
          }
        },
        "required": [
          "valid",
          "code",
          "type",
          "fundedBy",
          "freeShipping",
          "subtotal",
          "eligibleSubtotal",
          "discountAmount",
          "lines"
        ]
      },
      "CouponQuoteLine": {
        "type": "object",
        "properties": {
          "productId": {
            "type": "string"
          },
          "variantId": {
            "type": "string",
            "nullable": true
          },
          "vendorId": {
            "type": "string",
            "nullable": true
          },
          "quantity": {
            "type": "integer"
          },
          "unitPrice": {
            "type": "number",
            "description": "Server-resolved selling price (same rule as checkout)"
          },
          "lineTotal": {
            "type": "number"
          },
          "eligible": {
            "type": "boolean",
            "description": "True when the line is in the coupon's scope"
          },
          "discountAmount": {
            "type": "number",
            "description": "TND off this line; Σ over lines = discountAmount, to the millime"
          }
        },
        "required": [
          "productId",
          "variantId",
          "vendorId",
          "quantity",
          "unitPrice",
          "lineTotal",
          "eligible",
          "discountAmount"
        ]
      },
      "CouponQuoteLineInput": {
        "type": "object",
        "properties": {
          "productId": {
            "type": "string"
          },
          "variantId": {
            "type": "string",
            "nullable": true
          },
          "vendorId": {
            "type": "string",
            "nullable": true,
            "description": "Accepted and IGNORED — the product row says who sells it"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 99
          },
          "bundleId": {
            "type": "string",
            "nullable": true,
            "description": "A multi-vendor pack line. Pack lines are NOT eligible for coupons (same rule as checkout) — they are left out of the evaluation and of the returned `lines`."
          }
        },
        "required": [
          "productId",
          "quantity"
        ]
      },
      "CouponQuoteRequest": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "2-64 chars, case-insensitive"
          },
          "lines": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/CouponQuoteLineInput"
            }
          },
          "phone": {
            "type": "string",
            "description": "Shopper phone (any spelling). Needed for phone-bound codes (wheel prizes) and the per-shopper cap of guests (a capped code without a customer token or a phone → phone_required)."
          }
        },
        "required": [
          "code",
          "lines"
        ]
      },
      "CreateStoreReservationInput": {
        "type": "object",
        "required": [
          "vendorId",
          "productId",
          "variantId",
          "storeId",
          "firstName",
          "lastName",
          "phone"
        ],
        "properties": {
          "vendorId": {
            "type": "string",
            "maxLength": 64
          },
          "productId": {
            "type": "string",
            "maxLength": 64,
            "description": "The seller's own product id (vendors[].productId) or the page's canonical one."
          },
          "variantId": {
            "type": "string",
            "maxLength": 64,
            "description": "The seller's own variant id (vendors[].variantId) or the page's selected one."
          },
          "storeId": {
            "type": "string",
            "maxLength": 64,
            "description": "vendors[].stores[].storeId."
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2,
            "default": 1
          },
          "firstName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "lastName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "phone": {
            "type": "string",
            "description": "Tunisian: 8 digits, +216/00216/216 prefix and separators accepted."
          },
          "email": {
            "type": "string",
            "format": "email",
            "nullable": true,
            "description": "Optional — enables the confirmation and « prête » emails. Empty string = none."
          },
          "note": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          }
        }
      },
      "CustomerBlockedError": {
        "type": "object",
        "required": [
          "ok",
          "error",
          "message"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "CUSTOMER_BLOCKED"
                ]
              },
              "message": {
                "type": "string",
                "example": "Nous ne pouvons pas valider cette commande. Contactez le service client."
              }
            }
          },
          "message": {
            "type": "string"
          }
        }
      },
      "CustomerDevice": {
        "type": "object",
        "description": "A push device (FCM token) of the signed-in customer. The token itself is never returned.",
        "required": [
          "deviceId",
          "platform",
          "createdAt",
          "lastSeenAt"
        ],
        "properties": {
          "deviceId": {
            "type": "string"
          },
          "platform": {
            "type": "string",
            "enum": [
              "android",
              "ios"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastSeenAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CustomerExportPayload": {
        "type": "object",
        "properties": {
          "schemaVersion": {
            "type": "integer"
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "accountId": {
            "type": "string"
          },
          "customerId": {
            "type": "string"
          },
          "profile": {
            "description": "{ customerId,email,firstName,lastName,phone,status,createdAt,updatedAt } or null",
            "nullable": true
          },
          "addresses": {
            "type": "array",
            "items": {},
            "description": "Customer + order addresses"
          },
          "orders": {
            "type": "array",
            "items": {},
            "description": "Orders with line items"
          },
          "rma": {
            "type": "array",
            "items": {},
            "description": "Return / RMA records"
          }
        },
        "required": [
          "schemaVersion",
          "generatedAt",
          "accountId",
          "customerId",
          "profile",
          "addresses",
          "orders",
          "rma"
        ]
      },
      "CustomerOrderCancelError": {
        "type": "object",
        "required": [
          "ok",
          "error",
          "message",
          "data"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "enum": [
              "ORDER_NOT_CANCELLABLE",
              "ORDER_PAID_CONTACT_SUPPORT",
              "ORDER_CONFIRMED_BY_VENDOR",
              "ORDER_MODE_UNAVAILABLE"
            ]
          },
          "message": {
            "type": "string",
            "description": "French, shopper-facing."
          },
          "data": {
            "type": "object",
            "required": [
              "status"
            ],
            "properties": {
              "status": {
                "type": "string",
                "nullable": true,
                "description": "The order's current status."
              }
            }
          }
        }
      },
      "CustomerOrderCancelReasonCode": {
        "type": "string",
        "description": "The subset of `OrderCancelReasonCode` a customer may give on `POST /orders/{orderId}/cancel` (never a reason that judges the customer, nor an internal one). Default `customer_request`; `other` requires a note.",
        "enum": [
          "customer_request",
          "duplicate_order",
          "delivery_delay",
          "other"
        ]
      },
      "CustomerOrderCancelRequest": {
        "type": "object",
        "properties": {
          "reasonCode": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CustomerOrderCancelReasonCode"
              }
            ],
            "default": "customer_request"
          },
          "note": {
            "type": "string",
            "maxLength": 500,
            "description": "Free text; mandatory with `other`. Stored on the order (`cancelled_reason`) and in the timeline, visible to the back office."
          }
        }
      },
      "CustomerProfile": {
        "type": "object",
        "properties": {
          "customerId": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "emailVerified": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "customerId",
          "email",
          "firstName",
          "lastName",
          "phone",
          "emailVerified",
          "createdAt"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "ok",
          "error"
        ],
        "description": "Standard error envelope. `error` is a human-readable string for most failures, or a Zod field-error object for 400/422 validation failures.",
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "description": "Error message or structured validation detail.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": true
              }
            ]
          }
        }
      },
      "OrderDetail": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string"
          },
          "orderNumber": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "total": {
            "type": "number"
          },
          "paymentMethod": {
            "type": "string",
            "nullable": true
          },
          "paymentStatus": {
            "type": "string",
            "nullable": true
          },
          "itemCount": {
            "type": "integer"
          },
          "placedAt": {
            "type": "string",
            "format": "date-time"
          },
          "subtotal": {
            "type": "number"
          },
          "discountAmount": {
            "type": "number"
          },
          "shippingAmount": {
            "type": "number"
          },
          "customerNote": {
            "type": "string",
            "nullable": true
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderItemLine"
            }
          },
          "vendors": {
            "type": "array",
            "description": "One seller contact block per distinct ITEM vendor, in cart order. Public business contact only.",
            "items": {
              "$ref": "#/components/schemas/OrderVendorContact"
            }
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderEvent"
            }
          },
          "fulfillmentMode": {
            "type": "string",
            "enum": [
              "full",
              "simple"
            ],
            "nullable": true,
            "description": "Order mode at placement. `simple` = the vendor confirms or cancels, then delivers and collects in its own system — no parcel tracking on the marketplace. With status `confirmed`, print « Confirmée par le vendeur ». null = the vendor parts differ (see `vendorParts`) or the mode could not be read. ADDED field: the status slugs are unchanged."
          },
          "deliveredBy": {
            "type": "string",
            "enum": [
              "marketplace",
              "vendor"
            ],
            "nullable": true,
            "description": "`vendor` ⇒ « Livrée par <deliveredByName> ». null = parts differ / unknown."
          },
          "deliveredByName": {
            "type": "string",
            "nullable": true,
            "description": "The delivering vendor's name when deliveredBy = vendor (single vendor), else null."
          },
          "paymentCollectedBy": {
            "type": "string",
            "enum": [
              "marketplace",
              "vendor"
            ],
            "nullable": true,
            "description": "`vendor` ⇒ the customer pays the vendor (« Paiement au vendeur »). null = parts differ / unknown. Only for cash on delivery: a card (ClicToPay) order is always `marketplace`, even for a simple-mode vendor."
          },
          "vendorParts": {
            "type": "array",
            "description": "The same per vendor part (multi-vendor orders are decided per vendor).",
            "items": {
              "$ref": "#/components/schemas/ConsumerOrderVendorPart"
            }
          }
        },
        "required": [
          "orderId",
          "orderNumber",
          "status",
          "currency",
          "total",
          "paymentMethod",
          "paymentStatus",
          "itemCount",
          "placedAt",
          "subtotal",
          "discountAmount",
          "shippingAmount",
          "customerNote",
          "items",
          "vendors",
          "events",
          "fulfillmentMode",
          "deliveredBy",
          "deliveredByName",
          "paymentCollectedBy",
          "vendorParts"
        ]
      },
      "OrderEvent": {
        "type": "object",
        "properties": {
          "eventId": {
            "type": "string"
          },
          "eventType": {
            "type": "string"
          },
          "fromStatus": {
            "type": "string",
            "nullable": true
          },
          "toStatus": {
            "type": "string",
            "nullable": true
          },
          "note": {
            "type": "string",
            "nullable": true
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "eventId",
          "eventType",
          "fromStatus",
          "toStatus",
          "note",
          "occurredAt"
        ]
      },
      "OrderItemLine": {
        "type": "object",
        "properties": {
          "itemId": {
            "type": "string"
          },
          "productId": {
            "type": "string",
            "nullable": true
          },
          "vendorId": {
            "type": "string",
            "nullable": true
          },
          "vendorName": {
            "type": "string",
            "nullable": true,
            "description": "Seller's shop name (copied from `OrderDetail.vendors`)"
          },
          "vendorPhone": {
            "type": "string",
            "nullable": true,
            "description": "Seller's public business phone (copied from `OrderDetail.vendors`)"
          },
          "vendorWhatsapp": {
            "type": "string",
            "nullable": true,
            "description": "WhatsApp digits for wa.me (`216XXXXXXXX`) after the fallback chain"
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "quantity": {
            "type": "integer"
          },
          "unitPrice": {
            "type": "number"
          },
          "lineTotal": {
            "type": "number"
          }
        },
        "required": [
          "itemId",
          "productId",
          "vendorId",
          "vendorName",
          "vendorPhone",
          "vendorWhatsapp",
          "title",
          "quantity",
          "unitPrice",
          "lineTotal"
        ]
      },
      "OrderListItem": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string"
          },
          "orderNumber": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "nullable": true
          },
          "total": {
            "type": "number"
          },
          "paymentMethod": {
            "type": "string",
            "nullable": true
          },
          "paymentStatus": {
            "type": "string",
            "nullable": true
          },
          "itemCount": {
            "type": "integer"
          },
          "placedAt": {
            "type": "string",
            "format": "date-time"
          },
          "fulfillmentMode": {
            "type": "string",
            "enum": [
              "full",
              "simple"
            ],
            "nullable": true,
            "description": "Order mode at placement. `simple` = the vendor confirms or cancels, then delivers and collects in its own system — no parcel tracking on the marketplace. With status `confirmed`, print « Confirmée par le vendeur ». null = the vendor parts differ (see `vendorParts`) or the mode could not be read. ADDED field: the status slugs are unchanged."
          },
          "deliveredBy": {
            "type": "string",
            "enum": [
              "marketplace",
              "vendor"
            ],
            "nullable": true,
            "description": "`vendor` ⇒ « Livrée par <deliveredByName> ». null = parts differ / unknown."
          },
          "deliveredByName": {
            "type": "string",
            "nullable": true,
            "description": "The delivering vendor's name when deliveredBy = vendor (single vendor), else null."
          },
          "paymentCollectedBy": {
            "type": "string",
            "enum": [
              "marketplace",
              "vendor"
            ],
            "nullable": true,
            "description": "`vendor` ⇒ the customer pays the vendor (« Paiement au vendeur »). null = parts differ / unknown. Only for cash on delivery: a card (ClicToPay) order is always `marketplace`, even for a simple-mode vendor."
          },
          "vendorParts": {
            "type": "array",
            "description": "The same per vendor part (multi-vendor orders are decided per vendor).",
            "items": {
              "$ref": "#/components/schemas/ConsumerOrderVendorPart"
            }
          }
        },
        "required": [
          "orderId",
          "orderNumber",
          "status",
          "currency",
          "total",
          "paymentMethod",
          "paymentStatus",
          "itemCount",
          "placedAt",
          "fulfillmentMode",
          "deliveredBy",
          "deliveredByName",
          "paymentCollectedBy",
          "vendorParts"
        ]
      },
      "OrderListPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderListItem"
            }
          },
          "total": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          }
        },
        "required": [
          "items",
          "total",
          "page",
          "limit"
        ]
      },
      "OrderSummary": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "format": "uuid"
          },
          "orderNumber": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "subtotal": {
            "type": "number"
          },
          "discountAmount": {
            "type": "number",
            "description": "Coupon or loyalty discount (TND); total = subtotal − discountAmount + shippingAmount"
          },
          "couponCode": {
            "type": "string",
            "nullable": true
          },
          "loyaltyPoints": {
            "type": "integer",
            "description": "Loyalty points spent on this order — present only when some were."
          },
          "loyaltyDiscount": {
            "type": "number",
            "description": "TND value of `loyaltyPoints`, already included in `discountAmount` — present only with `loyaltyPoints`."
          },
          "shippingAmount": {
            "type": "number"
          },
          "total": {
            "type": "number"
          },
          "paymentMethod": {
            "type": "string"
          },
          "paymentStatus": {
            "type": "string"
          },
          "placedAt": {
            "type": "string",
            "format": "date-time"
          },
          "payment": {
            "type": "object",
            "description": "Online card payment only (`paymentMethod: clictopay`) — present on the POST /checkout response.",
            "properties": {
              "provider": {
                "type": "string",
                "enum": [
                  "clictopay"
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "paid",
                  "failed"
                ]
              },
              "formUrl": {
                "type": "string",
                "format": "uri",
                "description": "ClicToPay payment page — redirect the buyer here (pending only)."
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OrderSummaryItem"
            }
          },
          "vendors": {
            "type": "array",
            "description": "One seller contact block per distinct ITEM vendor, in cart order. Public business contact only.",
            "items": {
              "$ref": "#/components/schemas/OrderVendorContact"
            }
          }
        },
        "required": [
          "orderId",
          "orderNumber",
          "status",
          "currency",
          "subtotal",
          "shippingAmount",
          "total",
          "paymentMethod",
          "paymentStatus",
          "placedAt",
          "items",
          "vendors"
        ]
      },
      "OrderSummaryItem": {
        "type": "object",
        "properties": {
          "itemId": {
            "type": "string"
          },
          "productId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "unitPrice": {
            "type": "number"
          },
          "lineTotal": {
            "type": "number"
          },
          "discountAmount": {
            "type": "number",
            "description": "Coupon share of this line (TND), 0 without a coupon"
          },
          "vendorId": {
            "type": "string",
            "nullable": true,
            "description": "Seller of this line (item level; a multi-vendor order has no order-level vendor)"
          },
          "vendorName": {
            "type": "string",
            "nullable": true,
            "description": "Seller's shop name (copied from `vendors[]`)"
          },
          "vendorPhone": {
            "type": "string",
            "nullable": true,
            "description": "Seller's public business phone, as typed (copied from `vendors[]`)"
          },
          "vendorWhatsapp": {
            "type": "string",
            "nullable": true,
            "description": "WhatsApp digits for wa.me (`216XXXXXXXX`) after the fallback chain (seller's number, else the marketplace number; see `vendors[].whatsappSource`)"
          }
        },
        "required": [
          "itemId",
          "productId",
          "title",
          "quantity",
          "unitPrice",
          "lineTotal",
          "discountAmount",
          "vendorId",
          "vendorName",
          "vendorPhone",
          "vendorWhatsapp"
        ]
      },
      "OrderVendorContact": {
        "type": "object",
        "description": "How the customer reaches the seller of some lines of an order. Only the vendor's PUBLIC business contact (never customer data, never the vendor's internal contact people). Also exposed on the anonymous tracking endpoints.",
        "properties": {
          "vendorId": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "nullable": true,
            "description": "Shop name; null when the vendor row is gone"
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "description": "Business phone as typed (at least 8 digits), else null"
          },
          "email": {
            "type": "string",
            "nullable": true,
            "description": "Business email; null when absent or synthetic"
          },
          "whatsapp": {
            "type": "string",
            "nullable": true,
            "description": "WhatsApp digits for wa.me (`216XXXXXXXX`). The vendor's number when its `whatsapp` offer capability is on and the number is a valid Tunisian one, else the marketplace number (`GET /public/tenant` contact.whatsapp), else null."
          },
          "whatsappSource": {
            "type": "string",
            "nullable": true,
            "enum": [
              "vendor",
              "marketplace",
              null
            ]
          },
          "waLink": {
            "type": "string",
            "nullable": true,
            "description": "`https://wa.me/<whatsapp>?text=<url-encoded>` with \"Bonjour, je vous contacte au sujet de ma commande #<orderNumber> sur <siteName>.\" prefilled."
          },
          "store": {
            "allOf": [
              {
                "$ref": "#/components/schemas/OrderVendorStore"
              }
            ],
            "nullable": true
          },
          "address": {
            "type": "string",
            "nullable": true,
            "description": "Shortcut for `store.address`"
          }
        },
        "required": [
          "vendorId",
          "name",
          "phone",
          "email",
          "whatsapp",
          "whatsappSource",
          "waLink",
          "store",
          "address"
        ]
      },
      "OrderVendorStore": {
        "type": "object",
        "description": "The seller's main PUBLIC store (point de vente); same id as `GET /public/stores` storeId.",
        "properties": {
          "storeId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "address": {
            "type": "string",
            "nullable": true,
            "description": "One line, street then postal code and city"
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "storeId",
          "name",
          "address",
          "city",
          "phone"
        ]
      },
      "PasswordChangeError": {
        "type": "object",
        "description": "Coded error of `POST /auth/change-password`. `message` is French and meant to be shown to the customer.",
        "required": [
          "ok",
          "error"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "WRONG_PASSWORD",
                  "NO_PASSWORD"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "ProductBrand": {
        "type": "object",
        "description": "Brand surfaced on the product page.",
        "properties": {
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "logoUrl": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "name",
          "slug",
          "logoUrl"
        ]
      },
      "ProductDetail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "price": {
            "type": "number"
          },
          "compareAtPrice": {
            "type": "number",
            "nullable": true
          },
          "imageUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "vendorId": {
            "type": "string"
          },
          "vendorName": {
            "type": "string",
            "nullable": true
          },
          "inStock": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Last change of the product row — sitemap lastmod. A stock movement alone does not move it."
          },
          "brandSlug": {
            "type": "string",
            "nullable": true,
            "description": "Slug of the product's brand (links /marques/{slug}); null when unbranded."
          },
          "sale": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/ProductSale"
              }
            ],
            "description": "The dated promotion behind the strike price (+216 20 123 456). Present ONLY when the product is on sale by THE RULE (onSale) AND a promotion window covers now; otherwise null. No countdown without a real endsAt, no progress bar without soldCount + stockAtStart."
          },
          "madeInTunisia": {
            "type": "boolean",
            "description": "« Fabriqué en Tunisie » origin flag, resolved product override ?? vendor default ?? false. The override is keyed on the vendor's SOURCE product and the default on the vendor id, so a vendor's source and the marketplace copy listed here resolve the same."
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "ean": {
            "type": "string",
            "nullable": true
          },
          "commissionType": {
            "type": "string",
            "nullable": true
          },
          "commissionRate": {
            "type": "number",
            "nullable": true
          },
          "variants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductVariant"
            }
          },
          "options": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductOption"
            }
          },
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductImage"
            }
          },
          "offers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductOfferSummary"
            }
          },
          "brand": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ProductBrand"
              }
            ],
            "nullable": true,
            "description": "Brand for the product page; null when the product has no brand."
          },
          "seo": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ProductSeo"
              }
            ],
            "description": "Per-product SEO overrides (\"Yoast-in-MarketKit\"). ALWAYS present; each field is null when no override is set — the storefront reads them directly and derives the nulls from the product."
          },
          "rating": {
            "type": "object",
            "nullable": true,
            "description": "Aggregate rating from PUBLISHED reviews. `null` when there are no reviews (so the storefront never emits an invalid AggregateRating).",
            "properties": {
              "value": {
                "type": "number",
                "description": "Average rating 1–5, rounded to 2 decimals."
              },
              "count": {
                "type": "integer",
                "description": "Number of published reviews."
              }
            },
            "required": [
              "value",
              "count"
            ]
          },
          "faqs": {
            "type": "array",
            "description": "Editorial FAQ block, ordered, then the shoppers' questions answered by the seller (« Questions-réponses », newest answers first, at most 20; answer HTML-escaped; a question already in the editorial block is not repeated). Empty array when none.",
            "items": {
              "type": "object",
              "properties": {
                "question": {
                  "type": "string"
                },
                "answer": {
                  "type": "string"
                }
              },
              "required": [
                "question",
                "answer"
              ]
            }
          },
          "categories": {
            "type": "array",
            "description": "Breadcrumb of the product's MAIN « rayon Wildkard » (marketplace tree), general → precise: department first, most precise category last. Main = deepest linked active rayon; tie → the branch carrying the most of the product's links, then the lowest link sort order. Every slug exists in GET /categories/tree. Empty when the product is filed under no active rayon.",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                },
                "parentId": {
                  "type": "string",
                  "nullable": true
                }
              },
              "required": [
                "id",
                "name",
                "slug",
                "parentId"
              ]
            }
          },
          "regularPrice": {
            "type": "number",
            "nullable": true,
            "description": "\"Prix avant\" — the crossed-out price when on sale, otherwise equal to price. THE RULE (+216 20 123 456): selling = sale when 0 < sale < regular, else regular, else the legacy price; variant pair first, product pair as fallback."
          },
          "salePrice": {
            "type": "number",
            "nullable": true,
            "description": "\"Prix après\" — equals price when on sale, otherwise null."
          },
          "onSale": {
            "type": "boolean",
            "description": "sale > 0 AND regular > 0 AND sale < regular (never the stored on_sale column)."
          }
        },
        "required": [
          "id",
          "slug",
          "name",
          "price",
          "compareAtPrice",
          "imageUrl",
          "vendorId",
          "vendorName",
          "inStock",
          "createdAt",
          "description",
          "ean",
          "commissionType",
          "commissionRate",
          "variants",
          "options",
          "images",
          "offers",
          "brand",
          "seo",
          "updatedAt",
          "brandSlug",
          "madeInTunisia",
          "rating",
          "faqs",
          "categories"
        ]
      },
      "ProductFacetAttribute": {
        "type": "object",
        "required": [
          "code",
          "name",
          "values"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "PIM code — the key of `attr[code]`."
          },
          "name": {
            "type": "string"
          },
          "values": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductFacetAttributeValue"
            }
          }
        }
      },
      "ProductFacetAttributeValue": {
        "type": "object",
        "required": [
          "slug",
          "value",
          "count",
          "selected"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "description": "Normalised value — what `attr[code]=` matches."
          },
          "value": {
            "type": "string",
            "description": "Display label (the most frequent spelling)."
          },
          "count": {
            "type": "integer",
            "description": "Products with this value, every other filter applied (this attribute's own selection ignored)."
          },
          "selected": {
            "type": "boolean"
          }
        }
      },
      "ProductFacetBrand": {
        "type": "object",
        "required": [
          "id",
          "name",
          "slug",
          "count",
          "selected"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "count": {
            "type": "integer",
            "description": "Products of this brand with every other filter applied (the brand selection ignored)."
          },
          "selected": {
            "type": "boolean"
          }
        }
      },
      "ProductFacets": {
        "type": "object",
        "description": "Facet counts of a listing (GET /products/facets).",
        "required": [
          "total",
          "brands",
          "attributes",
          "price",
          "inStock",
          "stockStatus",
          "onSale",
          "madeInTunisia",
          "vendors",
          "inStockPrice",
          "inStockOnSale"
        ],
        "properties": {
          "total": {
            "type": "integer",
            "description": "Products matching every filter — equals GET /products total."
          },
          "brands": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductFacetBrand"
            }
          },
          "attributes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductFacetAttribute"
            }
          },
          "price": {
            "type": "object",
            "required": [
              "min",
              "max"
            ],
            "description": "Resolved card price bounds, ignoring minPrice/maxPrice; null when nothing is priced.",
            "properties": {
              "min": {
                "type": "number",
                "nullable": true
              },
              "max": {
                "type": "number",
                "nullable": true
              }
            }
          },
          "inStock": {
            "type": "integer",
            "description": "Products in stock, ignoring the stockStatus filter."
          },
          "stockStatus": {
            "type": "object",
            "required": [
              "instock",
              "outofstock",
              "onbackorder"
            ],
            "properties": {
              "instock": {
                "type": "integer"
              },
              "outofstock": {
                "type": "integer"
              },
              "onbackorder": {
                "type": "integer"
              }
            }
          },
          "onSale": {
            "type": "integer",
            "description": "Products whose card is on sale, ignoring the onSale filter."
          },
          "madeInTunisia": {
            "type": "integer",
            "description": "Products « made in Tunisia » (product override ?? vendor default ?? false), ignoring the madeInTunisia filter."
          },
          "vendors": {
            "type": "array",
            "maxItems": 100,
            "description": "Sellers of the filtered set (every filter applied), most products in stock first. Names HTML-unescaped.",
            "items": {
              "type": "object",
              "required": [
                "id",
                "name",
                "count",
                "inStock"
              ],
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "count": {
                  "type": "integer",
                  "description": "Filtered products of this seller."
                },
                "inStock": {
                  "type": "integer",
                  "description": "Of those",
                  "in stock.": null
                }
              }
            }
          },
          "inStockPrice": {
            "type": "object",
            "required": [
              "min",
              "max",
              "median"
            ],
            "description": "Resolved card prices of the filtered products that are IN STOCK; nulls when none is priced.",
            "properties": {
              "min": {
                "type": "number",
                "nullable": true
              },
              "max": {
                "type": "number",
                "nullable": true
              },
              "median": {
                "type": "number",
                "nullable": true
              }
            }
          },
          "inStockOnSale": {
            "type": "integer",
            "description": "Filtered products both in stock and on sale."
          }
        }
      },
      "ProductImage": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "url"
          },
          "alt": {
            "type": "string",
            "nullable": true
          },
          "position": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "url",
          "alt",
          "position"
        ]
      },
      "ProductListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "price": {
            "type": "number",
            "description": "SELLING price in account currency (TND) — what checkout charges. THE RULE (+216 20 123 456): selling = sale when 0 < sale < regular, else regular, else the legacy price; variant pair first, product pair as fallback. A product WITH variants shows its cheapest variant's resolution (\"à partir de\"); price, compareAtPrice, regularPrice, salePrice and onSale then all come from that same variant."
          },
          "compareAtPrice": {
            "type": "number",
            "description": "Crossed-out regular price (\"prix avant\"), set ONLY when on sale (strictly above price), else null. For a product with variants, the cheapest variant's own crossed-out price (even when the product row itself carries no promotion).",
            "nullable": true
          },
          "imageUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "vendorId": {
            "type": "string"
          },
          "vendorName": {
            "type": "string",
            "nullable": true
          },
          "inStock": {
            "type": "boolean"
          },
          "acceptsOnlineOrders": {
            "type": "boolean",
            "description": "Whether this product may be ORDERED online from its vendor, resolved product ?? vendor ?? marketplace. This is permission only — stock is reported separately by inStock — so a storefront can distinguish \"out of stock, come back later\" from \"this seller does not take online orders\". Deliberately not named canOrder: the product-detail offers[] carry a canOrder that is permission AND stock."
          },
          "hasVariants": {
            "type": "boolean",
            "description": "True when the product has at least one active (non-retired) variant: a cart line then needs a variant_id, so the card opens a choice instead of quick-adding."
          },
          "vendorWhatsapp": {
            "type": "string",
            "nullable": true,
            "description": "wa.me-ready vendor number (same normalisation as the product-detail offers), served only when the WhatsApp capability is on for this product × vendor; null otherwise. Never the marketplace's number."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "Last change of the product row — sitemap lastmod. A stock movement alone does not move it."
          },
          "brandSlug": {
            "type": "string",
            "nullable": true,
            "description": "Slug of the product's brand (links /marques/{slug}); null when unbranded."
          },
          "sale": {
            "nullable": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/ProductSale"
              }
            ],
            "description": "The dated promotion behind the strike price (+216 20 123 456). Present ONLY when the product is on sale by THE RULE (onSale) AND a promotion window covers now; otherwise null. No countdown without a real endsAt, no progress bar without soldCount + stockAtStart."
          },
          "madeInTunisia": {
            "type": "boolean",
            "description": "« Fabriqué en Tunisie » origin flag, resolved product override ?? vendor default ?? false. The override is keyed on the vendor's SOURCE product and the default on the vendor id, so a vendor's source and the marketplace copy listed here resolve the same."
          },
          "rating": {
            "type": "object",
            "nullable": true,
            "description": "Aggregate rating from PUBLISHED reviews — the same figures as the product page, one batched read per page (+216 20 123 456). `null` when the product has no published review.",
            "properties": {
              "value": {
                "type": "number",
                "description": "Average rating 1–5, rounded to 2 decimals."
              },
              "count": {
                "type": "integer",
                "description": "Number of published reviews."
              }
            },
            "required": [
              "value",
              "count"
            ]
          },
          "soldRecently": {
            "type": "boolean",
            "description": "Present ONLY on `sort=bestselling` (+216 20 123 456). True when the product sold at least one unit online inside the best-seller window. The sort fills with the newest unsold products once the real sellers run out; this flag says where, so a « best sellers » rail never shows a filler. A flag, not the unit count: per-vendor volumes stay private."
          },
          "regularPrice": {
            "type": "number",
            "nullable": true,
            "description": "\"Prix avant\" — the crossed-out price when on sale, otherwise equal to price. THE RULE (+216 20 123 456): selling = sale when 0 < sale < regular, else regular, else the legacy price; variant pair first, product pair as fallback."
          },
          "salePrice": {
            "type": "number",
            "nullable": true,
            "description": "\"Prix après\" — equals price when on sale, otherwise null."
          },
          "onSale": {
            "type": "boolean",
            "description": "sale > 0 AND regular > 0 AND sale < regular (never the stored on_sale column)."
          }
        },
        "required": [
          "id",
          "slug",
          "name",
          "price",
          "compareAtPrice",
          "imageUrl",
          "vendorId",
          "vendorName",
          "inStock",
          "acceptsOnlineOrders",
          "hasVariants",
          "vendorWhatsapp",
          "createdAt",
          "madeInTunisia"
        ]
      },
      "ProductListPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductListItem"
            }
          },
          "total": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          }
        },
        "required": [
          "items",
          "total",
          "page",
          "limit"
        ]
      },
      "ProductMovedResponse": {
        "type": "object",
        "description": "Body of a 301 from GET /products/{slug} — the requested slug is a merged duplicate's URL.",
        "required": [
          "ok",
          "error",
          "code",
          "redirect"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "string",
            "example": "Product moved"
          },
          "code": {
            "type": "string",
            "enum": [
              "PRODUCT_MOVED"
            ]
          },
          "redirect": {
            "type": "object",
            "required": [
              "slug",
              "productId"
            ],
            "properties": {
              "slug": {
                "type": "string",
                "description": "Current slug of the kept fiche."
              },
              "productId": {
                "type": "string",
                "description": "Id of the kept fiche."
              }
            }
          }
        }
      },
      "ProductOfferSummary": {
        "type": "object",
        "properties": {
          "productId": {
            "type": "string"
          },
          "vendorId": {
            "type": "string",
            "nullable": true
          },
          "vendorName": {
            "type": "string",
            "nullable": true
          },
          "vendorWhatsapp": {
            "type": "string",
            "nullable": true,
            "description": "wa.me-ready `216XXXXXXXX`, or null when the vendor has no number OR its stored number cannot open a chat (never a dead link) — fall back to the marketplace contact.whatsapp."
          },
          "price": {
            "type": "number"
          },
          "inStock": {
            "type": "boolean"
          },
          "isCanonical": {
            "type": "boolean"
          },
          "isFeatured": {
            "type": "boolean",
            "description": "Marketplace-pinned highlighted offer; sorts first in the offers list."
          },
          "perDepotAvailable": {
            "type": "boolean",
            "description": "True when this vendor's stock flow uses the `per_depot` merge rule — the storefront may offer per-store availability for this offer via GET /public/erp-stock-by-warehouse."
          },
          "compareAtPrice": {
            "type": "number",
            "nullable": true,
            "description": "Crossed-out regular price after the vendor price rule when on sale, else null. Null when a listing price override applies."
          },
          "onSale": {
            "type": "boolean",
            "description": "THE RULE's onSale for this offer (after the vendor price rule)."
          },
          "terms": {
            "allOf": [
              {
                "$ref": "#/components/schemas/VendorTerms"
              }
            ],
            "nullable": true,
            "description": "This vendor's delivery / returns terms (fee = what checkout charges for its sub-order). null = could not be read — show nothing rather than a guessed fee."
          }
        },
        "required": [
          "terms",
          "productId",
          "vendorId",
          "vendorName",
          "vendorWhatsapp",
          "price",
          "inStock",
          "isCanonical",
          "isFeatured",
          "perDepotAvailable"
        ]
      },
      "ProductOption": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Canonical PIM attribute code — match the chosen value against variants[].attributes[] carrying the same `code`. Selectable axes only; metadata axes such as `brand_color_code` are excluded."
          },
          "name": {
            "type": "string",
            "description": "Localized display label for the selector heading (e.g. `Couleur`)."
          },
          "values": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "code",
          "name",
          "values"
        ]
      },
      "ProductSale": {
        "type": "object",
        "description": "Promotion window of a product on sale (marketplace/promotions). Dates come from the vendor's ERP when the product is linked to it, else from the vendor's back office; an ERP window wins over a vendor one.",
        "required": [
          "endsAt",
          "startedAt",
          "soldCount",
          "stockAtStart"
        ],
        "properties": {
          "endsAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "End of the promotion. null = no real end (open-ended, or a permanent markdown ending more than 366 days away — e.g. ERP promos ending in 2050): render NO countdown."
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Start of the promotion; null when unknown."
          },
          "soldCount": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "description": "Units sold since startedAt on this product, its vendor source row and its product group (cancelled / refunded / refund_requested / failed orders and failed / refunded / cancelled payments excluded — the bestseller rule). null when startedAt is null. Cached up to 60 s."
          },
          "stockAtStart": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "description": "Units in stock when the promotion was created / synced; null when the product does not track stock."
          }
        }
      },
      "ProductSeo": {
        "type": "object",
        "description": "Per-product SEO overrides surfaced to the storefront. ALWAYS present with every field — each is `null` when the merchandiser hasn't set an override (`noindex` defaults to `false`).",
        "properties": {
          "title": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "focusKeyphrase": {
            "type": "string",
            "nullable": true
          },
          "ogImage": {
            "type": "string",
            "nullable": true
          },
          "canonicalUrl": {
            "type": "string",
            "nullable": true
          },
          "noindex": {
            "type": "boolean"
          },
          "effective": {
            "$ref": "#/components/schemas/ProductSeoEffective"
          }
        },
        "required": [
          "title",
          "description",
          "focusKeyphrase",
          "ogImage",
          "canonicalUrl",
          "noindex",
          "effective"
        ]
      },
      "ProductSeoEffective": {
        "type": "object",
        "description": "What the product page should print. Each value is the merchandiser's STORED override (the sibling fields of `seo`) when set, else a fallback COMPUTED on every read from the product's facts — French: name + brand (+ « en Tunisie » when it fits in 55 chars) for the title; name, brand, category, price, crossed-out price, stock, sellers, seller name and the product's own text (≤ 160 chars) for the description. Computed values are never written back. `source` names the origin of each value. Indexing: `noindex` only when stored — out of stock / showcase pages stay indexable (see `seo_policy`). Canonical: the stored override, else the canonical fiche of the product's same-EAN group when this page is another member of it (`group_canonical`), else the page's own path (`self`). Paths are relative.",
        "properties": {
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "ogImage": {
            "type": "string",
            "nullable": true,
            "description": "Stored override, else the first product image; null when none."
          },
          "canonicalUrl": {
            "type": "string",
            "example": "/boutique/nike-air-max-90"
          },
          "noindex": {
            "type": "boolean"
          },
          "robots": {
            "type": "string",
            "enum": [
              "index,follow",
              "noindex,follow"
            ]
          },
          "source": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string",
                "enum": [
                  "stored",
                  "computed"
                ]
              },
              "description": {
                "type": "string",
                "enum": [
                  "stored",
                  "computed"
                ]
              },
              "ogImage": {
                "type": "string",
                "enum": [
                  "stored",
                  "computed",
                  "none"
                ]
              },
              "canonicalUrl": {
                "type": "string",
                "enum": [
                  "stored",
                  "self",
                  "group_canonical"
                ]
              },
              "robots": {
                "type": "string",
                "enum": [
                  "stored",
                  "computed"
                ]
              }
            },
            "required": [
              "title",
              "description",
              "ogImage",
              "canonicalUrl",
              "robots"
            ]
          }
        },
        "required": [
          "title",
          "description",
          "ogImage",
          "canonicalUrl",
          "noindex",
          "robots",
          "source"
        ]
      },
      "ProductVariant": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "sku": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "price": {
            "type": "number",
            "nullable": true,
            "description": "SELLING price of THIS variant (its own regular/sale pair, else the product pair) — what checkout charges for it. Null only when nothing resolves."
          },
          "stock": {
            "type": "integer"
          },
          "inStock": {
            "type": "boolean"
          },
          "attributes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VariantAttribute"
            }
          },
          "imageUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "compareAtPrice": {
            "type": "number",
            "nullable": true,
            "description": "Crossed-out regular price of THIS variant when on sale, else null."
          },
          "regularPrice": {
            "type": "number",
            "nullable": true,
            "description": "\"Prix avant\" — the crossed-out price when on sale, otherwise equal to price. THE RULE (+216 20 123 456): selling = sale when 0 < sale < regular, else regular, else the legacy price; variant pair first, product pair as fallback."
          },
          "salePrice": {
            "type": "number",
            "nullable": true,
            "description": "\"Prix après\" — equals price when on sale, otherwise null."
          },
          "onSale": {
            "type": "boolean",
            "description": "sale > 0 AND regular > 0 AND sale < regular (never the stored on_sale column)."
          }
        },
        "required": [
          "id",
          "sku",
          "name",
          "price",
          "stock",
          "inStock",
          "attributes",
          "imageUrl"
        ]
      },
      "PublicBanner": {
        "type": "object",
        "required": [
          "id",
          "placement",
          "categoryId",
          "title",
          "subtitle",
          "ctaLabel",
          "href",
          "imageUrl",
          "mobileImageUrl",
          "alt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "placement": {
            "type": "string",
            "enum": [
              "home_hero",
              "home_promo",
              "category"
            ]
          },
          "categoryId": {
            "type": "string",
            "nullable": true,
            "description": "Set only on a `category` banner."
          },
          "title": {
            "type": "string",
            "nullable": true,
            "maxLength": 120
          },
          "subtitle": {
            "type": "string",
            "nullable": true,
            "maxLength": 200
          },
          "ctaLabel": {
            "type": "string",
            "nullable": true,
            "maxLength": 40
          },
          "href": {
            "type": "string",
            "nullable": true,
            "description": "Storefront path (`/boutique?promo=1`) or https URL."
          },
          "imageUrl": {
            "type": "string",
            "description": "Wide image (≈ 21:9)",
            "https": null,
            "no baked-in text.": null
          },
          "mobileImageUrl": {
            "type": "string",
            "nullable": true,
            "description": "Narrower image (≈ 3:2); null = use imageUrl."
          },
          "alt": {
            "type": "string",
            "nullable": true,
            "maxLength": 200
          }
        }
      },
      "PublicBundle": {
        "type": "object",
        "required": [
          "bundleId",
          "title",
          "items",
          "price",
          "compareAtPrice",
          "currency"
        ],
        "properties": {
          "bundleId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "price": {
            "type": "number",
            "description": "What the whole pack costs"
          },
          "compareAtPrice": {
            "type": "number",
            "nullable": true
          },
          "currency": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "productId",
                "variantId",
                "vendorId",
                "quantity",
                "title",
                "slug",
                "imageUrl",
                "unitPrice"
              ],
              "properties": {
                "productId": {
                  "type": "string"
                },
                "variantId": {
                  "type": "string",
                  "nullable": true,
                  "description": "null = any variant (the shopper picks)"
                },
                "vendorId": {
                  "type": "string",
                  "nullable": true
                },
                "quantity": {
                  "type": "integer"
                },
                "title": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                },
                "imageUrl": {
                  "type": "string",
                  "nullable": true
                },
                "unitPrice": {
                  "type": "number",
                  "description": "The item's own catalogue price"
                }
              }
            }
          }
        }
      },
      "PublicProductQuestion": {
        "type": "object",
        "required": [
          "id",
          "question",
          "askedAt",
          "answer"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "question": {
            "type": "string",
            "description": "Plain text."
          },
          "askedAt": {
            "type": "string",
            "format": "date-time"
          },
          "answer": {
            "type": "object",
            "required": [
              "body",
              "sellerName",
              "answeredAt"
            ],
            "properties": {
              "body": {
                "type": "string",
                "description": "Plain text (render escaped)."
              },
              "sellerName": {
                "type": "string",
                "nullable": true
              },
              "answeredAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "PublicRatingSummary": {
        "type": "object",
        "required": [
          "average",
          "count",
          "distribution"
        ],
        "properties": {
          "average": {
            "type": "number",
            "description": "Mean of published ratings, 2 decimals; 0 when none."
          },
          "count": {
            "type": "integer"
          },
          "distribution": {
            "$ref": "#/components/schemas/RatingDistribution"
          }
        }
      },
      "PublicReview": {
        "type": "object",
        "required": [
          "id",
          "rating",
          "title",
          "body",
          "authorDisplay",
          "verifiedPurchase",
          "variantLabel",
          "sellerName",
          "createdAt",
          "sellerReply"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "rating": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "body": {
            "type": "string",
            "nullable": true
          },
          "authorDisplay": {
            "type": "string",
            "description": "« Prénom + initiale » — never an e-mail or phone; `Client` when unusable."
          },
          "verifiedPurchase": {
            "type": "boolean"
          },
          "variantLabel": {
            "type": "string",
            "nullable": true,
            "description": "Variation bought, e.g. `Couleur: Noir · Pointure: 42`."
          },
          "sellerName": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "sellerReply": {
            "type": "object",
            "nullable": true,
            "required": [
              "body",
              "createdAt"
            ],
            "properties": {
              "body": {
                "type": "string"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "PublicReviewsPage": {
        "type": "object",
        "required": [
          "summary",
          "items",
          "pagination"
        ],
        "properties": {
          "summary": {
            "$ref": "#/components/schemas/PublicRatingSummary"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicReview"
            }
          },
          "pagination": {
            "type": "object",
            "required": [
              "page",
              "limit",
              "total"
            ],
            "properties": {
              "page": {
                "type": "integer"
              },
              "limit": {
                "type": "integer"
              },
              "total": {
                "type": "integer"
              }
            }
          }
        }
      },
      "PublicStore": {
        "type": "object",
        "required": [
          "storeId",
          "name",
          "vendorId",
          "vendorName",
          "address",
          "phone",
          "geo",
          "openingHours",
          "imageUrl"
        ],
        "properties": {
          "storeId": {
            "type": "string",
            "description": "Same id as per-store stock `storeId` and store reservations."
          },
          "name": {
            "type": "string"
          },
          "vendorId": {
            "type": "string"
          },
          "vendorName": {
            "type": "string",
            "nullable": true
          },
          "address": {
            "$ref": "#/components/schemas/StoreAddress"
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "geo": {
            "allOf": [
              {
                "$ref": "#/components/schemas/StoreGeo"
              }
            ],
            "nullable": true
          },
          "openingHours": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoreOpeningHours"
            }
          },
          "imageUrl": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PublicStoreEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "title",
          "detail",
          "startsAt",
          "endsAt",
          "allDay",
          "href",
          "store"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "sev_3f9a1c0b7d2e4a61"
          },
          "type": {
            "type": "string",
            "enum": [
              "promotion",
              "event"
            ]
          },
          "title": {
            "type": "string",
            "maxLength": 80,
            "example": "-30 % sur les chaussures de running"
          },
          "detail": {
            "type": "string",
            "nullable": true,
            "maxLength": 200
          },
          "startsAt": {
            "type": "string",
            "format": "date-time",
            "description": "With an offset. Past = running now."
          },
          "endsAt": {
            "type": "string",
            "format": "date-time",
            "description": "With an offset. Always in the future on this endpoint."
          },
          "allDay": {
            "type": "boolean",
            "description": "Print dates only (« Du 5 au 14 décembre »)."
          },
          "href": {
            "type": "string",
            "nullable": true,
            "description": "Storefront path (`/marques/nike`) or https URL."
          },
          "store": {
            "type": "object",
            "required": [
              "storeId",
              "name",
              "vendorId",
              "vendorName",
              "street",
              "city",
              "geo"
            ],
            "properties": {
              "storeId": {
                "type": "string",
                "description": "Same id as GET /public/stores."
              },
              "name": {
                "type": "string"
              },
              "vendorId": {
                "type": "string"
              },
              "vendorName": {
                "type": "string",
                "nullable": true
              },
              "street": {
                "type": "string",
                "nullable": true
              },
              "city": {
                "type": "string",
                "nullable": true
              },
              "geo": {
                "type": "object",
                "nullable": true,
                "required": [
                  "lat",
                  "lng"
                ],
                "properties": {
                  "lat": {
                    "type": "number"
                  },
                  "lng": {
                    "type": "number"
                  }
                }
              }
            }
          }
        }
      },
      "PublicTenantFeatures": {
        "type": "object",
        "required": [
          "storeReservation",
          "reviews",
          "coupons",
          "wheel",
          "cardActions",
          "homeFlash",
          "homeNearby",
          "homeWhatsapp",
          "homeFeed",
          "mobileTabBar"
        ],
        "properties": {
          "storeReservation": {
            "type": "boolean",
            "description": "« Réserver en boutique » on product pages."
          },
          "reviews": {
            "type": "boolean",
            "description": "Customer reviews on product pages."
          },
          "coupons": {
            "type": "boolean",
            "description": "Coupon field at checkout."
          },
          "wheel": {
            "type": "boolean",
            "description": "Promotional spin-the-wheel widget."
          },
          "cardActions": {
            "type": "boolean",
            "description": "Quick actions on product cards (« Ajouter »",
            "WhatsApp).": null
          },
          "homeFlash": {
            "type": "boolean",
            "description": "Home « ventes flash » block."
          },
          "homeNearby": {
            "type": "boolean",
            "description": "Home « près de chez vous » block."
          },
          "homeWhatsapp": {
            "type": "boolean",
            "description": "Home WhatsApp explainer block."
          },
          "homeFeed": {
            "type": "boolean",
            "description": "Home product feed."
          },
          "mobileTabBar": {
            "type": "boolean",
            "description": "Mobile bottom tab bar on the web storefront."
          }
        }
      },
      "PublicTenantSettings": {
        "type": "object",
        "required": [
          "siteName",
          "tagline",
          "defaultDescription",
          "country",
          "currency",
          "locale",
          "ogLocale",
          "logoUrl",
          "logoOnDarkUrl",
          "footerBlurb",
          "contact",
          "social",
          "paymentMethods",
          "trust",
          "faq",
          "features"
        ],
        "properties": {
          "siteName": {
            "type": "string",
            "maxLength": 120,
            "example": "Wildkard"
          },
          "tagline": {
            "type": "string",
            "nullable": true,
            "maxLength": 200
          },
          "defaultDescription": {
            "type": "string",
            "nullable": true,
            "maxLength": 400
          },
          "country": {
            "type": "object",
            "required": [
              "code",
              "name",
              "inName"
            ],
            "properties": {
              "code": {
                "type": "string",
                "pattern": "^[A-Z]{2}$",
                "example": "TN"
              },
              "name": {
                "type": "string",
                "example": "Tunisie"
              },
              "inName": {
                "type": "string",
                "nullable": true,
                "example": "en Tunisie"
              }
            }
          },
          "currency": {
            "type": "object",
            "required": [
              "code",
              "symbol",
              "decimals"
            ],
            "properties": {
              "code": {
                "type": "string",
                "pattern": "^[A-Z]{3}$",
                "example": "TND"
              },
              "symbol": {
                "type": "string",
                "example": "DT"
              },
              "decimals": {
                "type": "integer",
                "minimum": 0,
                "maximum": 4,
                "example": 3
              }
            }
          },
          "locale": {
            "type": "string",
            "example": "fr",
            "description": "Language of the storefront copy (ISO 639)."
          },
          "ogLocale": {
            "type": "string",
            "nullable": true,
            "example": "fr_TN"
          },
          "logoUrl": {
            "type": "string",
            "nullable": true,
            "description": "Absolute http(s) URL or storefront-relative path."
          },
          "logoOnDarkUrl": {
            "type": "string",
            "nullable": true,
            "description": "Logo variant for dark surfaces (footer)."
          },
          "footerBlurb": {
            "type": "string",
            "nullable": true,
            "maxLength": 600
          },
          "contact": {
            "type": "object",
            "required": [
              "email",
              "phone",
              "whatsapp",
              "languages"
            ],
            "properties": {
              "email": {
                "type": "string",
                "format": "email",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "whatsapp": {
                "type": "string",
                "nullable": true,
                "description": "wa.me-ready `216XXXXXXXX`; a stored value that cannot open a chat is served as null."
              },
              "languages": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "social": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "paymentMethods": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "type": "string"
            },
            "description": "Payment methods as the tenant names them in the footer (checkout only accepts cash on delivery today)."
          },
          "trust": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "type": "string"
            },
            "description": "Short trust microcopy under prices; [] = no trust line."
          },
          "faq": {
            "type": "array",
            "maxItems": 30,
            "items": {
              "type": "object",
              "required": [
                "question",
                "answer"
              ],
              "properties": {
                "question": {
                  "type": "string",
                  "maxLength": 300
                },
                "answer": {
                  "type": "string",
                  "maxLength": 2000
                }
              }
            }
          },
          "features": {
            "$ref": "#/components/schemas/PublicTenantFeatures"
          }
        }
      },
      "PublicTrackingCarrier": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "awb": {
            "type": "string",
            "nullable": true
          },
          "trackingUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          }
        },
        "required": [
          "name",
          "awb",
          "trackingUrl"
        ]
      },
      "PublicTrackingItem": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "imageUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "quantity": {
            "type": "integer"
          },
          "unitPrice": {
            "type": "number"
          },
          "lineTotal": {
            "type": "number"
          },
          "vendorId": {
            "type": "string",
            "nullable": true,
            "description": "Seller of this line (item level; a multi-vendor order has no order-level vendor)"
          },
          "vendorName": {
            "type": "string",
            "nullable": true,
            "description": "Seller's shop name (copied from `vendors[]`)"
          },
          "vendorPhone": {
            "type": "string",
            "nullable": true,
            "description": "Seller's public business phone, as typed (copied from `vendors[]`)"
          },
          "vendorWhatsapp": {
            "type": "string",
            "nullable": true,
            "description": "WhatsApp digits for wa.me (`216XXXXXXXX`) after the fallback chain (seller's number, else the marketplace number; see `vendors[].whatsappSource`)"
          }
        },
        "required": [
          "title",
          "imageUrl",
          "quantity",
          "unitPrice",
          "lineTotal",
          "vendorId",
          "vendorName",
          "vendorPhone",
          "vendorWhatsapp"
        ]
      },
      "PublicTrackingResponse": {
        "type": "object",
        "properties": {
          "orderNumber": {
            "type": "string"
          },
          "customerFirstName": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string"
          },
          "statusLabel": {
            "type": "string"
          },
          "paymentMethod": {
            "type": "string"
          },
          "paymentStatus": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicTrackingItem"
            }
          },
          "vendors": {
            "type": "array",
            "description": "One seller contact block per distinct ITEM vendor, in cart order. Public business contact only.",
            "items": {
              "$ref": "#/components/schemas/OrderVendorContact"
            }
          },
          "totals": {
            "$ref": "#/components/schemas/PublicTrackingTotals"
          },
          "shipping": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicTrackingShipping"
              }
            ],
            "nullable": true
          },
          "carrier": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicTrackingCarrier"
              }
            ],
            "nullable": true
          },
          "timeline": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicTrackingTimelineEntry"
            }
          },
          "placedAt": {
            "type": "string",
            "format": "date-time"
          },
          "canRequestReturn": {
            "type": "boolean"
          }
        },
        "required": [
          "orderNumber",
          "customerFirstName",
          "status",
          "statusLabel",
          "paymentMethod",
          "paymentStatus",
          "currency",
          "items",
          "vendors",
          "totals",
          "shipping",
          "carrier",
          "timeline",
          "placedAt",
          "canRequestReturn"
        ]
      },
      "PublicTrackingShipping": {
        "type": "object",
        "properties": {
          "address1": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "country": {
            "type": "string"
          }
        },
        "required": [
          "address1",
          "city",
          "country"
        ]
      },
      "PublicTrackingTimelineEntry": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string"
          },
          "statusLabel": {
            "type": "string",
            "description": "Localised (fr-TN) status label"
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "status",
          "statusLabel",
          "occurredAt"
        ]
      },
      "PublicTrackingTotals": {
        "type": "object",
        "properties": {
          "subtotal": {
            "type": "number"
          },
          "discount": {
            "type": "number"
          },
          "shipping": {
            "type": "number"
          },
          "tax": {
            "type": "number"
          },
          "total": {
            "type": "number"
          }
        },
        "required": [
          "subtotal",
          "discount",
          "shipping",
          "tax",
          "total"
        ]
      },
      "PublicWarehouseStock": {
        "type": "object",
        "description": "One store of the vendor. A store the vendor's ERP tracks but where the item is sold out is listed with `out_of_stock` (stores holding the item come first). `storeId` is the id of GET /public/stores.",
        "properties": {
          "storeId": {
            "type": "string",
            "description": "canonical mk warehouse id",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "lat": {
            "type": "number",
            "nullable": true,
            "description": "Store latitude (WGS84) picked by the vendor on the map; null until set. Same position as GET /public/stores `geo`.",
            "example": 36.8782
          },
          "lng": {
            "type": "number",
            "nullable": true,
            "description": "Store longitude (WGS84); null until set.",
            "example": 10.3247
          },
          "status": {
            "type": "string",
            "enum": [
              "in_stock",
              "low_stock",
              "out_of_stock"
            ]
          }
        },
        "required": [
          "storeId",
          "name",
          "city",
          "status"
        ]
      },
      "RatingDistribution": {
        "type": "object",
        "description": "Number of published reviews per star, keys \"1\"..\"5\".",
        "required": [
          "1",
          "2",
          "3",
          "4",
          "5"
        ],
        "properties": {
          "1": {
            "type": "integer"
          },
          "2": {
            "type": "integer"
          },
          "3": {
            "type": "integer"
          },
          "4": {
            "type": "integer"
          },
          "5": {
            "type": "integer"
          }
        }
      },
      "SearchResponse": {
        "type": "object",
        "properties": {
          "query": {
            "type": "string"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SearchResult"
            }
          },
          "total": {
            "type": "integer"
          },
          "facetDistribution": {
            "description": "Per-facet counts (brandId, categoryIds, vendorId, onSale, inStock)",
            "nullable": true
          }
        },
        "required": [
          "query",
          "results",
          "total",
          "facetDistribution"
        ]
      },
      "SearchResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "product"
            ]
          },
          "title": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "price": {
            "type": "number"
          },
          "salePrice": {
            "type": "number",
            "nullable": true
          },
          "onSale": {
            "type": "boolean"
          },
          "compareAtPrice": {
            "type": "number",
            "nullable": true,
            "description": "The crossed-out regular price, set ONLY when on sale (strictly above price), else null — same rule as the list endpoint. `price` is the SELLING price, `salePrice` equals it when on sale, and `onSale` is THE RULE's (never the stored on_sale column). Documents indexed before +216 20 123 456 are read defensively (a strike only for a consistent promo) until the next full reindex."
          },
          "imageUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "inStock": {
            "type": "boolean"
          },
          "vendorId": {
            "type": "string",
            "nullable": true
          },
          "vendorName": {
            "type": "string",
            "nullable": true
          },
          "brandId": {
            "type": "string",
            "nullable": true
          },
          "categoryIds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "acceptsOnlineOrders": {
            "type": "boolean",
            "description": "Whether this product may be ORDERED online from its vendor, resolved product ?? vendor ?? marketplace. Permission only — inStock reports stock separately, so a search card can distinguish \"out of stock, come back later\" from \"this seller does not take online orders\". Resolved at read time rather than indexed: indexing it would require re-indexing a vendor's whole catalogue on every capability toggle, and a stale index would put the add-to-cart button back."
          },
          "regularPrice": {
            "type": "number",
            "nullable": true,
            "description": "\"Prix avant\" — the crossed-out price when on sale, otherwise equal to price."
          }
        },
        "required": [
          "id",
          "type",
          "title",
          "slug",
          "price",
          "salePrice",
          "onSale",
          "compareAtPrice",
          "imageUrl",
          "inStock",
          "vendorId",
          "vendorName",
          "brandId",
          "categoryIds",
          "acceptsOnlineOrders"
        ]
      },
      "ShippingQuote": {
        "type": "object",
        "properties": {
          "shippingAmount": {
            "type": "number",
            "description": "Order-level shipping = sum of every vendor's share."
          },
          "perVendor": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "vendorId": {
                  "type": "string"
                },
                "shippingAmount": {
                  "type": "number"
                }
              },
              "required": [
                "vendorId",
                "shippingAmount"
              ]
            }
          },
          "currency": {
            "type": "string"
          }
        },
        "required": [
          "shippingAmount",
          "perVendor",
          "currency"
        ]
      },
      "StockChangeSample": {
        "type": "object",
        "required": [
          "reference",
          "sku",
          "title",
          "variation",
          "stockBefore",
          "stockAfter",
          "priceBefore",
          "priceAfter",
          "reason"
        ],
        "properties": {
          "reference": {
            "type": "string",
            "nullable": true,
            "description": "Product reference (its SKU)"
          },
          "sku": {
            "type": "string",
            "nullable": true,
            "description": "Article SKU (null on a product without variants)"
          },
          "title": {
            "type": "string"
          },
          "variation": {
            "type": "string",
            "nullable": true,
            "description": "Variation values, e.g. `Bleu / 27`"
          },
          "stockBefore": {
            "type": "integer",
            "nullable": true
          },
          "stockAfter": {
            "type": "integer",
            "nullable": true
          },
          "priceBefore": {
            "type": "number",
            "nullable": true,
            "description": "Selling price before"
          },
          "priceAfter": {
            "type": "number",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "enum": [
              "source",
              "absent"
            ],
            "description": "absent = not in the file, zeroMissing"
          }
        }
      },
      "StoreAddress": {
        "type": "object",
        "required": [
          "street",
          "city",
          "postalCode",
          "region"
        ],
        "properties": {
          "street": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "postalCode": {
            "type": "string",
            "nullable": true
          },
          "region": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "StoreGeo": {
        "type": "object",
        "required": [
          "lat",
          "lng"
        ],
        "properties": {
          "lat": {
            "type": "number",
            "minimum": -90,
            "maximum": 90,
            "example": 36.8782
          },
          "lng": {
            "type": "number",
            "minimum": -180,
            "maximum": 180,
            "example": 10.3247
          }
        }
      },
      "StoreOpeningHours": {
        "type": "object",
        "description": "One opening slot, schema.org OpeningHoursSpecification-ready.",
        "required": [
          "days",
          "opens",
          "closes"
        ],
        "properties": {
          "days": {
            "type": "array",
            "minItems": 1,
            "maxItems": 7,
            "items": {
              "type": "string",
              "enum": [
                "Monday",
                "Tuesday",
                "Wednesday",
                "Thursday",
                "Friday",
                "Saturday",
                "Sunday"
              ]
            }
          },
          "opens": {
            "type": "string",
            "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$",
            "example": "09:00"
          },
          "closes": {
            "type": "string",
            "pattern": "^(([01][0-9]|2[0-3]):[0-5][0-9]|24:00)$",
            "example": "19:00",
            "description": "After `opens`."
          }
        }
      },
      "StoreReservation": {
        "type": "object",
        "description": "« Réservation en boutique » as the shopper sees it.",
        "required": [
          "reservationId",
          "reservationNumber",
          "status",
          "quantity",
          "unitPrice",
          "compareAtPrice",
          "product",
          "store",
          "vendor",
          "customer",
          "note",
          "expiresAt",
          "createdAt",
          "confirmedAt",
          "readyAt",
          "collectedAt",
          "cancelledAt",
          "accessToken"
        ],
        "properties": {
          "reservationId": {
            "type": "string",
            "example": "rsv_3f9a0c1b2d4e5f6a7b8c9d0e"
          },
          "reservationNumber": {
            "type": "string",
            "example": "R-7KQ2MX"
          },
          "status": {
            "$ref": "#/components/schemas/StoreReservationStatus"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2
          },
          "unitPrice": {
            "type": "number",
            "description": "Snapshot of the seller's selling price (TND, 3 decimals)."
          },
          "compareAtPrice": {
            "type": "number",
            "nullable": true,
            "description": "Crossed-out price at reservation time when on sale."
          },
          "product": {
            "$ref": "#/components/schemas/StoreReservationProduct"
          },
          "store": {
            "$ref": "#/components/schemas/StoreReservationStore"
          },
          "vendor": {
            "$ref": "#/components/schemas/StoreReservationVendor"
          },
          "customer": {
            "$ref": "#/components/schemas/StoreReservationCustomer"
          },
          "note": {
            "type": "string",
            "nullable": true
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "confirmedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "readyAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "collectedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "cancelledAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "accessToken": {
            "type": "string",
            "description": "32 hex — pass as ?token= to read / cancel without a session."
          }
        }
      },
      "StoreReservationCustomer": {
        "type": "object",
        "required": [
          "firstName",
          "lastName",
          "phone",
          "email"
        ],
        "properties": {
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "phone": {
            "type": "string",
            "example": "+21622123456"
          },
          "email": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "StoreReservationError": {
        "type": "object",
        "required": [
          "ok",
          "error",
          "message"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "NOT_FOUND",
                  "STORE_UNAVAILABLE",
                  "VALIDATION",
                  "RESERVATION_LIMIT",
                  "INVALID_TRANSITION",
                  "RATE_LIMITED",
                  "FORBIDDEN",
                  "CUSTOMER_BLOCKED"
                ]
              },
              "message": {
                "type": "string",
                "description": "French, displayable."
              }
            }
          },
          "message": {
            "type": "string",
            "description": "Same as error.message."
          },
          "details": {
            "description": "Zod flatten output on VALIDATION."
          },
          "retryAfter": {
            "type": "integer",
            "description": "Seconds — on RATE_LIMITED."
          }
        }
      },
      "StoreReservationPage": {
        "type": "object",
        "required": [
          "items",
          "pagination"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StoreReservation"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/StoreReservationPagination"
          }
        }
      },
      "StoreReservationPagination": {
        "type": "object",
        "required": [
          "page",
          "limit",
          "total",
          "totalPages"
        ],
        "properties": {
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "totalPages": {
            "type": "integer"
          }
        }
      },
      "StoreReservationProduct": {
        "type": "object",
        "required": [
          "productId",
          "variantId",
          "title",
          "variantLabel",
          "imageUrl"
        ],
        "properties": {
          "productId": {
            "type": "string"
          },
          "variantId": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "variantLabel": {
            "type": "string",
            "nullable": true,
            "example": "Noir / 42"
          },
          "imageUrl": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "StoreReservationStatus": {
        "type": "string",
        "enum": [
          "pending",
          "confirmed",
          "ready",
          "collected",
          "cancelled",
          "expired"
        ],
        "description": "pending → confirmed → ready → collected; cancelled from any active status; expired by the 48 h sweep."
      },
      "StoreReservationStore": {
        "type": "object",
        "required": [
          "storeId",
          "name",
          "city",
          "address",
          "phone",
          "openingHours"
        ],
        "properties": {
          "storeId": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "address": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "openingHours": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "StoreReservationVendor": {
        "type": "object",
        "required": [
          "vendorId",
          "name"
        ],
        "properties": {
          "vendorId": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "StorefrontCodedError": {
        "type": "object",
        "required": [
          "ok",
          "error",
          "message"
        ],
        "description": "Error body of the storefront reviews / questions / category-alerts routes.",
        "properties": {
          "ok": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "NOT_FOUND",
                  "VALIDATION",
                  "NOT_ELIGIBLE",
                  "ALREADY_REVIEWED",
                  "FORBIDDEN",
                  "QUESTION_LIMIT",
                  "RATE_LIMITED",
                  "CATEGORY_NOT_FOUND",
                  "ALERT_LIMIT",
                  "INVALID_TOKEN"
                ]
              },
              "message": {
                "type": "string",
                "description": "French, displayable."
              }
            }
          },
          "message": {
            "type": "string",
            "description": "Same as error.message."
          },
          "details": {
            "description": "Zod flatten output on VALIDATION."
          }
        }
      },
      "SubmitProductReviewInput": {
        "type": "object",
        "required": [
          "rating"
        ],
        "properties": {
          "rating": {
            "type": "integer",
            "minimum": 1,
            "maximum": 5
          },
          "title": {
            "type": "string",
            "maxLength": 255,
            "nullable": true
          },
          "body": {
            "type": "string",
            "maxLength": 4000,
            "nullable": true
          },
          "orderId": {
            "type": "string",
            "nullable": true,
            "description": "Which of the customer's delivered orders the review rides on (default: the latest)."
          }
        }
      },
      "SubmittedProductReview": {
        "type": "object",
        "required": [
          "id",
          "status",
          "verifiedPurchase",
          "orderId",
          "createdAt"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending"
            ]
          },
          "verifiedPurchase": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "orderId": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TrackingItem": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "price": {
            "type": "number"
          },
          "vendorId": {
            "type": "string",
            "nullable": true,
            "description": "Seller of this line (item level; a multi-vendor order has no order-level vendor)"
          },
          "vendorName": {
            "type": "string",
            "nullable": true,
            "description": "Seller's shop name (copied from `vendors[]`)"
          },
          "vendorPhone": {
            "type": "string",
            "nullable": true,
            "description": "Seller's public business phone, as typed (copied from `vendors[]`)"
          },
          "vendorWhatsapp": {
            "type": "string",
            "nullable": true,
            "description": "WhatsApp digits for wa.me (`216XXXXXXXX`) after the fallback chain (seller's number, else the marketplace number; see `vendors[].whatsappSource`)"
          }
        },
        "required": [
          "name",
          "quantity",
          "price",
          "vendorId",
          "vendorName",
          "vendorPhone",
          "vendorWhatsapp"
        ]
      },
      "TrackingResponse": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "description": "Human-readable order number"
          },
          "status": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "total": {
            "type": "number"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TrackingItem"
            }
          },
          "vendors": {
            "type": "array",
            "description": "One seller contact block per distinct ITEM vendor, in cart order. Public business contact only.",
            "items": {
              "$ref": "#/components/schemas/OrderVendorContact"
            }
          },
          "shippingAddress": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TrackingShippingAddress"
              }
            ],
            "nullable": true
          }
        },
        "required": [
          "orderId",
          "status",
          "createdAt",
          "total",
          "items",
          "vendors",
          "shippingAddress"
        ]
      },
      "TrackingShippingAddress": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "address",
          "city",
          "phone"
        ]
      },
      "VariantAttribute": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Canonical PIM attribute code — a STABLE, locale-independent matching key (e.g. `color`, `size`, `brand_color_code`). Legacy/source names (Couleur, pa_couleur, nuance, …) are normalized to this on read so the same axis never appears under two keys. Match the selected option against this `code`."
          },
          "name": {
            "type": "string",
            "description": "Localized display label for this axis (e.g. `Couleur`)."
          },
          "value": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "name",
          "value"
        ]
      },
      "VariantAvailability": {
        "type": "object",
        "description": "Per-vendor online + in-store availability for one selected variation.",
        "properties": {
          "productId": {
            "type": "string"
          },
          "variantId": {
            "type": "string"
          },
          "vendors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VariantVendorAvailability"
            }
          }
        },
        "required": [
          "productId",
          "variantId",
          "vendors"
        ]
      },
      "VariantStoreAvailability": {
        "type": "object",
        "description": "Per-store in-store availability of the selected variation (qty hidden). Every store of a vendor whose ERP tracks the item is listed — `out_of_stock` where it is sold out, after the stores holding it. `storeId` is the id of GET /public/stores.",
        "properties": {
          "storeId": {
            "type": "string",
            "description": "canonical mk warehouse id",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "lat": {
            "type": "number",
            "nullable": true,
            "description": "Store latitude (WGS84) picked by the vendor on the map; null until set. Same position as GET /public/stores `geo`.",
            "example": 36.8782
          },
          "lng": {
            "type": "number",
            "nullable": true,
            "description": "Store longitude (WGS84); null until set.",
            "example": 10.3247
          },
          "status": {
            "type": "string",
            "enum": [
              "in_stock",
              "low_stock",
              "out_of_stock"
            ]
          }
        },
        "required": [
          "storeId",
          "name",
          "city",
          "status"
        ]
      },
      "VariantVendorAvailability": {
        "type": "object",
        "properties": {
          "vendorId": {
            "type": "string",
            "nullable": true
          },
          "vendorName": {
            "type": "string",
            "nullable": true
          },
          "vendorWhatsapp": {
            "type": "string",
            "nullable": true,
            "description": "wa.me-ready `216XXXXXXXX`, or null when the vendor has no number OR its stored number cannot open a chat (never a dead link) — fall back to the marketplace contact.whatsapp."
          },
          "price": {
            "type": "number",
            "description": "Selling price of the MATCHED variant from this vendor (its own regular/sale pair, else the product pair; vendor rule applied; a listing override wins). Falls back to the offer-level price when the vendor has no matching variant. This is what checkout charges."
          },
          "online": {
            "type": "object",
            "description": "Online availability of the selected variation from this vendor (qty hidden).",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "in_stock",
                  "low_stock",
                  "out_of_stock"
                ]
              }
            },
            "required": [
              "status"
            ]
          },
          "stores": {
            "type": "array",
            "description": "Per-store availability; empty when the vendor doesn't publish per-depot stock or doesn't carry the variation.",
            "items": {
              "$ref": "#/components/schemas/VariantStoreAvailability"
            }
          },
          "showsStoreStock": {
            "type": "boolean",
            "description": "The vendor publishes per-store stock AND its `store_stock` offer capability is on. Offer « Réserver en boutique » only when true — POST /store-reservations re-checks it (409 STORE_UNAVAILABLE)."
          },
          "stockScopedToVariant": {
            "type": "boolean",
            "description": "True when `stores` reflect the EXACT selected variation. False when they fall back to whole-product stock (the vendor's ERP matched at product level, not per size/colour) — the storefront may show an \"indicative\" note. Always false when `stores` is empty."
          },
          "productId": {
            "type": "string",
            "description": "This seller's OWN MK product id for the listing it offers in the EAN group. Equals the top-level `productId` for the canonical vendor. Pass as `items[].productId` to POST checkout / the shipping-quote endpoint so the storefront can cart this exact seller (not just the canonical)."
          },
          "variantId": {
            "type": "string",
            "nullable": true,
            "description": "This seller's OWN MK variant id matching the requested `mk_variant_id` (resolved by EAN, else by normalized selectable-axis signature). `null` when the vendor carries the product but has no equivalent size — the storefront keeps the row but disables add-to-cart. Equals the top-level `variantId` for the canonical vendor. Pass as `items[].variantId` at checkout."
          },
          "compareAtPrice": {
            "type": "number",
            "nullable": true,
            "description": "Crossed-out regular price of that variant when on sale, else null."
          },
          "onSale": {
            "type": "boolean",
            "description": "THE RULE's onSale for that variant."
          }
        },
        "required": [
          "vendorId",
          "vendorName",
          "vendorWhatsapp",
          "price",
          "online",
          "stores",
          "stockScopedToVariant",
          "productId",
          "variantId"
        ]
      },
      "VendorDetail": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "avatarUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "bannerUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "status": {
            "type": "string"
          },
          "commissionType": {
            "type": "string",
            "nullable": true
          },
          "commissionRate": {
            "type": "number",
            "nullable": true
          },
          "productCount": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "terms": {
            "allOf": [
              {
                "$ref": "#/components/schemas/VendorTerms"
              }
            ],
            "nullable": true,
            "description": "Same delivery / returns terms as on this vendor's product-page seller rows; null = unavailable."
          }
        },
        "required": [
          "id",
          "name",
          "email",
          "phone",
          "avatarUrl",
          "bannerUrl",
          "status",
          "commissionType",
          "commissionRate",
          "productCount",
          "createdAt"
        ]
      },
      "VendorListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Vendor id"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "avatarUrl": {
            "type": "string",
            "format": "url",
            "nullable": true
          },
          "status": {
            "type": "string"
          },
          "commissionType": {
            "type": "string",
            "nullable": true
          },
          "commissionRate": {
            "type": "number",
            "nullable": true
          },
          "productCount": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "name",
          "email",
          "phone",
          "avatarUrl",
          "status",
          "commissionType",
          "commissionRate",
          "productCount",
          "createdAt"
        ]
      },
      "VendorReturnTerms": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "boolean",
            "nullable": true,
            "description": "null = no policy stated. When false, days/fees/method are null."
          },
          "days": {
            "type": "integer",
            "nullable": true
          },
          "fees": {
            "type": "string",
            "enum": [
              "free",
              "customer"
            ],
            "nullable": true
          },
          "method": {
            "type": "string",
            "enum": [
              "pickup",
              "drop_off",
              "in_store"
            ],
            "nullable": true
          }
        },
        "required": [
          "accepted",
          "days",
          "fees",
          "method"
        ]
      },
      "VendorStockItem": {
        "type": "object",
        "additionalProperties": false,
        "description": "ONE article of the calling vendor: `sku`, else `ean`, else `reference` + `size` (+ `color`). At least `stock` or `price`.",
        "properties": {
          "sku": {
            "type": "string",
            "maxLength": 191
          },
          "ean": {
            "type": "string",
            "maxLength": 32
          },
          "reference": {
            "type": "string",
            "maxLength": 191
          },
          "size": {
            "type": "string",
            "maxLength": 64
          },
          "color": {
            "type": "string",
            "maxLength": 64
          },
          "stock": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000
          },
          "price": {
            "type": "number",
            "exclusiveMinimum": true,
            "minimum": 0,
            "description": "Prix de vente normal (TND, 3 decimals max)"
          },
          "salePrice": {
            "type": "number",
            "nullable": true,
            "description": "Prix promo, below price; null ends the promotion; absent keeps a running one still below price"
          }
        }
      },
      "VendorStockPushResult": {
        "type": "object",
        "required": [
          "dryRun",
          "received",
          "matched",
          "stockChanged",
          "priceChanged",
          "stockBlockedBy",
          "notFound",
          "changes",
          "errors"
        ],
        "properties": {
          "dryRun": {
            "type": "boolean"
          },
          "received": {
            "type": "integer"
          },
          "matched": {
            "type": "integer"
          },
          "stockChanged": {
            "type": "integer"
          },
          "priceChanged": {
            "type": "integer"
          },
          "stockBlockedBy": {
            "type": "string",
            "nullable": true,
            "enum": [
              "strict_erp"
            ]
          },
          "notFound": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "sku": {
                  "type": "string",
                  "nullable": true
                },
                "ean": {
                  "type": "string",
                  "nullable": true
                },
                "reference": {
                  "type": "string",
                  "nullable": true
                },
                "size": {
                  "type": "string",
                  "nullable": true
                },
                "reason": {
                  "type": "string",
                  "enum": [
                    "introuvable",
                    "ambigu",
                    "taille requise",
                    "doublon",
                    "géré par l'ERP"
                  ]
                }
              }
            }
          },
          "changes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StockChangeSample"
            }
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "externalId": {
                  "type": "string"
                },
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "VendorStockRow": {
        "type": "object",
        "required": [
          "reference",
          "sku",
          "ean",
          "title",
          "size",
          "color",
          "stock",
          "price",
          "salePrice",
          "erpManaged"
        ],
        "properties": {
          "reference": {
            "type": "string",
            "nullable": true
          },
          "sku": {
            "type": "string",
            "nullable": true
          },
          "ean": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string"
          },
          "size": {
            "type": "string",
            "nullable": true
          },
          "color": {
            "type": "string",
            "nullable": true
          },
          "stock": {
            "type": "integer",
            "nullable": true
          },
          "price": {
            "type": "number",
            "nullable": true,
            "description": "Prix de vente normal"
          },
          "salePrice": {
            "type": "number",
            "nullable": true,
            "description": "Prix promo when one runs"
          },
          "erpManaged": {
            "type": "boolean",
            "description": "Fed by the vendor's ERP: not writable through this API"
          }
        }
      },
      "VendorTerms": {
        "type": "object",
        "description": "A vendor's delivery and returns terms as the shopper sees them. `shipping.fee` / `shipping.freeAbove` are read through the same function checkout charges with (vendor fee columns, else the platform fallback 8 TND / never free) — the announced fee IS the fee charged for this vendor's sub-order. Delays, regions and returns resolve vendor ?? marketplace default ?? platform; the platform level declares nothing (null / []).",
        "properties": {
          "shipping": {
            "type": "object",
            "properties": {
              "fee": {
                "type": "number",
                "description": "Flat fee charged once per vendor sub-order."
              },
              "freeAbove": {
                "type": "number",
                "nullable": true,
                "description": "Vendor subtotal at/above which the fee is waived; null = never free."
              },
              "currency": {
                "type": "string",
                "example": "TND"
              },
              "minDays": {
                "type": "integer",
                "nullable": true
              },
              "maxDays": {
                "type": "integer",
                "nullable": true
              },
              "regions": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Regions served; empty = not restricted."
              }
            },
            "required": [
              "fee",
              "freeAbove",
              "currency",
              "minDays",
              "maxDays",
              "regions"
            ]
          },
          "returns": {
            "$ref": "#/components/schemas/VendorReturnTerms"
          },
          "cashOnDelivery": {
            "type": "boolean",
            "description": "Derived from the payment methods checkout accepts (COD today) — not a vendor setting."
          },
          "deliveredBy": {
            "type": "string",
            "enum": [
              "marketplace",
              "vendor"
            ],
            "description": "Order mode « Livraison assurée par le vendeur » — `vendor` ⇒ « Livrée par <deliveredByName> »."
          },
          "deliveredByName": {
            "type": "string",
            "nullable": true,
            "description": "The vendor's name when deliveredBy = vendor, else null."
          }
        },
        "required": [
          "shipping",
          "returns",
          "cashOnDelivery",
          "deliveredBy",
          "deliveredByName"
        ]
      },
      "WhatsappClickInput": {
        "type": "object",
        "description": "One \"order via WhatsApp\" button press. Contains no personal data by design — no IP, no user-agent, no customer id.",
        "required": [
          "vendorId"
        ],
        "properties": {
          "vendorId": {
            "type": "string",
            "description": "Seller contacted — legacy `ven_*` id, as served in `offers[].vendorId`. Unknown ids are rejected with 400.",
            "example": "vnd_exemple"
          },
          "productId": {
            "type": "string",
            "example": "prd_fd953fa611d3a989670c883b"
          },
          "variantId": {
            "type": "string"
          },
          "placement": {
            "type": "string",
            "enum": [
              "buy_box",
              "seller_list",
              "other"
            ],
            "default": "other",
            "description": "Where the button sat on the page."
          },
          "sessionHash": {
            "type": "string",
            "maxLength": 64,
            "description": "Random per-visit token minted client-side so repeat clicks collapse into one contact. Identifies nobody."
          },
          "referrerPath": {
            "type": "string",
            "maxLength": 512,
            "description": "Page PATH only (`location.pathname`) — never a full URL, so no query string is persisted."
          }
        }
      },
      "WishlistAddResponse": {
        "type": "object",
        "required": [
          "ok",
          "data"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "example": true
          },
          "data": {
            "type": "object",
            "required": [
              "productId",
              "added",
              "count"
            ],
            "properties": {
              "productId": {
                "type": "string",
                "description": "The LISTED product id stored (a vendor source id is resolved to its marketplace copy)."
              },
              "added": {
                "type": "boolean",
                "description": "false when it was already saved."
              },
              "count": {
                "type": "integer",
                "description": "Saved items after the call (visible or not)."
              }
            }
          }
        }
      },
      "WishlistItem": {
        "description": "A storefront product card (same as `GET /products`) plus when the customer saved it.",
        "allOf": [
          {
            "$ref": "#/components/schemas/ProductListItem"
          },
          {
            "type": "object",
            "required": [
              "addedAt"
            ],
            "properties": {
              "addedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "WishlistPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WishlistItem"
            }
          },
          "total": {
            "type": "integer",
            "description": "Visible saved products (hidden ones are not counted)."
          },
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          }
        },
        "required": [
          "items",
          "total",
          "page",
          "limit"
        ]
      }
    },
    "securitySchemes": {
      "agentKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "mk_live_<8>_<40>",
        "description": "Clé agent créée par le propriétaire de la marketplace (Sources › Réglages communs › Clés API). `Authorization: Bearer mk_live_…` ou `X-Api-Key`. Lecture seule, limitée aux portées choisies, valable uniquement sur `/agent/*`."
      },
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Jeton client obtenu par `POST /auth/login` (ou `/auth/register`), renouvelé par `POST /auth/refresh`."
      },
      "vendorStockKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "vk_<8>_<32>",
        "description": "Clé API vendeur avec la portée `stock` (`Authorization: Bearer vk_…` ou `X-Api-Key: vk_…`). Créée par le vendeur dans Sources › Réglages communs › Clés API. Valable uniquement sur `/vendor-api/stock`."
      }
    }
  }
}
