{
  "openapi": "3.1.0",
  "info": {
    "title": "CouponKhassm noon register",
    "version": "1.0.0",
    "description": "Read-only interfaces over an independent register of noon’s published rules and accredited codes in Saudi Arabia, the UAE, Egypt, Kuwait, Qatar, Oman and Bahrain. Every rule carries the noon page it came from and the date that page was observed.",
    "contact": {
      "email": "desk@couponkhassm.com"
    },
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    }
  },
  "servers": [
    {
      "url": "https://couponkhassm.com"
    }
  ],
  "paths": {
    "/noon-protocol/rpc": {
      "post": {
        "operationId": "mcpRpc",
        "summary": "MCP server over JSON-RPC 2.0 (initialize, ping, tools/list, tools/call).",
        "description": "Stateless MCP endpoint. Supported methods: initialize, ping, tools/list, tools/call, notifications/initialized. Protocol versions: 2025-06-18, 2025-03-26, 2024-11-05. Tools: order_balance, noon_one_break_even, return_check, find_code, market_rules, list_unstated, ask_register.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "202": {
            "description": "Notification accepted; no body."
          },
          "400": {
            "description": "Body is not valid JSON-RPC.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/concierge/ask": {
      "post": {
        "operationId": "askRegister",
        "summary": "Free-text question answered from the register with sources.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "question": {
                    "type": "string",
                    "description": "The question, up to 400 characters."
                  },
                  "market": {
                    "type": "string",
                    "enum": [
                      "sa",
                      "ae",
                      "eg",
                      "kw",
                      "qa",
                      "om",
                      "bh"
                    ],
                    "description": "Market: sa (Saudi Arabia), ae (UAE), eg (Egypt), kw (Kuwait), qa (Qatar), om (Oman) or bh (Bahrain)."
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "ar",
                      "en"
                    ],
                    "description": "Language of rule texts in the answer. Default: en."
                  }
                },
                "required": [
                  "question"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rules from the register with their sources; `matched` is false when nothing matched.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid question.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "Body too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/concierge/balance": {
      "get": {
        "operationId": "orderBalanceGet",
        "summary": "Order Balance for one cart in one market.",
        "parameters": [
          {
            "name": "market",
            "in": "query",
            "required": true,
            "description": "Market: sa (Saudi Arabia), ae (UAE), eg (Egypt), kw (Kuwait), qa (Qatar), om (Oman) or bh (Bahrain).",
            "schema": {
              "type": "string",
              "enum": [
                "sa",
                "ae",
                "eg",
                "kw",
                "qa",
                "om",
                "bh"
              ]
            }
          },
          {
            "name": "basket",
            "in": "query",
            "required": true,
            "description": "Value of the items in the cart, in the market currency. Must be above zero.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "customer",
            "in": "query",
            "required": false,
            "description": "first = first order, existing = existing customer. Default: first.",
            "schema": {
              "type": "string",
              "enum": [
                "first",
                "existing"
              ]
            }
          },
          {
            "name": "delivery_fee",
            "in": "query",
            "required": false,
            "description": "Delivery fee as shown at checkout. Default: 0.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "payment",
            "in": "query",
            "required": false,
            "description": "prepaid or cod (cash on delivery). Default: prepaid.",
            "schema": {
              "type": "string",
              "enum": [
                "prepaid",
                "cod"
              ]
            }
          },
          {
            "name": "cod_fee_shown",
            "in": "query",
            "required": false,
            "description": "Cash-on-delivery fee as shown at checkout; used only where the register holds no published cash-on-delivery fee (every market but Saudi Arabia and the UAE).",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "noon_one",
            "in": "query",
            "required": false,
            "description": "True if the buyer has noon One and the order is noon express items. Ignored where no membership is on record.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "bank_pct",
            "in": "query",
            "required": false,
            "description": "Optional bank offer rate in percent, to compare against the code.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "bank_cap",
            "in": "query",
            "required": false,
            "description": "Optional cap of that bank offer.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "department",
            "in": "query",
            "required": false,
            "description": "Optional department slug (for example noon-mobiles); selects that department’s code in sa and ae.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language of rule texts in the answer. Default: en.",
            "schema": {
              "type": "string",
              "enum": [
                "ar",
                "en"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The Order Balance figures, the code used and the sources of fixed fees.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid arguments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "orderBalancePost",
        "summary": "Order Balance for one cart in one market.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "market": {
                    "type": "string",
                    "enum": [
                      "sa",
                      "ae",
                      "eg",
                      "kw",
                      "qa",
                      "om",
                      "bh"
                    ],
                    "description": "Market: sa (Saudi Arabia), ae (UAE), eg (Egypt), kw (Kuwait), qa (Qatar), om (Oman) or bh (Bahrain)."
                  },
                  "basket": {
                    "type": "number",
                    "description": "Value of the items in the cart, in the market currency. Must be above zero."
                  },
                  "customer": {
                    "type": "string",
                    "enum": [
                      "first",
                      "existing"
                    ],
                    "description": "first = first order, existing = existing customer. Default: first."
                  },
                  "delivery_fee": {
                    "type": "number",
                    "description": "Delivery fee as shown at checkout. Default: 0."
                  },
                  "payment": {
                    "type": "string",
                    "enum": [
                      "prepaid",
                      "cod"
                    ],
                    "description": "prepaid or cod (cash on delivery). Default: prepaid."
                  },
                  "cod_fee_shown": {
                    "type": "number",
                    "description": "Cash-on-delivery fee as shown at checkout; used only where the register holds no published cash-on-delivery fee (every market but Saudi Arabia and the UAE)."
                  },
                  "noon_one": {
                    "type": "boolean",
                    "description": "True if the buyer has noon One and the order is noon express items. Ignored where no membership is on record."
                  },
                  "bank_pct": {
                    "type": "number",
                    "description": "Optional bank offer rate in percent, to compare against the code."
                  },
                  "bank_cap": {
                    "type": "number",
                    "description": "Optional cap of that bank offer."
                  },
                  "department": {
                    "type": "string",
                    "description": "Optional department slug (for example noon-mobiles); selects that department’s code in sa and ae."
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "ar",
                      "en"
                    ],
                    "description": "Language of rule texts in the answer. Default: en."
                  }
                },
                "required": [
                  "market",
                  "basket"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The Order Balance figures, the code used and the sources of fixed fees.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid arguments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/intake/report": {
      "post": {
        "operationId": "sendReport",
        "summary": "Error report inbox. Answers 503 when storage is not configured.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Report"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Stored. Returns the report id.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid report.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "Body too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Too many reports from this visitor in the last hour.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Storage is not configured; nothing was stored. Use the contact email.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/datasets/v1/registry.json": {
      "get": {
        "operationId": "get_registry_json",
        "summary": "The whole register in one file: markets, codes, departments, rules, unstated items and campaigns. It is the very file the agents’ interface answers from.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/codes.json": {
      "get": {
        "operationId": "get_codes_json",
        "summary": "Accredited codes with their status, terms and listing date.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/codes.csv": {
      "get": {
        "operationId": "get_codes_csv",
        "summary": "Accredited codes with their status, terms and listing date.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/departments.json": {
      "get": {
        "operationId": "get_departments_json",
        "summary": "Departments, each department’s code and the return clauses tied to it per country.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/departments.csv": {
      "get": {
        "operationId": "get_departments_csv",
        "summary": "Departments, each department’s code and the return clauses tied to it per country.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/rules.json": {
      "get": {
        "operationId": "get_rules_json",
        "summary": "noon’s published rules, one per row, with Source Authority and Observation Date.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/rules.csv": {
      "get": {
        "operationId": "get_rules_csv",
        "summary": "noon’s published rules, one per row, with Source Authority and Observation Date.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/sources.json": {
      "get": {
        "operationId": "get_sources_json",
        "summary": "The noon pages relied on and each page’s Observation Date.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/sources.csv": {
      "get": {
        "operationId": "get_sources_csv",
        "summary": "The noon pages relied on and each page’s Observation Date.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/unstated.json": {
      "get": {
        "operationId": "get_unstated_json",
        "summary": "What noon’s observed pages do not publish.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/unstated.csv": {
      "get": {
        "operationId": "get_unstated_csv",
        "summary": "What noon’s observed pages do not publish.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/campaigns.json": {
      "get": {
        "operationId": "get_campaigns_json",
        "summary": "Campaigns and the dates noon’s pages state.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/rectifications.json": {
      "get": {
        "operationId": "get_rectifications_json",
        "summary": "The Rectifications log.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    },
    "/datasets/v1/audit.json": {
      "get": {
        "operationId": "get_audit_json",
        "summary": "The date of the last automated audit the register passed, and what that audit covers.",
        "responses": {
          "200": {
            "description": "The file."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "JsonRpcRequest": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "const": "2.0"
          },
          "id": {},
          "method": {
            "type": "string"
          },
          "params": {
            "type": "object"
          }
        },
        "required": [
          "jsonrpc",
          "method"
        ]
      },
      "Report": {
        "type": "object",
        "properties": {
          "topic": {
            "type": "string",
            "enum": [
              "wrong-fact",
              "code-not-accepted",
              "page-problem",
              "other"
            ]
          },
          "market": {
            "type": "string",
            "enum": [
              "sa",
              "ae",
              "eg",
              "kw",
              "qa",
              "om",
              "bh",
              ""
            ]
          },
          "page": {
            "type": "string",
            "maxLength": 200
          },
          "message": {
            "type": "string",
            "minLength": 10,
            "maxLength": 1500
          },
          "contact": {
            "type": "string",
            "maxLength": 120
          },
          "agent": {
            "type": "string",
            "maxLength": 80,
            "description": "Name of the reporting agent, if automated."
          }
        },
        "required": [
          "message"
        ],
        "additionalProperties": false
      }
    }
  }
}
