{
  "openapi": "3.0.3",
  "info": {
    "title": "Yuanext Inquiry & Gateway API",
    "description": "High-throughput Enterprise API Gateway untuk validasi nomor rekening Bank dan E-Wallet di Indonesia. Dilengkapi proteksi idempotensi (X-Idempotency-Key), failover multi-upstream otomatis, dan latensi sub-100ms.",
    "version": "1.0.0",
    "contact": {
      "name": "Yuanext Engineering",
      "url": "https://yuanext.com",
      "email": "support@yuanext.com"
    }
  },
  "servers": [
    {
      "url": "https://api.yuanext.com",
      "description": "Production API Cluster"
    },
    {
      "url": "http://127.0.0.1:3220",
      "description": "Local Development / Internal Gateway"
    }
  ],
  "paths": {
    "/api/v1/inquiry": {
      "get": {
        "summary": "Validasi Rekening Bank / Akun E-Wallet",
        "description": "Mengecek keabsahan dan mengambil nama resmi pemilik rekening atau dompet digital tanpa transfer dan tanpa memotong saldo.",
        "operationId": "checkAccountInquiry",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "code",
            "in": "query",
            "required": true,
            "description": "Slug e-wallet (dana, gopay, ovo, shopeepay, linkaja) atau 3-digit kode BI / slug bank (bca, bri, mandiri, bni, 014, 002).",
            "schema": {
              "type": "string",
              "example": "dana"
            }
          },
          {
            "name": "accountNumber",
            "in": "query",
            "required": true,
            "description": "Nomor rekening bank atau nomor HP e-wallet (format 08xx atau 628xx otomatis dinormalisasi).",
            "schema": {
              "type": "string",
              "example": "081234567890"
            }
          },
          {
            "name": "pretty",
            "in": "query",
            "required": false,
            "description": "Format output JSON dengan indentasi rapi.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "X-Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "UUID unik untuk mencegah tagihan kuota ganda saat koneksi retry.",
            "schema": {
              "type": "string",
              "example": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Permintaan berhasil diproses.",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": { "type": "integer" },
                "description": "Alokasi total kuota harian."
              },
              "X-RateLimit-Remaining": {
                "schema": { "type": "integer" },
                "description": "Sisa kuota harian."
              },
              "X-RateLimit-Reset": {
                "schema": { "type": "integer" },
                "description": "Timestamp Unix saat kuota direset."
              },
              "X-RateLimit-RPM-Limit": {
                "schema": { "type": "integer" },
                "description": "Batas frekuensi permintaan per menit (RPM)."
              },
              "X-RateLimit-RPM-Remaining": {
                "schema": { "type": "integer" },
                "description": "Sisa alokasi RPM menit berjalan."
              },
              "X-Idempotency-Status": {
                "schema": { "type": "string", "enum": ["STORED", "HIT"] },
                "description": "Status eksekusi idempotensi."
              },
              "X-Response-Time": {
                "schema": { "type": "string" },
                "description": "Durasi pemrosesan internal gateway."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": true },
                    "message": { "type": "string", "example": "ok" },
                    "data": {
                      "type": "object",
                      "properties": {
                        "account_name": { "type": "string", "example": "BUDI SANTOSO" },
                        "account_number": { "type": "string", "example": "081234567890" },
                        "account_type": { "type": "string", "example": "wallet_account" },
                        "bank_code": { "type": "string", "example": "dana" },
                        "bank_name": { "type": "string", "example": "DANA" }
                      }
                    },
                    "response_time_seconds": { "type": "number", "example": 0.412 }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Parameter tidak lengkap atau kode channel tidak valid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": false },
                    "message": { "type": "string", "example": "Parameter code dan accountNumber wajib diisi." },
                    "error_code": { "type": "string", "example": "MISSING_PARAMS" }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key tidak ada atau salah.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": false },
                    "message": { "type": "string", "example": "API key tidak valid atau tidak aktif." },
                    "error_code": { "type": "string", "example": "INVALID_API_KEY" }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Nomor akun atau rekening tidak ditemukan.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": false },
                    "message": { "type": "string", "example": "nomor tidak ditemukan" },
                    "error_code": { "type": "string", "example": "NOT_FOUND" },
                    "response_time_seconds": { "type": "number", "example": 0.812 }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Kuota harian habis atau rate limit per menit terlampaui.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": false },
                    "message": { "type": "string", "example": "Kuota harian API key telah habis." },
                    "error_code": { "type": "string", "example": "QUOTA_EXCEEDED" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/channels": {
      "get": {
        "summary": "Katalog Bank & E-Wallet Aktif",
        "description": "Mendapatkan daftar lengkap bank umum, bank digital, dan penyedia e-wallet yang sedang online dan didukung sistem.",
        "operationId": "getActiveChannels",
        "responses": {
          "200": {
            "description": "Daftar channel berhasil diambil.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "example": true },
                    "data": {
                      "type": "object",
                      "properties": {
                        "banks": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "code": { "type": "string", "example": "014" },
                              "name": { "type": "string", "example": "Bank Central Asia (BCA)" },
                              "slug": { "type": "string", "example": "bca" },
                              "digits": { "type": "integer", "example": 10 },
                              "is_active": { "type": "boolean", "example": true }
                            }
                          }
                        },
                        "ewallets": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "code": { "type": "string", "example": "dana" },
                              "name": { "type": "string", "example": "DANA" },
                              "is_active": { "type": "boolean", "example": true }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Pemeriksaan Kesehatan Gateway (Healthcheck)",
        "description": "Menampilkan status konektivitas basis data PostgreSQL, Redis cache cluster, uptime, dan latensi diagnostik.",
        "operationId": "getHealthStatus",
        "responses": {
          "200": {
            "description": "Layanan berjalan optimal.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "ok" },
                    "service": { "type": "string", "example": "yuanext-core" },
                    "version": { "type": "string", "example": "1.0.0" },
                    "uptime": { "type": "integer", "example": 3600 },
                    "database": { "type": "string", "example": "ok" },
                    "redis": { "type": "string", "example": "connected" },
                    "latency_ms": { "type": "integer", "example": 2 }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "API Key B2B resmi Anda diawali prefix `ynx_live_`"
      }
    }
  }
}
