{
  "openapi": "3.1.0",
  "info": {
    "title": "RinxaPay Read-Only Agent Catalogue",
    "version": "0.4.0",
    "description": "RinxaPay public discovery and guarded guest payment interface. Razorpay backend, signed webhooks, verified callback and recovery are deployed but live checkout remains feature-gated pending merchant/provider configuration, gateway QA and funded acceptance tests.",
    "x-mcp-url": "https://api.rinxapay.com/mcp"
  },
  "servers": [
    {
      "url": "https://api.rinxapay.com/v1"
    }
  ],
  "paths": {
    "/services": {
      "get": {
        "summary": "List service availability",
        "operationId": "services",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Catalogue result; see service status and source freshness.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "503": {
            "description": "Catalogue unavailable"
          }
        }
      }
    },
    "/services/{service_id}": {
      "get": {
        "summary": "Describe one service",
        "operationId": "services_service_id",
        "parameters": [
          {
            "name": "service_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalogue result; see service status and source freshness.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "503": {
            "description": "Catalogue unavailable"
          }
        }
      }
    },
    "/operators": {
      "get": {
        "summary": "List mobile or DTH operators",
        "operationId": "operators",
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "description": "mobile or dth",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Name filter",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1 to 50",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "0 to 10000",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalogue result; see service status and source freshness.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "503": {
            "description": "Catalogue unavailable"
          }
        }
      }
    },
    "/circles": {
      "get": {
        "summary": "List service circles",
        "operationId": "circles",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1 to 50",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "0 to 10000",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalogue result; see service status and source freshness.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "503": {
            "description": "Catalogue unavailable"
          }
        }
      }
    },
    "/billers": {
      "get": {
        "summary": "List synchronized BBPS billers",
        "operationId": "billers",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "BBPS service category",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Biller name",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1 to 50",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "0 to 10000",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalogue result; see service status and source freshness.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "503": {
            "description": "Catalogue unavailable"
          }
        }
      }
    },
    "/recharge/plans": {
      "get": {
        "summary": "Find synchronized recharge plans; amounts in integer paise, live revalidation required",
        "operationId": "recharge_plans",
        "parameters": [
          {
            "name": "operator_id",
            "in": "query",
            "required": true,
            "description": "ClubAPI operator ID",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "circle_id",
            "in": "query",
            "required": false,
            "description": "Circle identifier",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Text or exact rupee amount",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "min_amount",
            "in": "query",
            "required": false,
            "description": "Minimum amount in whole INR",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "max_amount",
            "in": "query",
            "required": false,
            "description": "Maximum amount in whole INR",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1 to 50",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "0 to 10000",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalogue result; see service status and source freshness.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "503": {
            "description": "Catalogue unavailable"
          }
        }
      }
    },
    "/offers": {
      "get": {
        "summary": "List verified public offers; empty until offers engine validated",
        "operationId": "offers",
        "parameters": [
          {
            "name": "service",
            "in": "query",
            "description": "mobile, dth, bbps, travel (mobile_recharge also accepted)",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "operator_id",
            "in": "query",
            "description": "ClubAPI operator ID, not a brand label",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "circle_id",
            "in": "query",
            "description": "Service region",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "1–50",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "description": "0–10000",
            "required": false,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Verified campaign listing with `checkout_offers_enabled`; zero until activated. Cashback is separate from an instant discount.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "503": {
            "description": "Catalogue unavailable"
          }
        },
        "description": "Returns only activated, funded, verified public promotions when discounted checkout is enabled. Empty while rollout is disabled. Individual eligibility is not confirmed by listing."
      }
    },
    "/offers/estimate": {
      "get": {
        "summary": "Indicative server-side promotion evaluation (NOT a payment quote)",
        "description": "No private customer data. Requires a valid service/operator/face value. The response is conditional and MUST NOT be treated as a confirmed price, saving, or checkout authorization. The endpoint returns zero offers until rollout is enabled.",
        "operationId": "estimate_offers",
        "parameters": [
          {
            "name": "service",
            "in": "query",
            "description": "mobile, dth, bbps or travel",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "operator_id",
            "in": "query",
            "description": "ClubAPI operator ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "amount_paise",
            "in": "query",
            "description": "Integer service face value in INR paise, 100–10000000",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "circle_id",
            "in": "query",
            "description": "Circle identifier",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "plan_id",
            "in": "query",
            "description": "Optional cached numeric plan identifier",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "coupon",
            "in": "query",
            "description": "Coupon code if one is required",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "payment_method",
            "in": "query",
            "description": "Verified payment method only; do not assume eligibility",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Indicative promotion candidates or empty array when disabled",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "currency": {
                      "const": "INR"
                    },
                    "checkout_offers_enabled": {
                      "type": "boolean"
                    },
                    "base_face_value_paise": {
                      "type": "integer"
                    },
                    "source": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "422": {
            "description": "Invalid service or monetary inputs"
          },
          "503": {
            "description": "Catalogue temporarily unavailable"
          }
        }
      }
    },
    "/quotes": {
      "post": {
        "operationId": "createGuestQuote",
        "summary": "Create fresh guest recharge or BBPS quote",
        "description": "Revalidates selected plans with provider through the existing protected Oracle integration; creates only a short-lived quote. No payment or fulfillment occurs. Exact amounts are in integer INR paise. Requires operator/customer identifiers. Provider may be unavailable, and quoting can be rate-limited.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "kind",
                  "operator_id",
                  "customer_reference"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "mobile",
                      "dth",
                      "bbps"
                    ]
                  },
                  "operator_id": {
                    "type": "string",
                    "maxLength": 40
                  },
                  "circle_id": {
                    "type": "string",
                    "maxLength": 30
                  },
                  "customer_reference": {
                    "type": "string",
                    "minLength": 4,
                    "maxLength": 100,
                    "description": "Service identifier: recipient mobile number, DTH account ID, or bill consumer reference."
                  },
                  "plan_key": {
                    "type": "string",
                    "maxLength": 60,
                    "description": "Required for mobile and DTH; value from synchronized plan catalogue."
                  },
                  "params": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    },
                    "description": "BBPS parameters as defined by the authorized biller."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Fresh quote; expiry and amount in paise; no payment authorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {
                    "quote": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "amount_paise": {
                          "type": "integer"
                        },
                        "expires_at": {
                          "type": "string",
                          "format": "date-time"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Caller origin not permitted"
          },
          "422": {
            "description": "Invalid data or provider verification unavailable"
          },
          "429": {
            "description": "Lookup rate limit reached"
          },
          "503": {
            "description": "Quote or provider temporarily unavailable"
          }
        }
      }
    },
    "/orders/{order_id}/status": {
      "get": {
        "operationId": "getGuestOrderStatus",
        "summary": "Get capability-protected guest order status",
        "description": "Requires an unguessable status capability in Authorization: Bearer <guest_token>. UUID alone is not authorization. Does not trigger fulfillment or payment and does not disclose full customer contact details.",
        "security": [
          {
            "guestStatusCapability": []
          }
        ],
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized masked payment and fulfillment states, with timestamps",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid status capability format"
          },
          "404": {
            "description": "Order not found, or token does not authorize this order"
          },
          "503": {
            "description": "Status temporarily unavailable"
          }
        }
      }
    },
    "/checkout/sessions": {
      "post": {
        "operationId": "createGuestCheckoutSession",
        "summary": "Guest checkout creation (currently unavailable)",
        "description": "Universal agent session creation is still disabled. Existing human guest checkout handoff is generated only from approved server-side create-order flow and lives at https://rinxapay.com/checkout/session/ (opaque token in URL fragment).",
        "responses": {
          "503": {
            "description": "CHECKOUT_NOT_ENABLED"
          }
        }
      }
    },
    "/payments/razorpay/create-order": {
      "post": {
        "operationId": "createRazorpayGuestOrder",
        "summary": "Create Razorpay order from an existing verified guest quote",
        "description": "Existing quote ID, contact and Cloudflare Turnstile proof are required. Price cannot be submitted by client. The server rechecks the provider, creates one order per quote and returns a guest checkout link if live service gates are approved. Currently may return HTTP 503 until readiness is confirmed. Never automatically repeat ambiguous create responses.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "quote_id",
                  "contact_mobile",
                  "turnstile_token"
                ],
                "properties": {
                  "quote_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "contact_mobile": {
                    "type": "string",
                    "pattern": "^[6-9][0-9]{9}$"
                  },
                  "turnstile_token": {
                    "type": "string",
                    "minLength": 10
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Verified provider quote converted into single Razorpay order, guest capability and expiring secure checkout URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "order_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "razorpay_order_id": {
                      "type": "string"
                    },
                    "razorpay_key_id": {
                      "type": "string"
                    },
                    "amount_paise": {
                      "type": "integer"
                    },
                    "service_face_value_paise": {
                      "type": "integer"
                    },
                    "currency": {
                      "const": "INR"
                    },
                    "checkout_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "checkout_expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "payment_methods": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "403": {
            "description": "Origin or challenge rejected"
          },
          "409": {
            "description": "Expired quote, already-used quote, changed provider price or uncertain provider order"
          },
          "422": {
            "description": "Invalid quote, contact, or challenge data"
          },
          "503": {
            "description": "Payment category, merchant credentials or live service readiness is not verified"
          }
        }
      }
    },
    "/payments/razorpay/verify": {
      "post": {
        "operationId": "verifyRazorpayGuestPayment",
        "summary": "Verify Razorpay checkout callback and authoritative captured payment",
        "description": "Requires guest order capability plus all Razorpay checkout callback fields. Server validates HMAC, retrieves authoritative Razorpay payment and enforces amount, currency, UPI method and idempotency. This does not declare provider fulfillment success.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "order_id",
                  "guest_token",
                  "razorpay_payment_id",
                  "razorpay_order_id",
                  "razorpay_signature"
                ],
                "properties": {
                  "order_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "guest_token": {
                    "type": "string",
                    "minLength": 65,
                    "description": "Opaque transaction-scoped capability; never log or place in query"
                  },
                  "razorpay_payment_id": {
                    "type": "string",
                    "pattern": "^pay_"
                  },
                  "razorpay_order_id": {
                    "type": "string",
                    "pattern": "^order_"
                  },
                  "razorpay_signature": {
                    "type": "string",
                    "pattern": "^[a-f0-9]{64}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Captured payment confirmed OR payment pending/manual review; fulfillment reported separately",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "payment_status": {
                      "type": "string"
                    },
                    "fulfilment_status": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "403": {
            "description": "Capability or signature invalid"
          },
          "409": {
            "description": "Gateway amount/currency/order mismatch"
          },
          "422": {
            "description": "Invalid field format or unrecognized order"
          },
          "503": {
            "description": "Verification currently unavailable; check status without repaying"
          }
        }
      }
    },
    "/webhooks/razorpay": {
      "post": {
        "operationId": "receiveRazorpayWebhook",
        "summary": "Razorpay signed webhook delivery (provider only)",
        "description": "Razorpay must POST the EXACT raw JSON bytes. Signature is HMAC-SHA256 in X-Razorpay-Signature using a distinct webhook secret. Duplicate deliveries are recorded idempotently; payment.captured is verified against Razorpay API. Never use this route from browser. Other events are retained for accounting and reconciliation.",
        "parameters": [
          {
            "in": "header",
            "name": "X-Razorpay-Signature",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "HMAC over unchanged raw body from Razorpay webhook secret"
          },
          {
            "in": "header",
            "name": "X-Razorpay-Event-Id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed event durably recorded and appropriately reconciled"
          },
          "403": {
            "description": "Invalid signature"
          },
          "409": {
            "description": "Event/payments conflict"
          },
          "503": {
            "description": "Temporary failure; Razorpay should retry"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "guestStatusCapability": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Opaque guest capability",
        "description": "The status-scoped guest token returned by an approved order creation; not a Supabase JWT. Keep secret and never include in query strings."
      }
    }
  }
}
