{
  "openapi": "3.1.0",
  "info": {
    "title": "Minux Trading Group API",
    "version": "1.0.0",
    "description": "Versioned API contract for public Minux Trading Group endpoints. Admin and internal endpoints are documented as secured surfaces only."
  },
  "servers": [
    {
      "url": "https://minux.example",
      "description": "Canonical production origin"
    }
  ],
  "tags": [
    {
      "name": "Public"
    },
    {
      "name": "Admin",
      "description": "Requires authenticated admin session and CSRF protection for mutations."
    },
    {
      "name": "Internal",
      "description": "Requires internal authorization or platform-only access."
    }
  ],
  "components": {
    "securitySchemes": {
      "AdminSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "sb-access-token",
        "description": "Supabase-backed admin session cookie. Mutations also require CSRF validation."
      },
      "InternalBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Internal bearer token or configured platform secret."
      }
    },
    "headers": {
      "ApiVersion": {
        "description": "Stable API version for additive-compatible v1 responses.",
        "schema": {
          "type": "string",
          "const": "1"
        }
      },
      "ApiDeprecated": {
        "description": "Whether this API version/path is deprecated.",
        "schema": {
          "type": "string",
          "const": "false"
        }
      },
      "RateLimitRemaining": {
        "description": "Remaining requests in the current rate-limit window.",
        "schema": {
          "type": "integer",
          "minimum": 0
        }
      },
      "RateLimitReset": {
        "description": "Unix timestamp in seconds when the rate-limit window resets.",
        "schema": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Pagination": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "page",
          "limit",
          "total",
          "totalPages",
          "hasMore"
        ],
        "properties": {
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "limit": {
            "type": "integer",
            "minimum": 1
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "totalPages": {
            "type": "integer",
            "minimum": 0
          },
          "hasMore": {
            "type": "boolean"
          }
        }
      },
      "PublicProductListItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "name_en",
          "slug"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name_en": {
            "type": "string"
          },
          "name_ru": {
            "type": [
              "string",
              "null"
            ]
          },
          "name_ar": {
            "type": [
              "string",
              "null"
            ]
          },
          "slug": {
            "type": "string"
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "format": {
            "type": [
              "string",
              "null"
            ]
          },
          "material": {
            "type": [
              "string",
              "null"
            ]
          },
          "sizes": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "finish": {
            "type": [
              "string",
              "null"
            ]
          },
          "origin": {
            "type": [
              "string",
              "null"
            ]
          },
          "hs_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "featured_image": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "PublicProductDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PublicProductListItem"
          },
          {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "description_en": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description_ru": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "description_ar": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "thickness": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "moq": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "images": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "string"
                }
              },
              "meta_title": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "meta_description": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        ]
      },
      "PublicProductsPaginated": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "pagination"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicProductListItem"
            }
          },
          "pagination": {
            "$ref": "#/components/schemas/Pagination"
          }
        }
      },
      "PublicCatalogListItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "slug",
          "status",
          "title_en",
          "category",
          "catalog_language",
          "file_url",
          "file_type"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "const": "published"
          },
          "title_en": {
            "type": "string"
          },
          "title_ru": {
            "type": [
              "string",
              "null"
            ]
          },
          "title_ar": {
            "type": [
              "string",
              "null"
            ]
          },
          "description_en": {
            "type": [
              "string",
              "null"
            ]
          },
          "description_ru": {
            "type": [
              "string",
              "null"
            ]
          },
          "description_ar": {
            "type": [
              "string",
              "null"
            ]
          },
          "category": {
            "type": "string"
          },
          "material_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "catalog_language": {
            "type": "string"
          },
          "file_url": {
            "type": "string"
          },
          "file_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "file_size": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "file_type": {
            "type": "string"
          },
          "cover_image_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "published_at": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "ContactRequest": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "name",
          "email",
          "country"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 100
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 255
          },
          "company": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "country": {
            "type": "string",
            "minLength": 2,
            "maxLength": 100
          },
          "phone": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 50
          },
          "message": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "selectedProducts": {
            "type": "array",
            "maxItems": 12,
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "turnstileToken": {
            "type": "string",
            "maxLength": 4096
          }
        }
      },
      "ContactSuccess": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "success",
          "message"
        ],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/api/products": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "List public products",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "paginated",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "material",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "finish",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public products. Legacy array response unless paginated=true.",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PublicProductListItem"
                      }
                    },
                    {
                      "$ref": "#/components/schemas/PublicProductsPaginated"
                    }
                  ]
                }
              }
            }
          },
          "500": {
            "description": "Sanitized server error",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/products": {
      "get": {
        "$ref": "#/paths/~1api~1products/get"
      }
    },
    "/api/products/slug/{slug}": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Get a public product by slug",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public product",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicProductDetail"
                }
              }
            }
          },
          "404": {
            "description": "Product not found",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Sanitized server error",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/products/slug/{slug}": {
      "get": {
        "$ref": "#/paths/~1api~1products~1slug~1{slug}/get"
      }
    },
    "/api/catalogs": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "List published catalogs",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "material_type",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "catalog_language",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published catalogs",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicCatalogListItem"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Sanitized server error",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/catalogs": {
      "get": {
        "$ref": "#/paths/~1api~1catalogs/get"
      }
    },
    "/api/catalogs/{id}": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Get a published catalog by id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Published catalog",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCatalogListItem"
                }
              }
            }
          },
          "400": {
            "description": "Invalid catalog id",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Catalog not found",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Sanitized server error",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/contact": {
      "post": {
        "tags": [
          "Public"
        ],
        "summary": "Submit a contact inquiry",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Inquiry accepted",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactSuccess"
                }
              }
            }
          },
          "400": {
            "description": "Validation or verification failed",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Sanitized server error",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporary service failure",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/contact": {
      "post": {
        "$ref": "#/paths/~1api~1contact/post"
      }
    },
    "/api/cookie-consent/settings": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Get public cookie-consent copy and settings",
        "responses": {
          "200": {
            "description": "Cookie consent settings",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/api/csrf": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Bootstrap CSRF cookie for browser clients",
        "responses": {
          "200": {
            "description": "CSRF cookie initialized",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "success"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/admin/{path}": {
      "get": {
        "tags": [
          "Admin"
        ],
        "summary": "Admin API surface",
        "security": [
          {
            "AdminSession": []
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/internal/outbox/process": {
      "get": {
        "tags": [
          "Internal"
        ],
        "summary": "Internal outbox processor",
        "security": [
          {
            "InternalBearer": []
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/security/csp-report": {
      "get": {
        "tags": [
          "Internal"
        ],
        "summary": "CSP report collector",
        "security": [
          {
            "InternalBearer": []
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/performance/web-vitals": {
      "get": {
        "tags": [
          "Internal"
        ],
        "summary": "Web Vitals collector",
        "security": [
          {
            "InternalBearer": []
          }
        ],
        "responses": {
          "401": {
            "description": "Unauthorized",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "headers": {
              "X-API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "X-API-Deprecated": {
                "$ref": "#/components/headers/ApiDeprecated"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}
